source: branches/comu-ver2/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php @ 17713

Revision 17713, 5.2 KB checked in by Yammy, 15 years ago (diff)

カレンダーブロックの定休日表示のバグ 修正
http://svn.ec-cube.net/open_trac/ticket/399

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25$current_dir = realpath(dirname(__FILE__));
26define('CALENDAR_ROOT', DATA_PATH.'module/Calendar'.DIRECTORY_SEPARATOR);
27require_once($current_dir . "/../../../../module/Calendar/Month/Weekdays.php");
28require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php");
29
30/**
31 * Calendar のページクラス.
32 *
33 * @package Page
34 * @author LOCKON CO.,LTD.
35 * @version $ $
36 */
37class LC_Page_FrontParts_Bloc_Calendar extends LC_Page_FrontParts_Bloc {
38
39    // }}}
40    // {{{ functions
41
42    /**
43     * Page を初期化する.
44     *
45     * @return void
46     */
47    function init() {
48        parent::init();
49        $bloc_file = 'calendar.tpl';
50        $this->setTplMainpage($bloc_file);
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        if (defined("MOBILE_SITE") && MOBILE_SITE) {
60            $objView = new SC_MobileView();
61        } else {
62            $objView = new SC_SiteView();
63        }
64
65        // 休日取得取得
66        $this->arrHoliday = $this->lfGetHoliday();
67
68        // 定休日取得取得
69        $this->arrRegularHoliday = $this->lfGetRegularHoliday();
70
71        // カレンダーデータ取得
72        $this->arrCalendar = $this->lfGetCalendar(2);
73
74        $objView->assignobj($this);
75        $objView->display($this->tpl_mainpage);
76    }
77
78    /**
79     * モバイルページを初期化する.
80     *
81     * @return void
82     */
83    function mobileInit() {
84         $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "frontparts/"
85            . BLOC_DIR . 'best5.tpl';
86    }
87
88    /**
89     * Page のプロセス(モバイル).
90     *
91     * @return void
92     */
93    function mobileProcess() {
94        $this->process();
95    }
96
97    /**
98     * デストラクタ.
99     *
100     * @return void
101     */
102    function destroy() {
103        parent::destroy();
104    }
105
106    // カレンダー情報取得
107    function lfGetCalendar($disp_month = 1){
108
109        for ($j = 0; $j <= $disp_month-1; ++$j) {
110            $year = date('Y');
111            $month = date('n') + $j;
112            if ($month > 12) {
113                $month = $month%12;
114                $year = $year + $month%12;
115            }
116
117            $Month = new Calendar_Month_Weekdays($year, $month, 0);
118            $Month->build();
119            $i = 0;
120            while ($Day = $Month->fetch()) {
121                if ($month == $Day->month) {
122                    $arrCalendar[$j][$i]['in_month'] = true;
123                } else {
124                    $arrCalendar[$j][$i]['in_month'] = false;
125                }
126                $arrCalendar[$j][$i]['first'] = $Day->first;
127                $arrCalendar[$j][$i]['last'] = $Day->last;
128                $arrCalendar[$j][$i]['empty'] = $Day->empty;
129                $arrCalendar[$j][$i]['year'] = $year;
130                $arrCalendar[$j][$i]['month'] = $month;
131                $arrCalendar[$j][$i]['day'] = $Day->day;
132                #if ($this->lfCheckHoliday($month, $Day->day) || $Day->first || $Day->last) {
133                if ($this->lfCheckHoliday($year, $month, $Day->day)) {
134                    $arrCalendar[$j][$i]['holiday'] = true;
135                } else {
136                    $arrCalendar[$j][$i]['holiday'] = false;
137                }
138                ++$i;
139            }
140        }
141
142        return $arrCalendar;
143    }
144
145    // 休日取得
146    function lfGetHoliday() {
147        $objQuery = new SC_Query();
148        $objQuery->setorder("rank DESC");
149
150        $where = "del_flg <> 1";
151        $arrRet = $objQuery->select("month, day", "dtb_holiday", $where);
152        foreach ($arrRet AS $key=>$val) {
153            $arrHoliday[$val['month']][] = $val['day'];
154        }
155        return $arrHoliday;
156    }
157
158    // 定休日取得
159    function lfGetRegularHoliday() {
160        $objSIteInfo = new SC_SiteInfo();
161        $arrRegularHoliday = explode('|', $objSIteInfo->data['regular_holiday_ids']);
162        return $arrRegularHoliday;
163    }
164
165
166    // 休日チェック
167    function lfCheckHoliday($year, $month, $day) {
168        if (!empty($this->arrHoliday[$month])) {
169            if (in_array($day, $this->arrHoliday[$month])) {
170                return true;
171            }
172        }
173        if (!empty($this->arrRegularHoliday)) {
174            $w = date('w', mktime(0,0,0 ,$month, $day, $year));
175            if (in_array($w, $this->arrRegularHoliday)) {
176                return true;
177            }
178        }
179        return false;
180    }
181
182}
183?>
Note: See TracBrowser for help on using the repository browser.