/** * 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; }
/** * Sets the "markers" for the beginning and of a of week, in the * built Calendar_Day children * @return void * @access private */ function setWeekMarkers() { $dIW = $this->cE->getDaysInWeek($this->thisYear(), $this->thisMonth(), $this->thisDay()); $sDOM = $this->tableHelper->getNumTableDaysInMonth(); for ($i = 1; $i <= $sDOM; $i += $dIW) { $this->children[$i]->setFirst(); $this->children[$i + ($dIW - 1)]->setLast(); } }
/** * Builds Calendar_Week objects for the Month. Note that Calendar_Week * builds Calendar_Day object in tabular form (with Calendar_Day->empty) * @param array (optional) Calendar_Week objects representing selected dates * @return boolean * @access public */ function build($sDates = array()) { require_once CALENDAR_ROOT . 'Table' . DIRECTORY_SEPARATOR . 'Helper.php'; $this->tableHelper =& new Calendar_Table_Helper($this, $this->firstDay); require_once CALENDAR_ROOT . 'Week.php'; $numWeeks = $this->tableHelper->getNumWeeks(); for ($i = 1, $d = 1; $i <= $numWeeks; $i++, $d += $this->cE->getDaysInWeek($this->thisYear(), $this->thisMonth(), $this->thisDay())) { $this->children[$i] = new Calendar_Week($this->year, $this->month, $d, $this->tableHelper->getFirstDay()); } //used to set empty days $this->children[1]->setFirst(true); $this->children[$numWeeks]->setLast(true); // Handle selected weeks here if (count($sDates) > 0) { $this->setSelection($sDates); } return true; }
function testGetEmptyDaysAfterOffset() { $Helper = new Calendar_Table_Helper($this->mockcal); $this->assertEqual($Helper->getEmptyDaysAfterOffset(), 5); }