/** * Gets the next tag after this tag * * For page tags, this gets the next page if there is a next page. * * @return PinholePageTag the next tag after this tag or null if there is * no next tag. */ public function next() { $returned_tag = null; switch ($this->name) { case 'number': $value = intval($this->value) - 1; break; default: $value = null; break; } if ($value !== null) { $string = sprintf('%s.%s=%s', self::NS, $this->name, $value); $tag = new PinholeDateTag(); if ($tag->parse($string, $this->db) !== false) { $returned_tag = $tag; } } return $returned_tag; }
/** * Gets the previous tag before this tag * * @return PinholeDateTag the previous tag before this tag or null if there * is no previous tag. */ public function prev() { $returned_tag = null; switch ($this->name) { case 'date': $date = new SwatDate($this->value); $date->subtractDays(1); $value = $date->formatLikeIntl('yyyy-MM-dd'); break; case 'week': if (ctype_digit($this->value)) { $value = $this->value > 1 ? $this->value - 1 : null; } else { // beginning of previous week $start_date = new SwatDate($this->value); $start_date->subtractDays(7 + $start_date->getDayOfWeek()); $value = $start_date->formatLikeIntl('yyyy-MM-dd'); } break; case 'year': $value = $this->value > 0 ? $this->value - 1 : null; break; case 'month': $value = $this->value > 1 ? $this->value - 1 : null; break; case 'day': $value = $this->value > 1 ? $this->value - 1 : null; break; default: $value = null; break; } if ($value !== null) { $string = sprintf('%s.%s=%s', self::NS, $this->name, $value); $tag = new PinholeDateTag(); if ($tag->parse($string, $this->db, $this->instance) !== false) { $returned_tag = $tag; } } return $returned_tag; }