Exemplo n.º 1
0
 /**
  * Returns the data in $this->_current as a F0FTable instance
  *
  * @return  F0FTable
  *
  * @throws  OutOfBoundsException
  */
 protected function getTable()
 {
     if (!$this->valid()) {
         throw new OutOfBoundsException('Cannot get item past iterator\'s bounds', 500);
     }
     $this->_tableObject->bind($this->_current);
     return $this->_tableObject;
 }
Exemplo n.º 2
0
Arquivo: model.php Projeto: 01J/topm
 /**
  * Returns a single item. It uses the id set with setId, or the first ID in
  * the list of IDs for batch operations
  *
  * @param   integer  $id  Force a primary key ID to the model. Use null to use the id from the state.
  *
  * @return  F0FTable  A copy of the item's F0FTable array
  */
 public function &getItem($id = null)
 {
     if (!is_null($id)) {
         $this->record = null;
         $this->setId($id);
     }
     if (empty($this->record)) {
         $table = $this->getTable($this->table);
         $table->load($this->id);
         $this->record = $table;
         // Do we have saved data?
         $session = JFactory::getSession();
         if ($this->_savestate) {
             $serialized = $session->get($this->getHash() . 'savedata', null);
             if (!empty($serialized)) {
                 $data = @unserialize($serialized);
                 if ($data !== false) {
                     $k = $table->getKeyName();
                     if (!array_key_exists($k, $data)) {
                         $data[$k] = null;
                     }
                     if ($data[$k] != $this->id) {
                         $session->set($this->getHash() . 'savedata', null);
                     } else {
                         $this->record->bind($data);
                     }
                 }
             }
         }
         $this->onAfterGetItem($this->record);
     }
     return $this->record;
 }