- Timestamp:
- 2007/09/28 20:34:45 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/html/mobile/products/category_list.php
r15532 r16166 1 1 <?php 2 2 /** 3 * 3 * 4 4 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 5 5 * 6 6 * http://www.lockon.co.jp/ 7 *8 7 * 9 * モバイルサイト/カテゴリー一覧 8 * 9 * モバイルサイト/カテゴリリスト 10 10 */ 11 11 12 require_once('../require.php'); 12 // {{{ requires 13 require_once("../require.php"); 14 require_once(CLASS_PATH . "page_extends/products/LC_Page_Products_CategoryList_Ex.php"); 13 15 14 class LC_Page { 15 function LC_Page() { 16 /** 必ず指定する **/ 17 $this->tpl_mainpage = 'products/category_list.tpl'; // メインテンプレート 18 $this->tpl_title = 'カテゴリ一覧ページ'; 19 } 20 } 16 // }}} 17 // {{{ generate page 21 18 22 $objPage = new LC_Page(); 23 $objView = new SC_MobileView(); 24 25 // レイアウトデザインを取得 26 $objPage = sfGetPageLayout($objPage, false, DEF_LAYOUT); 27 28 // カテゴリー情報を取得する。 29 lfGetCategories(@$_GET['category_id'], true, $objPage); 30 31 $objView->assignobj($objPage); 32 $objView->display(SITE_FRAME); 33 34 //----------------------------------------------------------------------------------------------------------------------------------- 35 36 /** 37 * 選択されたカテゴリーとその子カテゴリーの情報を取得し、 38 * ページオブジェクトに格納する。 39 * 40 * @param string $category_id カテゴリーID 41 * @param boolean $count_check 有効な商品がないカテゴリーを除くかどうか 42 * @param object &$objPage ページオブジェクト 43 * @return void 44 */ 45 function lfGetCategories($category_id, $count_check = false, &$objPage) { 46 // カテゴリーの正しいIDを取得する。 47 $category_id = sfGetCategoryId('', $category_id); 48 if ($category_id == 0) { 49 sfDispSiteError(CATEGORY_NOT_FOUND, "", false, "", true); 50 } 51 52 $arrCategory = null; // 選択されたカテゴリー 53 $arrChildren = array(); // 子カテゴリー 54 55 $arrAll = sfGetCatTree($category_id, $count_check); 56 foreach ($arrAll as $category) { 57 // 選択されたカテゴリーの場合 58 if ($category['category_id'] == $category_id) { 59 $arrCategory = $category; 60 continue; 61 } 62 63 // 関係のないカテゴリーはスキップする。 64 if ($category['parent_category_id'] != $category_id) { 65 continue; 66 } 67 68 // 子カテゴリーの場合は、孫カテゴリーが存在するかどうかを調べる。 69 $arrGrandchildrenID = sfGetUnderChildrenArray($arrAll, 'parent_category_id', 'category_id', $category['category_id']); 70 $category['has_children'] = count($arrGrandchildrenID) > 0; 71 $arrChildren[] = $category; 72 } 73 74 if (!isset($arrCategory)) { 75 sfDispSiteError(CATEGORY_NOT_FOUND, "", false, "", true); 76 } 77 78 // 子カテゴリーの商品数を合計する。 79 $children_product_count = 0; 80 foreach ($arrChildren as $category) { 81 $children_product_count += $category['product_count']; 82 } 83 84 // 選択されたカテゴリーに直属の商品がある場合は、子カテゴリーの先頭に追加する。 85 if ($arrCategory['product_count'] > $children_product_count) { 86 $arrCategory['product_count'] -= $children_product_count; // 子カテゴリーの商品数を除く。 87 $arrCategory['has_children'] = false; // 商品一覧ページに遷移させるため。 88 array_unshift($arrChildren, $arrCategory); 89 } 90 91 // 結果を格納する。 92 $objPage->arrCategory = $arrCategory; 93 $objPage->arrChildren = $arrChildren; 94 } 19 $objPage = new LC_Page_Products_CategoryList_Ex(); 20 $objPage->mobileInit(); 21 $objPage->mobileProcess(); 22 register_shutdown_function(array($objPage, "destroy")); 95 23 ?>
Note: See TracChangeset
for help on using the changeset viewer.