public function init()
 {
     parent::init();
     $objCategory = new SC_Helper_Category_Ex();
     $this->arrCommonCategory = $objCategory->getList(true);
     $this->arrCommonCategoryTree = $objCategory->getTree();
     $this->arrCommonCategoryList = array();
     foreach ($this->arrCommonCategoryTree as $tree) {
         if (is_array($tree["children"]) && count($tree["children"]) > 0) {
             foreach ($tree["children"] as $stree) {
                 $this->arrCommonCategoryList[$stree["category_id"]] = array($tree["category_name"], $stree["category_name"]);
                 $this->arrCommonCategoryList[$stree["category_id"]] = implode(" > ", $this->arrCommonCategoryList[$stree["category_id"]]);
             }
         } else {
             $this->arrCommonCategoryList[$tree["category_id"]] = $tree["category_name"];
         }
     }
 }
 /**
  * カテゴリツリーの取得.
  *
  * @param  array   $arrParentCategoryId 親カテゴリの配列
  * @param  boolean $count_check         登録商品数をチェックする場合はtrue
  * @return array   $arrRet カテゴリツリーの配列を返す
  */
 public function lfGetCatTree($arrParentCategoryId, $count_check = false)
 {
     $objCategory = new SC_Helper_Category_Ex($count_check);
     $arrTree = $objCategory->getTree();
     $this->arrParentID = array();
     foreach ($arrParentCategoryId as $category_id) {
         $arrParentID = $objCategory->getTreeTrail($category_id);
         $this->arrParentID = array_merge($this->arrParentID, $arrParentID);
         $this->root_parent_id[] = $arrParentID[0];
     }
     return $arrTree;
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     $objDb = new SC_Helper_DB_Ex();
     $objFormParam = new SC_FormParam_Ex();
     $objCategory = new SC_Helper_Category_Ex();
     // 入力パラメーター初期化
     $this->initParam($objFormParam);
     $objFormParam->setParam($_POST);
     $objFormParam->convParam();
     switch ($this->getMode()) {
         // カテゴリ登録/編集実行
         case 'edit':
             $this->doEdit($objFormParam);
             break;
             // 入力ボックスへ編集対象のカテゴリ名をセット
         // 入力ボックスへ編集対象のカテゴリ名をセット
         case 'pre_edit':
             $this->doPreEdit($objFormParam);
             break;
             // カテゴリ削除
         // カテゴリ削除
         case 'delete':
             $this->doDelete($objFormParam, $objDb);
             break;
             // 表示順を上へ
         // 表示順を上へ
         case 'up':
             $this->doUp($objFormParam);
             break;
             // 表示順を下へ
         // 表示順を下へ
         case 'down':
             $this->doDown($objFormParam);
             break;
             // FIXME r19909 によってテンプレートが削除されている
         // FIXME r19909 によってテンプレートが削除されている
         case 'moveByDnD':
             // DnDしたカテゴリと移動先のセットを分解する
             $keys = explode('-', $_POST['keySet']);
             if ($keys[0] && $keys[1]) {
                 $objQuery =& SC_Query_Ex::getSingletonInstance();
                 $objQuery->begin();
                 // 移動したデータのrank、level、parent_category_idを取得
                 $rank = $objQuery->get('rank', 'dtb_category', 'category_id = ?', array($keys[0]));
                 $level = $objQuery->get('level', 'dtb_category', 'category_id = ?', array($keys[0]));
                 $parent = $objQuery->get('parent_category_id', 'dtb_category', 'category_id = ?', array($keys[0]));
                 // 同一level内のrank配列を作成
                 $objQuery->setOption('ORDER BY rank DESC');
                 if ($level == 1) {
                     // 第1階層の時
                     $arrRet = $objQuery->select('rank', 'dtb_category', 'level = ?', array($level));
                 } else {
                     // 第2階層以下の時
                     $arrRet = $objQuery->select('rank', 'dtb_category', 'level = ? AND parent_category_id = ?', array($level, $parent));
                 }
                 for ($i = 0; $i < sizeof($arrRet); $i++) {
                     $rankAry[$i + 1] = $arrRet[$i]['rank'];
                 }
                 // 移動したデータのグループ内データ数
                 $my_count = $this->lfCountChilds($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $keys[0]);
                 if ($rankAry[$keys[1]] > $rank) {
                     // データが今の位置より上がった時
                     $up_count = $rankAry[$keys[1]] - $rank;
                     $decAry = $objQuery->select('category_id', 'dtb_category', 'level = ? AND rank > ? AND rank <= ?', array($level, $rank, $rankAry[$keys[1]]));
                     foreach ($decAry as $value) {
                         // 上のグループから減算
                         $this->lfDownRankChilds($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $value['category_id'], $my_count);
                     }
                     // 自分のグループに加算
                     $this->lfUpRankChilds($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $keys[0], $up_count);
                 } elseif ($rankAry[$keys[1]] < $rank) {
                     // データが今の位置より下がった時
                     $down_count = 0;
                     $incAry = $objQuery->select('category_id', 'dtb_category', 'level = ? AND rank < ? AND rank >= ?', array($level, $rank, $rankAry[$keys[1]]));
                     foreach ($incAry as $value) {
                         // 下のグループに加算
                         $this->lfUpRankChilds($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $value['category_id'], $my_count);
                         // 合計減算値
                         $down_count += $this->lfCountChilds($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $value['category_id']);
                     }
                     // 自分のグループから減算
                     $this->lfDownRankChilds($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $keys[0], $down_count);
                 }
                 $objQuery->commit();
             }
             break;
             // カテゴリツリークリック時
         // カテゴリツリークリック時
         case 'tree':
             break;
             // CSVダウンロード
         // CSVダウンロード
         case 'csv':
             // CSVを送信する
             $objCSV = new SC_Helper_CSV_Ex();
             $objCSV->sfDownloadCsv('5', '', array(), '', true);
             SC_Response_Ex::actionExit();
             break;
         default:
             break;
     }
     $parent_category_id = $objFormParam->getValue('parent_category_id');
     // 空の場合は親カテゴリを0にする
     if (empty($parent_category_id)) {
         $parent_category_id = 0;
     }
     // 親カテゴリIDの保持
     $this->arrForm['parent_category_id'] = $parent_category_id;
     // カテゴリ一覧を取得
     $this->arrList = $this->findCategoiesByParentCategoryId($parent_category_id);
     // カテゴリツリーを取得
     $this->arrTree = $objCategory->getTree();
     $this->arrParentID = $objCategory->getTreeTrail($parent_category_id);
     // ぱんくずの生成
     $arrBread = $objCategory->getTreeTrail($this->arrForm['parent_category_id'], FALSE);
     $this->tpl_bread_crumbs = SC_Utils_Ex::jsonEncode(array_reverse($arrBread));
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     $objDb = new SC_Helper_DB_Ex();
     $objCategory = new SC_Helper_Category_Ex();
     $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : '';
     // 通常時は親カテゴリを0に設定する。
     $this->arrForm['parent_category_id'] = isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : 0;
     $this->arrForm['product_id'] = isset($_POST['product_id']) ? $_POST['product_id'] : '';
     switch ($this->getMode()) {
         case 'up':
             $this->lfRankUp($objDb, $this->arrForm['parent_category_id'], $this->arrForm['product_id']);
             break;
         case 'down':
             $this->lfRankDown($objDb, $this->arrForm['parent_category_id'], $this->arrForm['product_id']);
             break;
         case 'move':
             $this->lfRankMove($objDb, $this->arrForm['parent_category_id'], $this->arrForm['product_id']);
             break;
         case 'tree':
             // カテゴリの切替は、ページ番号をクリアする。
             $this->tpl_pageno = '';
             break;
         case 'renumber':
             $this->lfRenumber($this->arrForm['parent_category_id']);
             break;
         default:
             break;
     }
     $this->arrTree = $objCategory->getTree();
     $this->arrParentID = $objCategory->getTreeTrail($this->arrForm['parent_category_id']);
     $this->arrProductsList = $this->lfGetProduct($this->arrForm['parent_category_id']);
     $arrBread = $objCategory->getTreeTrail($this->arrForm['parent_category_id'], FALSE);
     $this->tpl_bread_crumbs = SC_Utils_Ex::jsonEncode(array_reverse($arrBread));
 }
 function init()
 {
     parent::init();
     $objCustomer = new SC_Customer_Ex();
     if (isset($_GET["sid"]) && isset($_GET["admin"])) {
         $sid = $_REQUEST["sid"];
         $email = $objCustomer->getValue("email");
         $osid = session_id();
         if ($osid != $sid) {
             session_destroy();
             session_id($sid);
             session_start();
         }
         $objCustomer->setLogin($email);
         $get = $_GET;
         unset($get["sid"]);
         SC_Response_Ex::reload($get, true);
     }
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     if (GC_Utils_Ex::isFrontFunction() && $this->skip_load_page_layout == false) {
         $objCustomer = new SC_Customer_Ex();
         // 画面更新毎に情報を更新する
         if ($objCustomer->isLoginSuccess()) {
             // 初回アクセス時に更新
             $objCustomer->updateSession();
             $this->tpl_login = true;
             $this->tpl_point = $objCustomer->getValue("point");
             $this->tpl_customer_id = $objCustomer->getValue("customer_id");
             $this->tpl_first_buy_date = $objCustomer->getValue("first_buy_date");
             $this->tpl_carrier = $objCustomer->getValue("carrier");
             $downloadable_days = $this->arrSiteInfo["downloadable_days"];
             $downloadable_days_unlimited = $this->arrSiteInfo["downloadable_days_unlimited"];
             $date = null;
             if ($downloadable_days_unlimited) {
                 $date = SC_Utils_Ex::sfGetTimestamp(RELEASE_YEAR, 1, 1, false);
                 $date2 = SC_Utils_Ex::sfGetTimestamp(9999, 12, 31, false);
             } else {
                 $xdate = strtotime("-{$downloadable_days} day");
                 $date = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false);
                 $xdate = strtotime("+{$downloadable_days} day");
                 $date2 = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false);
             }
             $this->downloadable_days = $date;
             $this->downloadable_days2 = $date2;
             $objPurchase = new SC_Helper_Purchase_Ex();
             $arrOrderId = $objQuery->getCol("order_id", "dtb_order", "payment_date > ? AND customer_id = ?", array($date, $this->tpl_customer_id));
             $this->arrRedownloadProduct = array();
             foreach ($arrOrderId as $order_id) {
                 $arrOrderDetail = $objPurchase->getOrderDetail($order_id, true);
                 $this->arrRedownloadProduct = array_merge($this->arrRedownloadProduct, $arrOrderDetail);
             }
             // 再ダウンロード可能な商品一覧
             $this->arrRedownloadProduct = SC_Utils_Ex::makeArrayIDToKey("product_id", $this->arrRedownloadProduct);
             foreach ($this->arrRedownloadProduct as $product_id => $row) {
                 $row["product"] = $objProduct->getDetail($product_id);
                 $this->arrRedownloadProduct[$product_id] = $row;
             }
         } else {
             $this->tpl_login = false;
             $this->tpl_point = 0;
             $this->tpl_customer_id = 0;
             $this->tpl_first_buy_date = null;
             $this->tpl_carrier = 9;
             $this->arrRedownloadProduct = array();
         }
         $objDb = new SC_Helper_DB_Ex();
         if ($objDb->sfColumnExists("cp_dtb_customer_transaction", "id")) {
             $where = " customer_id =  ? AND transaction_status =  ? AND continue_account_id IS NOT NULL AND del_flg = 0";
             $arrWhereVal = array($this->tpl_customer_id, 40);
             if ($objQuery->exists("cp_dtb_customer_transaction", $where, $arrWhereVal)) {
                 // OK
             } else {
                 switch (basename(dirname($_SERVER["SCRIPT_NAME"]))) {
                     case "au":
                         break;
                     default:
                         if ($objCustomer->isLoginSuccess()) {
                             $objCustomer->EndSession();
                             SC_Response_Ex::reload();
                         }
                         break;
                 }
             }
         }
         $objCategory = new SC_Helper_Category_Ex();
         $this->arrCommonCategory = $objCategory->getList(true);
         $this->arrCommonCategoryTree = $objCategory->getTree();
         $detect = new Mobile_Detect();
         $script_file = $_SERVER["SCRIPT_NAME"];
         $script_file = ltrim($script_file, "/");
         $script_file2 = str_replace("ios/", "", $script_file);
         if ($detect->is("iOS")) {
             if (file_exists(HTML_REALDIR . "ios/{$script_file}")) {
                 SC_Response_Ex::sendRedirect(HTTP_URL . "ios/{$script_file}", $_GET);
             }
         } elseif (strcmp($script_file, $script_file2) !== 0) {
             SC_Response_Ex::sendRedirect(HTTP_URL . "{$script_file2}", $_GET);
         }
         $_SESSION["is_android"] = $detect->is("AndroidOS");
         if ($detect->isMobile() == false) {
             // NG
             $this->device_support = false;
         } elseif ($detect->is("iOS")) {
             if ($detect->match("iPhone")) {
                 // OK
                 $this->device_support = true;
             } elseif ($detect->match("iPod")) {
                 // NG
                 $this->device_support = false;
             } elseif ($detect->match("iPad")) {
                 // NG
                 $this->device_support = false;
             } else {
                 // NG
                 $this->device_support = false;
             }
             $version = $detect->version("iOS", $detect::VERSION_TYPE_FLOAT);
             if ($version < 6) {
                 // NG
                 $this->device_support = false;
             }
         } elseif ($detect->match("Android") == false) {
             // NG
             $this->device_support = false;
         } elseif (class_exists("SC_DeviceAndroidSelect_Ex", true)) {
             $useragent = array();
             if (preg_match("|.*; ([^;]+) Build/.*|", $_SERVER["HTTP_USER_AGENT"], $useragent)) {
                 $device = new SC_DeviceAndroidSelect_Ex(array("search_device_user_agent_word" => $useragent[1], "search_status" => 1));
                 $this->device_support = $device->exists();
                 $this->tpl_device = $device->getOne();
             }
         } elseif ($detect->match("Android")) {
             // OK
             $this->device_support = true;
         } else {
             // NG
             $this->device_support = false;
         }
     }
     if ($this->device_support) {
         GC_Utils_Ex::gfPrintLog("対応端末:" . $_SERVER['HTTP_USER_AGENT']);
         return;
     } else {
         GC_Utils_Ex::gfPrintLog("非対応端末:" . $_SERVER['HTTP_USER_AGENT']);
         if (is_a($this, "LC_Page_Index")) {
             SC_Response_Ex::sendRedirect(HTTP_URL . "unsupported/index.php");
         } elseif (is_a($this, "LC_Page_Unsupported")) {
             // 非対応端末表示を行わない
             return;
         } elseif (is_a($this, "LC_Page_Entry_Kiyaku")) {
             // 非対応端末表示を行わない
             return;
         } elseif ($this->not_unsupported) {
             // 非対応端末表示を行わない
             return;
         } else {
             SC_Response_Ex::sendRedirect(HTTP_URL . "unsupported/index.php");
         }
     }
 }