Esempio n. 1
0
 function loadData()
 {
     if (empty($this->data)) {
         $query = 'SELECT a.*' . ' FROM #__phocagallery AS a' . ' WHERE a.id = ' . (int) $this->id;
         $this->_db->setQuery($query);
         $fileObject = $this->_db->loadObject();
         $file = new JObject();
         $refresh_url = 'index.php?option=com_phocagallery&view=phocagalleryd&tmpl=component&id=' . (int) $this->id;
         //Creata thumbnails if not exist
         PhocaGalleryFileThumbnail::getOrCreateThumbnail($fileObject->filename, $refresh_url, 1, 1, 1);
         jimport('joomla.filesystem.file');
         if (!isset($fileObject->filename)) {
             $file->set('linkthumbnailpath', '');
         } else {
             $thumbFile = PhocaGalleryFileThumbnail::getThumbnailName($fileObject->filename, 'large');
             $file->set('linkthumbnailpath', $thumbFile->rel);
             $file->set('extid', $fileObject->extid);
             $file->set('extl', $fileObject->extl);
             $file->set('extw', $fileObject->extw);
             $file->set('exth', $fileObject->exth);
         }
         $this->data = $file;
         return (bool) $this->data;
     }
     return true;
 }
 function getData()
 {
     if (empty($this->_data)) {
         $query = $this->_buildQuery();
         $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
     }
     if (!empty($this->_data)) {
         foreach ($this->_data as $key => $value) {
             $fileOriginal = PhocaGalleryFile::getFileOriginal($value->filename);
             //Let the user know that the file doesn't exists
             if (!JFile::exists($fileOriginal)) {
                 $this->_data[$key]->filename = JText::_('COM_PHOCAGALLERY_IMG_FILE_NOT_EXISTS');
                 $this->_data[$key]->fileoriginalexist = 0;
             } else {
                 //Create thumbnails small, medium, large
                 $refresh_url = 'index.php?option=com_phocagallery&view=phocagalleryimgs';
                 $fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($value->filename, $refresh_url, 1, 1, 1);
                 $this->_data[$key]->linkthumbnailpath = $fileThumb['thumb_name_s_no_rel'];
                 $this->_data[$key]->fileoriginalexist = 1;
             }
         }
     }
     return $this->_data;
 }
