- Timestamp:
- 2011/04/12 22:58:10 (13 years ago)
- bzr:base-revision:
- svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_11-dev:20829
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/Smarty/templates/admin/design/index.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fdesign%2Findex.tpl
data/class/SC_FormParam.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_FormParam.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.php 15680@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fdesign%2FLC_Page_Admin_Design.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- bzr:mapping-version:
- v4
- bzr:merge:
ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20110412135757-jzouuuwavr7z993z
- bzr:revno:
- 3541
- bzr:revprop:branch-nick:
- branches/version-2_11-dev
- bzr:root:
- branches/version-2_11-dev
- bzr:text-revisions:
data/Smarty/templates/admin/design/index.tpl ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/SC_FormParam.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/helper/SC_Helper_PageLayout.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/pages/admin/design/LC_Page_Admin_Design.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz
data/class/pages/admin/design/LC_Page_Admin_Design_MainEdit.php ohkouchi@loop-az.jp-20110412135550-rrkz5279jtmkd6rz- bzr:timestamp:
- 2011-04-12 22:57:57.092000008 +0900
- bzr:user-agent:
- bzr2.2.1+bzr-svn1.0.4
- svn:original-date:
- 2011-04-12T13:57:57.092000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_11-dev/data/class/helper/SC_Helper_PageLayout.php
r20764 r20830 35 35 36 36 /** 37 * ページのレイアウト情報をセットする. 38 * 39 * LC_Page オブジェクトにページのレイアウト情報をセットする. 40 * 41 * @param LC_Page $objPage ページ情報のインスタンス 37 * ページのレイアウト情報を取得し, 設定する. 38 * 39 * 現在の URL に応じたページのレイアウト情報を取得し, LC_Page インスタンスに 40 * 設定する. 41 * 42 * @access public 43 * @param LC_Page $objPage LC_Page インスタンス 42 44 * @param boolean $preview プレビュー表示の場合 true 43 45 * @param string $url ページのURL($_SERVER['PHP_SELF'] の情報) … … 46 48 */ 47 49 function sfGetPageLayout(&$objPage, $preview = false, $url = "", $device_type_id = DEVICE_TYPE_PC) { 48 $debug_message = ""; 49 $arrPageLayout = array(); 50 51 // 現在のURLの取得 50 51 // URLを元にページ情報を取得 52 52 if ($preview === false) { 53 53 $url = preg_replace('|^' . preg_quote(ROOT_URLPATH) . '|', '', $url); 54 55 // URLを元にページデザインを取得 56 $arrPageData = $this->lfGetPageData("device_type_id = ? AND url = ? AND page_id <> 0" , array($device_type_id, $url)); 57 } else { 58 // TODO 59 $arrPageData = $this->lfGetPageData("device_type_id = ? AND page_id = 0", array($device_type_id)); 60 $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) 61 . "preview/" . $arrPageData[0]['filename'] . ".tpl"; 62 } 63 64 $arrPageLayout = $arrPageData[0]; 65 66 $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) . $arrPageLayout['filename'] . ".tpl"; 54 $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', array($url)); 55 } 56 // プレビューの場合は, プレビュー用のデータを取得 57 else { 58 $arrPageData = $this->getPageProperties($device_type_id, 0); 59 } 60 $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) . $arrPageData[0]['filename'] . ".tpl"; 61 $objPage->arrPageLayout =& $arrPageData[0]; 67 62 68 63 // ページタイトルを設定 69 if (!isset($objPage->tpl_title)) { 70 $objPage->tpl_title = $arrPageLayout['page_name']; 71 } 72 73 // 全ナビデータを取得する 74 $arrNavi = $this->lfGetNaviData($arrPageLayout['page_id'], $device_type_id); 64 if (SC_Utils_Ex::isBlank($objPage->tpl_title)) { 65 $objPage->tpl_title = $objPage->arrPageLayout['page_name']; 66 } 67 68 // 該当ページのブロックを取得し, 配置する 75 69 $masterData = new SC_DB_MasterData(); 76 70 $arrTarget = $masterData->getMasterData("mtb_target"); 77 78 foreach (array_keys($arrTarget) as $key) { 79 if (TARGET_ID_UNUSED != $key) { 80 $arrPageLayout[$arrTarget[$key]] 81 = $this->lfGetNavi($arrNavi, $key, $device_type_id); 71 $arrBlocs = $this->getBlocPositions($device_type_id, $objPage->arrPageLayout['page_id']); 72 // php_path, tpl_path が存在するものを, 各ターゲットに配置 73 foreach (array_keys($arrTarget) as $target_id) { 74 foreach ($arrBlocs as $arrBloc) { 75 if ($arrBloc['target_id'] != $target_id) { 76 continue; 77 } 78 if (is_file($arrBloc['php_path']) 79 || is_file($arrBloc['tpl_path'])) { 80 $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc; 81 } else { 82 $error = "ブロックが見つかりません\n" 83 . "tpl_path: " . $arrBloc['tpl_path'] . "\n" 84 . "php_path: " . $arrBloc['php_path']; 85 GC_Utils_Ex::gfPrintLog($error); 86 } 82 87 } 83 88 } 84 $objPage->arrPageLayout = $arrPageLayout;85 86 89 // カラム数を取得する 87 $objPage->tpl_column_num = $this->lfGetColumnNum($arrPageLayout); 88 } 89 90 /** 91 * ページ情報を取得する. 92 * 93 * @param string $where クエリのWHERE句 94 * @param array $arrVal WHERE句の条件値 95 * @return array ページ情報を格納した配列 96 */ 97 function lfGetPageData($where = 'page_id <> 0', $arrVal = array()) { 98 $objQuery =& SC_Query_Ex::getSingletonInstance(); 90 $objPage->tpl_column_num = $this->getColumnNum($objPage->arrPageLayout); 91 } 92 93 /** 94 * ページの属性を取得する. 95 * 96 * この関数は, dtb_pagelayout の情報を検索する. 97 * $device_type_id は必須. デフォルト値は DEVICE_TYPE_PC. 98 * $page_id が null の場合は, $page_id が 0 以外のものを検索する. 99 * 100 * @access public 101 * @param integer $device_type_id 端末種別ID 102 * @param integer $page_id ページID; null の場合は, 0 以外を検索する. 103 * @param string $where 追加の検索条件 104 * @param array $arrParams 追加の検索パラメータ 105 * @return array ページ属性の配列 106 */ 107 function getPageProperties($device_type_id = DEVICE_TYPE_PC, $page_id = null, $where = '', $arrParams = array()) { 108 $objQuery =& SC_Query_Ex::getSingletonInstance(); 109 $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where); 110 if ($page_id === null) { 111 $where = 'page_id <> ? AND ' . $where; 112 $page_id = 0; 113 } else { 114 $where = 'page_id = ? AND ' . $where; 115 } 99 116 $objQuery->setOrder('page_id'); 100 return $objQuery->select("*", "dtb_pagelayout", $where, $arrVal); 101 } 102 103 /** 104 * ナビ情報を取得する. 105 * 117 $arrParams = array_merge(array($page_id, $device_type_id), $arrParams); 118 return $objQuery->select('*', 'dtb_pagelayout', $where, $arrParams); 119 } 120 121 /** 122 * ブロック情報を取得する. 123 * 124 * @access public 125 * @param integer $device_type_id 端末種別ID 126 * @param string $where 追加の検索条件 127 * @param array $arrParams 追加の検索パラメータ 128 * @param boolean $has_realpath php_path, tpl_path の絶対パスを含める場合 true 129 * @return array ブロック情報の配列 130 */ 131 function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = array(), $has_realpath = true) { 132 $objQuery =& SC_Query_Ex::getSingletonInstance(); 133 $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where); 134 $arrParams = array_merge(array($device_type_id), $arrParams); 135 $objQuery->setOrder('bloc_id'); 136 $arrBlocs = $objQuery->select('*', 'dtb_bloc', $where, $arrParams); 137 if ($has_realpath) { 138 $this->setBlocPathTo($device_type_id, $arrBlocs); 139 } 140 return $arrBlocs; 141 } 142 143 /** 144 * ブロック配置情報を取得する. 145 * 146 * @access public 147 * @param integer $device_type_id 端末種別ID 106 148 * @param integer $page_id ページID 107 * @param integer $device_type_id 端末種別ID108 * @return array ナビ情報の配列109 */ 110 function lfGetNaviData($page_id, $device_type_id = DEVICE_TYPE_PC) {149 * @param boolean $has_realpath php_path, tpl_path の絶対パスを含める場合 true 150 * @return array 配置情報を含めたブロックの配列 151 */ 152 function getBlocPositions($device_type_id, $page_id, $has_realpath = true) { 111 153 $objQuery =& SC_Query_Ex::getSingletonInstance(); 112 154 $table = <<< __EOF__ … … 118 160 $where = "bloc.device_type_id = ? AND (anywhere = 1 OR pos.page_id = ?)"; 119 161 $objQuery->setOrder('target_id, bloc_row'); 120 return $objQuery->select("*", $table, $where, 121 array($device_type_id, $page_id)); 122 } 123 124 /** 125 * 各部分のナビ情報を取得する. 126 * 127 * @param array $arrNavi ナビ情報の配列 128 * @param integer $target_id ターゲットID 129 * @param integer $device_type_id 端末種別ID 130 * @return array ブロック情報の配列 131 */ 132 function lfGetNavi($arrNavi, $target_id, $device_type_id = DEVICE_TYPE_PC) { 133 $arrRet = array(); 134 if (is_array($arrNavi)) { 135 foreach ($arrNavi as $key => $val) { 136 // 指定された箇所と同じデータだけを取得する 137 if ($target_id == $val['target_id'] ) { 138 if ($val['php_path'] != '') { 139 $arrNavi[$key]['php_path'] = HTML_REALDIR . $val['php_path']; 140 } else { 141 $arrNavi[$key]['tpl_path'] = $this->getTemplatePath($device_type_id) . BLOC_DIR . $val['tpl_path']; 142 } 143 // phpから呼び出されるか、tplファイルが存在する場合 144 if ($val['php_path'] != '' || is_file($arrNavi[$key]['tpl_path'])) { 145 $arrRet[] = $arrNavi[$key]; 146 } else { 147 GC_Utils_Ex::gfPrintLog("ブロック読み込みエラー:" . $arrNavi[$key]['tpl_path']); 148 } 149 } 150 } 151 } 152 return $arrRet; 153 } 154 155 /** 156 * カラム数を取得する. 157 * 158 * @param array $arrPageLayout レイアウト情報の配列 159 * @return integer $col_num カラム数 160 */ 161 function lfGetColumnNum($arrPageLayout) { 162 // メインは確定 163 $col_num = 1; 164 // LEFT NAVI 165 if (count($arrPageLayout['LeftNavi']) > 0) $col_num++; 166 // RIGHT NAVI 167 if (count($arrPageLayout['RightNavi']) > 0) $col_num++; 168 169 return $col_num; 162 $arrBlocs = $objQuery->select("*", $table, $where, 163 array($device_type_id, $page_id)); 164 if ($has_realpath) { 165 $this->setBlocPathTo($device_type_id, $arrBlocs); 166 } 167 return $arrBlocs; 170 168 } 171 169 … … 173 171 * ページ情報を削除する. 174 172 * 173 * XXX ファイルを確実に削除したかどうかのチェック 174 * 175 * @access public 175 176 * @param integer $page_id ページID 176 177 * @param integer $device_type_id 端末種別ID … … 183 184 // page_id が空でない場合にはdeleteを実行 184 185 if ($page_id != '') { 185 186 $arrPageData = $this->lfGetPageData("page_id = ? AND device_type_id = ?" , array($page_id, $device_type_id)); 186 $arrPageData = $this->getPageProperties($device_type_id, $page_id); 187 187 // SQL実行 188 188 $ret = $objQuery->delete("dtb_pagelayout", "page_id = ? AND device_type_id = ?", array($page_id, $device_type_id)); … … 198 198 * 199 199 * dtb_pagelayout の削除後に呼び出すこと。 200 * 201 * @access private 200 202 * @param string $filename 201 203 * @param integer $device_type_id 端末種別ID … … 224 226 225 227 /** 226 * データがベースデータかどうか. 227 * 228 * 編集可能ページかどうか. 229 * 230 * @access public 231 * @param integer $device_type_id 端末種別ID 228 232 * @param integer $page_id ページID 229 * @param integer $device_type_id 端末種別ID 230 * @return boolean ベースデータの場合 true 231 */ 232 function lfCheckBaseData($page_id, $device_type_id) { 233 $result = false; 234 233 * @return 編集可能ページの場合 true 234 */ 235 function isEditablePage($device_type_id, $page_id) { 235 236 if ($page_id == 0) { 236 return $result; 237 } 238 239 $arrChkData = $this->lfgetPageData("page_id = ? AND device_type_id = ?", 240 array($page_id, $device_type_id)); 241 242 if ($arrChkData[0]['edit_flg'] == 2) { 243 $result = true; 244 } 245 246 return $result; 237 return false; 238 } 239 $arrPages = $this->getPageProperties($device_type_id, $page_id); 240 if ($arrPages[0]['edit_flg'] != 2) { 241 return true; 242 } 243 return false; 247 244 } 248 245 249 246 /** 250 247 * テンプレートのパスを取得する. 248 * 249 * @access public 250 * @param integer $device_type_id 端末種別ID 251 * @param boolean $isUser USER_REALDIR 以下のパスを返す場合 true 252 * @return string テンプレートのパス 251 253 */ 252 254 function getTemplatePath($device_type_id = DEVICE_TYPE_PC, $isUser = false) { … … 281 283 * を取得する. 282 284 * 285 * @access public 283 286 * @param integer $device_type_id 端末種別ID 284 287 * @param boolean $hasPackage パッケージのパスも含める場合 true … … 305 308 return $userDir; 306 309 } 310 311 // }}} 312 // {{{ private functions 313 314 /** 315 * ブロックの php_path, tpl_path を設定する. 316 * 317 * @access private 318 * @param integer $device_type_id 端末種別ID 319 * @param array $arrBlocs 設定するブロックの配列 320 * @return void 321 */ 322 function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs) { 323 foreach (array_keys($arrBlocs) as $key) { 324 $arrBloc =& $arrBlocs[$key]; 325 $arrBloc['php_path'] = SC_Utils_Ex::isBlank($arrBloc['php_path']) ? '' : HTML_REALDIR . $arrBloc['php_path']; 326 $bloc_dir = $this->getTemplatePath($device_type_id) . BLOC_DIR; 327 $arrBloc['tpl_path'] = SC_Utils_Ex::isBlank($arrBloc['tpl_path']) ? '' : $bloc_dir . $arrBloc['tpl_path']; 328 } 329 } 330 331 /** 332 * カラム数を取得する. 333 * 334 * @access private 335 * @param array $arrPageLayout レイアウト情報の配列 336 * @return integer $col_num カラム数 337 */ 338 function getColumnNum($arrPageLayout) { 339 // メインは確定 340 $col_num = 1; 341 // LEFT NAVI 342 if (count($arrPageLayout['LeftNavi']) > 0) $col_num++; 343 // RIGHT NAVI 344 if (count($arrPageLayout['RightNavi']) > 0) $col_num++; 345 346 return $col_num; 347 } 307 348 } 308 349 ?>
Note: See TracChangeset
for help on using the changeset viewer.