function existsFileOriginal($filename) { $file_original = PhocaGalleryHelper::getFileOriginal($filename); if (JFile::exists($file_original)) { return true; } else { return false; } }
function getData() { //Params $params =& JComponentHelper::getParams('com_phocagallery'); //Standard Thumbs creation or Pagination Thumbs Creation if ($params->get('pagination_thumbnail_creation') != '') { $pagination_thumbnail_creation = $params->get('pagination_thumbnail_creation'); } else { $pagination_thumbnail_creation = 0; } //Clean Thumbnails or not if ($params->get('clean_thumbnails') != '') { $clean_thumbnails = $params->get('clean_thumbnails'); } else { $clean_thumbnails = 0; } // Lets load the content if it doesn't already exist if (empty($this->_data)) { $query = $this->_buildQuery(); $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit')); } //Server doesn't have CPU power //we do thumbnail for all images - there is no pagination... //or we do thumbanil for only listed images if (empty($this->_data_thumbnail)) { if ($pagination_thumbnail_creation == 1) { $this->_data_thumbnail = $this->_data; } else { $query = $this->_buildQueryThumbnail(); $this->_data_thumbnail = $this->_getList($query); } } //------------------------------------------------------------------------------------------------------ // Check if the file stored in database is on the server. If not please refer to user // Get filename from every object there is stored in database //------------------------------------------------------------------------------------------------------ //file - abc.img, file_no - folder/abc.img //Get folder variables from Helper $path = PhocaGalleryHelper::getPathSet(); $orig_path = $path['orig_abs_ds']; $orig_path_server = str_replace(DS, '/', $path['orig_abs'] . '/'); //----------------------------------------- //Do all thumbnails no limit no pagination if (!empty($this->_data_thumbnail)) { foreach ($this->_data_thumbnail as $key => $value) { $file_original_thumb = PhocaGalleryHelper::getFileOriginal($value->filename); //Let the user know that the file doesn't exists and delete all thumbnails if (!JFile::exists($file_original_thumb)) { //$this->_data[$key]->filename = JText::_( 'File does not exist' ); //$this->_data[$key]->fileoriginalexist = 0; //We must not delete the thumbnails if the file doesn't exist - we use cleanThumbsFolder() function } else { //Create thumbnails small, medium, large $refresh_url_thumb = 'index.php?option=com_phocagallery&view=phocagallerys'; //$refresh_url_thumb = 'index.php?option=com_phocagallery&controller=phocagallerys'; $file_thumb = PhocaGalleryHelper::getOrCreateThumbnail($orig_path, $value->filename, $refresh_url_thumb, 1, 1, 1); //$this->_data[$key]->linkthumbnailpath = $file_thumb['thumb_name_s_no_rel']; //$this->_data[$key]->path_without_name_relative = $file_thumb['path_without_name_relative']; //$this->_data[$key]->fileoriginalexist = 1; } } //Clean Thumbs Folder if there are thumbnail files but not original file //PhocaGalleryHelper::cleanThumbsFolder(); //------------------------------------------------------------------------------------------------------ } $this->_data_thumbnail = null; // delete data to reduce memory //Only the the site with limitation or pagination... if (!empty($this->_data)) { foreach ($this->_data as $key => $value) { $file_original = PhocaGalleryHelper::getFileOriginal($value->filename); //Let the user know that the file doesn't exists and delete all thumbnails if (!JFile::exists($file_original)) { $this->_data[$key]->filename = JText::_('Image Filename does not exist'); $this->_data[$key]->fileoriginalexist = 0; //We must not delete the thumbnails if the file doesn't exist - we use cleanThumbsFolder() function } else { //Create thumbnails small, medium, large $refresh_url = 'index.php?option=com_phocagallery&view=phocagallerys'; //$refresh_url = 'index.php?option=com_phocagallery&controller=phocagallerys'; $file_thumb = PhocaGalleryHelper::getOrCreateThumbnail($orig_path, $value->filename, $refresh_url, 1, 1, 1); $this->_data[$key]->linkthumbnailpath = $file_thumb['thumb_name_s_no_rel']; //$this->_data[$key]->path_without_name_relative = $file_thumb['path_without_name_relative']; $this->_data[$key]->fileoriginalexist = 1; } } //Clean Thumbs Folder if there are thumbnail files but not original file //PhocaGalleryHelper::cleanThumbsFolder(); //------------------------------------------------------------------------------------------------------ } //Clean Thumbs Folder if there are thumbnail files but not original file if ($clean_thumbnails == 1) { PhocaGalleryHelper::cleanThumbsFolder(); } return $this->_data; }