Exemplo n.º 1
0
 /**
  * Stores a Object/Table
  *
  * @param	boolean	$update_nulls	True to update fields even if they are null.
  * 
  * @return	boolean	$result			True on success, false on failure.
  * 
  */
 public function store($update_nulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     // Store any $_FILES input
     $files = $app->input->files->get('jform');
     if (empty($this->id)) {
         // New Object/Table. A created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!intval($this->created)) {
             $this->created = $date->toSQL();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Existing item
     $this->modified = $date->toSQL();
     $this->modified_by = $user->get('id');
     if (count($files) > 0 and isset($files['icon_16px']) and $files['icon_16px']['name'] != '') {
         $file = $files['icon_16px'];
         // Add parameters to the saveUpload call to specify the output file name and the width and height for image file uploads
         // e.g. saveUpload($file,'icon_16px.png', 100, 0)
         //[%%START_CUSTOM_CODE%%]
         //$result = ComponentArchitectHelper::saveUpload($file, 'Icon 16px');
         $result = ComponentArchitectHelper::saveUpload($file, 'Icon 16px', '', 16, 16);
         //[%%END_CUSTOM_CODE%%]
         if ($result === true) {
             $this->icon_16px = $file['name'];
         } else {
             if ($result !== false) {
                 $this->setError($result);
                 return false;
             }
         }
     }
     if (count($files) > 0 and isset($files['icon_48px']) and $files['icon_48px']['name'] != '') {
         $file = $files['icon_48px'];
         // Add parameters to the saveUpload call to specify the output file name and the width and height for image file uploads
         // e.g. saveUpload($file,'icon_48px.png', 100, 0)
         //[%%START_CUSTOM_CODE%%]
         //$result = ComponentArchitectHelper::saveUpload($file, 'Icon 48px');
         $result = ComponentArchitectHelper::saveUpload($file, 'Icon 48px', '', 48, 48);
         //[%%END_CUSTOM_CODE%%]
         if ($result === true) {
             $this->icon_48px = $file['name'];
         } else {
             if ($result !== false) {
                 $this->setError($result);
                 return false;
             }
         }
     }
     // Check and reformat entries in the json array
     $field_array = $this->joomla_parts;
     $this->joomla_parts = $field_array;
     if (isset($this->joomla_parts) and is_array($this->joomla_parts)) {
         $registry = new JRegistry();
         $registry->loadArray($this->joomla_parts);
         $this->joomla_parts = (string) $registry;
         $registry = null;
         //release memory
     }
     // Check and reformat entries in the json array
     $field_array = $this->joomla_features;
     $this->joomla_features = $field_array;
     if (isset($this->joomla_features) and is_array($this->joomla_features)) {
         $registry = new JRegistry();
         $registry->loadArray($this->joomla_features);
         $this->joomla_features = (string) $registry;
         $registry = null;
         //release memory
     }
     // Attempt to store the data.
     return parent::store($update_nulls);
 }