- Timestamp:
- 2013/08/26 12:42:34 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/module/Calendar/Decorator.php
r20119 r23125 1 1 <?php 2 2 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 // 4 // +----------------------------------------------------------------------+ 5 // | PHP Version 4 | 6 // +----------------------------------------------------------------------+ 7 // | Copyright (c) 1997-2002 The PHP Group | 8 // +----------------------------------------------------------------------+ 9 // | This source file is subject to version 2.02 of the PHP license, | 10 // | that is bundled with this package in the file LICENSE, and is | 11 // | available at through the world-wide-web at | 12 // | http://www.php.net/license/3_0.txt. | 13 // | If you did not receive a copy of the PHP license and are unable to | 14 // | obtain it through the world-wide-web, please send a note to | 15 // | license@php.net so we can mail you a copy immediately. | 16 // +----------------------------------------------------------------------+ 17 // | Authors: Harry Fuecks <hfuecks@phppatterns.com> | 18 // +----------------------------------------------------------------------+ 19 // 20 // $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $ 21 // 3 22 4 /** 23 * @package Calendar 24 * @version $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $ 5 * Contains the Calendar_Decorator 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 <hfuecks@phppatterns.com> 33 * @copyright 2003-2007 Harry Fuecks 34 * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) 35 * @version CVS: $Id: Decorator.php 300729 2010-06-24 12:05:53Z quipo $ 36 * @link http://pear.php.net/package/Calendar 25 37 */ 38 26 39 /** 27 40 * Decorates any calendar class. … … 37 50 * } 38 51 * } 39 * $Day = &new Calendar_Day(2003, 10, 25);40 * $DayDecorator = &new DayDecorator($Day);52 * $Day = new Calendar_Day(2003, 10, 25); 53 * $DayDecorator = new DayDecorator($Day); 41 54 * echo $DayDecorator->thisDay(); // Outputs "Sat" 42 55 * </code> 56 * 57 * @category Date and Time 58 * @package Calendar 59 * @author Harry Fuecks <hfuecks@phppatterns.com> 60 * @copyright 2003-2007 Harry Fuecks 61 * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) 62 * @link http://pear.php.net/package/Calendar 43 63 * @abstract 44 * @package Calendar45 64 */ 46 65 class Calendar_Decorator … … 55 74 /** 56 75 * Constructs the Calendar_Decorator 57 * @param object subclass to Calendar to decorate 58 */ 59 function Calendar_Decorator(& $calendar) 76 * 77 * @param object &$calendar subclass to Calendar to decorate 78 */ 79 function Calendar_Decorator(&$calendar) 60 80 { 61 81 $this->calendar = & $calendar; … … 65 85 * Defines the calendar by a Unix timestamp, replacing values 66 86 * passed to the constructor 67 * @param int Unix timestamp 87 * 88 * @param int $ts Unix timestamp 89 * 68 90 * @return void 69 91 * @access public … … 77 99 * Returns a timestamp from the current date / time values. Format of 78 100 * timestamp depends on Calendar_Engine implementation being used 79 * @return int timestamp 101 * 102 * @return int $ts timestamp 80 103 * @access public 81 104 */ … … 87 110 /** 88 111 * Defines calendar object as selected (e.g. for today) 89 * @param boolean state whether Calendar subclass 112 * 113 * @param boolean $state whether Calendar subclass must be selected 114 * 90 115 * @return void 91 116 * @access public … … 98 123 /** 99 124 * True if the calendar subclass object is selected (e.g. today) 125 * 100 126 * @return boolean 101 127 * @access public … … 108 134 /** 109 135 * Adjusts the date (helper method) 136 * 110 137 * @return void 111 138 * @access public … … 118 145 /** 119 146 * Returns the date as an associative array (helper method) 120 * @param mixed timestamp (leave empty for current timestamp) 147 * 148 * @param mixed $stamp timestamp (leave empty for current timestamp) 149 * 121 150 * @return array 122 151 * @access public 123 152 */ 124 function toArray($stamp =null)153 function toArray($stamp = null) 125 154 { 126 155 return $this->calendar->toArray($stamp); … … 129 158 /** 130 159 * Returns the value as an associative array (helper method) 131 * @param string type of date object that return value represents 132 * @param string $format ['int' | 'array' | 'timestamp' | 'object'] 133 * @param mixed timestamp (depending on Calendar engine being used) 134 * @param int integer default value (i.e. give me the answer quick) 160 * 161 * @param string $returnType type of date object that return value represents 162 * @param string $format ['int'|'timestamp'|'object'|'array'] 163 * @param mixed $stamp timestamp (depending on Calendar engine being used) 164 * @param integer $default default value (i.e. give me the answer quick) 165 * 135 166 * @return mixed 136 167 * @access private … … 144 175 * Defines Day object as first in a week 145 176 * Only used by Calendar_Month_Weekdays::build() 146 * @param boolean state 177 * 178 * @param boolean $state whether it's first or not 179 * 147 180 * @return void 148 181 * @access private 149 182 */ 150 function setFirst 151 { 152 if ( method_exists($this->calendar,'setFirst')) {183 function setFirst($state = true) 184 { 185 if (method_exists($this->calendar, 'setFirst')) { 153 186 $this->calendar->setFirst($state); 154 187 } … … 158 191 * Defines Day object as last in a week 159 192 * Used only following Calendar_Month_Weekdays::build() 160 * @param boolean state 193 * 194 * @param boolean $state whether it's last or not 195 * 161 196 * @return void 162 197 * @access private … … 164 199 function setLast($state = true) 165 200 { 166 if ( method_exists($this->calendar,'setLast')) {201 if (method_exists($this->calendar, 'setLast')) { 167 202 $this->calendar->setLast($state); 168 203 } … … 172 207 * Returns true if Day object is first in a Week 173 208 * Only relevant when Day is created by Calendar_Month_Weekdays::build() 209 * 174 210 * @return boolean 175 211 * @access public 176 212 */ 177 function isFirst() { 178 if ( method_exists($this->calendar,'isFirst') ) { 213 function isFirst() 214 { 215 if (method_exists($this->calendar, 'isFirst')) { 179 216 return $this->calendar->isFirst(); 180 217 } … … 184 221 * Returns true if Day object is last in a Week 185 222 * Only relevant when Day is created by Calendar_Month_Weekdays::build() 223 * 186 224 * @return boolean 187 225 * @access public … … 189 227 function isLast() 190 228 { 191 if ( method_exists($this->calendar,'isLast')) {229 if (method_exists($this->calendar, 'isLast')) { 192 230 return $this->calendar->isLast(); 193 231 } … … 197 235 * Defines Day object as empty 198 236 * Only used by Calendar_Month_Weekdays::build() 199 * @param boolean state 237 * 238 * @param boolean $state whether it's empty or not 239 * 200 240 * @return void 201 241 * @access private … … 203 243 function setEmpty ($state = true) 204 244 { 205 if ( method_exists($this->calendar,'setEmpty')) {245 if (method_exists($this->calendar, 'setEmpty')) { 206 246 $this->calendar->setEmpty($state); 207 247 } … … 209 249 210 250 /** 251 * Check if the current object is empty 252 * 211 253 * @return boolean 212 254 * @access public … … 214 256 function isEmpty() 215 257 { 216 if ( method_exists($this->calendar,'isEmpty')) {258 if (method_exists($this->calendar, 'isEmpty')) { 217 259 return $this->calendar->isEmpty(); 218 260 } … … 221 263 /** 222 264 * Build the children 223 * @param array containing Calendar objects to select (optional) 265 * 266 * @param array $sDates array containing Calendar objects to select (optional) 267 * 224 268 * @return boolean 225 269 * @access public … … 236 280 * the collection, returns false and resets the collection for 237 281 * further iteratations. 282 * 238 283 * @return mixed either an object subclass of Calendar or false 239 284 * @access public … … 246 291 /** 247 292 * Fetches all child from the current collection of children 293 * 248 294 * @return array 249 295 * @access public … … 255 301 256 302 /** 257 * Get the number Calendar subclass objects stored in the internal 258 * collection.303 * Get the number Calendar subclass objects stored in the internal collection 304 * 259 305 * @return int 260 306 * @access public … … 267 313 /** 268 314 * Determine whether this date is valid, with the bounds determined by 269 * the Calendar_Engine. The call is passed on to 270 * Calendar_Validator::isValid315 * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid 316 * 271 317 * @return boolean 272 318 * @access public … … 279 325 /** 280 326 * Returns an instance of Calendar_Validator 327 * 281 328 * @return Calendar_Validator 282 329 * @access public … … 291 338 * Returns a reference to the current Calendar_Engine being used. Useful 292 339 * for Calendar_Table_Helper and Calendar_Validator 340 * 293 341 * @return object implementing Calendar_Engine_Inteface 294 342 * @access private … … 296 344 function & getEngine() 297 345 { 298 return $this->calendar->getEngine(); 346 $engine = $this->calendar->getEngine(); 347 return $engine; 299 348 } 300 349 301 350 /** 302 351 * Returns the value for the previous year 303 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 352 * 353 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 354 * 304 355 * @return int e.g. 2002 or timestamp 305 356 * @access public … … 312 363 /** 313 364 * Returns the value for this year 314 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 365 * 366 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 367 * 315 368 * @return int e.g. 2003 or timestamp 316 369 * @access public … … 323 376 /** 324 377 * Returns the value for next year 325 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 378 * 379 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 380 * 326 381 * @return int e.g. 2004 or timestamp 327 382 * @access public … … 334 389 /** 335 390 * Returns the value for the previous month 336 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 391 * 392 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 393 * 337 394 * @return int e.g. 4 or Unix timestamp 338 395 * @access public … … 345 402 /** 346 403 * Returns the value for this month 347 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 404 * 405 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 406 * 348 407 * @return int e.g. 5 or timestamp 349 408 * @access public … … 356 415 /** 357 416 * Returns the value for next month 358 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 417 * 418 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 419 * 359 420 * @return int e.g. 6 or timestamp 360 421 * @access public … … 367 428 /** 368 429 * Returns the value for the previous week 369 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 430 * 431 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 432 * 370 433 * @return int e.g. 4 or Unix timestamp 371 434 * @access public … … 373 436 function prevWeek($format = 'n_in_month') 374 437 { 375 if ( method_exists($this->calendar, 'prevWeek')) {438 if ( method_exists($this->calendar, 'prevWeek')) { 376 439 return $this->calendar->prevWeek($format); 377 440 } else { 378 require_once 'PEAR.php';441 include_once 'PEAR.php'; 379 442 PEAR::raiseError( 380 443 'Cannot call prevWeek on Calendar object of type: '. … … 387 450 /** 388 451 * Returns the value for this week 389 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 452 * 453 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 454 * 390 455 * @return int e.g. 5 or timestamp 391 456 * @access public … … 393 458 function thisWeek($format = 'n_in_month') 394 459 { 395 if ( method_exists($this->calendar, 'thisWeek')) {460 if ( method_exists($this->calendar, 'thisWeek')) { 396 461 return $this->calendar->thisWeek($format); 397 462 } else { 398 require_once 'PEAR.php';463 include_once 'PEAR.php'; 399 464 PEAR::raiseError( 400 465 'Cannot call thisWeek on Calendar object of type: '. … … 407 472 /** 408 473 * Returns the value for next week 409 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 474 * 475 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 476 * 410 477 * @return int e.g. 6 or timestamp 411 478 * @access public … … 413 480 function nextWeek($format = 'n_in_month') 414 481 { 415 if ( method_exists($this->calendar, 'nextWeek')) {482 if ( method_exists($this->calendar, 'nextWeek')) { 416 483 return $this->calendar->nextWeek($format); 417 484 } else { 418 require_once 'PEAR.php';485 include_once 'PEAR.php'; 419 486 PEAR::raiseError( 420 487 'Cannot call thisWeek on Calendar object of type: '. … … 427 494 /** 428 495 * Returns the value for the previous day 429 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 496 * 497 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 498 * 430 499 * @return int e.g. 10 or timestamp 431 500 * @access public 432 501 */ 433 function prevDay($format = 'int') { 502 function prevDay($format = 'int') 503 { 434 504 return $this->calendar->prevDay($format); 435 505 } … … 437 507 /** 438 508 * Returns the value for this day 439 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 509 * 510 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 511 * 440 512 * @return int e.g. 11 or timestamp 441 513 * @access public … … 448 520 /** 449 521 * Returns the value for the next day 450 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 522 * 523 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 524 * 451 525 * @return int e.g. 12 or timestamp 452 526 * @access public … … 459 533 /** 460 534 * Returns the value for the previous hour 461 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 535 * 536 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 537 * 462 538 * @return int e.g. 13 or timestamp 463 539 * @access public … … 470 546 /** 471 547 * Returns the value for this hour 472 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 548 * 549 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 550 * 473 551 * @return int e.g. 14 or timestamp 474 552 * @access public … … 481 559 /** 482 560 * Returns the value for the next hour 483 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 561 * 562 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 563 * 484 564 * @return int e.g. 14 or timestamp 485 565 * @access public … … 492 572 /** 493 573 * Returns the value for the previous minute 494 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 574 * 575 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 576 * 495 577 * @return int e.g. 23 or timestamp 496 578 * @access public … … 503 585 /** 504 586 * Returns the value for this minute 505 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 587 * 588 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 589 * 506 590 * @return int e.g. 24 or timestamp 507 591 * @access public … … 514 598 /** 515 599 * Returns the value for the next minute 516 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 600 * 601 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 602 * 517 603 * @return int e.g. 25 or timestamp 518 604 * @access public 519 605 */ 520 function nextMinute($format = 'int')606 function nextMinute($format = 'int') 521 607 { 522 608 return $this->calendar->nextMinute($format); … … 525 611 /** 526 612 * Returns the value for the previous second 527 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 613 * 614 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 615 * 528 616 * @return int e.g. 43 or timestamp 529 617 * @access public … … 536 624 /** 537 625 * Returns the value for this second 538 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 626 * 627 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 628 * 539 629 * @return int e.g. 44 or timestamp 540 630 * @access public … … 547 637 /** 548 638 * Returns the value for the next second 549 * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 639 * 640 * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 641 * 550 642 * @return int e.g. 45 or timestamp 551 643 * @access public
Note: See TracChangeset
for help on using the changeset viewer.