Changeset 19966 for branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php
- Timestamp:
- 2011/01/19 14:20:39 (10 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:19965
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/class/pages/admin/design/LC_Page_Admin_Design_Template.php 16430@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_Template.php
data/class/pages/admin/design/LC_Page_Admin_Design_Up_Down.php 16677@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_Up_Down.php
data/mtb_constants_init.php 16505@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fmtb_constants_init.php
html/install/sql/create_table_mysql.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Fcreate_table_mysql.sql
html/install/sql/create_table_pgsql.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Fcreate_table_pgsql.sql
html/install/sql/insert_data.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Finsert_data.sql- bzr:mapping-version:
- v4
- bzr:merge:
ohkouchi@loop-az.jp-20110119051747-xgpjy36dee20bpe0- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20110119052036-djhmmdrf0dtm52gp
- bzr:revno:
- 2695
- bzr:revprop:branch-nick:
- branches/version-2_5-dev
- bzr:root:
- branches/version-2_5-dev
- bzr:text-revisions:
data/class/pages/admin/design/LC_Page_Admin_Design_Template.php ohkouchi@loop-az.jp-20110119051747-xgpjy36dee20bpe0
data/class/pages/admin/design/LC_Page_Admin_Design_Up_Down.php ohkouchi@loop-az.jp-20110119051747-xgpjy36dee20bpe0
data/mtb_constants_init.php ohkouchi@loop-az.jp-20110119025119-1ia8tvnnvxr55rdf
html/install/sql/create_table_mysql.sql ohkouchi@loop-az.jp-20110119051747-xgpjy36dee20bpe0
html/install/sql/create_table_pgsql.sql ohkouchi@loop-az.jp-20110119051747-xgpjy36dee20bpe0
html/install/sql/insert_data.sql ohkouchi@loop-az.jp-20110119051747-xgpjy36dee20bpe0- bzr:timestamp:
- 2011-01-19 14:20:36.427000046 +0900
- bzr:user-agent:
- bzr2.2.1+bzr-svn1.0.4
- svn:original-date:
- 2011-01-19T05:20:36.427000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php
r19807 r19966 53 53 $this->arrErr = array(); 54 54 $this->arrForm = array(); 55 $this->tpl_select = TEMPLATE_NAME;56 55 ini_set("max_execution_time", 300); 57 56 } … … 76 75 function action() { 77 76 // 認証可否の判定 78 $objSession = new SC_Session(); 79 SC_Utils::sfIsSuccess($objSession); 80 81 // uniqidをテンプレートへ埋め込み 82 $this->uniqid = $objSession->getUniqId(); 83 84 $objView = new SC_AdminView(); 85 86 switch($this->lfGetMode()) { 77 $objSession = new SC_Session(); 78 SC_Utils::sfIsSuccess($objSession); 79 80 // 端末種別IDを取得 81 if (isset($_REQUEST['device_type_id']) 82 && is_numeric($_REQUEST['device_type_id'])) { 83 $device_type_id = $_REQUEST['device_type_id']; 84 } else { 85 $device_type_id = DEVICE_TYPE_PC; 86 } 87 88 $this->tpl_select = $this->getTemplateName($device_type_id); 89 90 // uniqidをテンプレートへ埋め込み 91 $this->uniqid = $objSession->getUniqId(); 92 93 $objView = new SC_AdminView(); 94 95 switch($this->lfGetMode()) { 87 96 88 97 // 登録ボタン押下時 89 case 'register': 90 // 画面遷移の正当性チェック 91 if (!SC_Utils::sfIsValidTransition($objSession)) { 92 sfDispError(''); 93 } 94 // パラメータ検証 95 $objForm = $this->lfInitRegister(); 96 if ($objForm->checkError()) { 97 SC_Utils_Ex::sfDispError(''); 98 } 99 100 $template_code = $objForm->getValue('template_code'); 101 $this->tpl_select = $template_code; 102 103 if($template_code == "") { 104 $template_code = "default"; 105 } 106 107 // DBへ使用するテンプレートを登録 108 $this->lfRegisterTemplate($template_code); 109 110 // XXX コンパイルファイルのクリア処理を行う 111 $objView->_smarty->clear_compiled_tpl(); 112 113 // common.cssの内容を更新 114 $this->lfChangeCommonCss($template_code); 98 case 'register': 99 // 画面遷移の正当性チェック 100 if (!SC_Utils::sfIsValidTransition($objSession)) { 101 sfDispError(''); 102 } 103 // パラメータ検証 104 $objForm = $this->lfInitRegister(); 105 if ($objForm->checkError()) { 106 SC_Utils_Ex::sfDispError(''); 107 } 108 109 $template_code = $objForm->getValue('template_code'); 110 $this->tpl_select = $template_code; 111 112 if($template_code == "") { 113 $template_code = $this->getTemplateName($device_type_id, true); 114 } 115 116 // DBへ使用するテンプレートを登録 117 $this->lfRegisterTemplate($template_code); 118 119 // XXX コンパイルファイルのクリア処理を行う 120 $objView->_smarty->clear_compiled_tpl(); 121 122 // ブロック位置を更新 123 $this->lfChangeBloc($template_code); 124 125 // 完了メッセージ 126 $this->tpl_onload="alert('登録が完了しました。');"; 127 break; 128 129 // 削除ボタン押下時 130 case 'delete': 131 // 画面遷移の正当性チェック 132 if (!SC_Utils::sfIsValidTransition($objSession)) { 133 SC_Utils::sfDispError(''); 134 } 135 // パラメータ検証 136 $objForm = $this->lfInitDelete(); 137 if ($objForm->checkError()) { 138 SC_Utils::sfDispError(''); 139 } 115 140 116 // テンプレートのコピー 117 $this->lfCopyTemplate($template_code); 118 119 // ブロック位置を更新 120 $this->lfChangeBloc($template_code); 121 122 // 完了メッセージ 123 $this->tpl_onload="alert('登録が完了しました。');"; 141 //現在使用中のテンプレートとデフォルトのテンプレートは削除できないようにする 142 $template_code = $objForm->getValue('template_code_temp'); 143 if ($template_code == $this->getTemplateName($device_type_id) 144 || $template_code == $this->getTemplateName($device_type_id, true)) { 145 $this->tpl_onload = "alert('デフォルトテンプレートと、選択中のテンプレートは削除出来ません');"; 124 146 break; 125 126 // 削除ボタン押下時 127 case 'delete': 128 // 画面遷移の正当性チェック 129 if (!SC_Utils::sfIsValidTransition($objSession)) { 130 SC_Utils::sfDispError(''); 131 } 132 // パラメータ検証 133 $objForm = $this->lfInitDelete(); 134 if ($objForm->checkError()) { 135 SC_Utils::sfDispError(''); 136 } 137 138 //現在使用中のテンプレートとデフォルトのテンプレートは削除できないようにする 139 $template_code = $objForm->getValue('template_code_temp'); 140 if ($template_code == TEMPLATE_NAME || $template_code == DEFAULT_TEMPLATE_NAME) { 141 $this->tpl_onload = "alert('選択中のテンプレートは削除出来ません');"; 142 break; 143 } 144 $this->lfDeleteTemplate($template_code); 145 break; 147 } 148 $this->lfDeleteTemplate($template_code); 149 break; 146 150 147 151 // downloadボタン押下時 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 152 case 'download': 153 // 画面遷移の正当性チェック 154 if (!SC_Utils::sfIsValidTransition($objSession)) { 155 SC_Utils::sfDispError(''); 156 } 157 // パラメータ検証 158 $objForm = $this->lfInitDownload(); 159 $template_code = $objForm->getValue('template_code_temp'); 160 // ユーザデータの下のファイルも保存する。 161 $from_dir = USER_TEMPLATE_REALDIR . $template_code . "/"; 162 $to_dir = SMARTY_TEMPLATES_REALDIR . $template_code . "/_packages/"; 163 SC_Utils::sfMakeDir($to_dir); 164 SC_Utils::sfCopyDir($from_dir, $to_dir); 165 SC_Helper_FileManager::downloadArchiveFiles(SMARTY_TEMPLATES_REALDIR . $template_code); 166 break; 163 167 164 168 // プレビューボタン押下時 165 case 'preview': 166 break; 167 168 default: 169 break; 170 } 171 172 // defaultパラメータのセット 173 $this->templates = $this->lfGetAllTemplates(); 174 $this->now_template = TEMPLATE_NAME; 175 $this->device_type_id = $device_type_id; 169 case 'preview': 170 break; 171 172 default: 173 break; 174 } 175 176 $this->templates = $this->lfGetAllTemplates($device_type_id); 177 $this->now_template = TEMPLATE_NAME; 178 $this->device_type_id = $device_type_id; 176 179 } 177 180 … … 225 228 * 使用するテンプレートをDBへ登録する 226 229 */ 227 function lfRegisterTemplate($template_code ) {230 function lfRegisterTemplate($template_code, $device_type_id) { 228 231 $masterData = new SC_DB_MasterData_Ex(); 229 232 230 $data = array('TEMPLATE_NAME' => var_export($template_code, TRUE)); 233 $defineName = 'TEMPLATE_NAME'; 234 switch ($device_type_id) { 235 case DEVICE_TYPE_MOBILE: 236 $defineName = 'MOBILE_' . $defineName; 237 break; 238 239 case DEVICE_TYPE_SMARTPHONE: 240 $defineName = 'SMARTPHONE_' . $defineName; 241 break; 242 case DEVICE_TYPE_PC: 243 default: 244 } 245 246 $data = array($defineName => var_export($template_code, TRUE)); 231 247 232 248 // DBのデータを更新 … … 236 252 $masterData->createCache('mtb_constants', array(), true, array('id', 'remarks')); 237 253 } 238 239 /**240 * common.cssの更新241 */242 function lfChangeCommonCss($template_code) {243 $css_path = USER_REALDIR . "css/common.css";244 245 // ファイル内容取得246 $css_data = file_get_contents($css_path);247 248 // ファイル内容更新249 $pt = '/(@import url\("\.\.\/packages\/.+\/css\/import\.css"\);)/';250 $rp = '@import url("../packages/'. $template_code. '/css/import.css");';251 $css = preg_replace($pt, $rp, $css_data);252 253 // ファイル更新254 $fp = fopen($css_path,"w");255 fwrite($fp, $css);256 fclose($fp);257 }258 254 259 255 /** … … 262 258 function lfChangeBloc($template_code) { 263 259 $objQuery = new SC_Query(); 264 $filepath = USER_TEMPLATE_REALDIR. $template_code. "/sql/update_bloc.sql"; 260 /* 261 * FIXME 各端末に合わせて作成する必要あり 262 * $filepath = USER_TEMPLATE_REALDIR. $template_code. "/sql/update_bloc.sql"; 263 */ 265 264 266 265 // ブロック位置更新SQLファイル有 … … 299 298 } 300 299 301 function lfGetAllTemplates( ) {300 function lfGetAllTemplates($device_type_id) { 302 301 $objQuery = new SC_Query(); 303 $arrRet = $objQuery->select('*', 'dtb_templates' );302 $arrRet = $objQuery->select('*', 'dtb_templates', "device_type_id = ?", array($device_type_id)); 304 303 if (empty($arrRet)) return array(); 305 304 … … 307 306 } 308 307 309 /*310 * 関数名:lfCreateTemplate()311 * 引数1 :ディレクトリパス312 * 引数2 :作成ファイル名313 * 説明 :キャンペーンの初期テンプレート作成314 * 戻り値:無し315 */316 function lfCreateTemplate($dir, $file , $cart_flg) {317 umask(0);318 $objFileManager = new SC_Helper_FileManager_Ex();319 320 // 作成ファイルディレクトリ321 $create_dir = $dir . $file;322 $create_active_dir = $create_dir . "/" . CAMPAIGN_TEMPLATE_ACTIVE;323 $create_end_dir = $create_dir . "/" . CAMPAIGN_TEMPLATE_END;324 // デフォルトファイルディレクトリ325 $default_dir = TEMPLATE_REALDIR . CAMPAIGN_TEMPLATE_REALDIR;326 $default_active_dir = $default_dir . "/" . CAMPAIGN_TEMPLATE_ACTIVE;327 $default_end_dir = $default_dir . "/" . CAMPAIGN_TEMPLATE_END;328 329 $ret = $objFileManager->sfCreateFile($create_dir, 0755);330 $ret = $objFileManager->sfCreateFile($create_active_dir, 0755);331 $ret = $objFileManager->sfCreateFile($create_end_dir, 0755);332 333 // キャンペーン実行PHPをコピー334 $ret = $objFileManager->sfCreateFile(CAMPAIGN_PATH . $file);335 copy(HTML_REALDIR . CAMPAIGN_TEMPLATE_REALDIR . "index.php", CAMPAIGN_PATH . $file . "/index.php");336 copy(HTML_REALDIR . CAMPAIGN_TEMPLATE_REALDIR . "application.php", CAMPAIGN_PATH . $file . "/application.php");337 copy(HTML_REALDIR . CAMPAIGN_TEMPLATE_REALDIR . "complete.php", CAMPAIGN_PATH . $file . "/complete.php");338 copy(HTML_REALDIR . CAMPAIGN_TEMPLATE_REALDIR . "entry.php", CAMPAIGN_PATH . $file . "/entry.php");339 340 // デフォルトテンプレート作成(キャンペーン中)341 $header = $this->lfGetFileContents($default_active_dir."header.tpl");342 SC_Utils_Ex::sfWriteFile($header, $create_active_dir."header.tpl", "w");343 $contents = $this->lfGetFileContents($default_active_dir."contents.tpl");344 if(!$cart_flg) {345 $contents .= "\n" . '<!--{*ログインフォーム*}-->' . "\n";346 $contents .= $this->lfGetFileContents(CAMPAIGN_BLOC_PATH . "login.tpl");347 $contents .= '<!--{*会員登録フォーム*}-->'."\n";348 $contents .= $this->lfGetFileContents(CAMPAIGN_BLOC_PATH . "entry.tpl");349 }350 SC_Utils_Ex::sfWriteFile($contents, $create_active_dir."contents.tpl", "w");351 $footer = $this->lfGetFileContents($default_active_dir."footer.tpl");352 SC_Utils_Ex::sfWriteFile($footer, $create_active_dir."footer.tpl", "w");353 354 // サイトフレーム作成355 $site_frame = $header."\n";356 $site_frame .= '<script type="text/javascript" src="<!--{$TPL_DIR}-->js/navi.js"></script>'."\n";357 $site_frame .= '<script type="text/javascript" src="<!--{$TPL_DIR}-->js/site.js"></script>'."\n";358 $site_frame .= '<!--{include file=$tpl_mainpage}-->'."\n";359 $site_frame .= $footer."\n";360 SC_Utils_Ex::sfWriteFile($site_frame, $create_active_dir."site_frame.tpl", "w");361 362 /* デフォルトテンプレート作成(キャンペーン終了) */363 $header = $this->lfGetFileContents($default_end_dir."header.tpl");364 SC_Utils_Ex::sfWriteFile($header, $create_end_dir."header.tpl", "w");365 $contents = $this->lfGetFileContents($default_end_dir."contents.tpl");366 SC_Utils_Ex::sfWriteFile($contents, $create_end_dir."contents.tpl", "w");367 $footer = $this->lfGetFileContents($default_end_dir."footer.tpl");368 SC_Utils_Ex::sfWriteFile($footer, $create_end_dir."footer.tpl", "w");369 }370 371 308 /* 372 309 * 関数名:lfGetFileContents() … … 385 322 return $contents; 386 323 } 324 325 /** 326 * テンプレート名を返す. 327 */ 328 function getTemplateName($device_type_id, $isDefault = false) { 329 switch ($device_type_id) { 330 case DEVICE_TYPE_MOBILE: 331 return $isDefault ? MOBILE_DEFAULT_TEMPLATE_NAME : MOBILE_TEMPLATE_NAME; 332 break; 333 334 case DEVICE_TYPE_SMARTPHONE: 335 return $isDefault ? SMARTPHONE_DEFAULT_TEMPLATE_NAME : SMARTPHONE_TEMPLATE_NAME; 336 break; 337 338 case DEVICE_TYPE_PC: 339 default: 340 } 341 return $isDefault ? DEFAULT_TEMPLATE_NAME : TEMPLATE_NAME; 342 } 387 343 } 388 344 ?>
Note: See TracChangeset
for help on using the changeset viewer.