source: branches/comu/html/mobile/products/category_list.php @ 11982

Revision 11982, 2.7 KB checked in by uehara, 17 years ago (diff)
  • Property svn:eol-style set to native
Line 
1<?php
2/**
3 *
4 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 *
6 * http://www.lockon.co.jp/
7 *
8 *
9 * ¥â¥Ð¥¤¥ë¥µ¥¤¥È/¥«¥Æ¥´¥ê¡¼°ìÍ÷
10 */
11
12require_once('../require.php');
13
14class LC_Page {
15    function LC_Page() {
16        /** ɬ¤º»ØÄꤹ¤ë **/
17        $this->tpl_mainpage = 'products/category_list.tpl';         // ¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È
18        $this->tpl_title = '¥«¥Æ¥´¥ê°ìÍ÷¥Ú¡¼¥¸';
19    }
20}
21
22$objPage = new LC_Page();
23$objView = new SC_MobileView();
24
25// ¥ì¥¤¥¢¥¦¥È¥Ç¥¶¥¤¥ó¤ò¼èÆÀ
26$objPage = sfGetPageLayout($objPage, false, DEF_LAYOUT);
27
28// ¥«¥Æ¥´¥ê¡¼¾ðÊó¤ò¼èÆÀ¤¹¤ë¡£
29lfGetCategories(@$_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 */
45function 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}
95?>
Note: See TracBrowser for help on using the repository browser.