예제 #1
0
 /**
  * Builds Calendar_Day objects for this Week
  * @param array (optional) Calendar_Day objects representing selected dates
  * @return boolean
  * @access public
  */
 function build($sDates = array())
 {
     require_once CALENDAR_ROOT . 'Day.php';
     $year = $this->cE->stampToYear($this->thisWeek);
     $month = $this->cE->stampToMonth($this->thisWeek);
     $day = $this->cE->stampToDay($this->thisWeek);
     $end = $this->cE->getDaysInWeek($this->thisYear(), $this->thisMonth(), $this->thisDay());
     for ($i = 1; $i <= $end; $i++) {
         $stamp = $this->cE->dateToStamp($year, $month, $day++);
         $this->children[$i] = new Calendar_Day($this->cE->stampToYear($stamp), $this->cE->stampToMonth($stamp), $this->cE->stampToDay($stamp));
     }
     //set empty days (@see Calendar_Month_Weeks::build())
     if ($this->firstWeek) {
         $eBefore = $this->tableHelper->getEmptyDaysBefore();
         for ($i = 1; $i <= $eBefore; $i++) {
             $this->children[$i]->setEmpty();
         }
     }
     if ($this->lastWeek) {
         $eAfter = $this->tableHelper->getEmptyDaysAfterOffset();
         for ($i = $eAfter + 1; $i <= $end; $i++) {
             $this->children[$i]->setEmpty();
         }
     }
     if (count($sDates) > 0) {
         $this->setSelection($sDates);
     }
     return true;
 }
예제 #2
0
 /**
  * Prepends empty days before the real days in the month
  * @return void
  * @access private
  */
 function buildEmptyDaysBefore()
 {
     $eBefore = $this->tableHelper->getEmptyDaysBefore();
     for ($i = 0; $i < $eBefore; $i++) {
         $stamp = $this->cE->dateToStamp($this->year, $this->month, -$i);
         $Day = new Calendar_Day($this->cE->stampToYear($stamp), $this->cE->stampToMonth($stamp), $this->cE->stampToDay($stamp));
         $Day->setEmpty();
         array_unshift($this->children, $Day);
     }
 }
예제 #3
0
 function testGetEmptyDaysBefore()
 {
     $Helper = new Calendar_Table_Helper($this->mockcal);
     $this->assertEqual($Helper->getEmptyDaysBefore(), 2);
 }