hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
srv
/
www
/
virtual
/
wccweb.jp
/
web
/
biva.webapp
/
site
/
app
/
api
/
Upload FileeE
HOME
<?php /** * api/watchland.php * * @author Mitsutoshi Nakamura <mitsutoshi.nakamura.jp@gmail.com> */ require(BV_APPROOT . 'site/app/api/_core.php'); class watchland extends core { public function __construct() { parent::__construct(); } public function pageIndex() { $this->biva->error('Invalid access'); } /** * News * * Request Path: * /api/watchland/news/?client=[pc|sp]&type=[index|all] */ public function pageNews() { $uri = bvUriScheme() . bvUriDomain(); $this->tplvar['icon']['name'] = array( 1 => '新製品', 2 => 'フェア', 4 => 'イベント', 8 => 'ショップ', 16 => 'その他' ); $this->tplvar['icon']['path'] = array( 1 => $uri . '/assets/img/api/watchland/news/new.gif', 2 => $uri . '/assets/img/api/watchland/news/fair.gif', 4 => $uri . '/assets/img/api/watchland/news/event.gif', 8 => $uri . '/assets/img/api/watchland/news/shop.gif', 16 => $uri . '/assets/img/api/watchland/news/other.gif' ); switch (true) { case $_GET['client'] == 'pc' && $_GET['type'] == 'index': $this->newsPcIndex(); break; case $_GET['client'] == 'pc' && $_GET['type'] == 'all': $this->biva->error('pageNews: 未実装'); break; case $_GET['client'] == 'sp' && $_GET['type'] == 'index': $this->newsSpIndex(); break; case $_GET['client'] == 'sp' && $_GET['type'] == 'all': $this->biva->error('pageNews: 未実装'); break; default: $this->biva->error('pageNews: Invalid parameters'); break; } } /** * Get news data */ private function getNews($limit) { $where = array('target & 1', 'cat & 31', 'config & 16', 'date_fr <= NOW()', 'status & 1'); $sql_base = 'SELECT * FROM p_news WHERE %s ORDER BY date_fr DESC, id DESC%s'; $sql = sprintf($sql_base, join(' AND ', $where), $limit); //echo $sql; exit; $r_sql = $this->biva->Db->query($sql); return $this->biva->Db->fetchAll($r_sql); } /** * News for PC index page */ private function newsPcIndex() { $this->tplvar['list'] = $this->getNews(' LIMIT 4'); $this->view('news.pc.index.html'); } /** * News for SP index page */ private function newsSpIndex() { $this->tplvar['list'] = $this->getNews(' LIMIT 4'); $this->view('news.sp.index.html'); } /** * Special Issue * * Request Path: * PC: /api/watchland/spis/?client=[pc|sp]&type=[index|all] * SP: /api/watchland/spis/?client=[pc|sp]&type=[index|all]&sec=[1|2] */ public function pageSpis() { switch (true) { case $_GET['client'] == 'pc' && $_GET['type'] == 'index': $this->spisPcIndex(); break; case $_GET['client'] == 'pc' && $_GET['type'] == 'all': $this->biva->error('pageSpis: 未実装'); break; case $_GET['client'] == 'sp' && $_GET['type'] == 'index': $this->spisSpIndex(); break; case $_GET['client'] == 'sp' && $_GET['type'] == 'all': $this->biva->error('pageSpis: 未実装'); break; default: $this->biva->error('pageSpis: Invalid parameters'); break; } } private function getSpis($limit = '') { $where = array('position = 1', 'status & 1', 'date_fr <= NOW()'); $sql_base = 'SELECT * FROM p_special_issue WHERE %s ORDER BY date_fr DESC, id DESC%s'; $sql = sprintf($sql_base, join(' AND ', $where), $limit); // echo $sql; exit; $r_sql = $this->biva->Db->query($sql); return $this->biva->Db->fetchAll($r_sql); } private function spisPcIndex() { $this->tplvar['list'] = $this->getSpis(); $this->view('spis.pc.index.html'); } private function spisSpIndex() { switch (true) { case $_GET['sec'] == 1: $this->spisSpIndexSec1(); break; case $_GET['sec'] == 2: $this->spisSpIndexSec2(); break; default: $this->biva->error('spisSpIndex: Invalid section'); break; } } private function spisSpIndexSec1() { $all = $this->getSpis(); $data = array_slice($all, 0, 5); $this->tplvar['list'] = $data; $this->view('spis.sp.index.html'); } private function spisSpIndexSec2() { $all = $this->getSpis(); $data = array_slice($all, 5, 4); $this->tplvar['list'] = $data; $this->view('spis.sp.index.html'); } /** * Shop news * * Request Path: * /api/watchland/shop/?client=[pc|sp]&type=[index|all] */ public function pageShop() { switch (true) { case $_GET['client'] == 'pc' && $_GET['type'] == 'index': $this->shopPcIndex(); break; case $_GET['client'] == 'pc' && $_GET['type'] == 'all': $this->biva->error('pageShop: 未実装'); break; case $_GET['client'] == 'sp' && $_GET['type'] == 'index': $this->shopSpIndex(); break; case $_GET['client'] == 'sp' && $_GET['type'] == 'all': $this->biva->error('pageShop: 未実装'); break; default: $this->biva->error('pageSpis: Invalid parameters'); break; } } private function getShop($shop) { switch ($shop) { case 'tyo': $place = 2; break; case 'osa': $place = 4; break; case 'fuk': $place = 8; break; case 'six': $place = 32768; break; default: $this->biva->error('pageSpis: Invalid parameters'); break; } $limit = ' LIMIT 1'; $where = array('target & ' . $place, 'status & 1', 'date_fr <= NOW()'); $sql_base = "SELECT * FROM p_news WHERE %s ORDER BY date_fr DESC, id DESC%s"; $sql = sprintf($sql_base, join(' AND ', $where), $limit); // echo $sql; exit; $r_sql = $this->biva->Db->query($sql); $data = $this->biva->Db->fetchAll($r_sql); return array('count' => count($data), 'data' => $data); } private function shopPcIndex() { $data['tyo'] = $this->getShop('tyo'); $data['osa'] = $this->getShop('osa'); $data['fuk'] = $this->getShop('fuk'); $data['six'] = $this->getShop('six'); // bvPr($data); exit; $this->json($data); } private function shopSpIndex() { $this->shopPcIndex(); } private function view($page) { $this->biva->Smarty->assign($this->tplvar); $this->biva->Smarty->display('api/watchland/' . $page); } private function json($data) { header('Access-Control-Allow-Origin: *'); header('Content-Type: application/javascript; charset=utf-8'); echo json_encode($data); } }