1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * Page のプロセス. |
---|
53 | * |
---|
54 | * @return void |
---|
55 | */ |
---|
56 | function process() { |
---|
57 | $this->action(); |
---|
58 | $this->sendResponse(); |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * Page のアクション. |
---|
63 | * |
---|
64 | * @return void |
---|
65 | */ |
---|
66 | function action() { |
---|
67 | // 休日取得取得 |
---|
68 | $this->arrHoliday = $this->lfGetHoliday(); |
---|
69 | // 定休日取得取得 |
---|
70 | $this->arrRegularHoliday = $this->lfGetRegularHoliday(); |
---|
71 | // カレンダーデータ取得 |
---|
72 | $this->arrCalendar = $this->lfGetCalendar(2); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * デストラクタ. |
---|
77 | * |
---|
78 | * @return void |
---|
79 | */ |
---|
80 | function destroy() { |
---|
81 | parent::destroy(); |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * カレンダー情報取得. |
---|
86 | * |
---|
87 | * @param integer $disp_month 表示する月数 |
---|
88 | * @return array $arrCalendar カレンダー情報の配列を返す |
---|
89 | */ |
---|
90 | function lfGetCalendar($disp_month = 1){ |
---|
91 | |
---|
92 | for ($j = 0; $j <= $disp_month-1; ++$j) { |
---|
93 | $year = date('Y'); |
---|
94 | $month = date('n') + $j; |
---|
95 | if ($month > 12) { |
---|
96 | $month = $month%12; |
---|
97 | $year = $year + $month%12; |
---|
98 | } |
---|
99 | |
---|
100 | $objMonth = new Calendar_Month_Weekdays($year, $month, 0); |
---|
101 | $objMonth->build(); |
---|
102 | $i = 0; |
---|
103 | while ($objDay = $objMonth->fetch()) { |
---|
104 | if ($month == $objDay->month) { |
---|
105 | $arrCalendar[$j][$i]['in_month'] = true; |
---|
106 | } else { |
---|
107 | $arrCalendar[$j][$i]['in_month'] = false; |
---|
108 | } |
---|
109 | $arrCalendar[$j][$i]['first'] = $objDay->first; |
---|
110 | $arrCalendar[$j][$i]['last'] = $objDay->last; |
---|
111 | $arrCalendar[$j][$i]['empty'] = $objDay->empty; |
---|
112 | $arrCalendar[$j][$i]['year'] = $year; |
---|
113 | $arrCalendar[$j][$i]['month'] = $month; |
---|
114 | $arrCalendar[$j][$i]['day'] = $objDay->day; |
---|
115 | if ($this->lfCheckHoliday($year, $month, $objDay->day)) { |
---|
116 | $arrCalendar[$j][$i]['holiday'] = true; |
---|
117 | } else { |
---|
118 | $arrCalendar[$j][$i]['holiday'] = false; |
---|
119 | } |
---|
120 | ++$i; |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | return $arrCalendar; |
---|
125 | } |
---|
126 | |
---|
127 | /** |
---|
128 | * 休日取得. |
---|
129 | * |
---|
130 | * @return array $arrHoliday 休日情報の配列を返す |
---|
131 | */ |
---|
132 | function lfGetHoliday() { |
---|
133 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
134 | $objQuery->setOrder('rank DESC'); |
---|
135 | |
---|
136 | $where = 'del_flg <> 1'; |
---|
137 | $arrRet = $objQuery->select('month, day', 'dtb_holiday', $where); |
---|
138 | foreach ($arrRet AS $key=>$val) { |
---|
139 | $arrHoliday[$val['month']][] = $val['day']; |
---|
140 | } |
---|
141 | return $arrHoliday; |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | * 定休日取得. |
---|
146 | * |
---|
147 | * @return array $arrRegularHoliday 定休日情報の配列を返す |
---|
148 | */ |
---|
149 | function lfGetRegularHoliday() { |
---|
150 | $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
151 | $arrRegularHoliday = explode('|', $arrInfo['regular_holiday_ids']); |
---|
152 | return $arrRegularHoliday; |
---|
153 | } |
---|
154 | |
---|
155 | /** |
---|
156 | * 休日チェック取得. |
---|
157 | * |
---|
158 | * @param integer $year 年 |
---|
159 | * @param integer $month 月 |
---|
160 | * @param integer $day 日 |
---|
161 | * @return boolean 休日の場合trueを返す |
---|
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 | $day = date('w', mktime(0,0,0 ,$month, $day, $year)); |
---|
171 | if (in_array($day, $this->arrRegularHoliday)) { |
---|
172 | return true; |
---|
173 | } |
---|
174 | } |
---|
175 | return false; |
---|
176 | } |
---|
177 | |
---|
178 | } |
---|