PluginProbe
Welcart e-Commerce / 2.12.3
Welcart e-Commerce v2.12.3
2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 291 releases
usc-e-shop / classes / calendar.class.php

calendar.class.php in Welcart e-Commerce 2.12.3, at classes/calendar.class.php

183 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Calendar class
4 *
5 * @package Welcart
6 */
7 class calendarData {
8
9 /**
10 * Year
11 *
12 * @var string
13 */
14 public $_year;
15
16 /**
17 * Month
18 *
19 * @var string
20 */
21 public $_month;
22
23 /**
24 * Day
25 *
26 * @var string
27 */
28 public $_day;
29
30 /**
31 * Row weeks
32 *
33 * @var string
34 */
35 public $_row;
36
37 /**
38 * Date
39 *
40 * @var string
41 */
42 public $_date;
43
44 /**
45 * Date text
46 *
47 * @var string
48 */
49 public $_datetext;
50
51 /**
52 * Constructor
53 */
54 public function __construct() {
55 $this->_row = 0;
56 $this->_date = array();
57 $this->_datetext = array();
58 }
59
60 /**
61 * Set Today
62 *
63 * @param int $year Year.
64 * @param int $month Month.
65 * @param int $day Day.
66 * @return void
67 */
68 public function setToday( $year, $month, $day ) {
69 $this->_year = $year;
70 $this->_month = $month;
71 $this->_day = $day;
72 }
73
74 /**
75 * Get date
76 *
77 * @param int $row Row.
78 * @param int $d Day.
79 * @return string
80 */
81 public function getDate( $row, $d ) {
82 return $this->_date[ $row ][ $d ];
83 }
84
85 /**
86 * Get date text
87 *
88 * @param int $row Row.
89 * @param int $d Day.
90 * @return string
91 */
92 public function getDateText( $row, $d ) {
93 return $this->_datetext[ $row ][ $d ];
94 }
95
96 /**
97 * Get row
98 *
99 * @return int
100 */
101 public function getRow() {
102 return $this->_row;
103 }
104
105 /**
106 * Set Calendar
107 */
108 public function setCalendarData() {
109 $day = 1; /* 当月開始日に設定 */
110 $firstw = getWeek( $this->_year, $this->_month, $day ); /* 当月開始日の曜日 */
111 $lastday = getLastDay( $this->_year, $this->_month ); /* 当月最終日 */
112 $lastw = getWeek( $this->_year, $this->_month, $lastday ); /* 当月最終日の曜日 */
113
114 /* 1週目 */
115 for ( $d = 0; $d <= 6; $d++ ) {
116 if ( (int) $firstw === $d ) {
117 $this->_date[0][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
118 $this->_datetext[0][ $d ] = $day;
119 } elseif ( $firstw < $d ) {
120 list( $this->_year, $this->_month, $day ) = getNextDay( $this->_year, $this->_month, $day );
121 $this->_date[0][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
122 $this->_datetext[0][ $d ] = $day;
123 } else {
124 $this->_date[0][ $d ] = '';
125 $this->_datetext[0][ $d ] = '';
126 }
127 }
128 /* 2~4週目 */
129 for ( $d = 0; $d <= 6; $d++ ) {
130 list( $this->_year, $this->_month, $day ) = getNextDay( $this->_year, $this->_month, $day );
131 $this->_date[1][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
132 $this->_datetext[1][ $d ] = $day;
133 }
134 for ( $d = 0; $d <= 6; $d++ ) {
135 list( $this->_year, $this->_month, $day ) = getNextDay( $this->_year, $this->_month, $day );
136 $this->_date[2][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
137 $this->_datetext[2][ $d ] = $day;
138 }
139 for ( $d = 0; $d <= 6; $d++ ) {
140 list( $this->_year, $this->_month, $day ) = getNextDay( $this->_year, $this->_month, $day );
141 $this->_date[3][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
142 $this->_datetext[3][ $d ] = $day;
143 }
144 /* 5週目 */
145 for ( $d = 0; $d <= 6; $d++ ) {
146 if ( (int) $lastday === (int) $day ) {
147 break;
148 } else {
149 list( $this->_year, $this->_month, $day ) = getNextDay( $this->_year, $this->_month, $day );
150 $this->_date[4][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
151 $this->_datetext[4][ $d ] = $day;
152 }
153 }
154 if ( 0 < $d && $d <= 6 ) {
155 while ( $d <= 6 ) {
156 $this->_date[4][ $d ] = '';
157 $this->_datetext[4][ $d ] = '';
158 $d++;
159 }
160 } elseif ( 0 !== $d ) {
161 /* 6週目 */
162 for ( $d = 0; $d <= 6; $d++ ) {
163 if ( (int) $lastday === (int) $day ) {
164 break;
165 } else {
166 list( $this->_year, $this->_month, $day ) = getNextDay( $this->_year, $this->_month, $day );
167 $this->_date[5][ $d ] = sprintf( '%04d-%02d-%02d', $this->_year, $this->_month, $day );
168 $this->_datetext[5][ $d ] = $day;
169 }
170 }
171 if ( $d > 0 ) {
172 while ( $d <= 6 ) {
173 $this->_date[5][ $d ] = '';
174 $this->_datetext[5][ $d ] = '';
175 $d++;
176 }
177 }
178 }
179
180 $this->_row = ( is_array( $this->_date ) ) ? count( $this->_date ) : 0;
181 }
182 }
183