Ignore:
Timestamp:
2010/12/15 18:06:23 (13 years ago)
Author:
nanasess
bzr:base-revision:
svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:19724
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/Smarty/templates/admin/design/bloc.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fdesign%2Fbloc.tpl
data/Smarty/templates/admin/design/css.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fdesign%2Fcss.tpl
data/class/SC_View.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_View.php
data/class/helper/SC_Helper_PageLayout.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_PageLayout.php
data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php 15687@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_Bloc.php
data/class/pages/admin/design/LC_Page_Admin_Design_CSS.php 15689@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_CSS.php
data/class/pages/admin/design/LC_Page_Admin_Design_Header.php 15688@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_Header.php
data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php 15682@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design_MainEdit.php
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
bzr:mapping-version:
v4
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20101215090611-0mqtkfcbju06ba0c
bzr:revno:
2454
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:timestamp:
2010-12-15 18:06:11.522000074 +0900
bzr:user-agent:
bzr2.2.1+bzr-svn1.0.4
svn:original-date:
2010-12-15T09:06:11.522000Z
Message:

#748(モバイル/スマートフォンのデザイン管理)

  • テンプレートの取得方法を修正
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Template.php

    r19722 r19725  
    3939    // {{{ functions 
    4040 
    41     /** テンプレートデータ種別 */ 
    42     var $arrSubnavi = array( 
    43                      'title' => array( 
    44                                 1 => 'top', 
    45                                 2 => 'product', 
    46                                 3 => 'detail', 
    47                                 4 => 'mypage' 
    48                                              ), 
    49                      'name' =>array( 
    50                                 1 => 'TOPページ', 
    51                                 2 => '商品一覧ページ', 
    52                                 3 => '商品詳細ページ', 
    53                                 4 => 'MYページ' 
    54                               ) 
    55                      ); 
    56  
    5741    /** 
    5842     * Page を初期化する. 
     
    6246    function init() { 
    6347        parent::init(); 
    64         $this->tpl_mainpage = 'design/template.tpl'; 
    65         $this->tpl_subnavi  = 'design/subnavi.tpl'; 
    66         $this->tpl_subno    = 'template'; 
    67         $this->tpl_mainno   = "design"; 
    68         $this->tpl_subtitle = 'テンプレート設定'; 
    69         $this->arrErr  = array(); 
    70         $this->arrForm = array(); 
    71         $this->tpl_select = TEMPLATE_NAME; 
    72         ini_set("max_execution_time", 300); 
     48        $this->tpl_mainpage = 'design/template.tpl'; 
     49        $this->tpl_subnavi  = 'design/subnavi.tpl'; 
     50        $this->tpl_subno    = 'template'; 
     51        $this->tpl_mainno   = "design"; 
     52        $this->tpl_subtitle = 'テンプレート設定'; 
     53        $this->arrErr  = array(); 
     54        $this->arrForm = array(); 
     55        $this->tpl_select = TEMPLATE_NAME; 
     56        ini_set("max_execution_time", 300); 
    7357    } 
    7458 
     
    9276    function action() { 
    9377        // 認証可否の判定 
    94             $objSession = new SC_Session(); 
    95             SC_Utils::sfIsSuccess($objSession); 
    96  
    97             // uniqidをテンプレートへ埋め込み 
    98             $this->uniqid = $objSession->getUniqId(); 
    99  
    100             $objView = new SC_AdminView(); 
    101  
    102             switch($this->lfGetMode()) { 
    103  
    104             // 登録ボタン押下時 
    105             case 'register': 
    106                 // 画面遷移の正当性チェック 
    107                 if (!SC_Utils::sfIsValidTransition($objSession)) { 
    108                     sfDispError(''); 
    109                 } 
    110                 // パラメータ検証 
    111                 $objForm = $this->lfInitRegister(); 
    112                 if ($objForm->checkError()) { 
    113                     SC_Utils_Ex::sfDispError(''); 
    114                 } 
    115  
    116                 $template_code = $objForm->getValue('template_code'); 
     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()) { 
     87 
     88            // 登録ボタン押下時 
     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'); 
    117101                $this->tpl_select = $template_code; 
    118102 
    119                 if($template_code == "") { 
    120                     $template_code = "default"; 
    121                 } 
    122  
    123                 // DBへ使用するテンプレートを登録 
    124                 $this->lfRegisterTemplate($template_code); 
    125  
    126                 // XXX コンパイルファイルのクリア処理を行う 
    127                 $objView->_smarty->clear_compiled_tpl(); 
    128  
    129                 // common.cssの内容を更新 
    130                 $this->lfChangeCommonCss($template_code); 
    131                  
    132                 // テンプレートのコピー 
    133                 $this->lfCopyTemplate($template_code); 
    134                  
    135                 // ブロック位置を更新 
    136                 $this->lfChangeBloc($template_code); 
    137  
    138                 // 完了メッセージ 
    139                 $this->tpl_onload="alert('登録が完了しました。');"; 
    140                 break; 
    141  
    142             // 削除ボタン押下時 
    143             case 'delete': 
    144                 // 画面遷移の正当性チェック 
    145                 if (!SC_Utils::sfIsValidTransition($objSession)) { 
    146                     SC_Utils::sfDispError(''); 
    147                 } 
    148                 // パラメータ検証 
    149                 $objForm = $this->lfInitDelete(); 
    150                 if ($objForm->checkError()) { 
    151                     SC_Utils::sfDispError(''); 
    152                 } 
    153                  
    154                 //現在使用中のテンプレートとデフォルトのテンプレートは削除できないようにする 
    155                 $template_code = $objForm->getValue('template_code_temp'); 
    156                 if ($template_code == TEMPLATE_NAME || $template_code == DEFAULT_TEMPLATE_NAME) { 
    157                     $this->tpl_onload = "alert('選択中のテンプレートは削除出来ません');"; 
    158                     break; 
    159                 } 
    160                 $this->lfDeleteTemplate($template_code); 
    161                 break; 
    162  
    163             // downloadボタン押下時 
    164             case 'download': 
    165                 // 画面遷移の正当性チェック 
    166                 if (!SC_Utils::sfIsValidTransition($objSession)) { 
    167                     SC_Utils::sfDispError(''); 
    168                 } 
    169                 // パラメータ検証 
    170                 $objForm = $this->lfInitDownload(); 
    171                 $template_code = $objForm->getValue('template_code_temp'); 
    172                 // ユーザデータの下のファイルも保存する。 
    173                 $from_dir = USER_TEMPLATE_PATH . $template_code . "/"; 
    174                 $to_dir = SMARTY_TEMPLATES_DIR . $template_code . "/_packages/"; 
    175                 SC_Utils::sfMakeDir($to_dir); 
    176                 SC_Utils::sfCopyDir($from_dir, $to_dir); 
    177                 SC_Helper_FileManager::downloadArchiveFiles(SMARTY_TEMPLATES_DIR . $template_code); 
    178                 break; 
    179  
    180             // プレビューボタン押下時 
    181             case 'preview': 
    182                 break; 
    183  
    184             default: 
    185                 break; 
    186             } 
    187  
    188             // defaultパラメータのセット 
    189             $this->templates = $this->lfGetAllTemplates(); 
    190             $this->now_template = TEMPLATE_NAME; 
     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); 
     115                 
     116                // テンプレートのコピー 
     117                $this->lfCopyTemplate($template_code); 
     118                 
     119                // ブロック位置を更新 
     120                $this->lfChangeBloc($template_code); 
     121 
     122                // 完了メッセージ 
     123                $this->tpl_onload="alert('登録が完了しました。');"; 
     124                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; 
     146 
     147            // downloadボタン押下時 
     148            case 'download': 
     149                // 画面遷移の正当性チェック 
     150                if (!SC_Utils::sfIsValidTransition($objSession)) { 
     151                    SC_Utils::sfDispError(''); 
     152                } 
     153                // パラメータ検証 
     154                $objForm = $this->lfInitDownload(); 
     155                $template_code = $objForm->getValue('template_code_temp'); 
     156                // ユーザデータの下のファイルも保存する。 
     157                $from_dir = USER_TEMPLATE_PATH . $template_code . "/"; 
     158                $to_dir = SMARTY_TEMPLATES_DIR . $template_code . "/_packages/"; 
     159                SC_Utils::sfMakeDir($to_dir); 
     160                SC_Utils::sfCopyDir($from_dir, $to_dir); 
     161                SC_Helper_FileManager::downloadArchiveFiles(SMARTY_TEMPLATES_DIR . $template_code); 
     162                break; 
     163 
     164            // プレビューボタン押下時 
     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; 
    191175            $this->device_type_id = $device_type_id; 
    192176    } 
     
    201185    } 
    202186 
    203     function lfGetMode(){ 
    204         if (isset($_POST['mode'])) return $_POST['mode']; 
    205     } 
    206  
    207     function lfInitRegister() { 
    208         $objForm = new SC_FormParam(); 
    209         $objForm->addParam( 
    210             'template_code', 'template_code', STEXT_LEN, '', 
    211             array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") 
    212         ); 
    213         $objForm->setParam($_POST); 
    214  
    215         return $objForm; 
    216     } 
    217  
    218     function lfInitDelete() { 
    219         $objForm = new SC_FormParam(); 
    220         $objForm->addParam( 
    221             'template_code_temp', 'template_code_temp', STEXT_LEN, '', 
    222             array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") 
    223         ); 
    224         $objForm->setParam($_POST); 
    225  
    226         return $objForm; 
    227     } 
    228  
    229     function lfInitDownload() { 
    230         $objForm = new SC_FormParam(); 
    231         $objForm->addParam( 
    232             'template_code_temp', 'template_code_temp', STEXT_LEN, '', 
    233             array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") 
    234         ); 
    235         $objForm->setParam($_POST); 
    236  
    237         return $objForm; 
    238     } 
     187    function lfGetMode(){ 
     188        if (isset($_POST['mode'])) return $_POST['mode']; 
     189    } 
     190 
     191    function lfInitRegister() { 
     192        $objForm = new SC_FormParam(); 
     193        $objForm->addParam( 
     194            'template_code', 'template_code', STEXT_LEN, '', 
     195            array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") 
     196        ); 
     197        $objForm->setParam($_POST); 
     198 
     199        return $objForm; 
     200    } 
     201 
     202    function lfInitDelete() { 
     203        $objForm = new SC_FormParam(); 
     204        $objForm->addParam( 
     205            'template_code_temp', 'template_code_temp', STEXT_LEN, '', 
     206            array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") 
     207        ); 
     208        $objForm->setParam($_POST); 
     209 
     210        return $objForm; 
     211    } 
     212 
     213    function lfInitDownload() { 
     214        $objForm = new SC_FormParam(); 
     215        $objForm->addParam( 
     216            'template_code_temp', 'template_code_temp', STEXT_LEN, '', 
     217            array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") 
     218        ); 
     219        $objForm->setParam($_POST); 
     220 
     221        return $objForm; 
     222    } 
    239223 
    240224    /** 
     
    253237    } 
    254238 
    255     /** 
    256     * common.cssの更新 
    257     */ 
     239    /** 
     240    * common.cssの更新 
     241    */ 
    258242    function lfChangeCommonCss($template_code) { 
    259243        $css_path = USER_PATH . "css/common.css"; 
     
    272256        fclose($fp); 
    273257    } 
    274      
    275     /** 
    276     * ブロック位置の更新 
    277     */ 
    278     function lfChangeBloc($template_code) { 
    279         $objQuery = new SC_Query(); 
    280         $filepath = USER_TEMPLATE_PATH. $template_code. "/sql/update_bloc.sql"; 
    281          
    282         // ブロック位置更新SQLファイル有 
    283         if(file_exists($filepath)) { 
    284             if($fp = fopen($filepath, "r")) { 
    285                 $sql = fread($fp, filesize($filepath)); 
    286                 fclose($fp); 
    287             } 
    288             // 改行、タブを1スペースに変換 
    289             $sql = preg_replace("/[\r\n\t]/", " " ,$sql); 
    290             $sql_split = split(";", $sql); 
    291             foreach($sql_split as $key => $val){ 
    292                 if (trim($val) != "") { 
    293                     $objQuery->query($val); 
    294                 } 
    295             } 
    296         } 
    297     } 
    298  
    299     /** 
    300     * テンプレートパッケージの削除 
    301     */ 
    302     function lfDeleteTemplate($template_code) { 
    303         // DB更新 
    304         $objQuery = new SC_Query(); 
    305         $objQuery->delete('dtb_templates', 'template_code = ?', array($template_code)); 
    306         // テンプレート削除 
    307         $templates_dir = SMARTY_TEMPLATES_DIR. $template_code. "/"; 
    308         SC_Utils_Ex::sfDelFile($templates_dir); 
    309         // コンパイル削除 
    310         $templates_c_dir = DATA_PATH. "Smarty/templates_c/". $template_code. "/"; 
    311         SC_Utils_Ex::sfDelFile($templates_c_dir); 
    312         // ユーザーデータ削除 
    313         $user_dir = USER_TEMPLATE_PATH. $template_code. "/"; 
    314         SC_Utils_Ex::sfDelFile($user_dir); 
    315     } 
    316  
    317     function lfGetAllTemplates() { 
    318         $objQuery = new SC_Query(); 
    319         $arrRet = $objQuery->select('*', 'dtb_templates'); 
    320         if (empty($arrRet)) return array(); 
    321  
    322         return $arrRet; 
    323     } 
     258     
     259    /** 
     260    * ブロック位置の更新 
     261    */ 
     262    function lfChangeBloc($template_code) { 
     263        $objQuery = new SC_Query(); 
     264        $filepath = USER_TEMPLATE_PATH. $template_code. "/sql/update_bloc.sql"; 
     265         
     266        // ブロック位置更新SQLファイル有 
     267        if(file_exists($filepath)) { 
     268            if($fp = fopen($filepath, "r")) { 
     269                $sql = fread($fp, filesize($filepath)); 
     270                fclose($fp); 
     271            } 
     272            // 改行、タブを1スペースに変換 
     273            $sql = preg_replace("/[\r\n\t]/", " " ,$sql); 
     274            $sql_split = split(";", $sql); 
     275            foreach($sql_split as $key => $val){ 
     276                if (trim($val) != "") { 
     277                    $objQuery->query($val); 
     278                } 
     279            } 
     280        } 
     281    } 
     282 
     283    /** 
     284    * テンプレートパッケージの削除 
     285    */ 
     286    function lfDeleteTemplate($template_code) { 
     287        // DB更新 
     288        $objQuery = new SC_Query(); 
     289        $objQuery->delete('dtb_templates', 'template_code = ?', array($template_code)); 
     290        // テンプレート削除 
     291        $templates_dir = SMARTY_TEMPLATES_DIR. $template_code. "/"; 
     292        SC_Utils_Ex::sfDelFile($templates_dir); 
     293        // コンパイル削除 
     294        $templates_c_dir = DATA_PATH. "Smarty/templates_c/". $template_code. "/"; 
     295        SC_Utils_Ex::sfDelFile($templates_c_dir); 
     296        // ユーザーデータ削除 
     297        $user_dir = USER_TEMPLATE_PATH. $template_code. "/"; 
     298        SC_Utils_Ex::sfDelFile($user_dir); 
     299    } 
     300 
     301    function lfGetAllTemplates() { 
     302        $objQuery = new SC_Query(); 
     303        $arrRet = $objQuery->select('*', 'dtb_templates'); 
     304        if (empty($arrRet)) return array(); 
     305 
     306        return $arrRet; 
     307    } 
    324308 
    325309   /* 
     
    331315     */ 
    332316    function lfCreateTemplate($dir, $file , $cart_flg) { 
    333         umask(0); 
     317        umask(0); 
    334318        $objFileManager = new SC_Helper_FileManager_Ex(); 
    335          
     319         
    336320        // 作成ファイルディレクトリ 
    337321        $create_dir = $dir . $file; 
Note: See TracChangeset for help on using the changeset viewer.