source: branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php @ 21867

Revision 21867, 5.2 KB checked in by nakanishi, 10 years ago (diff)

#1831 Copyright Update

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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
25define('CALENDAR_ROOT', DATA_REALDIR.'module/Calendar'.DIRECTORY_SEPARATOR);
26require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Ex.php';
27
28/**
29 * Calendar のページクラス.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $ $
34 */
35class LC_Page_FrontParts_Bloc_Calendar extends LC_Page_FrontParts_Bloc_Ex {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init() {
46        parent::init();
47    }
48
49    /**
50     * Page のプロセス.
51     *
52     * @return void
53     */
54    function process() {
55        $this->action();
56        $this->sendResponse();
57    }
58
59    /**
60     * Page のアクション.
61     *
62     * @return void
63     */
64    function action() {
65
66        // 休日取得取得
67        $this->arrHoliday = $this->lfGetHoliday();
68        // 定休日取得取得
69        $this->arrRegularHoliday = $this->lfGetRegularHoliday();
70        // カレンダーデータ取得
71        $this->arrCalendar = $this->lfGetCalendar(2);
72
73
74    }
75
76    /**
77     * デストラクタ.
78     *
79     * @return void
80     */
81    function destroy() {
82        parent::destroy();
83    }
84
85    /**
86     * カレンダー情報取得.
87     *
88     * @param integer $disp_month 表示する月数
89     * @return array $arrCalendar カレンダー情報の配列を返す
90     */
91    function lfGetCalendar($disp_month = 1) {
92
93        $today = date('Y/m/d');
94        for ($j = 0; $j <= $disp_month-1; ++$j) {
95            $year = date('Y');
96            $month = date('n') + $j;
97            if ($month > 12) {
98                $month = $month%12;
99                $year = $year + $month%12;
100            }
101
102            $objMonth = new Calendar_Month_Weekdays($year, $month, 0);
103            $objMonth->build();
104            $i = 0;
105            while ($objDay = $objMonth->fetch()) {
106                if ($month == $objDay->month) {
107                    $arrCalendar[$j][$i]['in_month'] = true;
108                } else {
109                    $arrCalendar[$j][$i]['in_month'] = false;
110                }
111                $arrCalendar[$j][$i]['first'] = $objDay->first;
112                $arrCalendar[$j][$i]['last'] = $objDay->last;
113                $arrCalendar[$j][$i]['empty'] = $objDay->empty;
114                $arrCalendar[$j][$i]['year'] = $year;
115                $arrCalendar[$j][$i]['month'] = $month;
116                $arrCalendar[$j][$i]['day'] = $objDay->day;
117                if ($this->lfCheckHoliday($year, $month, $objDay->day)) {
118                    $arrCalendar[$j][$i]['holiday'] = true;
119                } else {
120                    $arrCalendar[$j][$i]['holiday'] = false;
121                }
122
123                if ($today === sprintf('%04d/%02d/%02d', $year, $month, $objDay->day)) {
124                    $arrCalendar[$j][$i]['today'] = true;
125                }
126
127                ++$i;
128            }
129        }
130
131        return $arrCalendar;
132    }
133
134    /**
135     * 休日取得.
136     *
137     * @return array $arrHoliday 休日情報の配列を返す
138     */
139    function lfGetHoliday() {
140        $objQuery = SC_Query_Ex::getSingletonInstance();
141        $objQuery->setOrder('rank DESC');
142
143        $where = 'del_flg <> 1';
144        $arrRet = $objQuery->select('month, day', 'dtb_holiday', $where);
145        foreach ($arrRet AS $key=>$val) {
146            $arrHoliday[$val['month']][] = $val['day'];
147        }
148        return $arrHoliday;
149    }
150
151    /**
152     * 定休日取得.
153     *
154     * @return array $arrRegularHoliday 定休日情報の配列を返す
155     */
156    function lfGetRegularHoliday() {
157        $arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
158        $arrRegularHoliday = explode('|', $arrInfo['regular_holiday_ids']);
159        return $arrRegularHoliday;
160    }
161
162    /**
163     * 休日チェック取得.
164     *
165     * @param integer $year 年
166     * @param integer $month 月
167     * @param integer $day 日
168     * @return boolean 休日の場合trueを返す
169     */
170    function lfCheckHoliday($year, $month, $day) {
171        if (!empty($this->arrHoliday[$month])) {
172            if (in_array($day, $this->arrHoliday[$month])) {
173                return true;
174            }
175        }
176        if (!empty($this->arrRegularHoliday)) {
177            $day = date('w', mktime(0,0,0 ,$month, $day, $year));
178            if (in_array($day, $this->arrRegularHoliday)) {
179                return true;
180            }
181        }
182        return false;
183    }
184
185}
Note: See TracBrowser for help on using the repository browser.