Exemple #1
0
 public function save($data)
 {
     if (parent::save($data)) {
         $id = (int) $this->getState($this->getName() . '.id');
         // Update images
         $currentImages = isset($_POST['current_images']) ? $_POST['current_images'] : array();
         $currentDesc = isset($_POST['current_desc']) ? $_POST['current_desc'] : array();
         Jnt_HanhphucHelper::updateImages($id, $currentImages, $currentDesc, 'albums');
         // Temp files
         if (isset($_POST['tmp_other_img'])) {
             // Copy file
             Jnt_HanhphucHelper::copyTempFiles($id, $_POST['tmp_other_img'], 'albums');
             // Insert images
             Jnt_HanhphucHelper::insertImages($id, $_POST['tmp_other_img'], $_POST['tmp_desc'], 'albums');
         }
         if ($id) {
             $data['id'] = $id;
         }
         $delImage = isset($data['del_image']) ? $data['del_image'] : null;
         // Upload thumb
         $item = $this->getItem();
         $data['images'] = Jnt_HanhphucHelper::uploadImages('images', $item, $delImage, 'albums');
         // update content
         $content = Jnt_HanhphucHelper::copyFilesOnSave($data['description'], 'albums', $id);
         if ($content) {
             $data['description'] = $content;
         }
         //TODO: Update count location
         //			Jnt_HanhphucHelper::updateCountLocations('albums');
         //TODO: Update count custom field for each location
         //			Jnt_HanhphucHelper::updateCountCustomFieldLocations('albums');
         return parent::save($data);
     }
     return false;
 }