1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 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 | define('CALENDAR_ROOT', DATA_REALDIR.'module/Calendar'.DIRECTORY_SEPARATOR); |
---|
25 | require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * Calendar のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $ $ |
---|
33 | */ |
---|
34 | class LC_Page_FrontParts_Bloc_Calendar extends LC_Page_FrontParts_Bloc_Ex |
---|
35 | { |
---|
36 | /** |
---|
37 | * Page を初期化する. |
---|
38 | * |
---|
39 | * @return void |
---|
40 | */ |
---|
41 | public function init() |
---|
42 | { |
---|
43 | parent::init(); |
---|
44 | } |
---|
45 | |
---|
46 | /** |
---|
47 | * Page のプロセス. |
---|
48 | * |
---|
49 | * @return void |
---|
50 | */ |
---|
51 | public function process() |
---|
52 | { |
---|
53 | $this->action(); |
---|
54 | $this->sendResponse(); |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * Page のアクション. |
---|
59 | * |
---|
60 | * @return void |
---|
61 | */ |
---|
62 | public function action() |
---|
63 | { |
---|
64 | // カレンダーデータ取得 |
---|
65 | $this->arrCalendar = $this->lfGetCalendar(2); |
---|
66 | } |
---|
67 | |
---|
68 | /** |
---|
69 | * カレンダー情報取得. |
---|
70 | * |
---|
71 | * @param integer $disp_month 表示する月数 |
---|
72 | * @return array カレンダー情報の配列を返す |
---|
73 | */ |
---|
74 | public function lfGetCalendar($disp_month = 1) |
---|
75 | { |
---|
76 | $objDate = new SC_Date_Ex(); |
---|
77 | $arrCalendar = array(); |
---|
78 | $today = date('Y/m/d'); |
---|
79 | |
---|
80 | for ($j = 0; $j <= $disp_month - 1; $j++) { |
---|
81 | $time = mktime(0, 0, 0, date('n') + $j, 1); |
---|
82 | $year = date('Y', $time); |
---|
83 | $month = date('n', $time); |
---|
84 | |
---|
85 | $objMonth = new Calendar_Month_Weekdays($year, $month, 0); |
---|
86 | $objMonth->build(); |
---|
87 | $i = 0; |
---|
88 | while ($objDay = $objMonth->fetch()) { |
---|
89 | $arrCalendar[$j][$i]['in_month'] = $month == $objDay->month; |
---|
90 | $arrCalendar[$j][$i]['first'] = $objDay->first; |
---|
91 | $arrCalendar[$j][$i]['last'] = $objDay->last; |
---|
92 | $arrCalendar[$j][$i]['empty'] = $objDay->empty; |
---|
93 | $arrCalendar[$j][$i]['year'] = $year; |
---|
94 | $arrCalendar[$j][$i]['month'] = $month; |
---|
95 | $arrCalendar[$j][$i]['day'] = $objDay->day; |
---|
96 | $arrCalendar[$j][$i]['holiday'] = $objDate->isHoliday($year, $month, $objDay->day); |
---|
97 | $arrCalendar[$j][$i]['today'] = $today === sprintf('%04d/%02d/%02d', $year, $month, $objDay->day); |
---|
98 | |
---|
99 | $i++; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | return $arrCalendar; |
---|
104 | } |
---|
105 | } |
---|