/**
  * Builds the Months of the Year.<br>
  * <b>Note:</b> by defining the constant CALENDAR_MONTH_STATE you can
  * control what class of Calendar_Month is built e.g.;
  * <code>
  * require_once 'Calendar/Calendar_Year.php';
  * define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays
  * // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks
  * // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month
  * </code>
  * It defaults to building Calendar_Month objects.
  * @param array (optional) array of Calendar_Month objects representing selected dates
  * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
  * @return boolean
  * @access public
  */
 function build($sDates = array(), $firstDay = null)
 {
     require_once CALENDAR_ROOT . 'Factory.php';
     $this->firstDay = $this->defineFirstDayOfWeek($firstDay);
     $monthsInYear = $this->cE->getMonthsInYear($this->thisYear());
     for ($i = 1; $i <= $monthsInYear; $i++) {
         $this->children[$i] = Calendar_Factory::create('Month', $this->year, $i);
     }
     if (count($sDates) > 0) {
         $this->setSelection($sDates);
     }
     return true;
 }
Example #2
0
 function build($events = array(), $firstDay = null)
 {
     $this->year = $this->calendar->year;
     require_once CALENDAR_ROOT . 'Factory.php';
     $this->calendar->firstDay = $this->calendar->defineFirstDayOfWeek($firstDay);
     $monthsInYear = $this->calendar->cE->getMonthsInYear($this->calendar->thisYear());
     for ($i = 1; $i <= $monthsInYear; $i++) {
         $month = Calendar_Factory::create('Month', $this->year, $i);
         $MonthDecorator = new MonthEvent_Decorator($month);
         $MonthDecorator->build($events);
         $this->children[$i] = $MonthDecorator->calendar;
     }
     $this->calendar->children = $this->children;
     return true;
 }
 function testSelectionCornerCase()
 {
     require_once CALENDAR_ROOT . 'Day.php';
     $selectedDays = array(Calendar_Factory::create('Day', 2003, 12, 28), Calendar_Factory::create('Day', 2003, 12, 29), Calendar_Factory::create('Day', 2003, 12, 30), Calendar_Factory::create('Day', 2003, 12, 31), Calendar_Factory::create('Day', 2004, 01, 01), Calendar_Factory::create('Day', 2004, 01, 02), Calendar_Factory::create('Day', 2004, 01, 03));
     $this->cal = Calendar_Factory::create('Week', 2003, 12, 31, 0);
     $this->cal->build($selectedDays);
     while ($Day = $this->cal->fetch()) {
         $this->assertTrue($Day->isSelected());
     }
     $this->cal = Calendar_Factory::create('Week', 2004, 1, 1, 0);
     $this->cal->build($selectedDays);
     while ($Day = $this->cal->fetch()) {
         $this->assertTrue($Day->isSelected());
     }
 }
Example #4
0
 /**
  * Creates an instance of a calendar object, given a type and timestamp
  * @param string type of object to create
  * @param mixed timestamp (depending on Calendar engine being used)
  * @return object subclass of Calendar
  * @access public
  * @static
  */
 function &createByTimestamp($type, $stamp)
 {
     $cE =& Calendar_Engine_Factory::getEngine();
     $y = $cE->stampToYear($stamp);
     $m = $cE->stampToMonth($stamp);
     $d = $cE->stampToDay($stamp);
     $h = $cE->stampToHour($stamp);
     $i = $cE->stampToMinute($stamp);
     $s = $cE->stampToSecond($stamp);
     $cal = Calendar_Factory::create($type, $y, $m, $d, $h, $i, $s);
     return $cal;
 }