Esempio n. 3
0
 function store($data, $return)
 {
     //If this file doesn't exists don't save it
     if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
         $this->setError('File not exists');
         return false;
     }
     $data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
     //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'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
     }
     if (!isset($data['alias']) || isset($data['alias']) && $data['alias'] == '') {
         $data['alias'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
     }
     //clean alias name (no bad characters)
     //$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
     if (!isset($data['longitude']) || isset($data['longitude']) && $data['longitude'] == '' || (!isset($data['latitude']) || isset($data['latitude']) && $data['latitude'] == '')) {
         phocagalleryimport('phocagallery.geo.geo');
         $coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
         if (!isset($data['longitude']) || isset($data['longitude']) && $data['longitude'] == '') {
             $data['longitude'] = $coords['longitude'];
         }
         if (!isset($data['latitude']) || isset($data['latitude']) && $data['latitude'] == '') {
             $data['latitude'] = $coords['latitude'];
         }
         if ((!isset($data['zoom']) || isset($data['zoom']) && $data['zoom'] == '') && $data['longitude'] != '' && $data['latitude'] != '') {
             $data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
         }
     }
     $row =& $this->getTable('phocagallery', 'Table');
     // 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
     $returnFrontMessage = PhocaGalleryFileThumbnail::getOrCreateThumbnail($row->filename, $return, 1, 1, 1, 1);
     if ($returnFrontMessage == 'Success') {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 4
0
echo '<div class="tab-pane" id="metadata">' . "\n";
echo $this->loadTemplate('metadata');
echo '</div>' . "\n";
echo '</div>';
//end tab content
echo '</div>';
//end span10
// Second Column
echo '<div class="span2">';
// - - - - - - - - - -
// Image
$fileOriginal = PhocaGalleryFile::getFileOriginal($this->item->filename);
if (!JFile::exists($fileOriginal)) {
    $this->item->fileoriginalexist = 0;
} else {
    $fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($this->item->filename, '', 0, 0, 0);
    $this->item->linkthumbnailpath = $fileThumb['thumb_name_m_no_rel'];
    $this->item->fileoriginalexist = 1;
}
echo '<div style="float:right;margin:5px;">';
// PICASA
if (isset($this->item->extid) && $this->item->extid != '') {
    $resW = explode(',', $this->item->extw);
    $resH = explode(',', $this->item->exth);
    $correctImageRes = PhocaGalleryImage::correctSizeWithRate($resW[2], $resH[2], 100, 100);
    $imgLink = $this->item->extl;
    echo '<img class="img-polaroid" src="' . $this->item->exts . '" width="' . $correctImageRes['width'] . '" height="' . $correctImageRes['height'] . '" alt="" />';
} else {
    if (isset($this->item->fileoriginalexist) && $this->item->fileoriginalexist == 1) {
        $imageRes = PhocaGalleryImage::getRealImageSize($this->item->filename, 'medium');
        //$correctImageRes 	= PhocaGalleryImage::correctSizeWithRate($imageRes['w'], $imageRes['h'], 100, 100);
Esempio n. 5
0
 function _singleFileUploadAvatar(&$errUploadMsg, $file, &$redirectUrl)
 {
     $app = JFactory::getApplication();
     JRequest::checkToken('request') or jexit('Invalid Token');
     jimport('joomla.client.helper');
     $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
     $path = PhocaGalleryPath::getPath();
     $format = JRequest::getVar('format', 'html', '', 'cmd');
     $return = JRequest::getVar('return-url', null, 'post', 'base64');
     $viewBack = JRequest::getVar('viewback', '', '', '');
     $view = JRequest::getVar('view', '', 'get', '', JREQUEST_NOTRIM);
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $limitStartUrl = $this->getLimitStartUrl(0, 'subcat');
     $return = JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false);
     $enableUploadAvatar = (int) $paramsC->get('enable_upload_avatar', 1);
     if ($enableUploadAvatar != 1) {
         $errUploadMsg = JText::_('COM_PHOCAGALLERY_NOT_ABLE_UPLOAD_AVATAR');
         $redirectUrl = $return;
         return false;
     }
     if (isset($file['name'])) {
         $fileAvatar = md5(uniqid(time())) . '.' . JFile::getExt($file['name']);
         $filepath = JPath::clean($path->avatar_abs . DS . $fileAvatar);
         if (!PhocaGalleryFileUpload::canUpload($file, $errUploadMsg)) {
             if ($errUploadMsg == 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE') {
                 $errUploadMsg = JText::_($errUploadMsg) . ' (' . PhocaGalleryFile::getFileSizeReadable($file['size']) . ')';
             } else {
                 if ($errUploadMsg == 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGERESOLUTION') {
                     $imgSize = PhocaGalleryImage::getImageSize($file['tmp_name']);
                     $errUploadMsg = JText::_($errUploadMsg) . ' (' . (int) $imgSize[0] . ' x ' . (int) $imgSize[1] . ' px)';
                 } else {
                     $errUploadMsg = JText::_($errUploadMsg);
                 }
             }
             $redirectUrl = $return;
             return false;
         }
         if (!JFile::upload($file['tmp_name'], $filepath)) {
             $errUploadMsg = JText::_('COM_PHOCAGALLERY_FILE_UNABLE_UPLOAD');
             $redirectUrl = $return;
             return false;
         } else {
             $redirectUrl = $return;
             //Create thumbnail small, medium, large (Delete previous before)
             PhocaGalleryFileThumbnail::deleteFileThumbnail('avatars/' . $fileAvatar, 1, 1, 1);
             $returnFrontMessage = PhocaGalleryFileThumbnail::getOrCreateThumbnail('avatars/' . $fileAvatar, $return, 1, 1, 1, 1);
             if ($returnFrontMessage != 'Success') {
                 $errUploadMsg = JText::_('COM_PHOCAGALLERY_THUMBNAIL_AVATAR_NOT_CREATED');
                 return false;
             }
             // Saving file name into database with relative path
             $succeeded = false;
             PhocaGalleryControllerUser::saveUser($fileAvatar, $succeeded, $errUploadMsg);
             $redirectUrl = $return;
             return $succeeded;
         }
     } else {
         $errUploadMsg = JText::_('COM_PHOCAGALLERY_WARNING_FILETYPE');
         $redirectUrl = $return;
         return false;
     }
     return false;
 }
Esempio n. 6
0
 public static function getList($small = 0, $medium = 0, $large = 0, $refreshUrl)
 {
     static $list;
     $params = JComponentHelper::getParams('com_phocagallery');
     $clean_thumbnails = $params->get('clean_thumbnails', 0);
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     // Get current path from request
     $current = JRequest::getVar('folder');
     // If undefined, set to empty
     if ($current == 'undefined') {
         $current = '';
     }
     //Get folder variables from Helper
     $path = PhocaGalleryPath::getPath();
     // Initialize variables
     if (strlen($current) > 0) {
         $origPath = JPath::clean($path->image_abs . $current);
     } else {
         $origPath = $path->image_abs;
     }
     $origPathServer = str_replace(DS, '/', $path->image_abs);
     $images = array();
     $folders = array();
     // Get the list of files and folders from the given folder
     $fileList = JFolder::files($origPath);
     $folderList = JFolder::folders($origPath, '', false, false, array(0 => 'thumbs'));
     if (is_array($fileList) && !empty($fileList)) {
         natcasesort($fileList);
     }
     $field = JRequest::getVar('field');
     $refreshUrl = $refreshUrl . '&folder=' . $current . '&field=' . $field;
     // Iterate over the files if they exist
     //file - abc.img, file_no - folder/abc.img
     if ($fileList !== false) {
         foreach ($fileList as $file) {
             $ext = strtolower(JFile::getExt($file));
             // Don't display thumbnails from defined files (don't save them into a database)...
             $dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($file);
             if ($dontCreateThumb == 1) {
                 $ext = '';
                 // WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE
             }
             if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg') {
                 if (JFile::exists($origPath . DS . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
                     //Create thumbnails small, medium, large
                     $fileNo = $current . "/" . $file;
                     $fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($fileNo, $refreshUrl, $small, $medium, $large);
                     $tmp = new JObject();
                     $tmp->name = $fileThumb['name'];
                     $tmp->nameno = $fileThumb['name_no'];
                     $tmp->linkthumbnailpath = $fileThumb['thumb_name_m_no_rel'];
                     $tmp->linkthumbnailpathabs = $fileThumb['thumb_name_m_no_abs'];
                     $images[] = $tmp;
                 }
             }
         }
     }
     //Clean Thumbs Folder if there are thumbnail files but not original file
     if ($clean_thumbnails == 1) {
         PhocaGalleryFileFolder::cleanThumbsFolder();
     }
     // - - - - - - - - - - - -
     // Iterate over the folders if they exist
     if ($folderList !== false) {
         foreach ($folderList as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path_with_name = str_replace(DS, '/', JPath::clean($origPath . DS . $folder));
             $tmp->path_without_name_relative = $path->image_abs . str_replace($origPathServer, '', $tmp->path_with_name);
             $tmp->path_with_name_relative_no = str_replace($origPathServer, '', $tmp->path_with_name);
             $folders[] = $tmp;
         }
     }
     $list = array('folders' => $folders, 'Images' => $images);
     return $list;
 }
Esempio n. 7
0
 protected function processImages()
 {
     if (!empty($this->items)) {
         $params = JComponentHelper::getParams('com_phocagallery');
         $pagination_thumbnail_creation = $params->get('pagination_thumbnail_creation', 0);
         $clean_thumbnails = $params->get('clean_thumbnails', 0);
         //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->items_thumbnail)) {
             if ($pagination_thumbnail_creation == 1) {
                 $this->items_thumbnail = $this->items;
             } else {
                 $this->items_thumbnail = $this->get('ItemsThumbnail');
             }
         }
         // - - - - - - - - - - - - - - - - - - - -
         // 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 = PhocaGalleryPath::getPath();
         $origPath = $path->image_abs;
         $origPathServer = str_replace(DS, '/', $path->image_abs);
         //-----------------------------------------
         //Do all thumbnails no limit no pagination
         if (!empty($this->items_thumbnail)) {
             foreach ($this->items_thumbnail as $key => $value) {
                 $fileOriginalThumb = PhocaGalleryFile::getFileOriginal($value->filename);
                 //Let the user know that the file doesn't exists and delete all thumbnails
                 if (JFile::exists($fileOriginalThumb)) {
                     $refreshUrlThumb = 'index.php?option=com_phocagallery&view=phocagalleryimgs';
                     $fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($value->filename, $refreshUrlThumb, 1, 1, 1);
                 }
             }
         }
         $this->items_thumbnail = null;
         // delete data to reduce memory
         //Only the the site with limitation or pagination...
         if (!empty($this->items)) {
             foreach ($this->items as $key => $value) {
                 $fileOriginal = PhocaGalleryFile::getFileOriginal($value->filename);
                 //Let the user know that the file doesn't exists and delete all thumbnails
                 if (!JFile::exists($fileOriginal)) {
                     $this->items[$key]->filename = JText::_('COM_PHOCAGALLERY_IMG_FILE_NOT_EXISTS');
                     $this->items[$key]->fileoriginalexist = 0;
                 } else {
                     //Create thumbnails small, medium, large
                     $refresh_url = 'index.php?option=com_phocagallery&view=phocagalleryimgs';
                     $fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($value->filename, $refresh_url, 1, 1, 1);
                     $this->items[$key]->linkthumbnailpath = $fileThumb['thumb_name_s_no_rel'];
                     $this->items[$key]->fileoriginalexist = 1;
                 }
             }
         }
         //Clean Thumbs Folder if there are thumbnail files but not original file
         if ($clean_thumbnails == 1) {
             PhocaGalleryFileFolder::cleanThumbsFolder();
         }
     }
 }
Esempio n. 8
0
 function save($data)
 {
     $app = JFactory::getApplication();
     $post = JRequest::get('post');
     $data = JRequest::getVar('jform', array(0), 'post', 'array');
     if (isset($post['foldercid'])) {
         $data['foldercid'] = $post['foldercid'];
     }
     if (isset($post['cid'])) {
         $data['cid'] = $post['cid'];
     }
     if (isset($data['catid']) && (int) $data['catid'] > 0) {
         $data['catid'] = (int) $data['catid'];
     } else {
         $data['catid'] = 0;
     }
     //Params
     $params = JComponentHelper::getParams('com_phocagallery');
     $clean_thumbnails = $params->get('clean_thumbnails', 0);
     //Get folder variables from Helper
     $path = PhocaGalleryPath::getPath();
     $origPath = $path->image_abs;
     $origPathServer = str_replace(DS, '/', $path->image_abs);
     // Cache all existing categories
     $query = 'SELECT id, title, parent_id' . ' FROM #__phocagallery_categories';
     $this->_db->setQuery($query);
     $existingCategories = $this->_db->loadObjectList();
     // Cache all existing images
     $query = 'SELECT catid, filename' . ' FROM #__phocagallery';
     $this->_db->setQuery($query);
     $existingImages = $this->_db->loadObjectList();
     $result = new stdClass();
     $result->category_count = 0;
     $result->image_count = 0;
     // Category will be saved - Images will be saved in recursive function
     if (isset($data['foldercid'])) {
         foreach ($data['foldercid'] as $foldername) {
             if (strlen($foldername) > 0) {
                 $fullPath = $path->image_abs . $foldername;
                 $result = $this->_createCategoriesRecursive($origPathServer, $fullPath, $existingCategories, $existingImages, $data['catid'], $data);
             }
         }
     }
     // Only Imagees will be saved
     if (isset($data['cid'])) {
         foreach ($data['cid'] as $filename) {
             if ($filename) {
                 $ext = strtolower(JFile::getExt($filename));
                 // Don't create thumbnails from defined files (don't save them into a database)...
                 $dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($filename);
                 if ($dontCreateThumb == 1) {
                     $ext = '';
                     // WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE
                 }
                 if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg') {
                     $row = $this->getTable('phocagallery');
                     $datam = array();
                     $datam['published'] = $data['published'];
                     $datam['catid'] = $data['catid'];
                     $datam['approved'] = $data['approved'];
                     $datam['language'] = $data['language'];
                     $datam['filename'] = $filename;
                     if ($data['title'] != '') {
                         $datam['title'] = $data['title'];
                     } else {
                         $datam['title'] = PhocaGalleryFile::getTitleFromFile($filename);
                     }
                     if ($data['alias'] != '') {
                         $datam['alias'] = $data['alias'];
                     } else {
                         $datam['alias'] = $datam['title'];
                         //PhocaGalleryText::getAliasName($datam['title']);
                     }
                     $datam['imgorigsize'] = PhocaGalleryFile::getFileSize($datam['filename'], 0);
                     $datam['format'] = PhocaGalleryFile::getFileFormat($datam['filename']);
                     // Geo
                     phocagalleryimport('phocagallery.geo.geo');
                     $coords = PhocaGalleryGeo::getGeoCoords($datam['filename']);
                     $datam['longitude'] = $coords['longitude'];
                     $datam['latitude'] = $coords['latitude'];
                     if ($datam['latitude'] != '' && $datam['longitude'] != '') {
                         $datam['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
                     }
                     // 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;
                     }
                     $result->image_count++;
                 }
             }
         }
         $this->setImageCount($result->image_count);
     }
     // - - - - - - - - - - - - - - - - -
     //Create thumbnail small, medium, large
     //file - abc.img, file_no - folder/abc.img
     //Get folder variables from Helper
     //	$refresh_url 	= 'index.php?option=com_phocagallery&task=phocagalleryimg.thumbs';
     $msg = $this->categoryCount . ' ' . JText::_('COM_PHOCAGALLERY_CATEGORIES_ADDED') . ', ' . $this->imageCount . ' ' . JText::_('COM_PHOCAGALLERY_IMAGES_ADDED');
     $app->enqueueMessage($msg);
     $app->redirect(JRoute::_('index.php?option=com_phocagallery&view=phocagalleryimgs&countimg=' . $this->imageCount . '&imagesid=' . md5(time()), false));
     // Only image without folder was added to the system
     if (isset($row->filename) && $row->filename != '') {
         $fileNameThumb = $row->filename;
     } else {
         if ($this->firstImageFolder != '') {
             $fileNameThumb = $this->firstImageFolder;
         } else {
             $fileNameThumb == '';
         }
     }
     if ($fileNameThumb != '') {
         $refresh_url = 'index.php?option=com_phocagallery&view=phocagalleryimgs&countimg=' . $this->imageCount;
         $fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($fileNameThumb, $refresh_url, 1, 1, 1);
     }
     //Clean Thumbs Folder if there are thumbnail files but not original file
     if ($clean_thumbnails == 1) {
         PhocaGalleryFolder::cleanThumbsFolder();
     }
     // - - - - - - - - - - - - - - - - -
     return true;
 }
Esempio n. 9
0
 function save($data)
 {
     $params =& JComponentHelper::getParams('com_phocagallery');
     $clean_thumbnails = $params->get('clean_thumbnails', 0);
     $fileOriginalNotExist = 0;
     if ((int) $data['extid'] > 0) {
         $data['imgorigsize'] = 0;
         if ($data['title'] == '') {
             $data['title'] = 'External Image';
         }
     } else {
         //If this file doesn't exists don't save it
         if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
             //$this->setError('Original File does not exist');
             //return false;
             $fileOriginalNotExist = 1;
             $errorMsg = JText::_('COM_PHOCAGALLERY_ORIGINAL_IMAGE_NOT_EXIST');
         }
         $data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
         $data['format'] = PhocaGalleryFile::getFileFormat($data['filename']);
         //If there is no title and no alias, use filename as title and alias
         if ($data['title'] == '') {
             $data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
         }
     }
     if ($data['extlink1link'] != '') {
         $extlink1 = str_replace('http://', '', $data['extlink1link']);
         $data['extlink1'] = $extlink1 . '|' . $data['extlink1title'] . '|' . $data['extlink1target'] . '|' . $data['extlink1icon'];
     } else {
         $data['extlink1'] = $data['extlink1link'] . '|' . $data['extlink1title'] . '|' . $data['extlink1target'] . '|' . $data['extlink1icon'];
     }
     if ($data['extlink2link'] != '') {
         $extlink2 = str_replace('http://', '', $data['extlink2link']);
         $data['extlink2'] = $extlink2 . '|' . $data['extlink2title'] . '|' . $data['extlink2target'] . '|' . $data['extlink2icon'];
     } else {
         $data['extlink2'] = $data['extlink2link'] . '|' . $data['extlink2title'] . '|' . $data['extlink2target'] . '|' . $data['extlink2icon'];
     }
     // Geo
     if ($data['longitude'] == '' || $data['latitude'] == '') {
         phocagalleryimport('phocagallery.geo.geo');
         $coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
         if ($data['longitude'] == '') {
             $data['longitude'] = $coords['longitude'];
         }
         if ($data['latitude'] == '') {
             $data['latitude'] = $coords['latitude'];
         }
         if ($data['latitude'] != '' && $data['longitude'] != '' && $data['zoom'] == '') {
             $data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
         }
     }
     if ($data['alias'] == '') {
         $data['alias'] = $data['title'];
     }
     //clean alias name (no bad characters)
     //$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
     // if new item, order last in appropriate group
     //if (!$row->id) {
     //	$where = 'catid = ' . (int) $row->catid ;
     //	$row->ordering = $row->getNextOrder( $where );
     //}
     // = = = = = = = = = =
     // Initialise variables;
     $dispatcher = JDispatcher::getInstance();
     $table = $this->getTable();
     $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState($this->getName() . '.id');
     $isNew = true;
     // Include the content plugins for the on save events.
     JPluginHelper::importPlugin('content');
     // Load the row if saving an existing record.
     if ($pk > 0) {
         $table->load($pk);
         $isNew = false;
     }
     // Bind the data.
     if (!$table->bind($data)) {
         $this->setError($table->getError());
         return false;
     }
     if (intval($table->date) == 0) {
         $table->date = JFactory::getDate()->toSql();
     }
     // Prepare the row for saving
     $this->prepareTable($table);
     // Check the data.
     if (!$table->check()) {
         $this->setError($table->getError());
         return false;
     }
     // Trigger the onContentBeforeSave event.
     /*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew));
     		if (in_array(false, $result, true)) {
     			$this->setError($table->getError());
     			return false;
     		}*/
     // Store the data.
     if (!$table->store()) {
         $this->setError($table->getError());
         return false;
     }
     // Store to ref table
     if (!isset($data['tags'])) {
         $data['tags'] = array();
     }
     if ((int) $table->id > 0) {
         PhocaGalleryTag::storeTags($data['tags'], (int) $table->id);
     }
     // Clean the cache.
     $cache = JFactory::getCache($this->option);
     $cache->clean();
     // Trigger the onContentAfterSave event.
     //$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew));
     $pkName = $table->getKeyName();
     if (isset($table->{$pkName})) {
         $this->setState($this->getName() . '.id', $table->{$pkName});
     }
     $this->setState($this->getName() . '.new', $isNew);
     // = = = = = =
     $task = JRequest::getVar('task');
     if (isset($table->{$pkName})) {
         $id = $table->{$pkName};
     }
     if ((int) $data['extid'] > 0 || $fileOriginalNotExist == 1) {
     } else {
         // - - - - - - - - - - - - - - - - - -
         //Create thumbnail small, medium, large
         //file - abc.img, file_no - folder/abc.img
         //Get folder variables from Helper
         //Create thumbnails small, medium, large
         $refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.thumbs';
         $task = JRequest::getVar('task');
         if (isset($table->{$pkName}) && $task == 'apply') {
             $id = $table->{$pkName};
             $refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.edit&id=' . (int) $id;
         }
         if ($task == 'save2new') {
             // Don't create automatically thumbnails in case, we are going to add new image
         } else {
             $file_thumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($data['filename'], $refresh_url, 1, 1, 1);
         }
         //Clean Thumbs Folder if there are thumbnail files but not original file
         if ($clean_thumbnails == 1) {
             phocagalleryimport('phocagallery.file.filefolder');
             PhocaGalleryFileFolder::cleanThumbsFolder();
         }
         // - - - - - - - - - - - - - - - - - - - - -
     }
     return true;
 }
