1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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__)); |
---|
26 | define('CALENDAR_ROOT', DATA_FILE_PATH.'module/Calendar'.DIRECTORY_SEPARATOR); |
---|
27 | require_once($current_dir . "/../../../../module/Calendar/Month/Weekdays.php"); |
---|
28 | require_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 | */ |
---|
37 | class 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 | $this->setTplMainpage('calendar.tpl'); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * Page のプロセス. |
---|
54 | * |
---|
55 | * @return void |
---|
56 | */ |
---|
57 | function process() { |
---|
58 | $this->action(); |
---|
59 | $this->sendResponse(); |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * Page のアクション. |
---|
64 | * |
---|
65 | * @return void |
---|
66 | */ |
---|
67 | function action() { |
---|
68 | // 休日取得取得 |
---|
69 | $this->arrHoliday = $this->lfGetHoliday(); |
---|
70 | // 定休日取得取得 |
---|
71 | $this->arrRegularHoliday = $this->lfGetRegularHoliday(); |
---|
72 | // カレンダーデータ取得 |
---|
73 | $this->arrCalendar = $this->lfGetCalendar(2); |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | * モバイルページを初期化する. |
---|
78 | * |
---|
79 | * @return void |
---|
80 | */ |
---|
81 | function mobileInit() { |
---|
82 | $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "frontparts/" |
---|
83 | . BLOC_DIR . 'best5.tpl'; |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * Page のプロセス(モバイル). |
---|
88 | * |
---|
89 | * @return void |
---|
90 | */ |
---|
91 | function mobileProcess() { |
---|
92 | $this->process(); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * デストラクタ. |
---|
97 | * |
---|
98 | * @return void |
---|
99 | */ |
---|
100 | function destroy() { |
---|
101 | parent::destroy(); |
---|
102 | } |
---|
103 | |
---|
104 | // カレンダー情報取得 |
---|
105 | function lfGetCalendar($disp_month = 1){ |
---|
106 | |
---|
107 | for ($j = 0; $j <= $disp_month-1; ++$j) { |
---|
108 | $year = date('Y'); |
---|
109 | $month = date('n') + $j; |
---|
110 | if ($month > 12) { |
---|
111 | $month = $month%12; |
---|
112 | $year = $year + $month%12; |
---|
113 | } |
---|
114 | |
---|
115 | $Month = new Calendar_Month_Weekdays($year, $month, 0); |
---|
116 | $Month->build(); |
---|
117 | $i = 0; |
---|
118 | while ($Day = $Month->fetch()) { |
---|
119 | if ($month == $Day->month) { |
---|
120 | $arrCalendar[$j][$i]['in_month'] = true; |
---|
121 | } else { |
---|
122 | $arrCalendar[$j][$i]['in_month'] = false; |
---|
123 | } |
---|
124 | $arrCalendar[$j][$i]['first'] = $Day->first; |
---|
125 | $arrCalendar[$j][$i]['last'] = $Day->last; |
---|
126 | $arrCalendar[$j][$i]['empty'] = $Day->empty; |
---|
127 | $arrCalendar[$j][$i]['year'] = $year; |
---|
128 | $arrCalendar[$j][$i]['month'] = $month; |
---|
129 | $arrCalendar[$j][$i]['day'] = $Day->day; |
---|
130 | if ($this->lfCheckHoliday($year, $month, $Day->day)) { |
---|
131 | $arrCalendar[$j][$i]['holiday'] = true; |
---|
132 | } else { |
---|
133 | $arrCalendar[$j][$i]['holiday'] = false; |
---|
134 | } |
---|
135 | ++$i; |
---|
136 | } |
---|
137 | } |
---|
138 | |
---|
139 | return $arrCalendar; |
---|
140 | } |
---|
141 | |
---|
142 | // 休日取得 |
---|
143 | function lfGetHoliday() { |
---|
144 | $objQuery = new SC_Query(); |
---|
145 | $objQuery->setOrder("rank DESC"); |
---|
146 | |
---|
147 | $where = "del_flg <> 1"; |
---|
148 | $arrRet = $objQuery->select("month, day", "dtb_holiday", $where); |
---|
149 | foreach ($arrRet AS $key=>$val) { |
---|
150 | $arrHoliday[$val['month']][] = $val['day']; |
---|
151 | } |
---|
152 | return $arrHoliday; |
---|
153 | } |
---|
154 | |
---|
155 | // 定休日取得 |
---|
156 | function lfGetRegularHoliday() { |
---|
157 | $objSIteInfo = new SC_SiteInfo(); |
---|
158 | $arrRegularHoliday = explode('|', $objSIteInfo->data['regular_holiday_ids']); |
---|
159 | return $arrRegularHoliday; |
---|
160 | } |
---|
161 | |
---|
162 | // 休日チェック |
---|
163 | function lfCheckHoliday($year, $month, $day) { |
---|
164 | if (!empty($this->arrHoliday[$month])) { |
---|
165 | if (in_array($day, $this->arrHoliday[$month])) { |
---|
166 | return true; |
---|
167 | } |
---|
168 | } |
---|
169 | if (!empty($this->arrRegularHoliday)) { |
---|
170 | $w = date('w', mktime(0,0,0 ,$month, $day, $year)); |
---|
171 | if (in_array($w, $this->arrRegularHoliday)) { |
---|
172 | return true; |
---|
173 | } |
---|
174 | } |
---|
175 | return false; |
---|
176 | } |
---|
177 | |
---|
178 | } |
---|
179 | ?> |
---|