Example #1
0
 function store($data, $return)
 {
     //If this file doesn't exists don't save it
     if (!PhocaGalleryHelper::existsFileOriginal($data['filename'])) {
         $this->setError('File not exists');
         return false;
     }
     //If there is no title and no alias, use filename as title and alias
     if (!isset($data['title']) || isset($data['title']) && $data['title'] == '') {
         $data['title'] = PhocaGalleryHelper::getTitleFromFilenameWithoutExt($data['filename']);
     }
     if (!isset($data['alias']) || isset($data['alias']) && $data['alias'] == '') {
         $data['alias'] = PhocaGalleryHelper::getTitleFromFilenameWithoutExt($data['filename']);
     }
     //clean alias name (no bad characters)
     $data['alias'] = PhocaGalleryHelper::getAliasName($data['alias']);
     $row =& $this->getTable('phocagallery');
     // Bind the form fields to the Phoca gallery table
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Create the timestamp for the date
     $row->date = gmdate('Y-m-d H:i:s');
     // if new item, order last in appropriate group
     if (!$row->id) {
         $where = 'catid = ' . (int) $row->catid;
         $row->ordering = $row->getNextOrder($where);
     }
     // Make sure the Phoca gallery table is valid
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Store the Phoca gallery table to the database
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     //Create thumbnail small, medium, large
     $path = PhocaGalleryHelper::getPathSet();
     $returnFrontMessage = PhocaGalleryHelper::getOrCreateThumbnail($path['orig_abs_ds'], $row->filename, $return, 1, 1, 1, 1);
     if ($returnFrontMessage == 'Success') {
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 function _addAllImagesFromFolder(&$existing_images, $category_id, $full_path, $rel_path)
 {
     $count = 0;
     $file_list = JFolder::files($full_path);
     natcasesort($file_list);
     // Iterate over the files if they exist
     //file - abc.img, file_no - folder/abc.img
     if ($file_list !== false) {
         foreach ($file_list as $filename) {
             $storedfilename = str_replace(DS, '/', JPath::clean($rel_path . DS . $filename));
             $ext = strtolower(JFile::getExt($filename));
             // Don't create thumbnails from defined files (don't save them into a database)...
             $dontCreateThumb = PhocaGalleryHelper::dontCreateThumb($filename);
             if ($dontCreateThumb == 1) {
                 $ext = '';
                 // WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE
             }
             if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg') {
                 if (is_file($full_path . DS . $filename) && substr($filename, 0, 1) != '.' && strtolower($filename) !== 'index.html' && !$this->_ImageExist($existing_images, $storedfilename, $category_id)) {
                     $row =& $this->getTable('phocagallery');
                     $datam = array();
                     $datam['published'] = 1;
                     $datam['catid'] = $category_id;
                     $datam['filename'] = $storedfilename;
                     $datam['title'] = PhocaGalleryHelper::getTitleFromFilenameWithoutExt($filename);
                     $datam['alias'] = PhocaGalleryHelper::getAliasName($datam['title']);
                     // Save
                     // Bind the form fields to the Phoca gallery table
                     if (!$row->bind($datam)) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                     // Create the timestamp for the date
                     $row->date = gmdate('Y-m-d H:i:s');
                     // if new item, order last in appropriate group
                     if (!$row->id) {
                         $where = 'catid = ' . (int) $row->catid;
                         $row->ordering = $row->getNextOrder($where);
                     }
                     // Make sure the Phoca gallery table is valid
                     if (!$row->check()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                     // Store the Phoca gallery table to the database
                     if (!$row->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                     $image = new JObject();
                     $image->filename = $storedfilename;
                     $image->catid = $category_id;
                     $existing_images[] =& $image;
                     $count++;
                 }
             }
         }
     }
     //	$this->setImageCount($count);
     return $count;
 }
Example #3
0
 function store($data)
 {
     //Params
     $params =& JComponentHelper::getParams('com_phocagallery');
     //Clean Thumbnails or not
     if ($params->get('clean_thumbnails') != '') {
         $clean_thumbnails = $params->get('clean_thumbnails');
     } else {
         $clean_thumbnails = 0;
     }
     //If this file doesn't exists don't save it
     if (!PhocaGalleryHelper::existsFileOriginal($data['filename'])) {
         $this->setError();
         return false;
     }
     //If there is no title and no alias, use filename as title and alias
     if ($data['title'] == '') {
         $data['title'] = PhocaGalleryHelper::getTitleFromFilenameWithoutExt($data['filename']);
     }
     if ($data['alias'] == '') {
         $data['alias'] = PhocaGalleryHelper::getTitleFromFilenameWithoutExt($data['filename']);
     }
     //clean alias name (no bad characters)
     $data['alias'] = PhocaGalleryHelper::getAliasName($data['alias']);
     $row =& $this->getTable();
     // Bind the form fields to the Phoca gallery table
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Create the timestamp for the date
     $row->date = gmdate('Y-m-d H:i:s');
     // if new item, order last in appropriate group
     if (!$row->id) {
         $where = 'catid = ' . (int) $row->catid;
         $row->ordering = $row->getNextOrder($where);
     }
     // Make sure the Phoca gallery table is valid
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Store the Phoca gallery table to the database
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     //------------------------------------------------------------------------------------------------------
     //Create thumbnail small, medium, large
     //------------------------------------------------------------------------------------------------------
     //file - abc.img, file_no - folder/abc.img
     //Get folder variables from Helper
     $path = PhocaGalleryHelper::getPathSet();
     $orig_path = $path['orig_abs_ds'];
     //Create thumbnails small, medium, large
     $refresh_url = 'index.php?option=com_phocagallery&controller=phocagallery&task=thumbs';
     $file_thumb = PhocaGalleryHelper::getOrCreateThumbnail($orig_path, $row->filename, $refresh_url, 1, 1, 1);
     //Clean Thumbs Folder if there are thumbnail files but not original file
     if ($clean_thumbnails == 1) {
         PhocaGalleryHelper::cleanThumbsFolder();
     }
     //---------------------------------------------------------------------------------------------------------------
     return true;
 }