1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Contains the Calendar_Month_Weekdays class |
6
|
|
|
* |
7
|
|
|
* PHP versions 4 and 5 |
8
|
|
|
* |
9
|
|
|
* LICENSE: Redistribution and use in source and binary forms, with or without |
10
|
|
|
* modification, are permitted provided that the following conditions are met: |
11
|
|
|
* 1. Redistributions of source code must retain the above copyright |
12
|
|
|
* notice, this list of conditions and the following disclaimer. |
13
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
14
|
|
|
* notice, this list of conditions and the following disclaimer in the |
15
|
|
|
* documentation and/or other materials provided with the distribution. |
16
|
|
|
* 3. The name of the author may not be used to endorse or promote products |
17
|
|
|
* derived from this software without specific prior written permission. |
18
|
|
|
* |
19
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
20
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
21
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22
|
|
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY |
23
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29
|
|
|
* |
30
|
|
|
* @category Date and Time |
31
|
|
|
* @package Calendar |
32
|
|
|
* @author Harry Fuecks <[email protected]> |
33
|
|
|
* @copyright 2003-2007 Harry Fuecks |
34
|
|
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
35
|
|
|
* @version CVS: $Id$ |
36
|
|
|
* @link http://pear.php.net/package/Calendar |
37
|
|
|
*/ |
38
|
|
|
namespace PEAR\Calendar\Month; |
39
|
|
|
|
40
|
|
|
use PEAR\Calendar\Day; |
41
|
|
|
use PEAR\Calendar\Month; |
42
|
|
|
use PEAR\Calendar\Table\Helper; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Represents a Month and builds Days in tabular form<br> |
46
|
|
|
* <code> |
47
|
|
|
* require_once 'Calendar/Month/Weekdays.php'; |
48
|
|
|
* $Month = new Calendar_Month_Weekdays(2003, 10); // Oct 2003 |
49
|
|
|
* $Month->build(); // Build Calendar_Day objects |
50
|
|
|
* while ($Day = & $Month->fetch()) { |
51
|
|
|
* if ($Day->isFirst()) { |
52
|
|
|
* echo '<tr>'; |
53
|
|
|
* } |
54
|
|
|
* if ($Day->isEmpty()) { |
55
|
|
|
* echo '<td> </td>'; |
56
|
|
|
* } else { |
57
|
|
|
* echo '<td>'.$Day->thisDay().'</td>'; |
58
|
|
|
* } |
59
|
|
|
* if ($Day->isLast()) { |
60
|
|
|
* echo '</tr>'; |
61
|
|
|
* } |
62
|
|
|
* } |
63
|
|
|
* </code> |
64
|
|
|
* |
65
|
|
|
* @category Date and Time |
66
|
|
|
* @package Calendar |
67
|
|
|
* @author Harry Fuecks <[email protected]> |
68
|
|
|
* @copyright 2003-2007 Harry Fuecks |
69
|
|
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
70
|
|
|
* @link http://pear.php.net/package/Calendar |
71
|
|
|
* @access public |
72
|
|
|
*/ |
73
|
|
|
class Weekdays extends Month |
74
|
|
|
{ |
75
|
|
|
/** |
76
|
|
|
* Instance of Calendar_Table_Helper |
|
|
|
|
77
|
|
|
* @var Calendar_Table_Helper |
78
|
|
|
* @access private |
79
|
|
|
*/ |
80
|
|
|
var $tableHelper; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* First day of the week |
84
|
|
|
* @access private |
85
|
|
|
* @var string |
86
|
|
|
*/ |
87
|
|
|
var $firstDay; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Constructs Calendar_Month_Weekdays |
91
|
|
|
* |
92
|
|
|
* @param int $y year e.g. 2003 |
93
|
|
|
* @param int $m month e.g. 5 |
94
|
|
|
* @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.) |
95
|
|
|
* |
96
|
|
|
* @access public |
97
|
|
|
*/ |
98
|
|
|
function __construct($y, $m, $firstDay=null) |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
parent::__construct($y, $m, $firstDay); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Builds Day objects in tabular form, to allow display of calendar month |
105
|
|
|
* with empty cells if the first day of the week does not fall on the first |
106
|
|
|
* day of the month. |
107
|
|
|
* |
108
|
|
|
* @param array $sDates (optional) Calendar_Day objects representing selected dates |
109
|
|
|
* |
110
|
|
|
* @return boolean |
111
|
|
|
* @access public |
112
|
|
|
* @see Day::isEmpty() |
113
|
|
|
* @see Calendar_Day_Base::isFirst() |
114
|
|
|
* @see Calendar_Day_Base::isLast() |
115
|
|
|
*/ |
116
|
|
|
function build($sDates = array()) |
|
|
|
|
117
|
|
|
{ |
118
|
|
|
$this->tableHelper = new Helper($this, $this->firstDay); |
|
|
|
|
119
|
|
|
Month::build($sDates); |
120
|
|
|
$this->buildEmptyDaysBefore(); |
121
|
|
|
$this->shiftDays(); |
122
|
|
|
$this->buildEmptyDaysAfter(); |
123
|
|
|
$this->setWeekMarkers(); |
124
|
|
|
return true; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Prepends empty days before the real days in the month |
129
|
|
|
* |
130
|
|
|
* @return void |
131
|
|
|
* @access private |
132
|
|
|
*/ |
133
|
|
|
function buildEmptyDaysBefore() |
|
|
|
|
134
|
|
|
{ |
135
|
|
|
$eBefore = $this->tableHelper->getEmptyDaysBefore(); |
136
|
|
|
for ($i=0; $i < $eBefore; $i++) { |
137
|
|
|
$stamp = $this->cE->dateToStamp($this->year, $this->month, -$i); |
138
|
|
|
$Day = new Day( |
139
|
|
|
$this->cE->stampToYear($stamp), |
140
|
|
|
$this->cE->stampToMonth($stamp), |
141
|
|
|
$this->cE->stampToDay($stamp)); |
142
|
|
|
$Day->setEmpty(); |
143
|
|
|
$Day->adjust(); |
144
|
|
|
array_unshift($this->children, $Day); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Shifts the array of children forward, if necessary |
150
|
|
|
* |
151
|
|
|
* @return void |
152
|
|
|
* @access private |
153
|
|
|
*/ |
154
|
|
|
function shiftDays() |
|
|
|
|
155
|
|
|
{ |
156
|
|
|
if (isset($this->children[0])) { |
157
|
|
|
array_unshift($this->children, null); |
158
|
|
|
unset($this->children[0]); |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Appends empty days after the real days in the month |
164
|
|
|
* |
165
|
|
|
* @return void |
166
|
|
|
* @access private |
167
|
|
|
*/ |
168
|
|
|
function buildEmptyDaysAfter() |
|
|
|
|
169
|
|
|
{ |
170
|
|
|
$eAfter = $this->tableHelper->getEmptyDaysAfter(); |
171
|
|
|
$sDOM = $this->tableHelper->getNumTableDaysInMonth(); |
172
|
|
|
for ($i=1; $i <= $sDOM-$eAfter; $i++) { |
173
|
|
|
$Day = new Day($this->year, $this->month+1, $i); |
174
|
|
|
$Day->setEmpty(); |
175
|
|
|
$Day->adjust(); |
176
|
|
|
array_push($this->children, $Day); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Sets the "markers" for the beginning and of a of week, in the |
182
|
|
|
* built Calendar_Day children |
183
|
|
|
* |
184
|
|
|
* @return void |
185
|
|
|
* @access private |
186
|
|
|
*/ |
187
|
|
|
function setWeekMarkers() |
|
|
|
|
188
|
|
|
{ |
189
|
|
|
$dIW = $this->cE->getDaysInWeek( |
190
|
|
|
$this->thisYear(), |
191
|
|
|
$this->thisMonth(), |
192
|
|
|
$this->thisDay() |
193
|
|
|
); |
194
|
|
|
$sDOM = $this->tableHelper->getNumTableDaysInMonth(); |
195
|
|
|
for ($i=1; $i <= $sDOM; $i+= $dIW) { |
196
|
|
|
$this->children[$i]->setFirst(); |
197
|
|
|
$this->children[$i+($dIW-1)]->setLast(); |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths