setDefaultForm(); $qf->buildForm(); $form = $qf->renderForm(); $this->smarty->assign('form', $form); // 検索条件をページャーに渡す為の変数. $searchQuery = array(); /************************************************* * お知らせ *************************************************/ $in = array(); $in["order"] = "news_startDatetime DESC, news_id DESC"; /********************** * カテゴリ指定. **********************/ $category = array(); $cat = appf::get_input("cat"); if ($cat && !ctype_digit($cat)) { $this->displayNotFound(); } if ($cat) { $in["news_categoryId"] = appf::get_input("cat"); $tmp = appf::getNewsCategories(false, appf::get_input("cat")); if (!$tmp) { $this->displayNotFound(); } $category = $tmp[0]; $searchQuery['cat'] = $cat; } $this->smarty->assign("cat", $category); /********************** * ショップ指定(業態). **********************/ $shop = array(); $topics = array(); $sp = appf::get_input("sp"); if ($sp && !ctype_digit($sp)) { $this->displayNotFound(); } if ($sp) { $in["gyotai_code->eq"] = $sp; $search = array(); $search["gyotai_code->eq"] = $sp; // 除外する業態(オフィシャル). $search["gyotai_code->not_in"] = array('0000'); $tmp = appf::getGyotai($search); if (!$tmp) { $this->displayNotFound(); } $shop = $tmp[0]; $searchQuery['sp'] = $sp; // ショップが指定された場合、TOPICSを表示する. $topics = appf::getTopics(array('gyotai_code->eq' => $sp), PAGE_LIMIT_TOPICS); $this->smarty->assign("topicsRows", $topics); } $this->smarty->assign("sp", $shop); $this->smarty->assign("topicsRows", $topics); /********************** * フリーワード. **********************/ $fw = strip_tags(appf::get_input("fw")); if ($fw) { $in['freeword'] = $fw; $searchQuery['fw'] = $fw; } $limit = PAGE_LIMIT_NEWS; $offset = ctype_digit(appf::get_input("p")) ? appf::get_input("p") : 0; $count = appf::getNews($in, 0, 0, TRUE); $news = appf::getNews($in, $limit, $offset); // $pager = appf::makePager($count, $offset, $limit); $pager = appf::makePagerFront($count, $offset, $limit, $searchQuery, 1); $this->smarty->assign("rows", $news); $this->smarty->assign("count", $count); $this->smarty->assign("pager", $pager); $this->display("public/shop-news/index.html"); } /** * 詳細表示アクション * * @author Shingo Isakawa * @access public * @return void */ function executeDetail() { $news = array(); /************************** * 管理画面からのプレビュー判定. **************************/ if (appf::get_input("exec") == "preview" && appf::get_input("wid") != "") { $dbo_workSession = DBO::factory("DBO_WorkSession"); $in = array(); $in["workSession_id"] = appf::get_input("wid"); $sess = appf::get($dbo_workSession, $in); $data = unserialize($sess[0]["workSession_memo"]); //期限切れ. if (($data["request"]["time"] + $data["request"]["expire"]) < time()) { die("このURLは期限切れです"); } //プレビュー時の調整. $data["request"]["news_displayDate"] = $data["request"]["news_displayDate"]["Y"] . "-" . $data["request"]["news_displayDate"]["m"] . "-" . $data["request"]["news_displayDate"]["d"]; $data["request"]["news_startDatetime"] = $data["request"]["news_startDatetime"]["Y"] . "-" . $data["request"]["news_startDatetime"]["m"] . "-" . $data["request"]["news_startDatetime"]["d"]; $data["request"]["news_endDatetime"] = $data["request"]["news_endDatetime"]["Y"] . "-" . $data["request"]["news_endDatetime"]["m"] . "-" . $data["request"]["news_endDatetime"]["d"]; //カテゴリ. if ($data["request"]["news_categoryId"]) { $dbo_newsCategory = DBO::factory("DBO_NewsCategory"); $in["newsCategory_id->eq"] = $data["request"]["news_categoryId"]; $newsCategory = appf::get($dbo_newsCategory, $in); $data["request"]["newsCategory_name"] = $newsCategory[0]["newsCategory_name"]; } $tmp = new News(); $tmp->initWithDataArray($data["request"]); $news[0] = $tmp; } /************************** * お知らせIDの検証. **************************/ else if (appf::get_input("id") == "") { $this->displayNotFound(); } /************************** * お知らせの取得. **************************/ if (appf::get_input("id") != "" && appf::get_input("exec") == "") { $in = array(); $in["news_id->eq"] = appf::get_input("id"); $news = appf::getNews($in); } if (!$news) { $this->displayNotFound(); } // URL設定が存在する場合、そちらへリダイレクトする. if($news[0]->url != ''){ $this->redirect($news[0]->url); } // ga用URL. // 2018.05.07 メルマガ計測パラメータが消えるのでREQUEST_URIを渡してクエリを引き継ぐように調整. // $pageURL = HTTP_ROOT_URL . "shop-news/{$news[0]->gyotai_dirName}/detail_{$news[0]->id}.html"; $pageURL = appf::getPageURL(); $pageURL = str_replace("shop-news/","shop-news/{$news[0]->gyotai_dirName}/",$pageURL); $this->smarty->assign("pageURL", $pageURL); $this->smarty->assign("news", $news[0]); // 所属するショップのTOPICSを表示する $topics = appf::getTopics(array('gyotai_code->eq' => $news[0]->gyotai_code), PAGE_LIMIT_TOPICS); $this->smarty->assign("topicsRows", $topics); $this->display("public/shop-news/detail.html"); } // Ajax用 function executeGetNewsCategory() { $gyotai_code = ""; if (appf::get_input("id") != '') { $gyotai_code = appf::get_input("id"); } $newsCategories = appf::getNewsCategories(true, null, $gyotai_code); // header('Content-Type: text/html; charset=UTF-8'); header('Content-Type: application/json'); if (count($newsCategories) == 0) { // header("HTTP/1.1 503 Service Unavailable"); // $error = 'カテゴリの取得に失敗しました'; // echo json_encode(compact('error')); // exit; } $cat = array(); $cat[] = array('id' => '', 'name' => '全てのカテゴリ', 'label' => '全てのカテゴリ'); foreach ($newsCategories as $category) { $id = $category['newsCategory_id']; $name = $category['newsCategory_name']; $label = $category['newsCategory_name'] . "({$category['news_count']})"; $cat[] = array('id' => $id, 'name' => $name, 'label' => $label); } echo json_encode($cat); exit; } function executeGetStyling() { if (appf::get_input("id") == '') { exit; } $id = appf::get_input("id"); $styling = appf::getStyling(array('styling_id' => $id), 1); header('Content-Type: text/html; charset=UTF-8'); if (count($styling) == 0) { // header("HTTP/1.1 503 Service Unavailable"); // $error = 'カテゴリの取得に失敗しました'; // echo json_encode(compact('error')); exit; } $this->smarty->assign("item", $styling[0]); $html = $this->smarty->fetch("public/shop-news/stylingRow.html"); echo $html; exit; } } // コントローラ実行 $controller = new PublicShopNewsController(); $controller->dispatch(); exit();