Ignore:
Timestamp:
2013/08/26 15:52:37 (11 years ago)
Author:
m_uehara
Message:

#2348 r23116 - r23125 をマージ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13_0/data/class/helper/SC_Helper_PageLayout.php

    r23069 r23126  
    2323 
    2424/** 
    25  * Webページのレイアウト情報を制御するヘルパークラス. 
     25 * Webページのレイアウト惠
     26報を制御するヘルパークラス. 
    2627 * 
    2728 * @package Helper 
     
    3233{ 
    3334    /** 
    34      * ページのレイアウト情報を取得し, 設定する. 
    35      * 
    36      * 現在の URL に応じたページのレイアウト情報を取得し, LC_Page インスタンスに 
    37      * 設定する. 
    38      * 
    39      * @access public 
    40      * @param LC_Page $objPage LC_Page インスタンス 
    41      * @param boolean $preview プレビュー表示の場合 true 
    42      * @param string $url ページのURL($_SERVER['SCRIPT_NAME'] の情報) 
    43      * @param integer $device_type_id 端末種別ID 
     35     * ページのレイアウト惠
     36報を取得し, 設定する. 
     37     * 
     38     * 現在の URL に応じたページのレイアウト惠
     39報を取得し, LC_Page インスタンスに 
     40     * 設定する. 
     41     * 
     42     * @access public 
     43     * @param  LC_Page $objPage        LC_Page インスタンス 
     44     * @param  boolean $preview        プレビュー表示の場合 true 
     45     * @param  string  $url            ページのURL($_SERVER['SCRIPT_NAME'] の惠
     46å ±) 
     47     * @param  integer $device_type_id 端末種別ID 
    4448     * @return void 
    4549     */ 
    46     function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_type_id = DEVICE_TYPE_PC) 
    47     { 
    48         // URLを元にページ情報を取得 
     50    public function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_type_id = DEVICE_TYPE_PC) 
     51    { 
     52        // URLをå 
     53ƒã«ãƒšãƒ¼ã‚¸æƒ 
     54報を取得 
    4955        if ($preview === false) { 
    5056            $url = preg_replace('|^' . preg_quote(ROOT_URLPATH) . '|', '', $url); 
    5157            $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', array($url)); 
    5258        } 
    53         // プレビューの場合は, プレビュー用のデータを取得 
     59        // プレビューの場合は, プレビュー用のデータを取得 
    5460        else { 
    5561            $arrPageData = $this->getPageProperties($device_type_id, 0); 
     
    5763 
    5864        if (empty($arrPageData[0])) { 
    59             trigger_error('ページ情報を取得できませんでした。', E_USER_ERROR); 
     65            trigger_error('ページ惠
     66報を取得できませんでした。', E_USER_ERROR); 
    6067        } 
    6168 
     
    6370         
    6471        if (!file_exists($objPage->tpl_mainpage)) { 
    65             $msg = 'メイン部のテンプレートが存在しません。[' . $objPage->tpl_mainpage . ']'; 
     72            $msg = 'メイン部のテンプレートが存在しません。[' . $objPage->tpl_mainpage . ']'; 
    6673            trigger_error($msg, E_USER_ERROR); 
    6774        } 
     
    7380        } 
    7481 
    75         // ページタイトルを設定 
     82        // ページタイトルを設定 
    7683        if (SC_Utils_Ex::isBlank($objPage->tpl_title)) { 
    7784            $objPage->tpl_title = $objPage->arrPageLayout['page_name']; 
    7885        } 
    7986 
    80         // 該当ページのブロックを取得し, 配置する 
     87        // 該当ページのブロックを取得し, é 
     88ç½®ã™ã‚‹ 
    8189        $masterData = new SC_DB_MasterData_Ex(); 
    8290        $arrTarget = $masterData->getMasterData('mtb_target'); 
    8391        $arrBlocs = $this->getBlocPositions($device_type_id, $objPage->arrPageLayout['page_id']); 
    84         // 無効なプラグインのブロックを取り除く. 
     92        // 無効なプラグインのブロックを取り除く. 
    8593        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); 
    8694        $arrBlocs = $objPlugin->getEnableBlocs($arrBlocs); 
    87         // php_path, tpl_path が存在するものを, 各ターゲットに配置 
     95        // php_path, tpl_path が存在するものを, 各ターゲットにé 
     96ç½® 
    8897        foreach ($arrTarget as $target_id => $value) { 
    8998            foreach ($arrBlocs as $arrBloc) { 
     
    95104                    $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc; 
    96105                } else { 
    97                     $error = "ブロックが見つかりません\n" 
     106                    $error = "ブロックが見つかりません\n" 
    98107                        . 'tpl_path: ' . $arrBloc['tpl_path'] . "\n" 
    99108                        . 'php_path: ' . $arrBloc['php_path']; 
     
    102111            } 
    103112        } 
    104         // カラム数を取得する 
     113        // カラム数を取得する 
    105114        $objPage->tpl_column_num = $this->getColumnNum($objPage->arrPageLayout); 
    106115    } 
    107116 
    108117    /** 
    109      * ページの属性を取得する. 
    110      * 
    111      * この関数は, dtb_pagelayout の情報を検索する. 
    112      * $device_type_id は必須. デフォルト値は DEVICE_TYPE_PC. 
    113      * $page_id が null の場合は, $page_id が 0 以外のものを検索する. 
    114      * 
    115      * @access public 
    116      * @param integer $device_type_id 端末種別ID 
    117      * @param integer $page_id ページID; null の場合は, 0 以外を検索する. 
    118      * @param string $where 追加の検索条件 
    119      * @param array $arrParams 追加の検索パラメーター 
    120      * @return array ページ属性の配列 
    121      */ 
    122     function getPageProperties($device_type_id = DEVICE_TYPE_PC, $page_id = null, $where = '', $arrParams = array()) 
     118     * ページの属性を取得する. 
     119     * 
     120     * この関数は, dtb_pagelayout の惠
     121報を検索する. 
     122     * $device_type_id は忠
     123須. デフォルト値は DEVICE_TYPE_PC. 
     124     * $page_id が null の場合は, $page_id が 0 以外のものを検索する. 
     125     * 
     126     * @access public 
     127     * @param  integer $device_type_id 端末種別ID 
     128     * @param  integer $page_id        ページID; null の場合は, 0 以外を検索する. 
     129     * @param  string  $where          追加の検索条件 
     130     * @param  array   $arrParams      追加の検索パラメーター 
     131     * @return array   ãƒšãƒ¼ã‚¸å±žæ€§ã®é 
     132åˆ— 
     133     */ 
     134    public function getPageProperties($device_type_id = DEVICE_TYPE_PC, $page_id = null, $where = '', $arrParams = array()) 
    123135    { 
    124136        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    137149 
    138150    /** 
    139      * ブロック情報を取得する. 
    140      * 
    141      * @access public 
    142      * @param integer $device_type_id 端末種別ID 
    143      * @param string $where 追加の検索条件 
    144      * @param array $arrParams 追加の検索パラメーター 
    145      * @param boolean $has_realpath php_path, tpl_path の絶対パスを含める場合 true 
    146      * @return array ブロック情報の配列 
    147      */ 
    148     function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = array(), $has_realpath = true) 
     151     * ブロック惠
     152報を取得する. 
     153     * 
     154     * @access public 
     155     * @param  integer $device_type_id 端末種別ID 
     156     * @param  string  $where          追加の検索条件 
     157     * @param  array   $arrParams      追加の検索パラメーター 
     158     * @param  boolean $has_realpath   php_path, tpl_path の絶対パスを含める場合 true 
     159     * @return array   ãƒ–ロック惠
     160報のé 
     161åˆ— 
     162     */ 
     163    public function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = array(), $has_realpath = true) 
    149164    { 
    150165        $objBloc = new SC_Helper_Bloc_Ex($device_type_id); 
     
    158173 
    159174    /** 
    160      * ブロック配置情報を取得する. 
    161      * 
    162      * @access public 
    163      * @param integer $device_type_id 端末種別ID 
    164      * @param integer $page_id ページID 
    165      * @param boolean $has_realpath php_path, tpl_path の絶対パスを含める場合 true 
    166      * @return array 配置情報を含めたブロックの配列 
    167      */ 
    168     function getBlocPositions($device_type_id, $page_id, $has_realpath = true) 
     175     * ブロックé 
     176ç½®æƒ 
     177報を取得する. 
     178     * 
     179     * @access public 
     180     * @param  integer $device_type_id 端末種別ID 
     181     * @param  integer $page_id        ページID 
     182     * @param  boolean $has_realpath   php_path, tpl_path の絶対パスを含める場合 true 
     183     * @return array   é 
     184ç½®æƒ 
     185報を含めたブロックのé 
     186åˆ— 
     187     */ 
     188    public function getBlocPositions($device_type_id, $page_id, $has_realpath = true) 
    169189    { 
    170190        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    183203        } 
    184204 
    185         //全ページ設定と各ページのブロックの重複を削除 
     205        //å 
     206¨ãƒšãƒ¼ã‚¸è¨­å®šã¨å„ページのブロックの重複を削除 
    186207        $arrUniqBlocIds = array(); 
    187208        foreach ($arrBlocs as $index => $arrBloc) { 
    188             if ($arrBloc['anywhere'] == 1){ 
     209            if ($arrBloc['anywhere'] == 1) { 
    189210                $arrUniqBlocIds[] = $arrBloc['bloc_id']; 
    190211            } 
    191212        } 
    192213        foreach ($arrBlocs as $bloc_index => $arrBlocData) { 
    193             if (in_array($arrBlocData['bloc_id'], $arrUniqBlocIds) && $arrBlocData['anywhere'] == 0){ 
     214            if (in_array($arrBlocData['bloc_id'], $arrUniqBlocIds) && $arrBlocData['anywhere'] == 0) { 
    194215                unset($arrBlocs[$bloc_index]); 
    195216            } 
     
    200221 
    201222    /** 
    202      * ページ情報を削除する. 
    203      * 
    204      * XXX ファイルを確実に削除したかどうかのチェック 
    205      * 
    206      * @access public 
    207      * @param integer $page_id ページID 
    208      * @param integer $device_type_id 端末種別ID 
    209      * @return integer 削除数 
    210      */ 
    211     function lfDelPageData($page_id, $device_type_id = DEVICE_TYPE_PC) 
     223     * ページ惠
     224報を削除する. 
     225     * 
     226     * XXX ファイルを確実に削除したかどうかのチェック 
     227     * 
     228     * @access public 
     229     * @param  integer $page_id        ページID 
     230     * @param  integer $device_type_id 端末種別ID 
     231     * @return integer 削除数 
     232     */ 
     233    public function lfDelPageData($page_id, $device_type_id = DEVICE_TYPE_PC) 
    212234    { 
    213235        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    214         // page_id が空でない場合にはdeleteを実行 
     236        // page_id が空でない場合にはdeleteを実行 
    215237        if ($page_id != '') { 
    216238            $arrPageData = $this->getPageProperties($device_type_id, $page_id); 
    217239            $ret = $objQuery->delete('dtb_pagelayout', 'page_id = ? AND device_type_id = ?', array($page_id, $device_type_id)); 
    218             // ファイルの削除 
     240            // ファイルの削除 
    219241            $this->lfDelFile($arrPageData[0]['filename'], $device_type_id); 
    220242        } 
     
    224246 
    225247    /** 
    226      * ページのファイルを削除する. 
    227      * 
    228      * dtb_pagelayout の削除後に呼び出すこと。 
     248     * ページのファイルを削除する. 
     249     * 
     250     * dtb_pagelayout の削除後に呼び出すこと。 
    229251     * 
    230252     * @access private 
    231      * @param string $filename 
    232      * @param integer $device_type_id 端末種別ID 
    233      * @return void // TODO boolean にするべき? 
    234      */ 
    235     function lfDelFile($filename, $device_type_id) 
     253     * @param  string $filename 
     254     * @param  integer $device_type_id 端末種別ID 
     255     * @return void    // TODO boolean にするべき? 
     256     */ 
     257    public function lfDelFile($filename, $device_type_id) 
    236258    { 
    237259        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    238260 
    239261        /* 
    240          * 同名ファイルの使用件数 
    241          * PHP ファイルは, 複数のデバイスで共有するため, device_type_id を条件に入れない 
     262         * 同名ファイルの使用件数 
     263         * PHP ファイルは, 複数のデバイスでå 
     264±æœ‰ã™ã‚‹ãŸã‚, device_type_id を条件にå 
     265¥ã‚Œãªã„ 
    242266         */ 
    243267        $exists = $objQuery->exists('dtb_pagelayout', 'filename = ?', array($filename)); 
    244268 
    245269        if (!$exists) { 
    246             // phpファイルの削除 
     270            // phpファイルの削除 
    247271            $del_php = HTML_REALDIR . $filename . '.php'; 
    248272            if (file_exists($del_php)) { 
     
    251275        } 
    252276 
    253         // tplファイルの削除 
     277        // tplファイルの削除 
    254278        $del_tpl = $this->getTemplatePath($device_type_id) . $filename . '.tpl'; 
    255279        if (file_exists($del_tpl)) { 
     
    259283 
    260284    /** 
    261      * 編集可能ページかどうか. 
    262      * 
    263      * @access public 
    264      * @param integer $device_type_id 端末種別ID 
    265      * @param integer $page_id ページID 
    266      * @return 編集可能ページの場合 true 
    267      */ 
    268     function isEditablePage($device_type_id, $page_id) 
     285     * 編集可能ページかどうか. 
     286     * 
     287     * @access public 
     288     * @param  integer                   $device_type_id 端末種別ID 
     289     * @param  integer                   $page_id        ページID 
     290     * @return ç·¨é›†å¯èƒ½ãƒšãƒ¼ã‚¸ã®å ´åˆ true 
     291     */ 
     292    public function isEditablePage($device_type_id, $page_id) 
    269293    { 
    270294        if ($page_id == 0) { 
     
    280304 
    281305    /** 
    282      * テンプレートのパスを取得する. 
    283      * 
    284      * @access public 
    285      * @param integer $device_type_id 端末種別ID 
    286      * @param boolean $isUser USER_REALDIR 以下のパスを返す場合 true 
    287      * @return string テンプレートのパス 
    288      */ 
    289     function getTemplatePath($device_type_id = DEVICE_TYPE_PC, $isUser = false) 
     306     * テンプレートのパスを取得する. 
     307     * 
     308     * @access public 
     309     * @param  integer $device_type_id 端末種別ID 
     310     * @param  boolean $isUser         USER_REALDIR 以下のパスを返す場合 true 
     311     * @return string  ãƒ†ãƒ³ãƒ—レートのパス 
     312     */ 
     313    public function getTemplatePath($device_type_id = DEVICE_TYPE_PC, $isUser = false) 
    290314    { 
    291315        $templateName = ''; 
     
    316340 
    317341    /** 
    318      * DocumentRoot から user_data のパスを取得する. 
    319      * 
    320      * 引数 $hasPackage を true にした場合は, user_data/packages/template_name 
    321      * を取得する. 
    322      * 
    323      * @access public 
    324      * @param integer $device_type_id 端末種別ID 
    325      * @param boolean $hasPackage パッケージのパスも含める場合 true 
    326      * @return string 端末に応じた DocumentRoot から user_data までのパス 
    327      */ 
    328     function getUserDir($device_type_id = DEVICE_TYPE_PC, $hasPackage = false) 
     342     * DocumentRoot から user_data のパスを取得する. 
     343     * 
     344     * 引数 $hasPackage を true にした場合は, user_data/packages/template_name 
     345     * を取得する. 
     346     * 
     347     * @access public 
     348     * @param  integer $device_type_id 端末種別ID 
     349     * @param  boolean $hasPackage     ãƒ‘ッケージのパスも含める場合 true 
     350     * @return string  ç«¯æœ«ã«å¿œã˜ãŸ DocumentRoot から user_data までのパス 
     351     */ 
     352    public function getUserDir($device_type_id = DEVICE_TYPE_PC, $hasPackage = false) 
    329353    { 
    330354        switch ($device_type_id) { 
     
    350374 
    351375    /** 
    352      * ブロックの php_path, tpl_path を設定する. 
     376     * ブロックの php_path, tpl_path を設定する. 
    353377     * 
    354378     * @access private 
    355      * @param integer $device_type_id 端末種別ID 
    356      * @param array $arrBlocs 設定するブロックの配列 
     379     * @param  integer $device_type_id 端末種別ID 
     380     * @param  array   $arrBlocs       è¨­å®šã™ã‚‹ãƒ–ロックのé 
     381åˆ— 
    357382     * @return void 
    358383     */ 
    359     function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs = array()) 
     384    public function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs = array()) 
    360385    { 
    361386        foreach ($arrBlocs as $key => $value) { 
     
    368393 
    369394    /** 
    370      * カラム数を取得する. 
     395     * カラム数を取得する. 
    371396     * 
    372397     * @access private 
    373      * @param array $arrPageLayout レイアウト情報の配列 
    374      * @return integer $col_num カラム数 
    375      */ 
    376     function getColumnNum($arrPageLayout) 
    377     { 
    378         // メインは確定 
     398     * @param  array   $arrPageLayout レイアウト惠
     399報のé 
     400åˆ— 
     401     * @return integer $col_num カラム数 
     402     */ 
     403    public function getColumnNum($arrPageLayout) 
     404    { 
     405        // メインは確定 
    379406        $col_num = 1; 
    380407        // LEFT NAVI 
     
    382409        // RIGHT NAVI 
    383410        if (count($arrPageLayout['RightNavi']) > 0) $col_num++; 
    384  
    385411        return $col_num; 
    386412    } 
Note: See TracChangeset for help on using the changeset viewer.