Changeset 17649
- Timestamp:
- 2008/10/08 12:42:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php
r17647 r17649 117 117 // common.cssの内容を更新 118 118 $this->lfChangeCommonCss($template_code); 119 119 120 // テンプレートのコピー 121 $this->lfCopyTemplate($template_code); 122 120 123 // ブロック位置を更新 121 124 $this->lfChangeBloc($template_code); … … 310 313 return $arrRet; 311 314 } 315 316 /** 317 * テンプレート変更時に既に存在するキャンペーンのテンプレートがない場合はテンプレートを生成する 318 * 319 */ 320 function lfCopyTemplate($template_code){ 321 //すべてのキャンペーンのテンプレートファイルを確認 322 $objQuery = new SC_Query(); 323 $sql = "SELECT directory_name,cart_flg FROM dtb_campaign WHERE del_flg = 0"; 324 $result = $objQuery->getall( $sql ); 325 //デザインテンプレートディレクトリにファイルが存在するか確認 326 foreach( $result as $key => $val ){ 327 //index.phpが存在すればキャンペーンのテンプレートがあると判定 328 //全部チェックした方がいいか? 329 $campaign_template_file_path = SMARTY_TEMPLATES_DIR.$template_code ."/". CAMPAIGN_TEMPLATE_DIR . $val['directory_name'] . "/" .CAMPAIGN_TEMPLATE_ACTIVE . "site_frame.tpl"; 330 var_dump("<font color='red'>$campaign_template_file_path</font><br>"); 331 if(!file_exists($campaign_template_file_path)){ 332 var_dump("<font color='red'>test</font>"); 333 //ファイルがなければコピーして作成 334 $this->lfCreateTemplate(SMARTY_TEMPLATES_DIR.$template_code ."/" . CAMPAIGN_TEMPLATE_DIR , $val['directory_name'],$val['cart_flg'] ); 335 } 336 } 337 } 338 339 /* 340 * 関数名:lfCreateTemplate() 341 * 引数1 :ディレクトリパス 342 * 引数2 :作成ファイル名 343 * 説明 :キャンペーンの初期テンプレート作成 344 * 戻り値:無し 345 */ 346 function lfCreateTemplate($dir, $file , $cart_flg) { 347 umask(0); 348 $objFileManager = new SC_Helper_FileManager_Ex(); 349 350 // 作成ファイルディレクトリ 351 $create_dir = $dir . $file; 352 $create_active_dir = $create_dir . "/" . CAMPAIGN_TEMPLATE_ACTIVE; 353 $create_end_dir = $create_dir . "/" . CAMPAIGN_TEMPLATE_END; 354 // デフォルトファイルディレクトリ 355 $default_dir = TEMPLATE_DIR . CAMPAIGN_TEMPLATE_DIR; 356 $default_active_dir = $default_dir . "/" . CAMPAIGN_TEMPLATE_ACTIVE; 357 $default_end_dir = $default_dir . "/" . CAMPAIGN_TEMPLATE_END; 358 359 $ret = $objFileManager->sfCreateFile($create_dir, 0755); 360 $ret = $objFileManager->sfCreateFile($create_active_dir, 0755); 361 $ret = $objFileManager->sfCreateFile($create_end_dir, 0755); 362 363 // キャンペーン実行PHPをコピー 364 $ret = $objFileManager->sfCreateFile(CAMPAIGN_PATH . $file); 365 copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "index.php", CAMPAIGN_PATH . $file . "/index.php"); 366 copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "application.php", CAMPAIGN_PATH . $file . "/application.php"); 367 copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "complete.php", CAMPAIGN_PATH . $file . "/complete.php"); 368 copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "entry.php", CAMPAIGN_PATH . $file . "/entry.php"); 369 370 // デフォルトテンプレート作成(キャンペーン中) 371 $header = $this->lfGetFileContents($default_active_dir."header.tpl"); 372 SC_Utils_Ex::sfWriteFile($header, $create_active_dir."header.tpl", "w"); 373 $contents = $this->lfGetFileContents($default_active_dir."contents.tpl"); 374 if(!$cart_flg) { 375 $contents .= "\n" . '<!--{*ログインフォーム*}-->' . "\n"; 376 $contents .= $this->lfGetFileContents(CAMPAIGN_BLOC_PATH . "login.tpl"); 377 $contents .= '<!--{*会員登録フォーム*}-->'."\n"; 378 $contents .= $this->lfGetFileContents(CAMPAIGN_BLOC_PATH . "entry.tpl"); 379 } 380 SC_Utils_Ex::sfWriteFile($contents, $create_active_dir."contents.tpl", "w"); 381 $footer = $this->lfGetFileContents($default_active_dir."footer.tpl"); 382 SC_Utils_Ex::sfWriteFile($footer, $create_active_dir."footer.tpl", "w"); 383 384 // サイトフレーム作成 385 $site_frame = $header."\n"; 386 $site_frame .= '<script type="text/javascript" src="<!--{$TPL_DIR}-->js/navi.js"></script>'."\n"; 387 $site_frame .= '<script type="text/javascript" src="<!--{$TPL_DIR}-->js/site.js"></script>'."\n"; 388 $site_frame .= '<!--{include file=$tpl_mainpage}-->'."\n"; 389 $site_frame .= $footer."\n"; 390 SC_Utils_Ex::sfWriteFile($site_frame, $create_active_dir."site_frame.tpl", "w"); 391 392 /* デフォルトテンプレート作成(キャンペーン終了) */ 393 $header = $this->lfGetFileContents($default_end_dir."header.tpl"); 394 SC_Utils_Ex::sfWriteFile($header, $create_end_dir."header.tpl", "w"); 395 $contents = $this->lfGetFileContents($default_end_dir."contents.tpl"); 396 SC_Utils_Ex::sfWriteFile($contents, $create_end_dir."contents.tpl", "w"); 397 $footer = $this->lfGetFileContents($default_end_dir."footer.tpl"); 398 SC_Utils_Ex::sfWriteFile($footer, $create_end_dir."footer.tpl", "w"); 399 } 400 401 /* 402 * 関数名:lfGetFileContents() 403 * 引数1 :ファイルパス 404 * 説明 :ファイル読込 405 * 戻り値:無し 406 */ 407 function lfGetFileContents($read_file) { 408 409 if(file_exists($read_file)) { 410 $contents = file_get_contents($read_file); 411 } else { 412 $contents = ""; 413 } 414 415 return $contents; 416 } 312 417 } 313 418 ?>
Note: See TracChangeset
for help on using the changeset viewer.