/**
  * Method to get the data that should be injected in the form.
  *
  * @throws \Exception
  *
  * @return  mixed   The data for the form.
  * @since   1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = JFactory::getApplication()->getUserState($this->option . '.edit.achievement.data', array());
     if (!$data) {
         $data = $this->getItem();
         if (isset($data->rewards) and $data->rewards !== '') {
             $rewards = new \Joomla\Registry\Registry($data->rewards);
             $data->rewards = $rewards->toArray();
             if ((int) $data->points_number === 0) {
                 $data->points_number = '';
             }
         }
     }
     return $data;
 }
示例#2
0
 /**
  * Method to get a single record.
  *
  * @param   integer $pk     The id of the primary key.
  * @param   integer $userId The id of the user.
  *
  * @return  CrowdfundingTableProject  Object on success, false on failure.
  *
  * @throws Exception
  *
  * @since   11.1
  */
 public function getItem($pk, $userId)
 {
     if ($this->item) {
         return $this->item;
     }
     // Initialise variables.
     $table = $this->getTable();
     if ($pk > 0 and $userId > 0) {
         $keys = array("id" => $pk, "user_id" => $userId);
         // Attempt to load the row.
         $return = $table->load($keys);
         // Check for a table object error.
         if ($return === false) {
             throw new Exception(JText::_("COM_CROWDFUNDING_ERROR_SYSTEM"));
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties();
     $this->item = Joomla\Utilities\ArrayHelper::toObject($properties, 'JObject');
     if (property_exists($this->item, 'params')) {
         $registry = new Joomla\Registry\Registry();
         /** @var  $registry Joomla\Registry\Registry */
         $registry->loadString($this->item->params);
         $this->item->params = $registry->toArray();
     }
     return $this->item;
 }
示例#3
0
 /**
  * Method to get a single record.
  *
  * @param   integer $pk The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  *
  * @since   12.2
  */
 public function getItem($pk = null)
 {
     $pk = $pk !== null ? (int) $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false) {
             throw new RuntimeException(JText::_('COM_USERIDEAS_ERROR_INVALID_ITEM'));
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = Joomla\Utilities\ArrayHelper::toObject($properties, 'JObject');
     if (property_exists($item, 'params')) {
         $registry = new Joomla\Registry\Registry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     $item->tags = new JHelperTags();
     $item->tags->getTagIds($item->id, 'com_userideas.item');
     return $item;
 }