source: branches/dev/html/mobile/products/category_list.php @ 11460

Revision 11460, 2.6 KB checked in by inoue, 17 years ago (diff)

モバイル版EC-CUBE

  • Property svn:eol-style set to native
Line 
1<?php
2/**
3 * ¥â¥Ð¥¤¥ë¥µ¥¤¥È/¥«¥Æ¥´¥ê¡¼°ìÍ÷
4 */
5
6require_once('../require.php');
7
8class LC_Page {
9    function LC_Page() {
10        /** ɬ¤º»ØÄꤹ¤ë **/
11        $this->tpl_mainpage = 'products/category_list.tpl';         // ¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È
12        $this->tpl_title = '¥«¥Æ¥´¥ê°ìÍ÷¥Ú¡¼¥¸';
13    }
14}
15
16$objPage = new LC_Page();
17$objView = new SC_SiteView();
18
19// ¥ì¥¤¥¢¥¦¥È¥Ç¥¶¥¤¥ó¤ò¼èÆÀ
20$objPage = sfGetPageLayout($objPage, false, DEF_LAYOUT);
21
22// ¥«¥Æ¥´¥ê¡¼¾ðÊó¤ò¼èÆÀ¤¹¤ë¡£
23lfGetCategories(@$_GET['category_id'], true, $objPage);
24
25$objView->assignobj($objPage);
26$objView->display(SITE_FRAME);
27
28//-----------------------------------------------------------------------------------------------------------------------------------
29
30/**
31 * ÁªÂò¤µ¤ì¤¿¥«¥Æ¥´¥ê¡¼¤È¤½¤Î»Ò¥«¥Æ¥´¥ê¡¼¤Î¾ðÊó¤ò¼èÆÀ¤·¡¢
32 * ¥Ú¡¼¥¸¥ª¥Ö¥¸¥§¥¯¥È¤Ë³ÊǼ¤¹¤ë¡£
33 *
34 * @param string $category_id ¥«¥Æ¥´¥ê¡¼ID
35 * @param boolean $count_check Í­¸ú¤Ê¾¦Éʤ¬¤Ê¤¤¥«¥Æ¥´¥ê¡¼¤ò½ü¤¯¤«¤É¤¦¤«
36 * @param object &$objPage ¥Ú¡¼¥¸¥ª¥Ö¥¸¥§¥¯¥È
37 * @return void
38 */
39function lfGetCategories($category_id, $count_check = false, &$objPage) {
40    // ¥«¥Æ¥´¥ê¡¼¤ÎÀµ¤·¤¤ID¤ò¼èÆÀ¤¹¤ë¡£
41    $category_id = sfGetCategoryId('', $category_id);
42    if ($category_id == 0) {
43        sfDispSiteError(CATEGORY_NOT_FOUND);
44    }
45
46    $arrCategory = null;    // ÁªÂò¤µ¤ì¤¿¥«¥Æ¥´¥ê¡¼
47    $arrChildren = array(); // »Ò¥«¥Æ¥´¥ê¡¼
48
49    $arrAll = sfGetCatTree($category_id, $count_check);
50    foreach ($arrAll as $category) {
51        // ÁªÂò¤µ¤ì¤¿¥«¥Æ¥´¥ê¡¼¤Î¾ì¹ç
52        if ($category['category_id'] == $category_id) {
53            $arrCategory = $category;
54            continue;
55        }
56
57        // ´Ø·¸¤Î¤Ê¤¤¥«¥Æ¥´¥ê¡¼¤Ï¥¹¥­¥Ã¥×¤¹¤ë¡£
58        if ($category['parent_category_id'] != $category_id) {
59            continue;
60        }
61
62        // »Ò¥«¥Æ¥´¥ê¡¼¤Î¾ì¹ç¤Ï¡¢Â¹¥«¥Æ¥´¥ê¡¼¤¬Â¸ºß¤¹¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¤ë¡£
63        $arrGrandchildrenID = sfGetUnderChildrenArray($arrAll, 'parent_category_id', 'category_id', $category['category_id']);
64        $category['has_children'] = count($arrGrandchildrenID) > 0;
65        $arrChildren[] = $category;
66    }
67
68    if (!isset($arrCategory)) {
69        sfDispSiteError(CATEGORY_NOT_FOUND);
70    }
71
72    // »Ò¥«¥Æ¥´¥ê¡¼¤Î¾¦ÉÊ¿ô¤ò¹ç·×¤¹¤ë¡£
73    $children_product_count = 0;
74    foreach ($arrChildren as $category) {
75        $children_product_count += $category['product_count'];
76    }
77
78    // ÁªÂò¤µ¤ì¤¿¥«¥Æ¥´¥ê¡¼¤Ëľ°¤Î¾¦Éʤ¬¤¢¤ë¾ì¹ç¤Ï¡¢»Ò¥«¥Æ¥´¥ê¡¼¤ÎÀèƬ¤ËÄɲ乤롣
79    if ($arrCategory['product_count'] > $children_product_count) {
80        $arrCategory['product_count'] -= $children_product_count;   // »Ò¥«¥Æ¥´¥ê¡¼¤Î¾¦ÉÊ¿ô¤ò½ü¤¯¡£
81        $arrCategory['has_children'] = false;   // ¾¦ÉÊ°ìÍ÷¥Ú¡¼¥¸¤ËÁ«°Ü¤µ¤»¤ë¤¿¤á¡£
82        array_unshift($arrChildren, $arrCategory);
83    }
84
85    // ·ë²Ì¤ò³ÊǼ¤¹¤ë¡£
86    $objPage->arrCategory = $arrCategory;
87    $objPage->arrChildren = $arrChildren;
88}
89?>
Note: See TracBrowser for help on using the repository browser.