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_REALDIR.'module/Calendar'.DIRECTORY_SEPARATOR); |
---|
27 | require_once($current_dir . "/../../../../module/Calendar/Month/Weekdays.php"); |
---|
28 | require_once(CLASS_REALDIR . "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_REALDIR . '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 | * カレンダー情報取得. |
---|
106 | * |
---|
107 | * @param integer $disp_month 表示する月数 |
---|
108 | * @return array $arrCalendar カレンダー情報の配列を返す |
---|
109 | */ |
---|
110 | function lfGetCalendar($disp_month = 1){ |
---|
111 | |
---|
112 | for ($j = 0; $j <= $disp_month-1; ++$j) { |
---|
113 | $year = date('Y'); |
---|
114 | $month = date('n') + $j; |
---|
115 | if ($month > 12) { |
---|
116 | $month = $month%12; |
---|
117 | $year = $year + $month%12; |
---|
118 | } |
---|
119 | |
---|
120 | $objMonth = new Calendar_Month_Weekdays($year, $month, 0); |
---|
121 | $objMonth->build(); |
---|
122 | $i = 0; |
---|
123 | while ($objDay = $objMonth->fetch()) { |
---|
124 | if ($month == $objDay->month) { |
---|
125 | $arrCalendar[$j][$i]['in_month'] = true; |
---|
126 | } else { |
---|
127 | $arrCalendar[$j][$i]['in_month'] = false; |
---|
128 | } |
---|
129 | $arrCalendar[$j][$i]['first'] = $objDay->first; |
---|
130 | $arrCalendar[$j][$i]['last'] = $objDay->last; |
---|
131 | $arrCalendar[$j][$i]['empty'] = $objDay->empty; |
---|
132 | $arrCalendar[$j][$i]['year'] = $year; |
---|
133 | $arrCalendar[$j][$i]['month'] = $month; |
---|
134 | $arrCalendar[$j][$i]['day'] = $objDay->day; |
---|
135 | if ($this->lfCheckHoliday($year, $month, $objDay->day)) { |
---|
136 | $arrCalendar[$j][$i]['holiday'] = true; |
---|
137 | } else { |
---|
138 | $arrCalendar[$j][$i]['holiday'] = false; |
---|
139 | } |
---|
140 | ++$i; |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | return $arrCalendar; |
---|
145 | } |
---|
146 | |
---|
147 | /** |
---|
148 | * 休日取得. |
---|
149 | * |
---|
150 | * @return array $arrHoliday 休日情報の配列を返す |
---|
151 | */ |
---|
152 | function lfGetHoliday() { |
---|
153 | $objQuery = SC_Query::getSingletonInstance(); |
---|
154 | $objQuery->setOrder('rank DESC'); |
---|
155 | |
---|
156 | $where = 'del_flg <> 1'; |
---|
157 | $arrRet = $objQuery->select('month, day', 'dtb_holiday', $where); |
---|
158 | foreach ($arrRet AS $key=>$val) { |
---|
159 | $arrHoliday[$val['month']][] = $val['day']; |
---|
160 | } |
---|
161 | return $arrHoliday; |
---|
162 | } |
---|
163 | |
---|
164 | /** |
---|
165 | * 定休日取得. |
---|
166 | * |
---|
167 | * @return array $arrRegularHoliday 定休日情報の配列を返す |
---|
168 | */ |
---|
169 | function lfGetRegularHoliday() { |
---|
170 | $objSiteInfo = new SC_SiteInfo(); |
---|
171 | $arrRegularHoliday = explode('|', $objSiteInfo->data['regular_holiday_ids']); |
---|
172 | return $arrRegularHoliday; |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | * 休日チェック取得. |
---|
177 | * |
---|
178 | * @param integer $year 年 |
---|
179 | * @param integer $month 月 |
---|
180 | * @param integer $day 日 |
---|
181 | * @return boolean 休日の場合trueを返す |
---|
182 | */ |
---|
183 | function lfCheckHoliday($year, $month, $day) { |
---|
184 | if (!empty($this->arrHoliday[$month])) { |
---|
185 | if (in_array($day, $this->arrHoliday[$month])) { |
---|
186 | return true; |
---|
187 | } |
---|
188 | } |
---|
189 | if (!empty($this->arrRegularHoliday)) { |
---|
190 | $day = date('w', mktime(0,0,0 ,$month, $day, $year)); |
---|
191 | if (in_array($day, $this->arrRegularHoliday)) { |
---|
192 | return true; |
---|
193 | } |
---|
194 | } |
---|
195 | return false; |
---|
196 | } |
---|
197 | |
---|
198 | } |
---|
199 | ?> |
---|