Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_FrontParts_Bloc_Calendar.php

Documentation is available at LC_Page_FrontParts_Bloc_Calendar.php

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

Documentation generated on Fri, 24 Feb 2012 14:01:59 +0900 by Seasoft