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; } }
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; }