/** * Page のプロセス. * * @return void */ function process() { $conn = new SC_DBConn(); $objView = new SC_AdminView(); $objSess = new SC_Session(); $objDb = new SC_Helper_DB_Ex(); // 認証可否の判定 SC_Utils_Ex::sfIsSuccess($objSess); $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : ""; // 通常時は親カテゴリを0に設定する。 $this->arrForm['parent_category_id'] = isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : 0; if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } switch ($_POST['mode']) { case 'up': $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']); $objDb->sfRankUp("dtb_product_categories", "product_id", $_POST['product_id'], $where); break; case 'down': $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']); $objDb->sfRankDown("dtb_product_categories", "product_id", $_POST['product_id'], $where); break; case 'move': $key = "pos-" . $_POST['product_id']; $input_pos = mb_convert_kana($_POST[$key], "n"); if (SC_Utils_Ex::sfIsInt($input_pos)) { $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']); $objDb->sfMoveRank("dtb_product_categories", "product_id", $_POST['product_id'], $input_pos, $where); } break; case 'tree': // カテゴリの切替は、ページ番号をクリアする。 $this->tpl_pageno = ""; break; default: break; } $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']); $this->arrProductsList = $this->lfGetProduct($this->arrForm['parent_category_id']); $objView->assignobj($this); $objView->display(MAIN_FRAME); }
/** * ニュースの表示順を指定する. * * @param integer $news_id ニュースID * @param integer $rank 移動先の表示順 * @return void */ public function moveRank($news_id, $rank) { $objDb = new SC_Helper_DB_Ex(); $objDb->sfMoveRank('dtb_news', 'news_id', $news_id, $rank); }
/** * Page のアクション. * * @return void */ function action() { $objDb = new SC_Helper_DB_Ex(); $objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($objFormParam); $objFormParam->setParam($_POST); $objFormParam->convParam(); $news_id = $objFormParam->getValue('news_id'); //---- 新規登録/編集登録 switch ($this->getMode()) { case 'regist': $arrPost = $objFormParam->getHashArray(); $this->arrErr = $this->lfCheckError($objFormParam); if (SC_Utils_Ex::isBlank($this->arrErr)) { // ニュースIDの値がPOSTされて来た場合は既存データの編集とみなし、 // 更新メソッドを呼び出す。 // ニュースIDが存在しない場合は新規登録を行う。 $arrPost['link_method'] = $this->checkLinkMethod($arrPost['link_method']); $arrPost['news_date'] = $this->getRegistDate($arrPost); $member_id = $_SESSION['member_id']; if (strlen($news_id) > 0 && is_numeric($news_id)) { $this->lfNewsUpdate($arrPost, $member_id); } else { $this->lfNewsInsert($arrPost, $member_id); } $news_id = ''; $this->tpl_onload = "window.alert('編集が完了しました');"; } else { $this->arrForm = $arrPost; } break; case 'search': if (is_numeric($news_id)) { list($this->arrForm) = $this->getNews($news_id); list($this->arrForm['year'], $this->arrForm['month'], $this->arrForm['day']) = $this->splitNewsDate($this->arrForm['cast_news_date']); $this->edit_mode = 'on'; } break; case 'delete': //---- データ削除 if (is_numeric($news_id)) { $pre_rank = $this->getRankByNewsId($news_id); $this->computeRankForDelete($news_id, $pre_rank); SC_Response_Ex::reload(); //自分にリダイレクト(再読込による誤動作防止) } break; case 'move': //---- 表示順位移動 if (strlen($news_id) > 0 && is_numeric($news_id) == true) { $term = $objFormParam->getValue('term'); if ($term == 'up') { $objDb->sfRankUp('dtb_news', 'news_id', $news_id); } else { if ($term == 'down') { $objDb->sfRankDown('dtb_news', 'news_id', $news_id); } } $this->objDisplay->reload(); } break; case 'moveRankSet': //---- 指定表示順位移動 $input_pos = $this->getPostRank($news_id); if (SC_Utils_Ex::sfIsInt($input_pos)) { $objDb->sfMoveRank('dtb_news', 'news_id', $news_id, $input_pos); $this->objDisplay->reload(); } break; default: break; } $this->arrNews = $this->getNews(); $this->tpl_news_id = $news_id; $this->line_max = count($this->arrNews); $this->max_rank = $this->getRankMax(); }
/** * @param SC_Helper_DB_Ex $objDb */ public function lfRankMove(&$objDb, $parent_category_id, $product_id) { $key = 'pos-' . $product_id; $input_pos = mb_convert_kana($_POST[$key], 'n'); if (SC_Utils_Ex::sfIsInt($input_pos)) { $where = 'category_id = ' . SC_Utils_Ex::sfQuoteSmart($parent_category_id); $objDb->sfMoveRank('dtb_product_categories', 'product_id', $product_id, $input_pos, $where); } }
/** * Page のプロセス. * * @return void */ function process() { //---- ページ初期設定 $conn = new SC_DbConn(); $objView = new SC_AdminView(); $objDate = new SC_Date(ADMIN_NEWS_STARTYEAR); $objDb = new SC_Helper_DB_Ex(); SC_Utils_Ex::sfIsSuccess(new SC_Session()); //---- 日付プルダウン設定 $this->arrYear = $objDate->getYear(); $this->arrMonth = $objDate->getMonth(); $this->arrDay = $objDate->getDay(); if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } //---- 新規登録/編集登録 if ($_POST['mode'] == 'regist') { $_POST = $this->lfConvData($_POST); if ($this->arrErr = $this->lfErrorCheck()) { // 入力エラーのチェック foreach ($_POST as $key => $val) { $this->{$key} = $val; } $this->selected_year = $_POST["year"]; $this->selected_month = $_POST["month"]; $this->selected_day = $_POST["day"]; } else { if (isset($_POST['link_method']) == "") { $_POST['link_method'] = 1; } $this->registDate = $_POST['year'] . "/" . $_POST['month'] . "/" . $_POST['day']; //-- 編集登録 if (strlen($_POST["news_id"]) > 0 && is_numeric($_POST["news_id"])) { $this->lfNewsUpdate($conn); //-- 新規登録 } else { $this->lfNewsInsert($conn); } $this->tpl_onload = "window.alert('編集が完了しました');"; } } //---- 編集データ取得 if ($_POST["mode"] == "search" && is_numeric($_POST["news_id"])) { $sql = "SELECT *, cast(news_date as date) as cast_news_date FROM dtb_news WHERE news_id = ? "; $result = $conn->getAll($sql, array($_POST["news_id"])); foreach ($result[0] as $key => $val) { $this->{$key} = $val; } $arrData = split("-", $result[0]["cast_news_date"]); $this->selected_year = $arrData[0]; $this->selected_month = $arrData[1]; $this->selected_day = $arrData[2]; $this->edit_mode = "on"; } //---- データ削除 if ($_POST['mode'] == 'delete' && is_numeric($_POST["news_id"])) { // rankを取得 $pre_rank = $conn->getone(" SELECT rank FROM dtb_news WHERE del_flg = 0 AND news_id = ? ", array($_POST['news_id'])); //-- 削除する新着情報以降のrankを1つ繰り上げておく $conn->query("BEGIN"); $sql = "UPDATE dtb_news SET rank = rank - 1, update_date = NOW() WHERE del_flg = 0 AND rank > ?"; $conn->query($sql, array($pre_rank)); $sql = "UPDATE dtb_news SET rank = 0, del_flg = 1, update_date = NOW() WHERE news_id = ?"; $conn->query($sql, array($_POST['news_id'])); $conn->query("COMMIT"); $this->reload(); //自分にリダイレクト(再読込による誤動作防止) } //---- 表示順位移動 if ($_POST['mode'] == 'move' && is_numeric($_POST["news_id"])) { if ($_POST["term"] == "up") { $objDb->sfRankUp("dtb_news", "news_id", $_POST["news_id"]); } else { if ($_POST["term"] == "down") { $objDb->sfRankDown("dtb_news", "news_id", $_POST["news_id"]); } } //sf_rebuildIndex($conn); $this->reload(); } //---- 指定表示順位移動 if ($_POST['mode'] == 'moveRankSet') { $key = "pos-" . $_POST['news_id']; $input_pos = mb_convert_kana($_POST[$key], "n"); if (SC_Utils_Ex::sfIsInt($input_pos)) { $objDb->sfMoveRank("dtb_news", "news_id", $_POST['news_id'], $input_pos); $this->reload(); } } //---- 全データ取得 $sql = "SELECT *, cast(news_date as date) as cast_news_date FROM dtb_news WHERE del_flg = '0' ORDER BY rank DESC"; $this->list_data = $conn->getAll($sql); $this->line_max = count($this->list_data); $sql = "SELECT MAX(rank) FROM dtb_news WHERE del_flg = '0'"; // rankの最大値を取得 $this->max_rank = $conn->getOne($sql); $this->arrForm['news_select'] = 0; //---- ページ表示 $objView->assignobj($this); $objView->display(MAIN_FRAME); }