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

Revision 20534, 5.1 KB checked in by Seasoft, 13 years ago (diff)

#627(ソース整形・ソースコメントの改善)
#628(未使用処理・定義などの削除)

  • 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-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__));
26define('CALENDAR_ROOT', DATA_REALDIR.'module/Calendar'.DIRECTORY_SEPARATOR);
27require_once $current_dir . '/../../../../module/Calendar/Month/Weekdays.php';
28require_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 */
37class 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 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        for ($j = 0; $j <= $disp_month-1; ++$j) {
94            $year = date('Y');
95            $month = date('n') + $j;
96            if ($month > 12) {
97                $month = $month%12;
98                $year = $year + $month%12;
99            }
100
101            $objMonth = new Calendar_Month_Weekdays($year, $month, 0);
102            $objMonth->build();
103            $i = 0;
104            while ($objDay = $objMonth->fetch()) {
105                if ($month == $objDay->month) {
106                    $arrCalendar[$j][$i]['in_month'] = true;
107                } else {
108                    $arrCalendar[$j][$i]['in_month'] = false;
109                }
110                $arrCalendar[$j][$i]['first'] = $objDay->first;
111                $arrCalendar[$j][$i]['last'] = $objDay->last;
112                $arrCalendar[$j][$i]['empty'] = $objDay->empty;
113                $arrCalendar[$j][$i]['year'] = $year;
114                $arrCalendar[$j][$i]['month'] = $month;
115                $arrCalendar[$j][$i]['day'] = $objDay->day;
116                if ($this->lfCheckHoliday($year, $month, $objDay->day)) {
117                    $arrCalendar[$j][$i]['holiday'] = true;
118                } else {
119                    $arrCalendar[$j][$i]['holiday'] = false;
120                }
121                ++$i;
122            }
123        }
124
125        return $arrCalendar;
126    }
127
128    /**
129     * 休日取得.
130     *
131     * @return array $arrHoliday 休日情報の配列を返す
132     */
133    function lfGetHoliday() {
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        $arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
152        $arrRegularHoliday = explode('|', $arrInfo['regular_holiday_ids']);
153        return $arrRegularHoliday;
154    }
155
156    /**
157     * 休日チェック取得.
158     *
159     * @param integer $year 年
160     * @param integer $month 月
161     * @param integer $day 日
162     * @return boolean 休日の場合trueを返す
163     */
164    function lfCheckHoliday($year, $month, $day) {
165        if (!empty($this->arrHoliday[$month])) {
166            if (in_array($day, $this->arrHoliday[$month])) {
167                return true;
168            }
169        }
170        if (!empty($this->arrRegularHoliday)) {
171            $day = date('w', mktime(0,0,0 ,$month, $day, $year));
172            if (in_array($day, $this->arrRegularHoliday)) {
173                return true;
174            }
175        }
176        return false;
177    }
178
179}
180?>
Note: See TracBrowser for help on using the repository browser.