Code Search for Developers
 
 
  

Month.php from LiveSupport at Krugle


Show Month.php syntax highlighted

<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | PHP Version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license,      |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
// +----------------------------------------------------------------------+
//
// $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $
//
/**
 * @package Calendar
 * @version $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $
 */

/**
 * Allows Calendar include path to be redefined
 * @ignore
 */
if (!defined('CALENDAR_ROOT')) {
    define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
}

/**
 * Load Calendar base class
 */
require_once CALENDAR_ROOT.'Calendar.php';

/**
 * Represents a Month and builds Days
 * <code>
 * require_once 'Calendar/Month.php';
 * $Month = & new Calendar_Month(2003, 10); // Oct 2003
 * $Month->build(); // Build Calendar_Day objects
 * while ($Day = & $Month->fetch()) {
 *     echo $Day->thisDay().'<br />';
 * }
 * </code>
 * @package Calendar
 * @access public
 */
class Calendar_Month extends Calendar
{
    /**
     * Constructs Calendar_Month
     * @param int $y year e.g. 2003
     * @param int $m month e.g. 5
     * @param int $firstDay first day of the week [optional]
     * @access public
     */
    function Calendar_Month($y, $m, $firstDay=null)
    {
        Calendar::Calendar($y, $m);
        $this->firstDay = $this->defineFirstDayOfWeek($firstDay);
    }

    /**
     * Builds Day objects for this Month. Creates as many Calendar_Day objects
     * as there are days in the month
     * @param array (optional) Calendar_Day objects representing selected dates
     * @return boolean
     * @access public
     */
    function build($sDates=array())
    {
        require_once CALENDAR_ROOT.'Day.php';
        $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
        for ($i=1; $i<=$daysInMonth; $i++) {
            $this->children[$i] = new Calendar_Day($this->year, $this->month, $i);
        }
        if (count($sDates) > 0) {
            $this->setSelection($sDates);
        }
        return true;
    }

    /**
     * Called from build()
     * @param array
     * @return void
     * @access private
     */
    function setSelection($sDates)
    {
        foreach ($sDates as $sDate) {
            if ($this->year == $sDate->thisYear()
                && $this->month == $sDate->thisMonth()
            ) {
                $key = $sDate->thisDay();
                if (isset($this->children[$key])) {
                    $sDate->setSelected();
                    $class = strtolower(get_class($sDate));
                    if ($class == 'calendar_day' || $class == 'calendar_decorator') {
                        $sDate->setFirst($this->children[$key]->isFirst());
                        $sDate->setLast($this->children[$key]->isLast());
                    }
                    $this->children[$key] = $sDate;
                }
            }
        }
    }
}
?>



See more files for this project here

LiveSupport

LiveSupport is a radio playout and automation system. It enables radio stations to automate their broadcasts by using playlists that are scheduled for airing. Playlists can contain music, talk, or even other playlists. A Web interface is included, so radio station personnel can manage the the station's broadcasts remotely.

Project homepage: http://www.campware.org/en/camp/livesupport_news/
Programming language(s): C++,PHP,Shell Script,XML
License: gpl2

  Decorator/
    Textual.php
    Uri.php
    Weekday.php
    Wrapper.php
  Engine/
    Interface.php
    PearDate.php
    UnixTS.php
  Month/
    Weekdays.php
    Weeks.php
  Table/
    Helper.php
  Util/
    Textual.php
    Uri.php
  docs/
    examples/
      1.php
      1.phps
      10.php
      10.phps
      11.php
      11.phps
      12.php
      12.phps
      13.php
      13.phps
      14.php
      14.phps
      15.php
      15.phps
      16.php
      16.phps
      17.php
      17.phps
      18.php
      18.phps
      19.php
      19.phps
      2.php
      2.phps
      20.php
      20.phps
      21.php
      21.phps
      22.php
      22.phps
      23.php
      23.phps
      3.php
      3.phps
      4.php
      4.phps
      5.php
      5.phps
      6.php
      6.phps
      7.php
      7.phps
      8.php
      8.phps
      9.php
      9.phps
      index.html
    Readme
  tests/
    README
    all_tests.php
    calendar_engine_tests.php
    calendar_include.php
    calendar_tabular_tests.php
    calendar_test.php
    calendar_tests.php
    day_test.php
    decorator_test.php
    decorator_tests.php
    decorator_textual_test.php
    decorator_uri_test.php
    helper_test.php
    hour_test.php
    minute_test.php
    month_test.php
    month_weekdays_test.php
    month_weeks_test.php
    peardate_engine_test.php
    second_test.php
    simple_include.php
    table_helper_tests.php
    unixts_engine_test.php
    util_tests.php
    util_textual_test.php
    util_uri_test.php
    validator_error_test.php
    validator_tests.php
    validator_unit_test.php
    week_firstday_0_test.php
    week_test.php
    year_test.php
  Calendar.php
  Day.php
  Decorator.php
  Factory.php
  Hour.php
  Minute.php
  Month.php
  Second.php
  Validator.php
  Week.php
  Year.php