Exemplo n.º 1
0
 /**
  * Adds a page to history.
  *
  * <h4>Note</h4>
  *
  * <p>If history is full, oldest value is removed to make space
  * for new entry.</p>
  *
  * <hr>
  *
  * @param \BLW\Type\HTTP\Browser\IPage $Page
  *            Page to add.
  * @return integer Returns a <code>DataMapper</code> status code.
  */
 public function addHistory($Page)
 {
     // Is $Page a real page?
     if ($Page instanceof IPage) {
         // Reindex
         $History = iterator_to_array($this->_History);
         $Length = min($this->_MaxHistory - 1, $this->_Current + 1);
         // Begining or array up to Current position or (Maxlength - 1)
         $Start = max(0, $this->_Current + 2 - $this->_MaxHistory);
         // Current posistion stepped back (Maxlength - 1) spaces
         $History = array_slice($History, $Start, $Length, false);
         // Add to history
         $History[] = $Page;
         // Update
         $this->_History->exchangeArray($History);
         $this->_Current = count($this->_History) - 1;
         // Done
         return IDataMapper::UPDATED;
         // Invalid
     } else {
         return IDataMapper::INVALID;
     }
 }