source: trunk/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php @ 18562

Revision 18562, 5.1 KB checked in by kajiwara, 14 years ago (diff)

EC-CUBE Ver2.4.3 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=210

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($year, $month, $Day->day)) {
133                    $arrCalendar[$j][$i]['holiday'] = true;
134                } else {
135                    $arrCalendar[$j][$i]['holiday'] = false;
136                }
137                ++$i;
138            }
139        }
140
141        return $arrCalendar;
142    }
143
144    // 休日取得
145    function lfGetHoliday() {
146        $objQuery = new SC_Query();
147        $objQuery->setorder("rank DESC");
148
149        $where = "del_flg <> 1";
150        $arrRet = $objQuery->select("month, day", "dtb_holiday", $where);
151        foreach ($arrRet AS $key=>$val) {
152            $arrHoliday[$val['month']][] = $val['day'];
153        }
154        return $arrHoliday;
155    }
156
157    // 定休日取得
158    function lfGetRegularHoliday() {
159        $objSIteInfo = new SC_SiteInfo();
160        $arrRegularHoliday = explode('|', $objSIteInfo->data['regular_holiday_ids']);
161        return $arrRegularHoliday;
162    }
163    // 休日チェック
164    function lfCheckHoliday($year, $month, $day) {
165        if (!empty($this->arrHoliday[$month])) {
166            if (in_array($day, $this->arrHoliday[$month])) {
167                return true;
168            }
169        }
170        if (!empty($this->arrRegularHoliday)) {
171            $w = date('w', mktime(0,0,0 ,$month, $day, $year));
172            if (in_array($w, $this->arrRegularHoliday)) {
173                return true;
174            }
175        }
176        return false;
177    }
178
179}
180?>
Note: See TracBrowser for help on using the repository browser.