コード例 #1
0
 function install(array $arrPlugin, SC_Plugin_Installer $installer)
 {
     $plugin_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
     $upload_plugin_dir = PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"] . DIRECTORY_SEPARATOR;
     $backup_plugin_dir = PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"] . "_" . date("Ymd") . DIRECTORY_SEPARATOR;
     if (!is_dir($backup_plugin_dir)) {
         SC_Utils_Ex::sfCopyDir($upload_plugin_dir, $backup_plugin_dir);
     }
     SC_Helper_FileManager_Ex::deleteFile($upload_plugin_dir, false);
     SC_Utils_Ex::sfCopyDir($plugin_dir . "/", $upload_plugin_dir);
     SC_Utils_Ex::sfCopyDir($plugin_dir . "/copy/Smarty/templates/admin/", TEMPLATE_ADMIN_REALDIR);
     SC_Utils_Ex::sfCopyDir($plugin_dir . "/copy/modules/", DATA_REALDIR . "module/");
     // logo コピー
     $installer->copyDirectory("copy/plugin_dir/", "");
     $table = "dtb_products";
     $fields = array('auto_display_status' => $this->intColumn('自動公開'), 'auto_display_start_date' => $this->timestampColumn('公開開始日'), 'auto_display_end_date' => $this->timestampColumn('公開終了日'));
     $type = "timestamp";
     $definition = compact("type");
     foreach ($fields as $name => $define) {
         $this->objDb->sfColumnExists($table, $name, $define["type"], "", true);
         $this->fieldComment($installer, $table, $name, $define["comment"]);
         switch ($define["type"]) {
             case "timestamp":
                 break;
             default:
                 continue;
         }
         $change = array();
         $change[$name] = compact('definition');
         $this->objManager->alterTable($table, compact("change"), false);
     }
     $this->objQuery->update("dtb_products", array(), "auto_display_start_date IS NULL", array(), array("auto_display_start_date" => "create_date"));
     $masterfields = array("id" => $this->intColumn("ID"), "name" => $this->textColumn("NAME"), "rank" => $this->intColumn("RANK"));
     $table = "atd_mtb_auto_display_status";
     if ($this->objDb->sfColumnExists($table, "id") == false) {
         $this->objManager->createTable($table, $masterfields);
     }
     foreach ($masterfields as $name => $define) {
         $this->objDb->sfColumnExists($table, $name, $define["type"], "", true);
         $this->fieldComment($installer, $table, $name, $define["comment"]);
     }
     $this->masterdata->deleteMasterData($table);
     $this->masterdata->clearCache($table);
     $this->masterdata->registMasterData($table, array(), explode(",", "常時公開,時限公開"));
     // $this->insertMasterData ( "PRODUCTS_RESULT_ROWSPAN", 1, '管理画面/商品管理一覧 行結合数' );
     // $this->insertMasterData ( "PRODUCTS_RESULT_COLUMN", 5, '管理画面/商品管理一覧 列位置' );
     // $this->insertMasterData ( "PRODUCTS_SEARCH_AUTO_DISPLAY", 1, '検索画面表示設定(1: ON/ 0:OFF)' );
     // $this->insertMasterData ( "PRODUCTS_DETAIL_AUTO_DISPLAY", 1, '検索画面表示設定(1: ON/ 0:OFF)' );
 }
コード例 #2
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     SC_Utils_Ex::sfIsSuccess(new SC_Session());
     $objView = new SC_AdminView();
     $this->arrMasterDataName = $this->getMasterDataNames(array("mtb_pref", "mtb_zip", "mtb_constants"));
     $masterData = new SC_DB_MasterData_Ex();
     if (!isset($_POST["mode"])) {
         $_POST["mode"] = "";
     }
     switch ($_POST["mode"]) {
         case "edit":
             // POST 文字列の妥当性チェック
             $this->checkMasterDataName();
             $this->errorMessage = $this->checkUniqueID();
             if (empty($this->errorMessage)) {
                 // 取得したデータからマスタデータを生成
                 $arrData = array();
                 foreach ($_POST['id'] as $key => $val) {
                     // ID が空のデータは生成しない
                     if ($val != "") {
                         $arrData[$val] = $_POST['name'][$key];
                     }
                 }
                 // マスタデータを更新
                 $masterData->objQuery = new SC_Query();
                 $masterData->objQuery->begin();
                 $masterData->deleteMasterData($this->masterDataName, false);
                 // TODO カラム名はメタデータから取得した方が良い
                 $masterData->registMasterData($this->masterDataName, array("id", "name", "rank"), $arrData, false);
                 $masterData->objQuery->commit();
                 $this->tpl_onload = "window.alert('マスタデータの設定が完了しました。');";
             }
         case "show":
             // POST 文字列の妥当性チェック
             $this->checkMasterDataName();
             // DB からマスタデータを取得
             $this->arrMasterData = $masterData->getDbMasterData($this->masterDataName);
             break;
         default:
     }
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * マスターデータの登録.
  *
  * @access private{
  * @param array $arrParams
  *            $_POST値
  * @param SC_DB_MasterData_Ex $masterData
  *            SC_DB_MasterData_Ex()
  * @param string $master_data_name
  *            登録対象のマスターデータのテーブル名
  * @return void
  */
 public function registMasterData($arrParams, &$masterData, $master_data_name)
 {
     $arrTmp = array();
     foreach ($arrParams['id'] as $key => $val) {
         // ID が空のデータは生成しない
         if ($val != '') {
             $arrTmp[$val] = $arrParams['name'][$key];
         }
     }
     // マスターデータを更新
     $masterData->objQuery =& SC_Query_Ex::getSingletonInstance();
     $masterData->objQuery->begin();
     $masterData->deleteMasterData($master_data_name, false);
     // TODO カラム名はメタデータから取得した方が良い
     $masterData->registMasterData($master_data_name, array('id', 'name', 'rank'), $arrTmp, false);
     $masterData->objQuery->commit();
 }