Esempio n. 10
0
 function cooliris($cids, &$message)
 {
     $db = JFactory::getDBO();
     $path = PhocaGalleryPath::getPath();
     $piclensImg = $path->image_rel_front . 'icon-phocagallery.png';
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // PARAMS
     // original 0, thumbnail 1
     $cooliris_image = $paramsC->get('piclens_image', 1);
     if (JFolder::exists($path->image_abs)) {
         foreach ($cids as $kcid => $vcid) {
             $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>' . "\n";
             $xml .= '<rss xmlns:media="http://search.yahoo.com/mrss" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">' . "\n";
             $xml .= ' <channel>' . "\n";
             $xml .= '  <atom:icon>' . JURI::root() . $piclensImg . '</atom:icon>' . "\n\n";
             $xml .= '  <title>Phoca Gallery</title>' . "\n";
             $xml .= '  <link>http://www.phoca.cz/</link>' . "\n";
             $xml .= '  <description>Phoca Gallery</description>' . "\n";
             $query = 'SELECT a.id, a.title, a.filename, a.description, a.extid, a.extl, a.exto' . ' FROM #__phocagallery AS a' . ' WHERE a.catid = ' . (int) $vcid . ' AND a.published = 1' . ' ORDER BY a.catid, a.ordering';
             $db->setQuery($query);
             $rows = $db->loadObjectList();
             foreach ($rows as $krow => $vrow) {
                 $file = PhocaGalleryFileThumbnail::getOrCreateThumbnail($vrow->filename, '');
                 $thumbFile = str_replace("administrator", "", $file['thumb_name_l_no_rel']);
                 $origFile = str_replace("administrator", "", $file['name_original_rel']);
                 $xml .= '   <item>' . "\n";
                 $xml .= '    <title>' . $vrow->title . '</title>' . "\n";
                 if ($vrow->extid != '') {
                     $xml .= '<link>' . $vrow->extl . '</link>' . "\n";
                 } else {
                     $xml .= '    <link>' . JURI::root() . $thumbFile . '</link>' . "\n";
                 }
                 $xml .= '    <description>' . JFilterOutput::cleanText(strip_tags($vrow->description)) . '</description>' . "\n";
                 if ($vrow->extid != '') {
                     $xml .= '    <media:thumbnail url="' . $vrow->extl . '" />' . "\n";
                     if ($cooliris_image == 1) {
                         $xml .= '    <media:content url="' . $vrow->extl . '" />' . "\n";
                     } else {
                         $xml .= '    <media:content url="' . $vrow->exto . '" />' . "\n";
                     }
                 } else {
                     $xml .= '    <media:thumbnail url="' . JURI::root() . $thumbFile . '" />' . "\n";
                     if ($cooliris_image == 1) {
                         $xml .= '    <media:content url="' . JURI::root() . $thumbFile . '" />' . "\n";
                     } else {
                         $xml .= '    <media:content url="' . JURI::root() . $origFile . '" />' . "\n";
                     }
                 }
                 if ($vrow->extid != '') {
                     $xml .= '    <guid isPermaLink="false">' . $vcid . '-phocagallerypiclenscode-' . $vrow->extid . '</guid>' . "\n";
                 } else {
                     $xml .= '    <guid isPermaLink="false">' . $vcid . '-phocagallerypiclenscode-' . $vrow->filename . '</guid>' . "\n";
                 }
                 $xml .= '   </item>' . "\n\n";
             }
             $xml .= ' </channel>' . "\n";
             $xml .= '</rss>' . "\n";
             ob_start();
             echo $xml;
             $xmlToWrite = ob_get_contents();
             ob_end_clean();
             if (!JFile::write($path->image_abs . DS . $vcid . '.rss', $xmlToWrite)) {
                 $message = 'COM_PHOCAGALLERY_ERROR_SAVING_RSS';
                 return false;
             }
         }
         return true;
     } else {
         $message = 'COM_PHOCAGALLERY_ERROR_IMAGE_FOLDER_NOT_EXIST';
         return false;
     }
 }