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

Revision 22567, 4.9 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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-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// {{{ 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    // }}}
39    // {{{ functions
40
41    /**
42     * Page を初期化する.
43     *
44     * @return void
45     */
46    function init()
47    {
48        parent::init();
49    }
50
51    /**
52     * Page のプロセス.
53     *
54     * @return void
55     */
56    function process()
57    {
58        $this->action();
59        $this->sendResponse();
60    }
61
62    /**
63     * Page のアクション.
64     *
65     * @return void
66     */
67    function action()
68    {
69
70        // 休日取得取得
71        $this->arrHoliday = $this->lfGetHoliday();
72        // 定休日取得取得
73        $this->arrRegularHoliday = $this->lfGetRegularHoliday();
74        // カレンダーデータ取得
75        $this->arrCalendar = $this->lfGetCalendar(2);
76
77
78    }
79
80    /**
81     * デストラクタ.
82     *
83     * @return void
84     */
85    function destroy()
86    {
87        parent::destroy();
88    }
89
90    /**
91     * カレンダー情報取得.
92     *
93     * @param integer $disp_month 表示する月数
94     * @return array カレンダー情報の配列を返す
95     */
96    function lfGetCalendar($disp_month = 1)
97    {
98        $arrCalendar = array();
99        $today = date('Y/m/d');
100
101        for ($j = 0; $j <= $disp_month - 1; $j++) {
102            $time = mktime(0, 0, 0, date('n') + $j, 1);
103            $year = date('Y', $time);
104            $month = date('n', $time);
105
106            $objMonth = new Calendar_Month_Weekdays($year, $month, 0);
107            $objMonth->build();
108            $i = 0;
109            while ($objDay = $objMonth->fetch()) {
110                $arrCalendar[$j][$i]['in_month']    = $month == $objDay->month;
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                $arrCalendar[$j][$i]['holiday']     = $this->lfCheckHoliday($year, $month, $objDay->day);
118                $arrCalendar[$j][$i]['today']       = $today === sprintf('%04d/%02d/%02d', $year, $month, $objDay->day);
119
120                $i++;
121            }
122        }
123
124        return $arrCalendar;
125    }
126
127    /**
128     * 休日取得.
129     *
130     * @return array $arrHoliday 休日情報の配列を返す
131     */
132    function lfGetHoliday()
133    {
134        $objQuery = SC_Query_Ex::getSingletonInstance();
135        $objQuery->setOrder('rank DESC');
136
137        $where = 'del_flg <> 1';
138        $arrRet = $objQuery->select('month, day', 'dtb_holiday', $where);
139        foreach ($arrRet AS $key=>$val) {
140            $arrHoliday[$val['month']][] = $val['day'];
141        }
142        return $arrHoliday;
143    }
144
145    /**
146     * 定休日取得.
147     *
148     * @return array $arrRegularHoliday 定休日情報の配列を返す
149     */
150    function lfGetRegularHoliday()
151    {
152        $arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
153        $arrRegularHoliday = explode('|', $arrInfo['regular_holiday_ids']);
154        return $arrRegularHoliday;
155    }
156
157    /**
158     * 休日チェック取得.
159     *
160     * @param integer $year 年
161     * @param integer $month 月
162     * @param integer $day 日
163     * @return boolean 休日の場合trueを返す
164     */
165    function lfCheckHoliday($year, $month, $day)
166    {
167        if (!empty($this->arrHoliday[$month])) {
168            if (in_array($day, $this->arrHoliday[$month])) {
169                return true;
170            }
171        }
172        if (!empty($this->arrRegularHoliday)) {
173            $day = date('w', mktime(0,0,0 ,$month, $day, $year));
174            if (in_array($day, $this->arrRegularHoliday)) {
175                return true;
176            }
177        }
178        return false;
179    }
180
181}
Note: See TracBrowser for help on using the repository browser.