Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
493 ddelon 1
<?php
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: Minute.php,v 1.1 2005-09-30 14:58:00 ddelon Exp $
21
//
22
/**
23
 * @package Calendar
24
 * @version $Id: Minute.php,v 1.1 2005-09-30 14:58:00 ddelon Exp $
25
 */
26
 
27
/**
28
 * Allows Calendar include path to be redefined
29
 * @ignore
30
 */
31
if (!defined('CALENDAR_ROOT')) {
32
    define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
33
}
34
 
35
/**
36
 * Load Calendar base class
37
 */
38
require_once CALENDAR_ROOT.'Calendar.php';
39
 
40
/**
41
 * Represents a Minute and builds Seconds
42
 * <code>
43
 * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Minute.php';
44
 * $Minute = & new Calendar_Minute(2003, 10, 21, 15, 31); // Oct 21st 2003, 3:31pm
45
 * $Minute->build(); // Build Calendar_Second objects
46
 * while ($Second = & $Minute->fetch()) {
47
 *     echo $Second->thisSecond().'<br />';
48
 * }
49
 * </code>
50
 * @package Calendar
51
 * @access public
52
 */
53
class Calendar_Minute extends Calendar
54
{
55
    /**
56
     * Constructs Minute
57
     * @param int year e.g. 2003
58
     * @param int month e.g. 5
59
     * @param int day e.g. 11
60
     * @param int hour e.g. 13
61
     * @param int minute e.g. 31
62
     * @access public
63
     */
64
    function Calendar_Minute($y, $m, $d, $h, $i)
65
    {
66
        Calendar::Calendar($y, $m, $d, $h, $i);
67
    }
68
 
69
    /**
70
     * Builds the Calendar_Second objects
71
     * @param array (optional) Calendar_Second objects representing selected dates
72
     * @return boolean
73
     * @access public
74
     */
75
    function build($sDates=array())
76
    {
77
        require_once CALENDAR_ROOT.'Second.php';
78
        $sIM = $this->cE->getSecondsInMinute($this->year, $this->month,
79
                $this->day, $this->hour, $this->minute);
80
        for ($i=0; $i < $sIM; $i++) {
81
            $this->children[$i] = new Calendar_Second($this->year, $this->month,
82
                $this->day, $this->hour, $this->minute, $i);
83
        }
84
        if (count($sDates) > 0) {
85
            $this->setSelection($sDates);
86
        }
87
        return true;
88
    }
89
 
90
    /**
91
     * Called from build()
92
     * @param array
93
     * @return void
94
     * @access private
95
     */
96
    function setSelection($sDates)
97
    {
98
        foreach ($sDates as $sDate) {
99
            if ($this->year == $sDate->thisYear()
100
                && $this->month == $sDate->thisMonth()
101
                && $this->day == $sDate->thisDay()
102
                && $this->hour == $sDate->thisHour()
103
                && $this->minute == $sDate->thisMinute())
104
            {
105
                $key = (int)$sDate->thisSecond();
106
                if (isset($this->children[$key])) {
107
                    $sDate->setSelected();
108
                    $this->children[$key] = $sDate;
109
                }
110
            }
111
        }
112
    }
113
}
114
?>