Example #1
0
 function display($tpl = null)
 {
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $path = PhocaGalleryPath::getPath();
     $this->tmpl['avatarpathabs'] = $path->avatar_abs . DS . 'thumbs' . DS . 'phoca_thumb_s_';
     $this->tmpl['avatarpathrel'] = $path->avatar_rel . 'thumbs/phoca_thumb_s_';
     $this->tmpl['avtrpathrel'] = $path->avatar_rel;
     JHTML::stylesheet('administrator/components/com_phocagallery/assets/phocagallery.css');
     $document =& JFactory::getDocument();
     $document->addCustomTag(PhocaGalleryRenderAdmin::renderIeCssLink(1));
     // Button
     JHTML::_('behavior.modal', 'a.modal_phocagalleryusers');
     $this->button = new JObject();
     $this->button->set('modal', true);
     $this->button->set('methodname', 'modal-button');
     //$this->button->set('link', $link);
     $this->button->set('text', JText::_('COM_PHOCAGALLERY_DISPLAY_IMAGE_DETAIL'));
     //$this->button->set('name', 'image');
     $this->button->set('modalname', 'modal_phocagalleryusers');
     $this->button->set('options', "{handler: 'image', size: {x: 200, y: 150}}");
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Example #2
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document =& JFactory::getDocument();
     $uri =& JFactory::getURI();
     //$menus				= &JSite::getMenu();
     $menus = JFactory::getApplication()->getMenu();
     $menu = $menus->getActive();
     $this->params =& $app->getParams();
     $this->tmpl['path'] =& PhocaGalleryPath::getPath();
     $model =& $this->getModel();
     // PARAMS
     $this->tmpl['displaycatnametitle'] = $this->params->get('display_cat_name_title', 1);
     $display_cat_name_breadcrumbs = $this->params->get('display_cat_name_breadcrumbs', 1);
     $this->tmpl['showpageheading'] = $this->params->get('show_page_heading', 1);
     $this->tmpl['cooliris3d_wall_width'] = $this->params->get('cooliris3d_wall_width', 600);
     $this->tmpl['cooliris3d_wall_height'] = $this->params->get('cooliris3d_wall_height', 370);
     $this->tmpl['pmt'] = PhocaGalleryRenderInfo::getPhocaIc((int) $this->params->get('display_phoca_info', 1));
     $this->tmpl['gallerymetakey'] = $this->params->get('gallery_metakey', '');
     $this->tmpl['gallerymetadesc'] = $this->params->get('gallery_metadesc', '');
     $this->tmpl['enablecustomcss'] = $this->params->get('enable_custom_css', 0);
     $this->tmpl['customcss'] = $this->params->get('custom_css', '');
     $idCategory = JRequest::getVar('id', 0, 'get', 'int');
     // CSS
     JHtml::stylesheet('components/com_phocagallery/assets/phocagallery.css');
     if ($this->tmpl['enablecustomcss'] == 1) {
         JHtml::stylesheet('components/com_phocagallery/assets/phocagallerycustom.css');
         PhocaGalleryRenderFront::displayCustomCSS($this->tmpl['customcss']);
     }
     if ((int) $idCategory > 0) {
         $category = $model->getCategory($idCategory);
         $this->_prepareDocument($category);
         // Define image tag attributes
         /*if (!empty ($category->image)) {
         			$attribs['align'] = '"'.$category->image_position.'"';
         			$attribs['hspace'] = '"6"';
         			$this->tmpl['image'] = JHtml::_('image', 'images/stories/'.$category->image, '', $attribs);
         		}*/
         $this->_addBreadCrumbs($category, isset($menu->query['id']) ? $menu->query['id'] : 0, $display_cat_name_breadcrumbs);
         // ASIGN
         $this->tmpl['display_category'] = 1;
         $this->assignRef('tmpl', $this->tmpl);
         $this->assignRef('category', $category);
         $this->assignRef('params', $this->params);
     } else {
         $this->tmpl['display_category'] = 0;
         $this->assignRef('tmpl', $this->tmpl);
     }
     parent::display($tpl);
 }
Example #3
0
 public function display($tpl = null)
 {
     $params = JComponentHelper::getParams('com_phocagallery');
     JResponse::allowCache(false);
     JHTML::stylesheet('media/com_phocagallery/css/administrator/phocagallery.css');
     $document = JFactory::getDocument();
     //$document->addCustomTag(PhocaGalleryRenderAdmin::renderIeCssLink(1));
     $path = PhocaGalleryPath::getPath();
     $this->field = JRequest::getVar('field');
     $this->fce = 'phocaSelectFolder_' . $this->field;
     $this->assignRef('session', JFactory::getSession());
     $this->assign('path_orig_rel', $path->image_rel);
     $this->assignRef('folders', $this->get('folders'));
     $this->assignRef('state', $this->get('state'));
     parent::display($tpl);
 }
Example #4
0
 function getImageSize($filename, $returnString = 0, $extLink = 0)
 {
     phocagalleryimport('phocagallery.image.image');
     phocagalleryimport('phocagallery.path.path');
     if ($extLink == 1) {
         $fileNameAbs = $filename;
     } else {
         $path =& PhocaGalleryPath::getPath();
         $fileNameAbs = JPath::clean($path->image_abs . $filename);
         if (!JFile::exists($fileNameAbs)) {
             $fileNameAbs = $path->image_abs_front . 'phoca_thumb_l_no_image.png';
         }
     }
     if ($returnString == 1) {
         $imageSize = @getimagesize($fileNameAbs);
         return $imageSize[0] . ' x ' . $imageSize[1];
     } else {
         return @getimagesize($fileNameAbs);
     }
 }
Example #5
0
 function getList()
 {
     static $list;
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     // Get current path from request
     $current = $this->getState('folder');
     // If undefined, set to empty
     if ($current == 'undefined') {
         $current = '';
     }
     //Get folder variables from Helper
     $path = PhocaGalleryPath::getPath();
     // Initialize variables
     if (strlen($current) > 0) {
         $orig_path = JPath::clean($path->image_abs . $current);
     } else {
         $orig_path = $path->image_abs;
     }
     $orig_path_server = str_replace(DS, '/', $path->image_abs);
     $folders = array();
     // Get the list of files and folders from the given folder
     $folder_list = JFolder::folders($orig_path, '', false, false, array(0 => 'thumbs'));
     // Iterate over the folders if they exist
     if ($folder_list !== false) {
         foreach ($folder_list as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $folder));
             $tmp->path_without_name_relative = $path->image_rel . str_replace($orig_path_server, '', $tmp->path_with_name);
             $tmp->path_with_name_relative_no = str_replace($orig_path_server, '', $tmp->path_with_name);
             $folders[] = $tmp;
         }
     }
     $list = array('folders' => $folders);
     return $list;
 }
Example #6
0
 function getOrCreateThumbnail($fileNo, $refreshUrl, $small = 0, $medium = 0, $large = 0, $frontUpload = 0)
 {
     if ($frontUpload) {
         $returnFrontMessage = '';
     }
     $onlyThumbnailInfo = 0;
     if ($small == 0 && $medium == 0 && $large == 0) {
         $onlyThumbnailInfo = 1;
     }
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $additional_thumbnails = $paramsC->get('additional_thumbnails', 0);
     $path = PhocaGalleryPath::getPath();
     $origPathServer = str_replace(DS, '/', $path->image_abs);
     $file['name'] = PhocaGalleryFile::getTitleFromFile($fileNo, 1);
     $file['name_no'] = ltrim($fileNo, '/');
     $file['name_original_abs'] = PhocaGalleryFile::getFileOriginal($fileNo);
     $file['name_original_rel'] = PhocaGalleryFile::getFileOriginal($fileNo, 1);
     $file['path_without_file_name_original'] = str_replace($file['name'], '', $file['name_original_abs']);
     $file['path_without_file_name_thumb'] = str_replace($file['name'], '', $file['name_original_abs'] . 'thumbs' . DS);
     //$file['path_without_name']				= str_replace(DS, '/', JPath::clean($origPathServer));
     //$file['path_with_name_relative_no']		= str_replace($origPathServer, '', $file['name_original']);
     /*
     		$file['path_with_name_relative']		= $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['name_original']);
     		$file['path_with_name_relative_no']		= str_replace($origPathServer, '', $file['name_original']);
     		
     		$file['path_without_name']				= str_replace(DS, '/', JPath::clean($origPath.DS));
     		$file['path_without_name_relative']		= $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['path_without_name']);
     		$file['path_without_name_relative_no']	= str_replace($origPathServer, '', $file['path_without_name']);
     		$file['path_without_name_thumbs'] 		= $file['path_without_name'] .'thumbs';
     		$file['path_without_file_name_original'] 			= str_replace($file['name'], '', $file['name_original']);
     		$file['path_without_name_thumbs_no'] 	= str_replace($file['name'], '', $file['name_original'] .'thumbs');*/
     $ext = strtolower(JFile::getExt($file['name']));
     switch ($ext) {
         case 'jpg':
         case 'png':
         case 'gif':
         case 'jpeg':
             //Get File thumbnails name
             $thumbNameS = PhocaGalleryFileThumbnail::getThumbnailName($fileNo, 'small');
             $file['thumb_name_s_no_abs'] = $thumbNameS->abs;
             $file['thumb_name_s_no_rel'] = $thumbNameS->rel;
             $thumbNameM = PhocaGalleryFileThumbnail::getThumbnailName($fileNo, 'medium');
             $file['thumb_name_m_no_abs'] = $thumbNameM->abs;
             $file['thumb_name_m_no_rel'] = $thumbNameM->rel;
             $thumbNameL = PhocaGalleryFileThumbnail::getThumbnailName($fileNo, 'large');
             $file['thumb_name_l_no_abs'] = $thumbNameL->abs;
             $file['thumb_name_l_no_rel'] = $thumbNameL->rel;
             // Don't create thumbnails from watermarks...
             $dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($file['name']);
             if ($dontCreateThumb == 1) {
                 $onlyThumbnailInfo = 1;
                 // WE USE $onlyThumbnailInfo FOR NOT CREATE A THUMBNAIL CLAUSE
             }
             // We want only information from the pictures OR
             if ($onlyThumbnailInfo == 0) {
                 $thumbInfo = $fileNo;
                 //Create thumbnail folder if not exists
                 $errorMsg = 'ErrorCreatingFolder';
                 $creatingFolder = PhocaGalleryFileThumbnail::createThumbnailFolder($file['path_without_file_name_original'], $file['path_without_file_name_thumb'], $errorMsg);
                 switch ($errorMsg) {
                     case 'Success':
                         //case 'ThumbnailExists':
                     //case 'ThumbnailExists':
                     case 'DisabledThumbCreation':
                         //case 'OnlyInformation':
                         break;
                     default:
                         // BACKEND OR FRONTEND
                         if ($frontUpload != 1) {
                             PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl, $errorMsg, $frontUpload);
                             exit;
                         } else {
                             $returnFrontMessage = $errorMsg;
                         }
                         break;
                 }
                 // Folder must exist
                 if (JFolder::exists($file['path_without_file_name_thumb'])) {
                     $errorMsgS = $errorMsgM = $errorMsgL = '';
                     //Small thumbnail
                     if ($small == 1) {
                         PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameS->abs, 'small', $frontUpload, $errorMsgS);
                         if ($additional_thumbnails == 2 || $additional_thumbnails == 3) {
                             PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s1_', $thumbNameS->abs), 'small1', $frontUpload, $errorMsgS);
                             PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s2_', $thumbNameS->abs), 'small2', $frontUpload, $errorMsgS);
                             PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s3_', $thumbNameS->abs), 'small3', $frontUpload, $errorMsgS);
                         }
                     } else {
                         $errorMsgS = 'ThumbnailExists';
                         // in case we only need medium or large, because of if clause bellow
                     }
                     //Medium thumbnail
                     if ($medium == 1) {
                         PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameM->abs, 'medium', $frontUpload, $errorMsgM);
                         if ($additional_thumbnails == 1 || $additional_thumbnails == 3) {
                             PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m1_', $thumbNameM->abs), 'medium1', $frontUpload, $errorMsgM);
                             PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m2_', $thumbNameM->abs), 'medium2', $frontUpload, $errorMsgM);
                             PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m3_', $thumbNameM->abs), 'medium3', $frontUpload, $errorMsgM);
                         }
                     } else {
                         $errorMsgM = 'ThumbnailExists';
                         // in case we only need small or large, because of if clause bellow
                     }
                     //Large thumbnail
                     if ($large == 1) {
                         PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameL->abs, 'large', $frontUpload, $errorMsgL);
                     } else {
                         $errorMsgL = 'ThumbnailExists';
                         // in case we only need small or medium, because of if clause bellow
                     }
                     // Error messages for all 3 thumbnails (if the message contains error string, we got error
                     // Other strings can be:
                     // - ThumbnailExists  - do not display error message nor success page
                     // - OnlyInformation - do not display error message nor success page
                     // - DisabledThumbCreation - do not display error message nor success page
                     $creatingSError = $creatingMError = $creatingLError = false;
                     $creatingSError = preg_match("/Error/i", $errorMsgS);
                     $creatingMError = preg_match("/Error/i", $errorMsgM);
                     $creatingLError = preg_match("/Error/i", $errorMsgL);
                     // BACKEND OR FRONTEND
                     if ($frontUpload != 1) {
                         // There is an error while creating thumbnail in m or in s or in l
                         if ($creatingSError || $creatingMError || $creatingLError) {
                             // if all or two errors appear, we only display the last error message
                             // because the errors in this case is the same
                             if ($errorMsgS != '') {
                                 $creatingError = $errorMsgS;
                             }
                             if ($errorMsgM != '') {
                                 $creatingError = $errorMsgM;
                             }
                             if ($errorMsgL != '') {
                                 $creatingError = $errorMsgL;
                             }
                             PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl, $creatingError);
                             exit;
                         } else {
                             if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') {
                                 PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                 exit;
                             } else {
                                 if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
                                     PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                     exit;
                                 } else {
                                     if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') {
                                         PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                         exit;
                                     } else {
                                         if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
                                             PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                             exit;
                                         } else {
                                             if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
                                                 PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                                 exit;
                                             } else {
                                                 if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') {
                                                     PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                                     exit;
                                                 } else {
                                                     if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
                                                         PhocaGalleryRenderProcess::getProcessPage($file['name'], $thumbInfo, $refreshUrl);
                                                         exit;
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         // There is an error while creating thumbnail in m or in s or in l
                         if ($creatingSError || $creatingMError || $creatingLError) {
                             // if all or two errors appear, we only display the last error message
                             // because the errors in this case is the same
                             if ($errorMsgS != '') {
                                 $creatingError = $errorMsgS;
                             }
                             if ($errorMsgM != '') {
                                 $creatingError = $errorMsgM;
                             }
                             if ($errorMsgL != '') {
                                 $creatingError = $errorMsgL;
                             }
                             // because the errors in this case is the same
                             $returnFrontMessage = $creatingError;
                         } else {
                             if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') {
                                 $returnFrontMessage = 'Success';
                             } else {
                                 if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
                                     $returnFrontMessage = 'Success';
                                 } else {
                                     if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') {
                                         $returnFrontMessage = 'Success';
                                     } else {
                                         if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
                                             $returnFrontMessage = 'Success';
                                         } else {
                                             if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
                                                 $returnFrontMessage = 'Success';
                                             } else {
                                                 if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') {
                                                     $returnFrontMessage = 'Success';
                                                 } else {
                                                     if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
                                                         $returnFrontMessage = 'Success';
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($frontUpload == 1) {
                         return $returnFrontMessage;
                     }
                 }
             }
             break;
     }
     return $file;
 }
Example #7
0
 public function getFiles()
 {
     $result = array();
     jimport('joomla.filesystem.folder');
     $paths = PhocaGalleryPath::getPath();
     $path = JPath::clean($paths->media_css_abs . '/main/');
     if (is_dir($path)) {
         $files = JFolder::files($path, '\\.css$', false, false);
         foreach ($files as $file) {
             $fileO = new stdClass();
             $fileO->filename = $file;
             $fileO->exists = file_exists($path . $file);
             $fileO->type = 1;
             $result[] = $fileO;
         }
     } else {
         $this->setError(JText::_('COM_PHOCAGALLERY_ERROR_CSS_FOLDER_NOT_FOUND') . ' (1)');
         return false;
     }
     $path = JPath::clean($paths->media_css_abs . '/custom/');
     if (is_dir($path)) {
         $files = JFolder::files($path, '\\.css$', false, false);
         foreach ($files as $file) {
             $fileO = new stdClass();
             $fileO->filename = $file;
             $fileO->exists = file_exists($path . $file);
             $fileO->type = 2;
             $result[] = $fileO;
         }
     } else {
         $this->setError(JText::_('COM_PHOCAGALLERY_ERROR_CSS_FOLDER_NOT_FOUND') . ' (2)');
         return false;
     }
     return $result;
 }
Example #8
0
 /**
  * need GD library (first PHP line WIN: dl("php_gd.dll"); UNIX: dl("gd.so");
  * www.boutell.com/gd/
  * interval.cz/clanky/php-skript-pro-generovani-galerie-obrazku-2/
  * cz.php.net/imagecopyresampled
  * www.linuxsoft.cz/sw_detail.php?id_item=871
  * www.webtip.cz/art/wt_tech_php/liquid_ir.html
  * php.vrana.cz/zmensovani-obrazku.php
  * diskuse.jakpsatweb.cz/
  *
  * @param string $fileIn Vstupni soubor (mel by existovat)
  * @param string $fileOut Vystupni soubor, null ho jenom zobrazi (taky kdyz nema pravo se zapsat :)
  * @param int $width Vysledna sirka (maximalni)
  * @param int $height Vysledna vyska (maximalni)
  * @param bool $crop Orez (true, obrazek bude presne tak velky), jinak jenom Resample (udane maximalni rozmery)
  * @param int $typeOut IMAGETYPE_type vystupniho obrazku
  * @return bool Chyba kdyz vrati false
  */
 public static function imageMagic($fileIn, $fileOut = null, $width = null, $height = null, $crop = null, $typeOut = null, $watermarkParams = array(), $frontUpload = 0, &$errorMsg)
 {
     $params = JComponentHelper::getParams('com_phocagallery');
     $jfile_thumbs = $params->get('jfile_thumbs', 1);
     $jpeg_quality = $params->get('jpeg_quality', 85);
     $jpeg_quality = PhocaGalleryImage::getJpegQuality($jpeg_quality);
     $fileWatermark = '';
     // While front upload we don't display the process page
     if ($frontUpload == 0) {
         $stopText = PhocaGalleryRenderProcess::displayStopThumbnailsCreating('processpage');
         echo $stopText;
     }
     // Memory - - - - - - - -
     $memory = 8;
     $memoryLimitChanged = 0;
     $memory = (int) ini_get('memory_limit');
     if ($memory == 0) {
         $memory = 8;
     }
     // - - - - - - - - - - -
     if ($fileIn !== '' && JFile::exists($fileIn)) {
         // array of width, height, IMAGETYPE, "height=x width=x" (string)
         list($w, $h, $type) = GetImageSize($fileIn);
         if ($w > 0 && $h > 0) {
             // we got the info from GetImageSize
             // size of the image
             if ($width == null || $width == 0) {
                 // no width added
                 $width = $w;
             } else {
                 if ($height == null || $height == 0) {
                     // no height, adding the same as width
                     $height = $width;
                 }
             }
             if ($height == null || $height == 0) {
                 // no height, no width
                 $height = $h;
             }
             // miniaturizing
             if (!$crop) {
                 // new size - nw, nh (new width/height)
                 $scale = $width / $w < $height / $h ? $width / $w : $height / $h;
                 // smaller rate
                 $src = array(0, 0, $w, $h);
                 $dst = array(0, 0, floor($w * $scale), floor($h * $scale));
             } else {
                 // will be cropped
                 $scale = $width / $w > $height / $h ? $width / $w : $height / $h;
                 // greater rate
                 $newW = $width / $scale;
                 // check the size of in file
                 $newH = $height / $scale;
                 // which side is larger (rounding error)
                 if ($w - $newW > $h - $newH) {
                     $src = array(floor(($w - $newW) / 2), 0, floor($newW), $h);
                 } else {
                     $src = array(0, floor(($h - $newH) / 2), $w, floor($newH));
                 }
                 $dst = array(0, 0, floor($width), floor($height));
             }
             // Watermark - - - - - - - - - - -
             if (!empty($watermarkParams) && ($watermarkParams['create'] == 1 || $watermarkParams['create'] == 2)) {
                 $thumbnailSmall = false;
                 $thumbnailMedium = false;
                 $thumbnailLarge = false;
                 $thumbnailMedium = preg_match("/phoca_thumb_m_/i", $fileOut);
                 $thumbnailLarge = preg_match("/phoca_thumb_l_/i", $fileOut);
                 $path = PhocaGalleryPath::getPath();
                 $fileName = PhocaGalleryFile::getTitleFromFile($fileIn, 1);
                 // Which Watermark will be used
                 // If watermark is in current directory use it else use Default
                 $fileWatermarkMedium = str_replace($fileName, 'watermark-medium.png', $fileIn);
                 $fileWatermarkLarge = str_replace($fileName, 'watermark-large.png', $fileIn);
                 clearstatcache();
                 // Which Watermark will be used
                 if ($thumbnailMedium) {
                     if (JFile::exists($fileWatermarkMedium)) {
                         $fileWatermark = $fileWatermarkMedium;
                     } else {
                         if ($watermarkParams['create'] == 2) {
                             $fileWatermark = $path->image_abs . 'watermark-medium.png';
                         } else {
                             $fileWatermark = '';
                         }
                     }
                 } else {
                     if ($thumbnailLarge) {
                         if (JFile::exists($fileWatermarkLarge)) {
                             $fileWatermark = $fileWatermarkLarge;
                         } else {
                             if ($watermarkParams['create'] == 2) {
                                 $fileWatermark = $path->image_abs . 'watermark-large.png';
                             } else {
                                 $fileWatermark = '';
                             }
                         }
                     } else {
                         $fileWatermark = '';
                     }
                 }
                 if (!JFile::exists($fileWatermark)) {
                     $fileWatermark = '';
                 }
                 if ($fileWatermark != '') {
                     list($wW, $hW, $typeW) = GetImageSize($fileWatermark);
                     switch ($watermarkParams['x']) {
                         case 'left':
                             $locationX = 0;
                             break;
                         case 'right':
                             $locationX = $dst[2] - $wW;
                             break;
                         case 'center':
                         default:
                             $locationX = $dst[2] / 2 - $wW / 2;
                             break;
                     }
                     switch ($watermarkParams['y']) {
                         case 'top':
                             $locationY = 0;
                             break;
                         case 'bottom':
                             $locationY = $dst[3] - $hW;
                             break;
                         case 'middle':
                         default:
                             $locationY = $dst[3] / 2 - $hW / 2;
                             break;
                     }
                 }
             } else {
                 $fileWatermark = '';
             }
         }
         if ($memory < 50) {
             ini_set('memory_limit', '50M');
             $memoryLimitChanged = 1;
         }
         // Resampling
         // in file
         // Watemark
         if ($fileWatermark != '') {
             if (!function_exists('ImageCreateFromPNG')) {
                 $errorMsg = 'ErrorNoPNGFunction';
                 return false;
             }
             $waterImage1 = ImageCreateFromPNG($fileWatermark);
         }
         // End Watermark - - - - - - - - - - - - - - - - - -
         switch ($type) {
             case IMAGETYPE_JPEG:
                 if (!function_exists('ImageCreateFromJPEG')) {
                     $errorMsg = 'ErrorNoJPGFunction';
                     return false;
                 }
                 //$image1 = ImageCreateFromJPEG($fileIn);
                 try {
                     $image1 = ImageCreateFromJPEG($fileIn);
                 } catch (\Exception $exception) {
                     $errorMsg = 'ErrorJPGFunction';
                     return false;
                 }
                 break;
             case IMAGETYPE_PNG:
                 if (!function_exists('ImageCreateFromPNG')) {
                     $errorMsg = 'ErrorNoPNGFunction';
                     return false;
                 }
                 //$image1 = ImageCreateFromPNG($fileIn);
                 try {
                     $image1 = ImageCreateFromPNG($fileIn);
                 } catch (\Exception $exception) {
                     $errorMsg = 'ErrorPNGFunction';
                     return false;
                 }
                 break;
             case IMAGETYPE_GIF:
                 if (!function_exists('ImageCreateFromGIF')) {
                     $errorMsg = 'ErrorNoGIFFunction';
                     return false;
                 }
                 //$image1 = ImageCreateFromGIF($fileIn);
                 try {
                     $image1 = ImageCreateFromGIF($fileIn);
                 } catch (\Exception $exception) {
                     $errorMsg = 'ErrorGIFFunction';
                     return false;
                 }
                 break;
             case IMAGETYPE_WBMP:
                 if (!function_exists('ImageCreateFromWBMP')) {
                     $errorMsg = 'ErrorNoWBMPFunction';
                     return false;
                 }
                 //$image1 = ImageCreateFromWBMP($fileIn);
                 try {
                     $image1 = ImageCreateFromWBMP($fileIn);
                 } catch (\Exception $exception) {
                     $errorMsg = 'ErrorWBMPFunction';
                     return false;
                 }
                 break;
             default:
                 $errorMsg = 'ErrorNotSupportedImage';
                 return false;
                 break;
         }
         if ($image1) {
             $image2 = @ImageCreateTruecolor($dst[2], $dst[3]);
             if (!$image2) {
                 $errorMsg = 'ErrorNoImageCreateTruecolor';
                 return false;
             }
             switch ($type) {
                 case IMAGETYPE_PNG:
                     //imagealphablending($image1, false);
                     @imagealphablending($image2, false);
                     //imagesavealpha($image1, true);
                     @imagesavealpha($image2, true);
                     break;
             }
             ImageCopyResampled($image2, $image1, $dst[0], $dst[1], $src[0], $src[1], $dst[2], $dst[3], $src[2], $src[3]);
             // Watermark - - - - - -
             if ($fileWatermark != '') {
                 ImageCopy($image2, $waterImage1, $locationX, $locationY, 0, 0, $wW, $hW);
             }
             // End Watermark - - - -
             // Display the Image - not used
             if ($fileOut == null) {
                 header("Content-type: " . image_type_to_mime_type($typeOut));
             }
             // Create the file
             if ($typeOut == null) {
                 // no bitmap
                 $typeOut = $type == IMAGETYPE_WBMP ? IMAGETYPE_PNG : $type;
             }
             switch ($typeOut) {
                 case IMAGETYPE_JPEG:
                     if (!function_exists('ImageJPEG')) {
                         $errorMsg = 'ErrorNoJPGFunction';
                         return false;
                     }
                     if ($jfile_thumbs == 1) {
                         ob_start();
                         if (!@ImageJPEG($image2, NULL, $jpeg_quality)) {
                             ob_end_clean();
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                         $imgJPEGToWrite = ob_get_contents();
                         ob_end_clean();
                         if (!JFile::write($fileOut, $imgJPEGToWrite)) {
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                     } else {
                         if (!@ImageJPEG($image2, $fileOut, $jpeg_quality)) {
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                     }
                     break;
                 case IMAGETYPE_PNG:
                     if (!function_exists('ImagePNG')) {
                         $errorMsg = 'ErrorNoPNGFunction';
                         return false;
                     }
                     if ($jfile_thumbs == 1) {
                         ob_start();
                         if (!@ImagePNG($image2, NULL)) {
                             ob_end_clean();
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                         $imgPNGToWrite = ob_get_contents();
                         ob_end_clean();
                         if (!JFile::write($fileOut, $imgPNGToWrite)) {
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                     } else {
                         if (!@ImagePNG($image2, $fileOut)) {
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                     }
                     break;
                 case IMAGETYPE_GIF:
                     if (!function_exists('ImageGIF')) {
                         $errorMsg = 'ErrorNoGIFFunction';
                         return false;
                     }
                     if ($jfile_thumbs == 1) {
                         ob_start();
                         if (!@ImageGIF($image2, NULL)) {
                             ob_end_clean();
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                         $imgGIFToWrite = ob_get_contents();
                         ob_end_clean();
                         if (!JFile::write($fileOut, $imgGIFToWrite)) {
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                     } else {
                         if (!@ImageGIF($image2, $fileOut)) {
                             $errorMsg = 'ErrorWriteFile';
                             return false;
                         }
                     }
                     break;
                 default:
                     $errorMsg = 'ErrorNotSupportedImage';
                     return false;
                     break;
             }
             // free memory
             ImageDestroy($image1);
             ImageDestroy($image2);
             if (isset($waterImage1)) {
                 ImageDestroy($waterImage1);
             }
             if ($memoryLimitChanged == 1) {
                 $memoryString = $memory . 'M';
                 ini_set('memory_limit', $memoryString);
             }
             $errorMsg = '';
             // Success
             return true;
         } else {
             $errorMsg = 'Error1';
             return false;
         }
         if ($memoryLimitChanged == 1) {
             $memoryString = $memory . 'M';
             ini_set('memory_limit', $memoryString);
         }
     }
     $errorMsg = 'Error2';
     return false;
 }
Example #9
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document =& JFactory::getDocument();
     $this->params = $app->getParams();
     $user =& JFactory::getUser();
     $var['slideshow'] = JRequest::getVar('phocaslideshow', 0, '', 'int');
     $var['download'] = JRequest::getVar('phocadownload', 0, '', 'int');
     $uri =& JFactory::getURI();
     $this->tmpl['action'] = $uri->toString();
     $path = PhocaGalleryPath::getPath();
     $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
     $access = PhocaGalleryAccess::isAccess($user->authorisedLevels(), $neededAccessLevels);
     // Information from the plugin - window is displayed after plugin action
     $get = array();
     $get['detail'] = JRequest::getVar('detail', '', 'get', 'string');
     $get['buttons'] = JRequest::getVar('buttons', '', 'get', 'string');
     $get['ratingimg'] = JRequest::getVar('ratingimg', '', 'get', 'string');
     $this->tmpl['picasa_correct_width_l'] = (int) $this->params->get('large_image_width', 640);
     $this->tmpl['picasa_correct_height_l'] = (int) $this->params->get('large_image_height', 480);
     $this->tmpl['enablecustomcss'] = $this->params->get('enable_custom_css', 0);
     $this->tmpl['customcss'] = $this->params->get('custom_css', '');
     $this->tmpl['enable_multibox'] = $this->params->get('enable_multibox', 0);
     $this->tmpl['multibox_height'] = (int) $this->params->get('multibox_height', 560);
     $this->tmpl['multibox_width'] = (int) $this->params->get('multibox_width', 980);
     $this->tmpl['multibox_map_height'] = (int) $this->params->get('multibox_map_height', 300);
     $this->tmpl['multibox_map_width'] = (int) $this->params->get('multibox_map_width', 280);
     $this->tmpl['multibox_height_overflow'] = (int) $this->tmpl['multibox_height'] - 10;
     //padding
     $this->tmpl['multibox_left_bgcolor'] = $this->params->get('multibox_left_bgcolor', '#000000');
     $this->tmpl['multibox_right_bgcolor'] = $this->params->get('multibox_right_bgcolor', '#ffffff');
     $this->tmpl['multibox_comments_width'] = $this->params->get('multibox_comments_width', 300);
     $this->tmpl['multibox_comments_height'] = $this->params->get('multibox_comments_height', 600);
     $this->tmpl['multibox_thubms_box_width'] = $this->params->get('multibox_thubms_box_width', 300);
     $this->tmpl['multibox_thubms_count'] = $this->params->get('multibox_thubms_count', 4);
     $this->tmpl['large_image_width'] = $this->params->get('large_image_width', 640);
     $this->tmpl['large_image_height'] = $this->params->get('large_image_height', 640);
     $this->tmpl['multibox_fixed_cols'] = $this->params->get('multibox_fixed_cols', 1);
     $this->tmpl['display_multibox'] = $this->params->get('display_multibox', array(1, 2));
     // CSS
     JHtml::stylesheet('components/com_phocagallery/assets/phocagallery.css');
     if ($this->tmpl['enablecustomcss'] == 1) {
         JHtml::stylesheet('components/com_phocagallery/assets/phocagallerycustom.css');
         PhocaGalleryRenderFront::displayCustomCSS($this->tmpl['customcss']);
     }
     // Plugin information
     $this->tmpl['detailwindow'] = $this->params->get('detail_window', 0);
     if (isset($get['detail']) && $get['detail'] != '') {
         $this->tmpl['detailwindow'] = $get['detail'];
     }
     // Plugin information
     $this->tmpl['detailbuttons'] = $this->params->get('detail_buttons', 1);
     if (isset($get['buttons']) && $get['buttons'] != '') {
         $this->tmpl['detailbuttons'] = $get['buttons'];
     }
     // Close and Reload links (for different window types)
     $close = PhocaGalleryRenderFront::renderCloseReloadDetail($this->tmpl['detailwindow']);
     $this->tmpl['detailwindowclose'] = $close['detailwindowclose'];
     $this->tmpl['detailwindowreload'] = $close['detailwindowreload'];
     $this->tmpl['displaydescriptiondetail'] = $this->params->get('display_description_detail', 0);
     $this->tmpl['displaytitleindescription'] = $this->params->get('display_title_description', 0);
     $this->tmpl['descriptiondetailheight'] = $this->params->get('description_detail_height', 16);
     $this->tmpl['fontsizedesc'] = $this->params->get('font_size_desc', 11);
     $this->tmpl['fontcolordesc'] = $this->params->get('font_color_desc', '#333333');
     $this->tmpl['detailwindowbackgroundcolor'] = $this->params->get('detail_window_background_color', '#ffffff');
     $this->tmpl['descriptionlightboxfontcolor'] = $this->params->get('description_lightbox_font_color', '#ffffff');
     $this->tmpl['descriptionlightboxbgcolor'] = $this->params->get('description_lightbox_bg_color', '#000000');
     $this->tmpl['descriptionlightboxfontsize'] = $this->params->get('description_lightbox_font_size', 12);
     $this->tmpl['displayratingimg'] = $this->params->get('display_rating_img', 0);
     $this->tmpl['displayicondownload'] = $this->params->get('display_icon_download', 0);
     $this->tmpl['externalcommentsystem'] = $this->params->get('external_comment_system', 0);
     $this->tmpl['largewidth'] = $this->params->get('large_image_width', 640);
     $this->tmpl['largeheight'] = $this->params->get('large_image_height', 480);
     $this->tmpl['boxlargewidth'] = $this->params->get('front_modal_box_width', 680);
     $this->tmpl['boxlargeheight'] = $this->params->get('front_modal_box_height', 560);
     $this->tmpl['slideshow_delay'] = $this->params->get('slideshow_delay', 3000);
     $this->tmpl['slideshow_pause'] = $this->params->get('slideshow_pause', 2500);
     $this->tmpl['slideshowrandom'] = $this->params->get('slideshow_random', 0);
     $this->tmpl['slideshow_description'] = $this->params->get('slideshow_description', 'peekaboo');
     $this->tmpl['gallerymetakey'] = $this->params->get('gallery_metakey', '');
     $this->tmpl['gallerymetadesc'] = $this->params->get('gallery_metadesc', '');
     $this->tmpl['altvalue'] = $this->params->get('alt_value', 1);
     $this->tmpl['enablecustomcss'] = $this->params->get('enable_custom_css', 0);
     $this->tmpl['customcss'] = $this->params->get('custom_css', '');
     $this->tmpl['display_tags_links'] = $this->params->get('display_tags_links', 0);
     $this->tmpl['ytb_display'] = $this->params->get('ytb_display', 0);
     $paramsFb = PhocaGalleryFbSystem::getCommentsParams($this->params->get('fb_comment_user_id', ''));
     // Facebook
     $this->tmpl['fb_comment_app_id'] = isset($paramsFb['fb_comment_app_id']) ? $paramsFb['fb_comment_app_id'] : '';
     $this->tmpl['fb_comment_width'] = isset($paramsFb['fb_comment_width']) ? $paramsFb['fb_comment_width'] : 550;
     $this->tmpl['fb_comment_lang'] = isset($paramsFb['fb_comment_lang']) ? $paramsFb['fb_comment_lang'] : 'en_US';
     $this->tmpl['fb_comment_count'] = isset($paramsFb['fb_comment_count']) ? $paramsFb['fb_comment_count'] : '';
     $oH = '';
     if ($this->tmpl['enable_multibox'] == 1) {
         $this->tmpl['fb_comment_width'] = $this->tmpl['multibox_comments_width'];
         $oH = 'overflow:hidden;';
     }
     // CSS
     JHtml::stylesheet('components/com_phocagallery/assets/phocagallery.css');
     if ($this->tmpl['enablecustomcss'] == 1) {
         JHtml::stylesheet('components/com_phocagallery/assets/phocagallerycustom.css');
         if ($this->tmpl['customcss'] != '') {
             $document->addCustomTag("\n <style type=\"text/css\"> \n" . $this->escape(strip_tags($this->tmpl['customcss'])) . "\n </style> \n");
         }
     }
     //Multibox displaying
     $this->tmpl['mb_title'] = PhocaGalleryUtils::isEnabledMultiboxFeature(1);
     $this->tmpl['mb_desc'] = PhocaGalleryUtils::isEnabledMultiboxFeature(2);
     $this->tmpl['mb_uploaded_by'] = PhocaGalleryUtils::isEnabledMultiboxFeature(3);
     $this->tmpl['mb_rating'] = PhocaGalleryUtils::isEnabledMultiboxFeature(4);
     $this->tmpl['mb_maps'] = PhocaGalleryUtils::isEnabledMultiboxFeature(5);
     $this->tmpl['mb_tags'] = PhocaGalleryUtils::isEnabledMultiboxFeature(6);
     $this->tmpl['mb_comments'] = PhocaGalleryUtils::isEnabledMultiboxFeature(7);
     $this->tmpl['mb_thumbs'] = PhocaGalleryUtils::isEnabledMultiboxFeature(8);
     // No bar in Detail View
     if ($this->tmpl['detailwindow'] == 7) {
     } else {
         $document->addCustomTag("<style type=\"text/css\"> \n" . " html, body, .contentpane, #all, #main {" . $oH . "background:" . $this->tmpl['detailwindowbackgroundcolor'] . ";padding:0px !important;margin:0px !important; width: 100% !important; max-width: 100% !important;} \n" . " center, table {background:" . $this->tmpl['detailwindowbackgroundcolor'] . ";} \n" . " #sbox-window {background-color:#fff;padding:5px} \n" . "body {min-width:100%} \n" . ".rt-container {width:100%} \n" . " </style> \n");
     }
     // Download from the detail view which is not in the popupbox
     if ($var['download'] == 2) {
         $this->tmpl['displayicondownload'] = 2;
     }
     // Plugin Information
     if (isset($get['ratingimg']) && $get['ratingimg'] != '') {
         $this->tmpl['displayratingimg'] = $get['ratingimg'];
     }
     // Model
     $model =& $this->getModel();
     $item = $model->getData();
     //Multibox Thumbnails
     $this->tmpl['mb_thumbs_data'] = '';
     if ($this->tmpl['mb_thumbs'] == 1) {
         // if we get item variable, we have rights to load the thumbnails, this is why we checking it
         if (isset($item->id) && isset($item->catid) && (int) $item->id > 0 && (int) $item->catid > 0) {
             $this->tmpl['mb_thumbs_data'] = $model->getThumbnails((int) $item->id, (int) $item->catid, (int) $item->ordering);
         }
     }
     // User Avatar
     $this->tmpl['useravatarimg'] = '';
     $this->tmpl['useravatarmiddle'] = '';
     $userAvatar = PhocaGalleryUser::getUserAvatar($item->userid);
     if ($userAvatar) {
         $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_s_' . $userAvatar->avatar;
         $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_s_' . $userAvatar->avatar;
         if (JFile::exists($pathAvatarAbs)) {
             $sIH = $this->params->get('small_image_height', 50);
             $sIHR = @getImageSize($pathAvatarAbs);
             if (isset($sIHR[1])) {
                 $sIH = $sIHR[1];
             }
             if ((int) $sIH > 0) {
                 $this->tmpl['useravatarmiddle'] = (int) $sIH / 2 - 10;
             }
             $this->tmpl['useravatarimg'] = '<img src="' . JURI::base(true) . '/' . $pathAvatarRel . '?imagesid=' . md5(uniqid(time())) . '" alt="" />';
         }
     }
     // Access check - don't display the image if you have no access to this image (if user add own url)
     // USER RIGHT - ACCESS - - - - - - - - - -
     $rightDisplay = 0;
     if (!empty($item)) {
         $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $item->cataccessuserid, $item->cataccess, $user->authorisedLevels(), $user->get('id', 0), 0);
     }
     if ((int) $rightDisplay == 0) {
         echo $close['html'];
         //Some problem with cache - Joomla! return this message if there is no reason for do it.
         //$this->tmpl['pl']		= 'index.php?option=com_users&view=login&return='.base64_encode($uri->toString());
         //$app->redirect(JRoute::_($this->tmpl['pl'], false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
         exit;
     }
     // - - - - - - - - - - - - - - - - - - - -
     phocagalleryimport('phocagallery.image.image');
     phocagalleryimport('phocagallery.render.renderdetailbutton');
     // Javascript Slideshow buttons
     $detailButton = new PhocaGalleryRenderDetailButton();
     if ($this->tmpl['enable_multibox'] == 1) {
         $detailButton->setType('multibox');
     }
     $item->reloadbutton = $detailButton->getReload($item->catslug, $item->slug);
     $item->closebutton = $detailButton->getClose($item->catslug, $item->slug);
     $item->closetext = $detailButton->getCloseText($item->catslug, $item->slug);
     $item->nextbutton = $detailButton->getNext((int) $item->catid, (int) $item->id, (int) $item->ordering);
     $item->nextbuttonhref = $detailButton->getNext((int) $item->catid, (int) $item->id, (int) $item->ordering, 1);
     $item->prevbutton = $detailButton->getPrevious((int) $item->catid, (int) $item->id, (int) $item->ordering);
     $slideshowData = $detailButton->getJsSlideshow((int) $item->catid, (int) $item->id, (int) $var['slideshow'], $item->catslug, $item->slug);
     $item->slideshowbutton = $slideshowData['icons'];
     $item->slideshowfiles = $slideshowData['files'];
     $item->slideshow = $var['slideshow'];
     $item->download = $var['download'];
     // ALT VALUE
     $altValue = PhocaGalleryRenderFront::getAltValue($this->tmpl['altvalue'], $item->title, $item->description, $item->metadesc);
     $item->altvalue = $altValue;
     // Get file thumbnail or No Image
     $item->filenameno = $item->filename;
     $item->filename = PhocaGalleryFile::getTitleFromFile($item->filename, 1);
     $item->filesize = PhocaGalleryFile::getFileSize($item->filenameno);
     $realImageSize = '';
     $extImage = PhocaGalleryImage::isExtImage($item->extid);
     if ($extImage) {
         $item->extl = $item->extl;
         $item->exto = $item->exto;
         $realImageSize = PhocaGalleryImage::getRealImageSize($item->extl, '', 1);
         $item->imagesize = PhocaGalleryImage::getImageSize($item->exto, 1, 1);
         if ($item->extw != '') {
             $extw = explode(',', $item->extw);
             $item->extw = $extw[0];
         }
         $correctImageRes = PhocaGalleryPicasa::correctSizeWithRate($item->extw, $item->exth, $this->tmpl['picasa_correct_width_l'], $this->tmpl['picasa_correct_height_l']);
         $item->linkimage = JHtml::_('image', $item->extl, $item->altvalue, array('width' => $correctImageRes['width'], 'height' => $correctImageRes['height'], 'class' => 'pg-detail-image'));
         $item->realimagewidth = $correctImageRes['width'];
         $item->realimageheight = $correctImageRes['height'];
     } else {
         $item->linkthumbnailpath = PhocaGalleryImageFront::displayCategoryImageOrNoImage($item->filenameno, 'large');
         $item->linkimage = JHtml::_('image', $item->linkthumbnailpath, $item->altvalue, array('class' => 'pg-detail-image'));
         $realImageSize = PhocaGalleryImage::getRealImageSize($item->filenameno);
         $item->imagesize = PhocaGalleryImage::getImageSize($item->filenameno, 1);
         if (isset($realImageSize['w']) && isset($realImageSize['h'])) {
             $item->realimagewidth = $realImageSize['w'];
             $item->realimageheight = $realImageSize['h'];
         } else {
             $item->realimagewidth = $this->tmpl['largewidth'];
             $item->realimageheight = $this->tmpl['largeheight'];
         }
     }
     // Add Statistics
     $model->hit(JRequest::getVar('id', '', '', 'int'));
     // R A T I N G
     // Only registered (VOTES + COMMENTS)
     $this->tmpl['notregisteredimg'] = true;
     $this->tmpl['usernameimg'] = '';
     if ($access > 0) {
         $this->tmpl['notregisteredimg'] = false;
         $this->tmpl['usernameimg'] = $user->name;
     }
     // VOTES Statistics Img
     if ((int) $this->tmpl['displayratingimg'] == 1 || $this->tmpl['mb_rating']) {
         $this->tmpl['votescountimg'] = 0;
         $this->tmpl['votesaverageimg'] = 0;
         $this->tmpl['voteswidthimg'] = 0;
         $votesStatistics = PhocaGalleryRateImage::getVotesStatistics((int) $item->id);
         if (!empty($votesStatistics->count)) {
             $this->tmpl['votescountimg'] = $votesStatistics->count;
         }
         if (!empty($votesStatistics->average)) {
             $this->tmpl['votesaverageimg'] = $votesStatistics->average;
             if ($this->tmpl['votesaverageimg'] > 0) {
                 $this->tmpl['votesaverageimg'] = round((double) $this->tmpl['votesaverageimg'] / 0.5) * 0.5;
                 $this->tmpl['voteswidthimg'] = 22 * $this->tmpl['votesaverageimg'];
             } else {
                 $this->tmpl['votesaverageimg'] = (int) 0;
                 // not float displaying
             }
         }
         if ((int) $this->tmpl['votescountimg'] > 1) {
             $this->tmpl['votestextimg'] = 'COM_PHOCAGALLERY_VOTES';
         } else {
             $this->tmpl['votestextimg'] = 'COM_PHOCAGALLERY_VOTE';
         }
         // Already rated?
         $this->tmpl['alreadyratedimg'] = PhocaGalleryRateImage::checkUserVote((int) $item->id, (int) $user->id);
     }
     // Tags
     $this->tmpl['displaying_tags_output'] = '';
     if ($this->tmpl['display_tags_links'] == 1 || $this->tmpl['display_tags_links'] == 3 || $this->tmpl['mb_tags']) {
         if ($this->tmpl['detailwindow'] == 7) {
             $this->tmpl['displaying_tags_output'] = PhocaGalleryTag::displayTags($item->id);
         } else {
             $this->tmpl['displaying_tags_output'] = PhocaGalleryTag::displayTags($item->id, 1);
         }
     }
     // Back button
     $this->tmpl['backbutton'] = '';
     if ($this->tmpl['detailwindow'] == 7) {
         phocagalleryimport('phocagallery.image.image');
         $formatIcon =& PhocaGalleryImage::getFormatIcon();
         $this->tmpl['backbutton'] = '<div><a href="' . JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $item->catslug . '&Itemid=' . JRequest::getVar('Itemid', 0, '', 'int')) . '"' . ' title="' . JText::_('COM_PHOCAGALLERY_BACK_TO_CATEGORY') . '">' . JHtml::_('image', 'components/com_phocagallery/assets/images/icon-up-images.' . $formatIcon, JText::_('COM_PHOCAGALLERY_BACK_TO_CATEGORY')) . '</a></div>';
     }
     // ASIGN
     $this->assignRef('tmpl', $this->tmpl);
     $this->assignRef('item', $item);
     $this->_prepareDocument($item);
     if ($this->tmpl['enable_multibox'] == 1) {
         if ($item->download > 0) {
             if ($this->tmpl['displayicondownload'] == 2) {
                 $backLink = 'index.php?option=com_phocagallery&view=category&id=' . $item->catslug . '&Itemid=' . JRequest::getVar('Itemid', 0, '', 'int');
                 phocagalleryimport('phocagallery.file.filedownload');
                 if (isset($item->exto) && $item->exto != '') {
                     PhocaGalleryFileDownload::download($item, $backLink, 1);
                 } else {
                     PhocaGalleryFileDownload::download($item, $backLink);
                 }
                 exit;
             } else {
                 parent::display('multibox');
                 //parent::display('download');
             }
         } else {
             if (isset($item->videocode) && $item->videocode != '' && $item->videocode != '0') {
                 $item->videocode = PhocaGalleryYoutube::displayVideo($item->videocode);
             }
             parent::display('multibox');
         }
     } else {
         if (isset($item->videocode) && $item->videocode != '' && $item->videocode != '0') {
             $item->videocode = PhocaGalleryYoutube::displayVideo($item->videocode);
             if ($this->tmpl['detailwindow'] != 7 && $this->tmpl['ytb_display'] == 1) {
                 $document->addCustomTag("<style type=\"text/css\"> \n" . " html, body, .contentpane, div#all, div#main, div#system-message-container {padding: 0px !important;margin: 0px !important;} \n" . " div#sbox-window {background-color:#fff;padding: 0px;margin: 0px;} \n" . " </style> \n");
             }
             parent::display('video');
         } else {
             parent::display('slideshowjs');
             if ($item->slideshow == 1) {
                 parent::display('slideshow');
             } else {
                 if ($item->download > 0) {
                     if ($this->tmpl['displayicondownload'] == 2) {
                         $backLink = 'index.php?option=com_phocagallery&view=category&id=' . $item->catslug . '&Itemid=' . JRequest::getVar('Itemid', 0, '', 'int');
                         phocagalleryimport('phocagallery.file.filedownload');
                         if (isset($item->exto) && $item->exto != '') {
                             PhocaGalleryFileDownload::download($item, $backLink, 1);
                         } else {
                             PhocaGalleryFileDownload::download($item, $backLink);
                         }
                         exit;
                     } else {
                         parent::display('download');
                     }
                 } else {
                     parent::display($tpl);
                 }
             }
         }
     }
 }
Example #10
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user =& JFactory::getUser();
     $uri =& JFactory::getURI();
     $path =& PhocaGalleryPath::getPath();
     $this->params = $app->getParams();
     $this->tmplGeo = array();
     $this->tmpl['categories_description'] = $this->params->get('categories_description', '');
     $image_categories_size = $this->params->get('image_categories_size', 4);
     $medium_image_width = (int) $this->params->get('medium_image_width', 100) + 18;
     $medium_image_height = (int) $this->params->get('medium_image_height', 100) + 18;
     $small_image_width = (int) $this->params->get('small_image_width', 50) + 18;
     $small_image_height = (int) $this->params->get('small_image_height', 50) + 18;
     $this->tmpl['phocagallerywidth'] = $this->params->get('phocagallery_width', '');
     $this->tmpl['categoriescolumns'] = $this->params->get('categories_columns', 1);
     $this->tmpl['displayrating'] = $this->params->get('display_rating', 0);
     $this->tmpl['phocagallerycenter'] = $this->params->get('phocagallery_center', '');
     $this->tmpl['categoriesimageordering'] = $this->params->get('categories_image_ordering', 9);
     $this->tmpl['displayimagecategories'] = $this->params->get('display_image_categories', 1);
     $display_categories_geotagging = $this->params->get('display_categories_geotagging', 0);
     $display_access_category = $this->params->get('display_access_category', 1);
     $display_empty_categories = $this->params->get('display_empty_categories', 0);
     $hideCatArray = explode(',', trim($this->params->get('hide_categories', '')));
     $showCatArray = explode(',', trim($this->params->get('show_categories', '')));
     $this->tmpl['equalpercentagewidth'] = $this->params->get('equal_percentage_width');
     $this->tmpl['categoriesdisplayavatar'] = $this->params->get('categories_display_avatar');
     $this->tmpl['categoriesboxwidth'] = $this->params->get('categories_box_width');
     $this->tmpl['enablecustomcss'] = $this->params->get('enable_custom_css', 0);
     $this->tmpl['customcss'] = $this->params->get('custom_css', '');
     // = = = = = = = = = =
     // CSS
     // = = = = = = = = = =
     $document =& JFactory::getDocument();
     $library =& PhocaGalleryLibrary::getLibrary();
     JHtml::stylesheet('components/com_phocagallery/assets/phocagallery.css');
     if ($this->tmpl['enablecustomcss'] == 1) {
         JHtml::stylesheet('components/com_phocagallery/assets/phocagallerycustom.css');
         PhocaGalleryRenderFront::displayCustomCSS($this->tmpl['customcss']);
     } else {
         $libraries['pg-css-ie'] = $library->getLibrary('pg-css-ie');
         // CSS for IE 8
         if ($libraries['pg-css-ie']->value == 0) {
             $document->addCustomTag("<!--[if lt IE 8]>\n<link rel=\"stylesheet\" href=\"" . JURI::base(true) . "/components/com_phocagallery/assets/phocagalleryieall.css\" type=\"text/css\" />\n<![endif]-->");
             $library->setLibrary('pg-css-ie', 1);
         }
     }
     // = = = = = = = = = =
     // Correct Picasa Images - get Info
     switch ($image_categories_size) {
         // medium
         case 1:
         case 5:
             $this->tmpl['picasa_correct_width'] = (int) $this->params->get('medium_image_width', 100);
             $this->tmpl['picasa_correct_height'] = (int) $this->params->get('medium_image_height', 100);
             $this->tmpl['class_suffix'] = 'medium';
             break;
         case 0:
         case 4:
         default:
             $this->tmpl['picasa_correct_width'] = (int) $this->params->get('small_image_width', 50);
             $this->tmpl['picasa_correct_height'] = (int) $this->params->get('small_image_height', 50);
             $this->tmpl['class_suffix'] = 'small';
             break;
     }
     // - - - - - - - - - - - - - - -
     // Get background for the image
     $catImg = PhocaGalleryImageFront::getCategoriesImageBackground($image_categories_size, $small_image_width, $small_image_height, $medium_image_height, $medium_image_width);
     $this->tmpl['imagebg'] = $catImg->image;
     $this->tmpl['imagewidth'] = $catImg->width;
     //$total					= $this->get('total');
     //$this->tmpl['pagination']	= &$this->get('pagination');
     // Image next to Category in Categories View is ordered by Random as default
     $categoriesImageOrdering = PhocaGalleryOrdering::getOrderingString($this->tmpl['categoriesimageordering']);
     // MODEL
     $model =& $this->getModel();
     $this->tmpl['ordering'] =& $model->getOrdering();
     $this->categories = $this->get('data');
     // Add link and unset the categories which user cannot see (if it is enabled in params)
     // If it will be unset while access view, we must sort the keys from category array - ACCESS
     $unSet = 0;
     foreach ($this->categories as $key => $item) {
         // Unset empty categories if it is set
         if ($display_empty_categories == 0) {
             if ($this->categories[$key]->numlinks < 1) {
                 unset($this->categories[$key]);
                 $unSet = 1;
                 continue;
             }
         }
         // Set only selected category ID
         if (!empty($showCatArray[0]) && is_array($showCatArray)) {
             $unSetHCA = 0;
             foreach ($showCatArray as $valueHCA) {
                 if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                     $unSetHCA = 0;
                     $unSet = 0;
                     break;
                 } else {
                     $unSetHCA = 1;
                     $unSet = 1;
                 }
             }
             if ($unSetHCA == 1) {
                 unset($this->categories[$key]);
                 continue;
             }
         }
         // Unset hidden category
         if (!empty($hideCatArray) && is_array($hideCatArray)) {
             $unSetHCA = 0;
             foreach ($hideCatArray as $valueHCA) {
                 if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                     unset($this->categories[$key]);
                     $unSet = 1;
                     $unSetHCA = 1;
                     break;
                 }
             }
             if ($unSetHCA == 1) {
                 continue;
             }
         }
         // Link
         //$this->categories[$key]->link	= JRoute::_('index.php?option=com_phocagallery&view=category&id='. $item->slug.'&Itemid='. JRequest::getVar('Itemid', 0, '', 'int') );
         $this->categories[$key]->link = PhocaGalleryRoute::getCategoryRoute($item->id, $item->alias);
         // USER RIGHT - ACCESS - - - - -
         // First Check - check if we can display category
         $rightDisplay = 1;
         if (!empty($this->categories[$key])) {
             $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->authorisedLevels(), $user->get('id', 0), $display_access_category);
         }
         // Second Check - if we can display hidden category, set Key icon for them
         //                if we don't have access right to see them
         // Display Key Icon (in case we want to display unaccessable categories in list view)
         $rightDisplayKey = 1;
         if ($display_access_category == 1) {
             // we simulate that we want not to display unaccessable categories
             // so if we get rightDisplayKey = 0 then the key will be displayed
             if (!empty($this->categories[$key])) {
                 $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->authorisedLevels(), $user->get('id', 0), 0);
                 // 0 - simulation
             }
         }
         // Is Ext Image Album?
         $extCategory = PhocaGalleryImage::isExtImage($this->categories[$key]->extid, $this->categories[$key]->extfbcatid);
         // DISPLAY AVATAR, IMAGE(ordered), IMAGE(not ordered, not recursive) OR FOLDER ICON
         $displayAvatar = 0;
         if ($this->tmpl['categoriesdisplayavatar'] == 1 && isset($this->categories[$key]->avatar) && $this->categories[$key]->avatar != '' && $this->categories[$key]->avatarapproved == 1 && $this->categories[$key]->avatarpublished == 1) {
             $sizeString = PhocaGalleryImageFront::getSizeString($image_categories_size);
             $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
             $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
             if (JFile::exists($pathAvatarAbs)) {
                 $this->categories[$key]->linkthumbnailpath = $pathAvatarRel;
                 $displayAvatar = 1;
             }
         }
         if ($displayAvatar == 0) {
             if ($extCategory) {
                 if ($this->tmpl['categoriesimageordering'] != 10) {
                     $imagePic = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering, 1);
                     $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($imagePic->exts, $imagePic->extm, $imagePic->extw, $imagePic->exth, $image_categories_size, $rightDisplayKey);
                 } else {
                     $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($this->categories[$key]->exts, $this->categories[$key]->extm, $this->categories[$key]->extw, $this->categories[$key]->exth, $image_categories_size, $rightDisplayKey);
                 }
                 $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                 $this->categories[$key]->extw = $fileThumbnail->extw;
                 $this->categories[$key]->exth = $fileThumbnail->exth;
                 $this->categories[$key]->extpic = $fileThumbnail->extpic;
             } else {
                 if ($this->tmpl['categoriesimageordering'] != 10) {
                     $this->categories[$key]->filename = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering);
                 }
                 $fileThumbnail = PhocaGalleryImageFront::displayCategoriesImageOrFolder($this->categories[$key]->filename, $image_categories_size, $rightDisplayKey);
                 $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
             }
         }
         if ($rightDisplay == 0) {
             unset($this->categories[$key]);
             $unSet = 1;
         }
         // - - - - - - - - - - - - - - -
     }
     $this->tmpl['mtb'] = PhocaGalleryRenderInfo::getPhocaIc((int) $this->params->get('display_phoca_info', 1));
     // ACCESS - - - - - -
     // In case we unset some category from the list, we must sort the array new
     if ($unSet == 1) {
         $this->categories = array_values($this->categories);
     }
     // - - - - - - - - - - - - - - - -
     // Do Pagination - we can do it after reducing all unneeded $this->categories, not before
     $totalCount = count($this->categories);
     $model->setTotal($totalCount);
     $this->tmpl['pagination'] =& $this->get('pagination');
     $this->categories = array_slice($this->categories, (int) $this->tmpl['pagination']->limitstart, (int) $this->tmpl['pagination']->limit);
     // - - - - - - - - - - - - - - - -
     // Display Image of Categories Description
     /*	if ($this->params->get('image') != -1) {
     			$attribs['align']	= $this->params->get('image_align');
     			$attribs['hspace']	= 6;
     			// Use the static HTML library to build the image tag
     			$this->tmpl['image'] 		= JHtml::_('image', 'images/stories/'.$this->params->get('image'), '', $attribs);
     		}*/
     // ACTION
     $this->tmpl['action'] = $uri->toString();
     //Design
     $this->tmpl['countcategories'] = count($this->categories);
     $this->tmpl['begin'] = array();
     $this->tmpl['end'] = array();
     $this->tmpl['begin'][0] = 0;
     // first
     $this->tmpl['begin'][1] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns']);
     $this->tmpl['end'][0] = $this->tmpl['begin'][1] - 1;
     for ($j = 2; $j < (int) $this->tmpl['categoriescolumns']; $j++) {
         $this->tmpl['begin'][$j] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns'] * $j);
         $this->tmpl['end'][$j - 1] = $this->tmpl['begin'][$j] - 1;
     }
     $this->tmpl['end'][$j - 1] = $this->tmpl['countcategories'] - 1;
     // last
     $this->tmpl['endfloat'] = $this->tmpl['countcategories'] - 1;
     if ($this->tmpl['equalpercentagewidth'] == 1) {
         $fixedWidth = 100 / (int) (int) $this->tmpl['categoriescolumns'];
         $this->tmpl['fixedwidthstyle1'] = 'width:' . $fixedWidth . '%;';
         $this->tmpl['fixedwidthstyle2'] = 'width:' . $fixedWidth . '%;';
     } else {
         $this->tmpl['fixedwidthstyle1'] = '';
         //'margin: 10px;';
         $this->tmpl['fixedwidthstyle2'] = '';
         //'margin: 0px;';
     }
     // ASSIGN
     //$this->assignRef('tmpl',		$this->tmpl);
     $this->assignRef('params', $this->params);
     $this->_prepareDocument();
     if ($display_categories_geotagging == 1) {
         // PARAMS - - - - - - - - - -
         $this->tmplGeo['categorieslng'] = $this->params->get('categories_lng', '');
         $this->tmplGeo['categorieslat'] = $this->params->get('categories_lat', '');
         $this->tmplGeo['categorieszoom'] = $this->params->get('categories_zoom', 2);
         $this->tmplGeo['googlemapsapikey'] = $this->params->get('google_maps_api_key', '');
         $this->tmplGeo['categoriesmapwidth'] = $this->params->get('categories_map_width', '');
         $this->tmplGeo['categoriesmapheight'] = $this->params->get('categorires_map_height', 500);
         // - - - - - - - - - - - - - - -
         // if no lng and lat will be added, Phoca Gallery will try to find it in categories
         if ($this->tmplGeo['categorieslat'] == '' || $this->tmplGeo['categorieslng'] == '') {
             phocagalleryimport('phocagallery.geo.geo');
             $latLng = PhocaGalleryGeo::findLatLngFromCategory($this->categories);
             $this->tmplGeo['categorieslng'] = $latLng['lng'];
             $this->tmplGeo['categorieslat'] = $latLng['lat'];
         }
         $this->assignRef('tmplGeo', $this->tmplGeo);
         parent::display('map');
     } else {
         parent::display($tpl);
     }
 }
Example #11
0
 function themeName()
 {
     // Get an array of all the xml files from teh installation directory
     $path = PhocaGalleryPath::getPath();
     $xmlFiles = JFolder::files($path->image_abs_front, '.xml$', 1, true);
     // If at least one xml file exists
     if (count($xmlFiles) > 0) {
         foreach ($xmlFiles as $file) {
             // Is it a valid joomla installation manifest file?
             $manifest = $this->_isManifest($file);
             if (!is_null($manifest)) {
                 foreach ($manifest->children() as $key => $value) {
                     if ((string) $value->name() == 'name') {
                         return (string) $value;
                     }
                 }
             }
             return false;
         }
         return false;
     } else {
         return false;
     }
 }
 function createfolder()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $folder_permissions = $paramsC->get('folder_permissions', 0755);
     //$folder_permissions = octdec((int)$folder_permissions);
     $path = PhocaGalleryPath::getPath();
     $folderNew = JRequest::getCmd('foldername', '');
     $folderCheck = JRequest::getVar('foldername', null, '', 'string', JREQUEST_ALLOWRAW);
     $parent = JRequest::getVar('folderbase', '', '', 'path');
     $tab = JRequest::getVar('tab', '', '', 'string');
     $field = JRequest::getVar('field');
     $viewBack = JRequest::getVar('viewback', '', '', '');
     $link = '';
     switch ($viewBack) {
         case 'phocagalleryi':
             $link = 'index.php?option=com_phocagallery&view=phocagalleryi&tmpl=component&folder=' . $parent . '&tab=' . (string) $tab . '&field=' . $field;
             break;
         case 'phocagallerym':
             $link = 'index.php?option=com_phocagallery&view=phocagallerym&layout=edit&hidemainmenu=1&tab=' . (string) $tab . '&folder=' . $parent;
             break;
         case 'phocagalleryf':
             $link = 'index.php?option=com_phocagallery&view=phocagalleryf&tmpl=component&folder=' . $parent . '&field=' . $field;
             break;
         default:
             $app->redirect('index.php?option=com_phocagallery', JText::_('COM_PHOCAGALLERY_ERROR_CONTROLLER'));
             break;
     }
     JRequest::setVar('folder', $parent);
     if ($folderCheck !== null && $folderNew !== $folderCheck) {
         $app->redirect($link, JText::_('COM_PHOCAGALLERY_WARNING_DIRNAME'));
     }
     if (strlen($folderNew) > 0) {
         $folder = JPath::clean($path->image_abs . DS . $parent . DS . $folderNew);
         if (!JFolder::exists($folder) && !JFile::exists($folder)) {
             //JFolder::create($path, $folder_permissions );
             switch ((int) $folder_permissions) {
                 case 777:
                     JFolder::create($folder, 0777);
                     break;
                 case 705:
                     JFolder::create($folder, 0705);
                     break;
                 case 666:
                     JFolder::create($folder, 0666);
                     break;
                 case 644:
                     JFolder::create($folder, 0644);
                     break;
                 case 755:
                 default:
                     JFolder::create($folder, 0755);
                     break;
             }
             if (isset($folder)) {
                 $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
                 JFile::write($folder . DS . "index.html", $data);
             }
             $app->redirect($link, JText::_('COM_PHOCAGALLERY_SUCCESS_FOLDER_CREATING'));
         } else {
             $app->redirect($link, JText::_('COM_PHOCAGALLERY_ERROR_FOLDER_CREATING_EXISTS'));
         }
         //JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder);
     }
     $app->redirect($link);
 }
Example #13
0
 function display($tpl = null)
 {
     if (!JRequest::checkToken('request')) {
         $response = array('status' => '0', 'error' => JText::_('JINVALID_TOKEN'));
         echo json_encode($response);
         return;
     }
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $commentValue = $app->input->get('commentValue', '', 'string');
     $commentId = $app->input->get('commentId', 0, 'int');
     // ID of File
     $format = $app->input->get('format', '', 'string');
     $task = $app->input->get('task', '', 'string');
     $view = $app->input->get('view', '', 'string');
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $param['display_comment_img'] = $paramsC->get('display_comment_img', 0);
     if ($task == 'refreshcomment' && ((int) $param['display_comment_img'] == 2 || (int) $param['display_comment_img'] == 3)) {
         $user =& JFactory::getUser();
         //$view 		= JRequest::getVar( 'view', '', 'get', '', JREQUEST_NOTRIM  );
         //$Itemid		= JRequest::getVar( 'Itemid', 0, '', 'int');
         $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
         $access = PhocaGalleryAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels);
         $post['imgid'] = (int) $commentId;
         $post['userid'] = $user->id;
         $post['comment'] = strip_tags($commentValue);
         if ($format != 'json') {
             $msg = JText::_('COM_PHOCAGALLERY_ERROR_WRONG_COMMENT');
             $response = array('status' => '0', 'error' => $msg);
             echo json_encode($response);
             return;
         }
         if ((int) $post['imgid'] < 1) {
             $msg = JText::_('COM_PHOCAGALLERY_ERROR_IMAGE_NOT_EXISTS');
             $response = array('status' => '0', 'error' => $msg);
             echo json_encode($response);
             return;
         }
         $model = $this->getModel();
         $checkUserComment = PhocaGalleryCommentImage::checkUserComment($post['imgid'], $post['userid']);
         // User has already commented this category
         if ($checkUserComment) {
             $msg = JText::_('COM_PHOCAGALLERY_COMMENT_ALREADY_SUBMITTED');
             $response = array('status' => '0', 'error' => '', 'message' => $msg);
             echo json_encode($response);
             return;
         } else {
             if ($access > 0 && $user->id > 0) {
                 if (!$model->comment($post)) {
                     $msg = JText::_('COM_PHOCAGALLERY_ERROR_COMMENTING_IMAGE');
                     $response = array('status' => '0', 'error' => $msg);
                     echo json_encode($response);
                     return;
                 } else {
                     $o = '<div class="pg-cv-comment-img-box-item">';
                     $o .= '<div class="pg-cv-comment-img-box-avatar">';
                     $avatar = PhocaGalleryCommentImage::getUserAvatar($user->id);
                     $this->tmpl['path'] = PhocaGalleryPath::getPath();
                     $img = '<div style="width: 20px; height: 20px;">&nbsp;</div>';
                     if (isset($avatar->avatar) && $avatar->avatar != '') {
                         $pathAvatarAbs = $this->tmpl['path']->avatar_abs . 'thumbs' . DS . 'phoca_thumb_s_' . $avatar->avatar;
                         $pathAvatarRel = $this->tmpl['path']->avatar_rel . 'thumbs/phoca_thumb_s_' . $avatar->avatar;
                         if (JFile::exists($pathAvatarAbs)) {
                             $avSize = getimagesize($pathAvatarAbs);
                             $avRatio = $avSize[0] / $avSize[1];
                             $avHeight = 20;
                             $avWidth = 20 * $avRatio;
                             $img = '<img src="' . JURI::base() . '/' . $pathAvatarRel . '" width="' . $avWidth . '" height="' . $avHeight . '" alt="" />';
                         }
                     }
                     $o .= $img;
                     $o .= '</div>';
                     $o .= '<div class="pg-cv-comment-img-box-comment">' . $user->name . ': ' . $post['comment'] . '</div>';
                     $o .= '<div style="clear:both"></div>';
                     $o .= '</div>';
                     $msg = $o . '<br />' . JText::_('COM_PHOCAGALLERY_SUCCESS_COMMENT_SUBMIT');
                     $response = array('status' => '1', 'error' => '', 'message' => $msg);
                     echo json_encode($response);
                     return;
                 }
             } else {
                 $msg = JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION');
                 $response = array('status' => '0', 'error' => $msg);
                 echo json_encode($response);
                 return;
             }
         }
     } else {
         $msg = JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION');
         $response = array('status' => '0', 'error' => $msg);
         echo json_encode($response);
         return;
     }
 }
Example #14
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();
         }
     }
 }
Example #15
0
 function getFileOriginal($filename, $rel = 0)
 {
     $path = PhocaGalleryPath::getPath();
     if ($rel == 1) {
         return str_replace('//', '/', $path->image_rel . $filename);
     } else {
         return JPath::clean($path->image_abs . $filename);
     }
 }
Example #16
0
 function getPath()
 {
     $instance =& PhocaGalleryPath::getInstance();
     return $instance;
 }
Example #17
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;
 }
Example #18
0
 function multipleupload()
 {
     JResponse::allowCache(false);
     // Chunk Files
     header('Content-type: text/plain; charset=UTF-8');
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // Invalid Token
     JRequest::checkToken('request') or jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 100, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_INVALID_TOKEN'))));
     jimport('joomla.client.helper');
     $app = JFactory::getApplication();
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $user = JFactory::getUser();
     $path = PhocaGalleryPath::getPath();
     $return = $this->input->get('return-url', null, 'base64');
     $format = $this->input->get('format', 'html', 'cmd');
     $viewBack = $this->input->get('viewback', '', 'string');
     $tab = $this->input->get('tab', 0, 'int');
     $catid = $this->input->get('id', '', 'string');
     $rating = $this->input->get('rating', '', 'string');
     $Itemid = $this->input->get('Itemid', 0, 'int');
     $limitStart = $this->input->get('limitstart', 0, 'int');
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $model = $this->getModel('category');
     $catid = (int) $catid;
     // USER RIGHT - UPLOAD - - - - - - - - - - -
     // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
     $rightDisplayUpload = 0;
     $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $catid);
     if (!empty($catAccess)) {
         $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $catAccess->uploaduserid, 2, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     // USER RIGHT - FOLDER - - - - - - - - - - - -
     $rightFolder = '';
     if (isset($catAccess->userfolder)) {
         $rightFolder = $catAccess->userfolder;
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     if ($rightDisplayUpload == 1) {
         if ($rightFolder == '') {
             jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_DEFINED'))));
             return false;
         }
         if (!JFolder::exists($path->image_abs . $rightFolder . DS)) {
             jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_EXISTS'))));
             return false;
         }
         // Check the size of all images by users
         /*	$maxUserImageSize 	= (int)$paramsC->get( 'user_images_max_size', 20971520 );
         			$allFileSize		= PhocaGalleryFileUploadFront::getSizeAllOriginalImages($file, $this->_user->id);
         
         			if ($maxUserImageSize > 0 && (int) $allFileSize > $maxUserImageSize) {
         				$errUploadMsg = JText::_('COM_PHOCAGALLERY_WARNING_USERIMAGES_TOOLARGE');	
         				$app->redirect($redirectUrl, $errUploadMsg);
         				return false;
         			}*/
         // Sending and setting data for common realsingleupload function
         $this->input->set('folder', $rightFolder);
         //Set the right path for uploaded image (category folder included)
         $this->input->set('return-url', base64_encode($return));
         // set return url
         $fileName = PhocaGalleryFileUpload::realMultipleUpload(1);
         if ($fileName != '') {
             // Saving file name into database with relative path
             $fileName = $rightFolder . '/' . strtolower($fileName);
             if (PhocaGalleryControllerCategory::save((int) $catid, $fileName, false, $succeeded, $errUploadMsg, false)) {
                 jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'OK', 'code' => 200, 'message' => JText::_('COM_PHOCAGALERY_SUCCESS') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_IMAGES_UPLOADED'))));
                 return true;
             } else {
                 jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'))));
                 return false;
             }
         }
     } else {
         jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'))));
         return false;
     }
 }
Example #19
0
 function displayBackFolder($size, $rightDisplayKey)
 {
     $fileThumbnail = new JObject();
     // if category is not accessable, display the key in the image:
     $key = '';
     if ((int) $rightDisplayKey == 0) {
         $key = '-key';
     }
     phocagalleryimport('phocagallery.image.image');
     phocagalleryimport('phocagallery.path.path');
     $path =& PhocaGalleryPath::getPath();
     $fileThumbnail->abs = '';
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     if ($paramsC->get('image_background_shadow') != 'None') {
         $fileThumbnail->rel = $path->image_rel_front . 'icon-up-images' . $key . '.png';
     } else {
         $fileThumbnail->rel = $path->image_rel_front . 'icon-up-images' . $key . '.png';
     }
     return $fileThumbnail->rel;
 }
Example #20
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;
 }
Example #21
0
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->folderstate = $this->get('FolderState');
     $this->images = $this->get('Images');
     $this->folders = $this->get('Folders');
     $this->session = JFactory::getSession();
     $this->path = PhocaGalleryPath::getPath();
     // Set Default Value
     $this->form->setValue('published', '', 1);
     $this->form->setValue('approved', '', 1);
     $this->form->setValue('language', '', '*');
     JHTML::stylesheet('media/com_phocagallery/css/administrator/phocagallery.css');
     $params = JComponentHelper::getParams('com_phocagallery');
     $this->tmpl['enablethumbcreation'] = $params->get('enable_thumb_creation', 1);
     $this->tmpl['enablethumbcreationstatus'] = PhocaGalleryRenderAdmin::renderThumbnailCreationStatus((int) $this->tmpl['enablethumbcreation']);
     $this->tmpl['multipleuploadchunk'] = $params->get('multiple_upload_chunk', 0);
     $this->tmpl['large_image_width'] = $params->get('large_image_width', 640);
     $this->tmpl['large_image_height'] = $params->get('large_image_height', 480);
     $this->tmpl['javaboxwidth'] = $params->get('java_box_width', 480);
     $this->tmpl['javaboxheight'] = $params->get('java_box_height', 480);
     $this->tmpl['uploadmaxsize'] = $params->get('upload_maxsize', 3145728);
     $this->tmpl['uploadmaxsizeread'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['uploadmaxsize']);
     $this->tmpl['uploadmaxreswidth'] = $params->get('upload_maxres_width', 3072);
     $this->tmpl['uploadmaxresheight'] = $params->get('upload_maxres_height', 2304);
     $this->tmpl['enablejava'] = $params->get('enable_java', -1);
     $this->tmpl['enablemultiple'] = $params->get('enable_multiple', 0);
     $this->tmpl['multipleuploadmethod'] = $params->get('multiple_upload_method', 1);
     $this->tmpl['multipleresizewidth'] = $params->get('multiple_resize_width', -1);
     $this->tmpl['multipleresizeheight'] = $params->get('multiple_resize_height', -1);
     $this->currentFolder = '';
     if (isset($this->folderstate->folder) && $this->folderstate->folder != '') {
         $this->currentFolder = $this->folderstate->folder;
     }
     // - - - - - - - - - -
     //TABS
     // - - - - - - - - - -
     $this->tmpl['tab'] = JRequest::getVar('tab', '', '', 'string');
     $this->tmpl['displaytabs'] = 0;
     // UPLOAD
     $this->tmpl['currenttab']['upload'] = $this->tmpl['displaytabs'];
     $this->tmpl['displaytabs']++;
     // MULTIPLE UPLOAD
     if ((int) $this->tmpl['enablemultiple'] >= 0) {
         $this->tmpl['currenttab']['multipleupload'] = $this->tmpl['displaytabs'];
         $this->tmpl['displaytabs']++;
     } else {
         $this->tmpl['currenttab']['multipleupload'] = 0;
     }
     // MULTIPLE UPLOAD
     if ($this->tmpl['enablejava'] >= 0) {
         $this->tmpl['currenttab']['javaupload'] = $this->tmpl['displaytabs'];
         $this->tmpl['displaytabs']++;
     } else {
         $this->tmpl['currenttab']['javaupload'] = 0;
     }
     // - - - - - - - - - - -
     // Upload
     // - - - - - - - - - - -
     $sU = new PhocaGalleryFileUploadSingle();
     $sU->returnUrl = 'index.php?option=com_phocagallery&view=phocagallerym&layout=edit&tab=upload&folder=' . $this->currentFolder;
     $sU->tab = 'upload';
     $this->tmpl['su_output'] = $sU->getSingleUploadHTML();
     $this->tmpl['su_url'] = JURI::base() . 'index.php?option=com_phocagallery&task=phocagalleryu.upload&amp;' . $this->session->getName() . '=' . $this->session->getId() . '&amp;' . JSession::getFormToken() . '=1&amp;viewback=phocagallerym&amp;' . 'folder=' . $this->currentFolder . '&amp;tab=upload';
     // - - - - - - - - - - -
     // Multiple Upload
     // - - - - - - - - - - -
     // Get infos from multiple upload
     $muFailed = JRequest::getVar('mufailed', '0', '', 'int');
     $muUploaded = JRequest::getVar('muuploaded', '0', '', 'int');
     $this->tmpl['mu_response_msg'] = $muUploadedMsg = '';
     if ($muUploaded > 0) {
         $muUploadedMsg = JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded;
     }
     if ($muFailed > 0) {
         $muFailedMsg = JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed;
     }
     if ($muFailed > 0 && $muUploaded > 0) {
         $this->tmpl['mu_response_msg'] = '<div class="alert alert-info">' . '<button type="button" class="close" data-dismiss="alert">&times;</button>' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '<br />' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
     } else {
         if ($muFailed > 0 && $muUploaded == 0) {
             $this->tmpl['mu_response_msg'] = '<div class="alert alert-error">' . '<button type="button" class="close" data-dismiss="alert">&times;</button>' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
         } else {
             if ($muFailed == 0 && $muUploaded > 0) {
                 $this->tmpl['mu_response_msg'] = '<div class="alert alert-success">' . '<button type="button" class="close" data-dismiss="alert">&times;</button>' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '</div>';
             } else {
                 $this->tmpl['mu_response_msg'] = '';
             }
         }
     }
     if ((int) $this->tmpl['enablemultiple'] >= 0) {
         PhocaGalleryFileUploadMultiple::renderMultipleUploadLibraries();
         $mU = new PhocaGalleryFileUploadMultiple();
         $mU->frontEnd = 0;
         $mU->method = $this->tmpl['multipleuploadmethod'];
         $mU->url = JURI::base() . 'index.php?option=com_phocagallery&task=phocagalleryu.multipleupload&amp;' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=multipleupload&folder=' . $this->currentFolder;
         $mU->reload = JURI::base() . 'index.php?option=com_phocagallery&view=phocagallerym&layout=edit&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=multipleupload&folder=' . $this->currentFolder;
         $mU->maxFileSize = PhocaGalleryFileUploadMultiple::getMultipleUploadSizeFormat($this->tmpl['uploadmaxsize']);
         $mU->chunkSize = '1mb';
         $mU->imageHeight = $this->tmpl['multipleresizeheight'];
         $mU->imageWidth = $this->tmpl['multipleresizewidth'];
         $mU->imageQuality = 100;
         $mU->renderMultipleUploadJS(0, $this->tmpl['multipleuploadchunk']);
         $this->tmpl['mu_output'] = $mU->getMultipleUploadHTML();
     }
     // - - - - - - - - - - -
     // Java Upload
     // - - - - - - - - - - -
     if ((int) $this->tmpl['enablejava'] >= 0) {
         $jU = new PhocaGalleryFileUploadJava();
         $jU->width = $this->tmpl['javaboxwidth'];
         $jU->height = $this->tmpl['javaboxheight'];
         $jU->resizewidth = $this->tmpl['multipleresizewidth'];
         $jU->resizeheight = $this->tmpl['multipleresizeheight'];
         $jU->uploadmaxsize = $this->tmpl['uploadmaxsize'];
         $jU->returnUrl = JURI::base() . 'index.php?option=com_phocagallery&view=phocagallerym&layout=edit&tab=javaupload&folder=' . $this->currentFolder;
         $jU->url = JURI::base() . htmlspecialchars('index.php?option=com_phocagallery&task=phocagalleryu.javaupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=phocagallerym&tab=javaupload&folder=' . $this->currentFolder);
         $jU->source = JURI::root(true) . '/components/com_phocagallery/assets/jupload/wjhk.jupload.jar';
         $this->tmpl['ju_output'] = $jU->getJavaUploadHTML();
     }
     $this->tmpl['ftp'] = !JClientHelper::hasCredentials('ftp');
     $this->addToolbar();
     parent::display($tpl);
     echo JHTML::_('behavior.keepalive');
 }
Example #22
0
    public function display($tpl = null)
    {
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        $uri = JFactory::getURI();
        $path = PhocaGalleryPath::getPath();
        $this->params = $app->getParams();
        $this->tmplGeo = array();
        $this->tmpl = array();
        $this->itemId = $app->input->get('Itemid', 0, 'int');
        $document = JFactory::getDocument();
        $library = PhocaGalleryLibrary::getLibrary();
        $this->tmpl['action'] = $uri->toString();
        // CSS
        PhocaGalleryRenderFront::renderAllCSS();
        // Params
        $this->tmpl['display_name'] = 1;
        //$this->params->get( 'display_name', 1);
        $this->tmpl['image_categories_size'] = $this->params->get('image_categories_size', 1);
        $display_categories_geotagging = $this->params->get('display_categories_geotagging', 0);
        $display_access_category = $this->params->get('display_access_category', 1);
        $display_empty_categories = $this->params->get('display_empty_categories', 0);
        $hideCatArray = explode(',', trim($this->params->get('hide_categories', '')));
        $showCatArray = explode(',', trim($this->params->get('show_categories', '')));
        $showParentCatArray = explode(',', trim($this->params->get('show_parent_categories', '')));
        $this->tmpl['categoriesimageordering'] = $this->params->get('categories_image_ordering', 10);
        $this->tmpl['categoriesdisplayavatar'] = $this->params->get('categories_display_avatar');
        $this->tmpl['categories_description'] = $this->params->get('categories_description', '');
        $this->tmpl['phocagallery_width'] = $this->params->get('phocagallery_width', '');
        $this->tmpl['phocagallery_center'] = $this->params->get('phocagallery_center', '');
        $this->tmpl['display_rating'] = $this->params->get('display_rating', 0);
        $this->tmpl['categories_box_space'] = $this->params->get('categories_box_space', '');
        $this->tmpl['display_cat_desc_box'] = $this->params->get('display_cat_desc_box', 0);
        $this->tmpl['char_cat_length_name'] = $this->params->get('char_cat_length_name', 9);
        $this->tmpl['categories_mosaic_images'] = $this->params->get('categories_mosaic_images', 0);
        $this->tmpl['diff_thumb_height'] = $this->params->get('diff_thumb_height', 0);
        // L E G A C Y ===
        $this->tmpl['equalpercentagewidth'] = $this->params->get('equal_percentage_width', 1);
        $this->tmpl['categoriesboxwidth'] = $this->params->get('categories_box_width', '33%');
        $this->tmpl['categoriescolumns'] = $this->params->get('categories_columns', 1);
        $this->tmpl['displayrating'] = $this->params->get('display_rating', 0);
        $this->tmpl['display_image_categories'] = $this->params->get('display_image_categories', 1);
        if ($this->tmpl['display_image_categories'] == 1) {
        } else {
            // If legacy no different height, no mosaic
            $this->tmpl['diff_thumb_height'] = 0;
            $this->tmpl['categories_mosaic_images'] = 0;
        }
        // END L E G A C Y ===
        switch ($this->tmpl['image_categories_size']) {
            // medium
            case 1:
                $this->tmpl['picasa_correct_width'] = (int) $this->params->get('medium_image_width', 100);
                $this->tmpl['picasa_correct_height'] = (int) $this->params->get('medium_image_height', 100);
                $this->tmpl['imagewidth'] = (int) $this->params->get('medium_image_width', 100);
                $this->tmpl['imageheight'] = (int) $this->params->get('medium_image_height', 100);
                $this->tmpl['class_suffix'] = 'medium';
                if ($this->tmpl['categories_mosaic_images'] == 1) {
                    $this->tmpl['imagewidth'] = (int) $this->params->get('medium_image_width', 100) * 3;
                    $this->tmpl['imageheight'] = (int) $this->params->get('medium_image_height', 100) * 2;
                }
                break;
                // small
            // small
            case 0:
            default:
                $this->tmpl['picasa_correct_width'] = (int) $this->params->get('small_image_width', 50);
                $this->tmpl['picasa_correct_height'] = (int) $this->params->get('small_image_height', 50);
                $this->tmpl['imagewidth'] = (int) $this->params->get('small_image_width', 50);
                $this->tmpl['imageheight'] = (int) $this->params->get('small_image_height', 50);
                $this->tmpl['class_suffix'] = 'small';
                if ($this->tmpl['categories_mosaic_images'] == 1) {
                    $this->tmpl['imagewidth'] = (int) $this->params->get('small_image_width', 50) * 3;
                    $this->tmpl['imageheight'] = (int) $this->params->get('small_image_height', 50) * 2;
                }
                break;
        }
        $this->tmpl['boxsize'] = PhocaGalleryImage::setBoxSize($this->tmpl, 1);
        if ($this->tmpl['diff_thumb_height'] == 2) {
            $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/masonry/masonry.min.js');
            $document->addCustomTag('<script type="text/javascript">
			window.onload = function() {
			  var wall = new Masonry( document.getElementById(\'pg-msnr-container\'), {
				isFitWidth: true
			  });
			};
			</script>');
        }
        $s = '#phocagallery {' . "\n";
        if ($this->tmpl['phocagallery_center'] != '') {
            $s .= '   margin: 0 auto; text-align: center;' . "\n";
        }
        if ($this->tmpl['phocagallery_width'] != '') {
            $s .= '   width: ' . $this->tmpl['phocagallery_width'] . 'px;' . "\n";
        }
        $s .= '}' . "\n";
        if ($this->tmpl['phocagallery_center'] != '') {
            $s = "\n" . '#pg-msnr-container {' . "\n";
            $s .= '   margin: 0 auto;' . "\n";
            $s .= '}' . "\n";
        }
        $s .= '.pg-csv-box {' . "\n";
        $s .= '   height: ' . $this->tmpl['boxsize']['height'] . 'px;' . "\n";
        $s .= '   width: ' . $this->tmpl['boxsize']['width'] . 'px;' . "\n";
        $s .= '}' . "\n";
        $s .= '.pg-csv-box-img {' . "\n";
        $s .= '   height: ' . $this->tmpl['imageheight'] . 'px;' . "\n";
        $s .= '   width: ' . $this->tmpl['imagewidth'] . 'px;' . "\n";
        $s .= '}' . "\n";
        $document->addCustomTag('<style type="text/css">' . $s . '</style>');
        // Image next to Category in Categories View is ordered by Random as default
        $categoriesImageOrdering = PhocaGalleryOrdering::getOrderingString($this->tmpl['categoriesimageordering']);
        // MODEL
        $model = $this->getModel();
        $this->tmpl['ordering'] = $model->getOrdering();
        $this->categories = $this->get('data');
        // Add link and unset the categories which user cannot see (if it is enabled in params)
        // If it will be unset while access view, we must sort the keys from category array - ACCESS
        $unSet = 0;
        foreach ($this->categories as $key => $item) {
            // Unset empty categories if it is set
            if ($display_empty_categories == 0) {
                if ($this->categories[$key]->numlinks < 1) {
                    unset($this->categories[$key]);
                    $unSet = 1;
                    continue;
                }
            }
            // Set only selected category ID
            if (!empty($showCatArray[0]) && is_array($showCatArray)) {
                $unSetHCA = 0;
                foreach ($showCatArray as $valueHCA) {
                    if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                        $unSetHCA = 0;
                        $unSet = 0;
                        break;
                    } else {
                        $unSetHCA = 1;
                        $unSet = 1;
                    }
                }
                if ($unSetHCA == 1) {
                    unset($this->categories[$key]);
                    continue;
                }
            }
            // Unset hidden category
            if (!empty($hideCatArray) && is_array($hideCatArray)) {
                $unSetHCA = 0;
                foreach ($hideCatArray as $valueHCA) {
                    if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                        unset($this->categories[$key]);
                        $unSet = 1;
                        $unSetHCA = 1;
                        break;
                    }
                }
                if ($unSetHCA == 1) {
                    continue;
                }
            }
            // Unset not set parent categories - only categories which have specific parent id will be displayed
            if (!empty($showParentCatArray[0]) && is_array($showParentCatArray)) {
                $unSetPHCA = 0;
                foreach ($showParentCatArray as $valuePHCA) {
                    if ((int) trim($valuePHCA) == $this->categories[$key]->parent_id) {
                        $unSetPHCA = 0;
                        //$unSet  	= 0;
                        break;
                    } else {
                        $unSetPHCA = 1;
                        $unSet = 1;
                    }
                }
                if ($unSetPHCA == 1) {
                    unset($this->categories[$key]);
                    continue;
                }
            }
            // Link
            $this->categories[$key]->link = PhocaGalleryRoute::getCategoryRoute($item->id, $item->alias);
            // USER RIGHT - ACCESS - - - - -
            // First Check - check if we can display category
            $rightDisplay = 1;
            if (!empty($this->categories[$key])) {
                $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->getAuthorisedViewLevels(), $user->get('id', 0), $display_access_category);
            }
            // Second Check - if we can display hidden category, set Key icon for them
            //                if we don't have access right to see them
            // Display Key Icon (in case we want to display unaccessable categories in list view)
            $rightDisplayKey = 1;
            if ($display_access_category == 1) {
                // we simulate that we want not to display unaccessable categories
                // so if we get rightDisplayKey = 0 then the key will be displayed
                if (!empty($this->categories[$key])) {
                    $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
                    // 0 - simulation
                }
            }
            // Is Ext Image Album?
            $extCategory = PhocaGalleryImage::isExtImage($this->categories[$key]->extid, $this->categories[$key]->extfbcatid);
            // DISPLAY AVATAR, IMAGE(ordered), IMAGE(not ordered, not recursive) OR FOLDER ICON
            $displayAvatar = 0;
            if ($this->tmpl['categoriesdisplayavatar'] == 1 && isset($this->categories[$key]->avatar) && $this->categories[$key]->avatar != '' && $this->categories[$key]->avatarapproved == 1 && $this->categories[$key]->avatarpublished == 1) {
                $sizeString = PhocaGalleryImageFront::getSizeString($this->tmpl['image_categories_size']);
                $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
                $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
                if (JFile::exists($pathAvatarAbs)) {
                    $this->categories[$key]->linkthumbnailpath = $pathAvatarRel;
                    $displayAvatar = 1;
                }
            }
            if ($displayAvatar == 0) {
                if ($extCategory) {
                    if ($this->tmpl['categories_mosaic_images'] == 1) {
                        if ($this->tmpl['categoriesimageordering'] == 10) {
                            // Special cannot be used in this case:
                            $categoriesImageOrdering = 1;
                            // set to default ordering
                        }
                        $this->categories[$key]->filenames = PhocaGalleryImageFront::getCategoryImages($this->categories[$key]->id, $categoriesImageOrdering);
                        $this->categories[$key]->mosaic = PhocaGalleryImageFront::renderMosaic($this->categories[$key]->filenames, $this->tmpl['image_categories_size'], 1, $this->tmpl['picasa_correct_width'], $this->tmpl['picasa_correct_height']);
                    } else {
                        if ($this->tmpl['categoriesimageordering'] != 10) {
                            $imagePic = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering, 1);
                            if ($rightDisplayKey == 0) {
                                $imagePic = new StdClass();
                                $imagePic->exts = '';
                                $imagePic->extm = '';
                                $imagePic->extw = '';
                                $imagePic->exth = '';
                            }
                            $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($imagePic->exts, $imagePic->extm, $imagePic->extw, $imagePic->exth, $this->tmpl['image_categories_size'], $rightDisplayKey);
                            $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                            $this->categories[$key]->extw = $fileThumbnail->extw;
                            $this->categories[$key]->exth = $fileThumbnail->exth;
                            $this->categories[$key]->extpic = $fileThumbnail->extpic;
                        } else {
                            $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($this->categories[$key]->exts, $this->categories[$key]->extm, $this->categories[$key]->extw, $this->categories[$key]->exth, $this->tmpl['image_categories_size'], $rightDisplayKey);
                            $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                            $this->categories[$key]->extw = $fileThumbnail->extw;
                            $this->categories[$key]->exth = $fileThumbnail->exth;
                            $this->categories[$key]->extpic = $fileThumbnail->extpic;
                        }
                    }
                } else {
                    if ($this->tmpl['categories_mosaic_images'] == 1) {
                        if ($this->tmpl['categoriesimageordering'] == 10) {
                            // Special cannot be used in this case:
                            $categoriesImageOrdering = 1;
                            // set to default ordering
                        }
                        $this->categories[$key]->filenames = PhocaGalleryImageFront::getCategoryImages($this->categories[$key]->id, $categoriesImageOrdering);
                        $this->categories[$key]->mosaic = PhocaGalleryImageFront::renderMosaic($this->categories[$key]->filenames, $this->tmpl['image_categories_size']);
                    } else {
                        // Standard Internal Image
                        if ($this->tmpl['categoriesimageordering'] != 10) {
                            $this->categories[$key]->filename = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering);
                        }
                        $fileThumbnail = PhocaGalleryImageFront::displayCategoriesImageOrFolder($this->categories[$key]->filename, $this->tmpl['image_categories_size'], $rightDisplayKey);
                        $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                    }
                }
            }
            if ($rightDisplay == 0) {
                unset($this->categories[$key]);
                $unSet = 1;
            }
            // - - - - - - - - - - - - - - -
        }
        // ACCESS - - - - - -
        // In case we unset some category from the list, we must sort the array new
        if ($unSet == 1) {
            $this->categories = array_values($this->categories);
        }
        // - - - - - - - - - - - - - - - -
        // Do Pagination - we can do it after reducing all unneeded $this->categories, not before
        $totalCount = count($this->categories);
        $model->setTotal($totalCount);
        $this->tmpl['pagination'] = $this->get('pagination');
        $this->categories = array_slice($this->categories, (int) $this->tmpl['pagination']->limitstart, (int) $this->tmpl['pagination']->limit);
        // - - - - - - - - - - - - - - - -
        $this->tmpl['ems'] = '';
        // L E G A C Y ===
        $this->tmpl['countcategories'] = count($this->categories);
        $this->tmpl['begin'] = array();
        $this->tmpl['end'] = array();
        $this->tmpl['begin'][0] = 0;
        // first
        $this->tmpl['begin'][1] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns']);
        $this->tmpl['end'][0] = $this->tmpl['begin'][1] - 1;
        for ($j = 2; $j < (int) $this->tmpl['categoriescolumns']; $j++) {
            $this->tmpl['begin'][$j] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns'] * $j);
            $this->tmpl['end'][$j - 1] = $this->tmpl['begin'][$j] - 1;
        }
        $this->tmpl['end'][$j - 1] = $this->tmpl['countcategories'] - 1;
        // last
        $this->tmpl['endfloat'] = $this->tmpl['countcategories'] - 1;
        if ($this->tmpl['equalpercentagewidth'] == 1) {
            $fixedWidth = 100 / (int) (int) $this->tmpl['categoriescolumns'];
            $this->tmpl['fixedwidthstyle1'] = 'width:' . $fixedWidth . '%;';
            $this->tmpl['fixedwidthstyle2'] = 'width:' . $fixedWidth . '%;';
        } else {
            $this->tmpl['fixedwidthstyle1'] = '';
            //'margin: 10px;';
            $this->tmpl['fixedwidthstyle2'] = '';
            //'margin: 0px;';
        }
        // END L E G A C Y ===
        $this->_prepareDocument();
        if ($display_categories_geotagging == 1) {
            // Params
            $this->tmplGeo['categorieslng'] = $this->params->get('categories_lng', '');
            $this->tmplGeo['categorieslat'] = $this->params->get('categories_lat', '');
            $this->tmplGeo['categorieszoom'] = $this->params->get('categories_zoom', 2);
            $this->tmplGeo['googlemapsapikey'] = $this->params->get('google_maps_api_key', '');
            $this->tmplGeo['categoriesmapwidth'] = $this->params->get('categories_map_width', '');
            $this->tmplGeo['categoriesmapheight'] = $this->params->get('categorires_map_height', 500);
            // If no lng and lat will be added, Phoca Gallery will try to find it in categories
            if ($this->tmplGeo['categorieslat'] == '' || $this->tmplGeo['categorieslng'] == '') {
                phocagalleryimport('phocagallery.geo.geo');
                $latLng = PhocaGalleryGeo::findLatLngFromCategory($this->categories);
                $this->tmplGeo['categorieslng'] = $latLng['lng'];
                $this->tmplGeo['categorieslat'] = $latLng['lat'];
            }
            $this->assignRef('tmplGeo', $this->tmplGeo);
            parent::display('map');
        } else {
            parent::display($tpl);
        }
    }
Example #23
0
 public static function realJavaUpload($frontEnd = 0)
 {
     $app = JFactory::getApplication();
     JRequest::checkToken('request') or exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_INVALID_TOKEN'));
     //	$files 	= JRequest::getVar( 'Filedata', '', 'files', 'array' );
     $path = PhocaGalleryPath::getPath();
     $folder = JRequest::getVar('folder', '', '', 'path');
     if (isset($folder) && $folder != '') {
         $folder = $folder . DS;
     }
     $errUploadMsg = '';
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     foreach ($_FILES as $fileValue => $file) {
         echo 'File key: ' . $fileValue . "\n";
         foreach ($file as $item => $val) {
             echo ' Data received: ' . $item . '=>' . $val . "\n";
         }
         // Make the filename safe
         if (isset($file['name'])) {
             $file['name'] = JFile::makeSafe($file['name']);
         }
         if (isset($file['name'])) {
             $filepath = JPath::clean($path->image_abs . $folder . strtolower($file['name']));
             if (!PhocaGalleryFileUpload::canUpload($file, $errUploadMsg, $frontEnd)) {
                 exit('ERROR: ' . JText::_($errUploadMsg));
             }
             if (JFile::exists($filepath)) {
                 exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'));
             }
             if (!JFile::upload($file['tmp_name'], $filepath)) {
                 exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'));
             }
             if ((int) $frontEnd > 0) {
                 return $file['name'];
             }
             exit('SUCCESS');
         } else {
             exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'));
         }
     }
     return true;
 }
Example #24
0
    function display($tpl = null)
    {
        $app = JFactory::getApplication();
        // Don't load all the framework if nonsense
        $id = $app->input->get('id', 0, 'int');
        $this->tagId = $app->input->get('tagid', 0, 'int');
        if ($id < 1 && $this->tagId < 1) {
            JError::raiseError(404, JText::_("COM_PHOCAGALLERY_CATEGORY_IS_UNPUBLISHED"));
            exit;
        }
        $document = JFactory::getDocument();
        $uri = JFactory::getURI();
        $menus = $app->getMenu();
        $menu = $menus->getActive();
        $this->params = $app->getParams();
        $this->tmpl['user'] = JFactory::getUser();
        $this->tmpl['action'] = $uri->toString();
        $this->tmpl['path'] = PhocaGalleryPath::getPath();
        $limitStart = $app->input->get('limitstart', 0, 'int');
        $this->tmpl['tab'] = $app->input->get('tab', 0, 'int');
        $this->tmpl['pl'] = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
        $this->tmpl['icon_path'] = 'media/com_phocagallery/images/';
        $this->tmpl['plcat'] = 'index.php?option=com_phocagallery&view=category';
        $this->itemId = $app->input->get('Itemid', 0, 'int');
        $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
        $access = PhocaGalleryAccess::isAccess($this->tmpl['user']->getAuthorisedViewLevels(), $neededAccessLevels);
        // CSS
        PhocaGalleryRenderFront::renderAllCSS();
        // LIBRARY
        $library = PhocaGalleryLibrary::getLibrary();
        $libraries['pg-group-shadowbox'] = $library->getLibrary('pg-group-shadowbox');
        $libraries['pg-group-highslide'] = $library->getLibrary('pg-group-highslide');
        $libraries['pg-group-jak'] = $library->getLibrary('pg-group-jak');
        // PARAMS
        $this->tmpl['image_categories_size_cv'] = $this->params->get('image_categories_size_cv', 1);
        $this->tmpl['display_cat_name_title'] = $this->params->get('display_cat_name_title', 1);
        $this->tmpl['display_categories_cv'] = $this->params->get('display_categories_cv', 0);
        $this->tmpl['switch_image'] = $this->params->get('switch_image', 0);
        $this->tmpl['switch_height'] = $this->params->get('switch_height', 480);
        $this->tmpl['switch_width'] = $this->params->get('switch_width', 640);
        $this->tmpl['switch_fixed_size'] = $this->params->get('switch_fixed_size', 0);
        $this->tmpl['show_page_heading'] = $this->params->get('show_page_heading', 1);
        $this->tmpl['phocagallery_width'] = $this->params->get('phocagallery_width', '');
        $this->tmpl['phocagallery_center'] = $this->params->get('phocagallery_center', '');
        $this->tmpl['imagewidth'] = $this->params->get('medium_image_width', 100);
        $this->tmpl['imageheight'] = $this->params->get('medium_image_height', 100);
        $this->tmpl['picasa_correct_width_m'] = (int) $this->params->get('medium_image_width', 100);
        $this->tmpl['picasa_correct_height_m'] = (int) $this->params->get('medium_image_height', 100);
        $this->tmpl['picasa_correct_width_s'] = (int) $this->params->get('small_image_width', 50);
        $this->tmpl['picasa_correct_height_s'] = (int) $this->params->get('small_image_height', 50);
        $this->tmpl['picasa_correct_width_l'] = (int) $this->params->get('large_image_width', 640);
        $this->tmpl['picasa_correct_height_l'] = (int) $this->params->get('large_image_height', 480);
        $this->tmpl['category_box_space'] = $this->params->get('category_box_space', 0);
        $this->tmpl['detail_window'] = $this->params->get('detail_window', 0);
        $this->tmpl['display_name'] = $this->params->get('display_name', 1);
        $this->tmpl['display_rating'] = $this->params->get('display_rating', 0);
        $this->tmpl['display_rating_img'] = $this->params->get('display_rating_img', 0);
        $this->tmpl['display_comment'] = $this->params->get('display_comment', 0);
        $this->tmpl['display_comment_img'] = $this->params->get('display_comment_img', 0);
        $this->tmpl['display_subcategory'] = $this->params->get('display_subcategory', 1);
        $this->tmpl['display_icon_detail'] = $this->params->get('display_icon_detail', 1);
        $this->tmpl['display_icon_download'] = $this->params->get('display_icon_download', 2);
        $this->tmpl['display_icon_vm'] = $this->params->get('display_icon_vm', 0);
        $this->tmpl['display_img_desc_box'] = $this->params->get('display_img_desc_box', 0);
        $this->tmpl['diff_thumb_height'] = $this->params->get('diff_thumb_height', 0);
        $this->tmpl['overlib_attributes'] = $this->params->get('overlib_attributes', "BELOW, RIGHT, CSSCLASS, TEXTFONTCLASS, 'fontPhocaClass', FGCLASS, 'fgPhocaClass', BGCLASS, 'bgPhocaClass', CAPTIONFONTCLASS,'capfontPhocaClass', CLOSEFONTCLASS, 'capfontclosePhocaClass'");
        // Switch image JS
        $this->tmpl['basic_image'] = '';
        if ($this->tmpl['switch_image'] == 1) {
            $this->tmpl['wait_image'] = $this->tmpl['path']->image_rel_front_full . 'icon-switch.gif';
            $this->tmpl['basic_image'] = $this->tmpl['path']->image_rel_front_full . 'phoca_thumb_l_no_image.png';
            $document->addCustomTag(PhocaGalleryRenderFront::switchImage($this->tmpl['wait_image']));
            $basic_imageSelected = 0;
            // we have not selected the basic image yet
        }
        $display_cat_name_breadcrumbs = $this->params->get('display_cat_name_breadcrumbs', 1);
        $popup_width = $this->params->get('front_modal_box_width', 680);
        $popup_height = $this->params->get('front_modal_box_height', 560);
        $this->tmpl['maxuploadchar'] = $this->params->get('max_upload_char', 1000);
        $this->tmpl['maxcommentchar'] = $this->params->get('max_comment_char', 1000);
        $this->tmpl['maxcreatecatchar'] = $this->params->get('max_create_cat_char', 1000);
        $this->tmpl['commentwidth'] = $this->params->get('comment_width', 500);
        $this->tmpl['displaycategorygeotagging'] = $this->params->get('display_category_geotagging', 0);
        $this->tmpl['displaycategorystatistics'] = $this->params->get('display_category_statistics', 0);
        // Used for Highslide JS (only image)
        $this->tmpl['displaydescriptiondetail'] = $this->params->get('display_description_detail', 0);
        $this->tmpl['display_title_description'] = $this->params->get('display_title_description', 0);
        $this->tmpl['charlengthname'] = $this->params->get('char_length_name', 15);
        $this->tmpl['char_cat_length_name'] = $this->params->get('char_cat_length_name', 9);
        $this->tmpl['display_icon_geo'] = $this->params->get('display_icon_geotagging', 0);
        // Check the category
        $this->tmpl['display_icon_geoimage'] = $this->params->get('display_icon_geotagging', 0);
        // Check the image
        $this->tmpl['display_camera_info'] = $this->params->get('display_camera_info', 0);
        // PARAMS - Upload
        $this->tmpl['multipleuploadchunk'] = $this->params->get('multiple_upload_chunk', 0);
        $this->tmpl['displaytitleupload'] = $this->params->get('display_title_upload', 0);
        $this->tmpl['displaydescupload'] = $this->params->get('display_description_upload', 0);
        $this->tmpl['enablejava'] = $this->params->get('enable_java', -1);
        $this->tmpl['enablemultiple'] = $this->params->get('enable_multiple', 0);
        $this->tmpl['multipleuploadmethod'] = $this->params->get('multiple_upload_method', 1);
        $this->tmpl['multipleresizewidth'] = $this->params->get('multiple_resize_width', -1);
        $this->tmpl['multipleresizeheight'] = $this->params->get('multiple_resize_height', -1);
        $this->tmpl['javaboxwidth'] = $this->params->get('java_box_width', 480);
        $this->tmpl['javaboxheight'] = $this->params->get('java_box_height', 480);
        $this->tmpl['large_image_width'] = $this->params->get('large_image_width', 640);
        $this->tmpl['large_image_height'] = $this->params->get('large_image_height', 640);
        $this->tmpl['uploadmaxsize'] = $this->params->get('upload_maxsize', 3145728);
        $this->tmpl['uploadmaxsizeread'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['uploadmaxsize']);
        $this->tmpl['uploadmaxreswidth'] = $this->params->get('upload_maxres_width', 3072);
        $this->tmpl['uploadmaxresheight'] = $this->params->get('upload_maxres_height', 2304);
        $display_description_detail = $this->params->get('display_description_detail', 0);
        $description_detail_height = $this->params->get('description_detail_height', 16);
        $detail_buttons = $this->params->get('detail_buttons', 1);
        //$modal_box_overlay_color 				= $this->params->get( 'modal_box_overlay_color', '#000000' );
        $modal_box_overlay_opacity = $this->params->get('modal_box_overlay_opacity', 0.3);
        //$modal_box_border_color 				= $this->params->get( 'modal_box_border_color', '#6b6b6b' );
        //$modal_box_border_width 				= $this->params->get( 'modal_box_border_width', '2' );
        $this->tmpl['enablecooliris'] = $this->params->get('enable_cooliris', 0);
        $highslide_class = $this->params->get('highslide_class', 'rounded-white');
        $highslide_opacity = $this->params->get('highslide_opacity', 0);
        $highslide_outline_type = $this->params->get('highslide_outline_type', 'rounded-white');
        $highslide_fullimg = $this->params->get('highslide_fullimg', 0);
        $highslide_slideshow = $this->params->get('highslide_slideshow', 1);
        $highslide_close_button = $this->params->get('highslide_close_button', 0);
        $this->tmpl['jakslideshowdelay'] = $this->params->get('jak_slideshow_delay', 5);
        $this->tmpl['jakorientation'] = $this->params->get('jak_orientation', 'none');
        $this->tmpl['jakdescription'] = $this->params->get('jak_description', 1);
        $this->tmpl['jakdescriptionheight'] = $this->params->get('jak_description_height', 0);
        $this->tmpl['categoryimageordering'] = $this->params->get('category_image_ordering', 10);
        $this->tmpl['externalcommentsystem'] = $this->params->get('external_comment_system', 0);
        $display_subcat_page_cv = $this->params->get('display_subcat_page_cv', 0);
        $this->tmpl['display_back_button_cv'] = $this->params->get('display_back_button_cv', 1);
        $this->tmpl['display_categories_back_button_cv'] = $this->params->get('display_categories_back_button_cv', 1);
        $medium_image_width_cv = (int) $this->params->get('medium_image_width', 100) + 18;
        $medium_image_height_cv = (int) $this->params->get('medium_image_height', 100) + 18;
        $small_image_width_cv = (int) $this->params->get('small_image_width', 50) + 18;
        $small_image_height_cv = (int) $this->params->get('small_image_height', 50) + 18;
        $this->tmpl['imagetypecv'] = $this->tmpl['image_categories_size_cv'];
        $this->tmpl['overlibimagerate'] = (int) $this->params->get('overlib_image_rate', '');
        $this->tmpl['gallerymetakey'] = $this->params->get('gallery_metakey', '');
        $this->tmpl['gallerymetadesc'] = $this->params->get('gallery_metadesc', '');
        $this->tmpl['altvalue'] = $this->params->get('alt_value', 1);
        $paramsFb = PhocaGalleryFbSystem::getCommentsParams($this->params->get('fb_comment_user_id', ''));
        // Facebook
        $this->tmpl['fb_comment_app_id'] = isset($paramsFb['fb_comment_app_id']) ? $paramsFb['fb_comment_app_id'] : '';
        $this->tmpl['fb_comment_width'] = isset($paramsFb['fb_comment_width']) ? $paramsFb['fb_comment_width'] : 550;
        $this->tmpl['fb_comment_lang'] = isset($paramsFb['fb_comment_lang']) ? $paramsFb['fb_comment_lang'] : 'en_US';
        $this->tmpl['fb_comment_count'] = isset($paramsFb['fb_comment_count']) ? $paramsFb['fb_comment_count'] : '';
        $this->tmpl['enable_direct_subcat'] = $this->params->get('enable_direct_subcat', 0);
        $this->tmpl['display_comment_nopup'] = $this->params->get('display_comment_nopup', 0);
        $this->tmpl['boxplus_theme'] = $this->params->get('boxplus_theme', 'lightsquare');
        $this->tmpl['boxplus_bautocenter'] = (int) $this->params->get('boxplus_bautocenter', 1);
        $this->tmpl['boxplus_autofit'] = (int) $this->params->get('boxplus_autofit', 1);
        $this->tmpl['boxplus_slideshow'] = (int) $this->params->get('boxplus_slideshow', 0);
        $this->tmpl['boxplus_loop'] = (int) $this->params->get('boxplus_loop', 0);
        $this->tmpl['boxplus_captions'] = $this->params->get('boxplus_captions', 'bottom');
        $this->tmpl['boxplus_thumbs'] = $this->params->get('boxplus_thumbs', 'inside');
        $this->tmpl['boxplus_duration'] = (int) $this->params->get('boxplus_duration', 250);
        $this->tmpl['boxplus_transition'] = $this->params->get('boxplus_transition', 'linear');
        $this->tmpl['boxplus_contextmenu'] = (int) $this->params->get('boxplus_contextmenu', 1);
        $this->tmpl['enablecustomcss'] = $this->params->get('enable_custom_css', 0);
        $this->tmpl['customcss'] = $this->params->get('custom_css', '');
        $this->tmpl['display_tags_links'] = $this->params->get('display_tags_links', 0);
        $this->tmpl['displaying_tags_true'] = 0;
        //No tag found, if yes, the box will be resized
        $this->tmpl['ytbupload'] = $this->params->get('youtube_upload', 0);
        $this->tmpl['ytb_display'] = $this->params->get('ytb_display', 0);
        $this->tmpl['enable_multibox'] = $this->params->get('enable_multibox', 0);
        $this->tmpl['multibox_height'] = (int) $this->params->get('multibox_height', 560);
        $this->tmpl['multibox_width'] = (int) $this->params->get('multibox_width', 980);
        // CSS
        /*switch($this->tmpl['image_categories_size']) {
        			// medium
        			case 1:
        				$this->tmpl['picasa_correct_width']		= (int)$this->params->get( 'medium_image_width', 100 );	
        				$this->tmpl['picasa_correct_height']	= (int)$this->params->get( 'medium_image_height', 100 );
        				$this->tmpl['imagewidth']				= (int)$this->params->get( 'medium_image_width', 100 );	
        				$this->tmpl['imageheight']				= (int)$this->params->get( 'medium_image_height', 100 );
        				$this->tmpl['class_suffix']				= 'medium';
        			break;
        			
        			// small
        			case 0:
        			default:
        				$this->tmpl['picasa_correct_width']		= (int)$this->params->get( 'small_image_width', 50 );	
        				$this->tmpl['picasa_correct_height']	= (int)$this->params->get( 'small_image_height', 50 );
        				$this->tmpl['imagewidth']				= (int)$this->params->get( 'small_image_width', 50 );
        				$this->tmpl['imageheight'] 				= (int)$this->params->get( 'small_image_height', 50 );
        				$this->tmpl['class_suffix']				= 'small';
        			break;
        		}*/
        // CSS Specific
        /*$s = '.pg-cv {'."\n";
        		if ($this->tmpl['phocagallerywidth'] != '') {
        			$s .= '   margin: auto;'."\n";
        			$s .= '   width: '.$this->tmpl['phocagallerywidth'].'px;'."\n";
        		}
        		$s .= '}'."\n";
        
        		$s .= '.pg-cv-box {'."\n";
        		$s .= '   height: '.$this->tmpl['boxsize']['height'].'px;'."\n";
        		$s .= '   width: '.$this->tmpl['boxsize']['width'].'px;"'."\n";
        		$s .= '}'."\n";
        		
        		$s .= '.pg-cv-box-img {'."\n";
        		$s .= '   height: '.$this->tmpl['imageheight'].'px;'."\n";
        		$s .= '   width: '.$this->tmpl['imagewidth'].'px;"'."\n";
        		$s .= '}'."\n";
        		
        		$document->addCustomTag('<style type="text/css">'.$s.'</style>');*/
        // Correct Height
        // Description detail height
        if ($display_description_detail == 1) {
            $popup_height = $popup_height + $description_detail_height;
        }
        // Detail buttons in detail view
        if ($detail_buttons != 1) {
            $popup_height = $popup_height - 45;
        }
        if ($this->tmpl['display_rating_img'] == 1) {
            $popup_height = $popup_height + 35;
        }
        // Youtube video without padding, margin
        if ($this->tmpl['detail_window'] != 7 && $this->tmpl['ytb_display'] == 1) {
            $document->addCustomTag("<style type=\"text/css\"> \n" . " #boxplus .boxplus-dialog .boxplus-controlsclose {\n\t\t\t\ttop: -15px !important;\n\t\t\t\tright: -15px !important;\n\t\t\t\tmargin:0px 0 0 0 !important;\n\t\t\t} \n" . " </style> \n");
            $popup_width = PhocaGallerySettings::getAdvancedSettings('youtubewidth');
            $popup_height = PhocaGallerySettings::getAdvancedSettings('youtubeheight');
        }
        // Multibox
        if ($this->tmpl['enable_multibox'] == 1) {
            $popup_width = $this->tmpl['multibox_width'];
            $popup_height = $this->tmpl['multibox_height'];
        }
        if ($this->tmpl['detail_window'] == 4) {
            $popup_height = $popup_height + 12;
        }
        // Comment Image JS
        if ((int) $this->tmpl['display_comment_img'] == 2 || (int) $this->tmpl['display_comment_img'] == 3) {
            PhocaGalleryCommentImage::renderCommentImageJS();
        }
        // Rate Image JS
        if ((int) $this->tmpl['display_rating_img'] == 2) {
            PhocaGalleryRateImage::renderRateImgJS();
        }
        // =======================================================
        // DIFFERENT METHODS OF DISPLAYING THE DETAIL VIEW
        // =======================================================
        // MODAL - will be displayed in case e.g. highslide or shadowbox too, because in there are more links
        JHtml::_('behavior.modal', 'a.pg-modal-button');
        $btn = new PhocaGalleryRenderDetailWindow();
        $btn->popupWidth = $popup_width;
        $btn->popupHeight = $popup_height;
        $btn->mbOverlayOpacity = $modal_box_overlay_opacity;
        $btn->sbSlideshowDelay = $this->params->get('sb_slideshow_delay', 5);
        $btn->sbSettings = $this->params->get('sb_settings', "overlayColor: '#000',overlayOpacity:0.5,resizeDuration:0.35,displayCounter:true,displayNav:true");
        $btn->hsSlideshow = $highslide_slideshow;
        $btn->hsClass = $highslide_class;
        $btn->hsOutlineType = $highslide_outline_type;
        $btn->hsOpacity = $highslide_opacity;
        $btn->hsCloseButton = $highslide_close_button;
        $btn->hsFullImg = $highslide_fullimg;
        $btn->jakDescHeight = $this->tmpl['jakdescriptionheight'];
        $btn->jakDescWidth = '';
        $btn->jakOrientation = $this->tmpl['jakorientation'];
        $btn->jakSlideshowDelay = $this->tmpl['jakslideshowdelay'];
        $btn->bpTheme = $this->tmpl['boxplus_theme'];
        $btn->bpBautocenter = (int) $this->tmpl['boxplus_bautocenter'];
        $btn->bpAutofit = (int) $this->tmpl['boxplus_autofit'];
        $btn->bpSlideshow = (int) $this->tmpl['boxplus_slideshow'];
        $btn->bpLoop = (int) $this->tmpl['boxplus_loop'];
        $btn->bpCaptions = $this->tmpl['boxplus_captions'];
        $btn->bpThumbs = $this->tmpl['boxplus_thumbs'];
        $btn->bpDuration = (int) $this->tmpl['boxplus_duration'];
        $btn->bpTransition = $this->tmpl['boxplus_transition'];
        $btn->bpContextmenu = (int) $this->tmpl['boxplus_contextmenu'];
        $btn->setButtons($this->tmpl['detail_window'], $libraries, $library);
        $this->button = $btn->getB1();
        $this->button2 = $btn->getB2();
        $this->buttonother = $btn->getB3();
        $this->tmpl['highslideonclick'] = '';
        // for using with highslide
        if (isset($this->button->highslideonclick)) {
            $this->tmpl['highslideonclick'] = $this->button->highslideonclick;
            // TODO
        }
        $this->tmpl['highslideonclick2'] = '';
        if (isset($this->button->highslideonclick2)) {
            $this->tmpl['highslideonclick2'] = $this->button->highslideonclick2;
            // TODO
        }
        $folderButton = new JObject();
        $folderButton->set('name', 'image');
        $folderButton->set('options', "");
        // End open window parameters
        // ==================================================================
        // Information about current category
        $this->category = $this->get('category');
        // Cooliris (Piclens)
        $this->tmpl['start_cooliris'] = 0;
        if ($this->tmpl['enablecooliris'] == 1) {
            $this->tmpl['start_cooliris'] = $this->params->get('start_cooliris', 0);
            // CSS - PicLens START
            $document->addCustomTag(PhocaGalleryRenderFront::renderPicLens($this->category->id));
        }
        // PARAMS - Pagination and subcategories on other sites
        // Subcategories will be displayed only on first page if pagination will be used
        $display_subcat_page = $this->params->get('display_subcat_page', 0);
        // On the first site subcategories will be displayed always
        $get['start'] = $app->input->get('limitstart', '', 'string');
        if ($display_subcat_page == 2) {
            $display_subcat_page = 0;
            // Nowhere
        } else {
            if ($display_subcat_page == 0 && $get['start'] > 0) {
                $display_subcat_page = 0;
                //in case: second page and param=0
            } else {
                $display_subcat_page = 1;
                //in case:first page or param==1
            }
        }
        // Categories View in Category View
        if ($display_subcat_page_cv == 2) {
            $display_subcat_page_cv = 0;
            // Nowhere
        } else {
            if ($display_subcat_page_cv == 0 && $get['start'] > 0) {
                $display_subcat_page_cv = 0;
                //in case: second page and param=0
            } else {
                $display_subcat_page_cv = 1;
                //in case:first page or param==1
            }
        }
        // PARAMS - Display Back Buttons
        $display_back_button = $this->params->get('display_back_button', 1);
        $display_categories_back_button = $this->params->get('display_categories_back_button', 1);
        // PARAMS - Access Category - display category (subcategory folder or backbutton  to not accessible cat
        $display_access_category = $this->params->get('display_access_category', 1);
        // Set page title per category
        if ($this->tmpl['display_cat_name_title'] == 1 && isset($this->category->title)) {
            $document->setTitle($this->params->get('page_title') . ' - ' . $this->category->title);
        } else {
            $document->setTitle($this->params->get('page_title'));
        }
        // Breadcrumb display:
        // 0 - only menu link
        // 1 - menu link - category name
        // 2 - only category name
        $this->_addBreadCrumbs(isset($menu->query['id']) ? $menu->query['id'] : 0, $display_cat_name_breadcrumbs);
        // Define image tag attributes
        /*	if (!empty ($this->category->image)) {
        			$attribs['align'] = '"'.$this->category->image_position.'"';
        			$attribs['hspace'] = '"6"';
        			$this->tmpl['image'] = JHtml::_('image', 'images/stories/'.$this->category->image,'', $attribs);
        		}*/
        // Overlib
        $enable_overlib = $this->params->get('enable_overlib', 0);
        if ((int) $enable_overlib > 0) {
            $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/overlib/overlib_mini.js');
        }
        // MODEL
        $model = $this->getModel();
        // Trash
        $this->tmpl['trash'] = 0;
        $this->tmpl['publish_unpublish'] = 0;
        $this->tmpl['approved_not_approved'] = 0;
        // only to see the info
        // USER RIGHT - DELETE - - - - - - - - - - -
        // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
        $rightDisplayDelete = 0;
        // default is to null (all users cannot upload)
        if (!empty($this->category)) {
            $rightDisplayDelete = PhocaGalleryAccess::getUserRight('deleteuserid', $this->category->deleteuserid, 2, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), 0);
        }
        if ($rightDisplayDelete == 1) {
            $this->tmpl['trash'] = 1;
            $this->tmpl['publish_unpublish'] = 1;
            $this->tmpl['approved_not_approved'] = 1;
            // only to see the info
        }
        // - - - - - - - - - - - - - - - - - - - - -
        // Upload
        $this->tmpl['displayupload'] = 0;
        // USER RIGHT - UPLOAD - - - - - - - - - - -
        // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
        $rightDisplayUpload = 0;
        // default is to null (all users cannot upload)
        if (!empty($this->category)) {
            $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $this->category->uploaduserid, 2, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), 0);
        }
        if ($rightDisplayUpload == 1) {
            $this->tmpl['displayupload'] = 1;
            $document->addCustomTag(PhocaGalleryRenderFront::renderOnUploadCategoryJS());
            $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionUploadJS((int) $this->tmpl['maxuploadchar']));
        }
        $this->tmpl['displaycreatecat'] = 0;
        if ($rightDisplayUpload == 1 && $this->tmpl['enable_direct_subcat'] == 1) {
            $this->tmpl['displaycreatecat'] = 1;
            $document->addCustomTag(PhocaGalleryRenderFront::renderOnUploadCategoryJS());
            $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionCreateSubCatJS((int) $this->tmpl['maxcreatecatchar']));
        }
        // - - - - - - - - - - - - - - - - - - - - -
        // USER RIGHT - ACCESS - - - - - - - - - - -
        $rightDisplay = 1;
        //default is set to 1 (all users can see the category)
        if (!empty($this->category)) {
            $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->category->accessuserid, 0, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), $display_access_category);
        }
        if ($rightDisplay == 0) {
            $app->redirect(JRoute::_($this->tmpl['pl'], false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
            exit;
        }
        // - - - - - - - - - - - - - - - - - - - - -
        // 1. GEOTAGGING CATEGORY
        $this->map['longitude'] = '';
        // will be used for 1. default_geotagging to not display pane and 2. to remove pane (line cca 1554)
        $this->map['latitude'] = '';
        if (isset($this->category->latitude) && $this->category->latitude != '' && $this->category->latitude != 0 && isset($this->category->longitude) && $this->category->longitude != '' && $this->category->longitude != 0) {
            $this->map['longitude'] = $this->category->longitude;
            $this->map['latitude'] = $this->category->latitude;
            $this->map['zoom'] = $this->category->zoom;
            $this->map['geotitle'] = $this->category->geotitle;
            $this->map['description'] = $this->category->description;
            if ($this->map['geotitle'] == '') {
                $this->map['geotitle'] = $this->category->title;
            }
        } else {
            $this->tmpl['display_icon_geo'] = 0;
        }
        $this->tmpl['categoryimageordering'] = $this->params->get('category_image_ordering', 10);
        //$this->tmpl['categoryimageorderingcv']	= 10;//$this->params->get( 'category_image_ordering_cv', 10 );
        // Image next to Category in Categories View in Category View is ordered by Random as default
        phocagalleryimport('phocagallery.ordering.ordering');
        $this->categoryImageOrdering = PhocaGalleryOrdering::getOrderingString($this->tmpl['categoryimageordering']);
        //$this->categoryImageOrderingCV = PhocaGalleryOrdering::getOrderingString($this->tmpl['categoryimageorderingcv']);
        // = = = = = = = = = = = = = = = = = = = =
        // BOXES
        // = = = = = = = = = = = = = = = = = = = =
        // Information because of height of box (if they are used not by all images)
        $this->tmpl['display_icon_extlink1_box'] = 0;
        $this->tmpl['display_icon_extlink2_box'] = 0;
        $this->tmpl['display_icon_vmbox'] = 0;
        $this->tmpl['display_icon_geo_box'] = 0;
        $iS = 0;
        $iCV = 0;
        $this->items = array();
        // Category View
        $this->itemscv = array();
        // Category List (Categories View) in Category View
        // ----------------------------------------
        // PARENT FOLDERS(I) or Back Button STANDARD
        // ----------------------------------------
        /*
        		// Set Back Button to CATEGORIES VIEW
        		$this->itemsLink	= $menu->getItems('link', 'index.php?option=com_phocagallery&view=categories');
        
        		$itemId	= 0;
        		if(isset($this->itemsLink[0])) {
        			$itemId = $this->itemsLink[0]->id;
        		}	
        		$backLink = 'index.php?option=com_phocagallery&view=categories&Itemid='.$itemId;*/
        $posItemid = $posItemidNull = $backLinkItemId = false;
        $backLink = PhocaGalleryRoute::getCategoriesRoute();
        $posItemidNull = strpos($backLink, "Itemid=0");
        $posItemid = strpos($backLink, "Itemid=");
        if ($posItemidNull === false && $posItemid) {
            $backLinkItemId = 1;
        }
        $parentCategory = $this->get('parentcategory');
        if ($display_back_button == 1) {
            if (!empty($parentCategory)) {
                $this->items[$iS] = $parentCategory;
                // USER RIGHT - ACCESS - - - - - - - - - - -
                // Should be the link to parentcategory displayed
                $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->items[$iS]->accessuserid, $this->items[$iS]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), $display_access_category);
                // Display Key Icon (in case we want to display unaccessable categories in list view)
                $rightDisplayKey = 1;
                if ($display_access_category == 1) {
                    // we simulate that we want not to display unaccessable categories
                    // so we get rightDisplayKey = 0 then the key will be displayed
                    if (!empty($parentCategory)) {
                        $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->items[$iS]->accessuserid, $this->items[$iS]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), 0);
                    }
                }
                // - - - - - - - - - - - - - - - - - - - - -
                if ($rightDisplay > 0) {
                    $this->items[$iS]->cls = 'pg-box-parentfolder';
                    $this->items[$iS]->slug = $this->items[$iS]->id . ':' . $this->items[$iS]->alias;
                    $this->items[$iS]->item_type = "parentfolder";
                    $this->items[$iS]->linkthumbnailpath = PhocaGalleryImageFront::displayBackFolder('medium', $rightDisplayKey);
                    $this->items[$iS]->extm = $this->items[$iS]->linkthumbnailpath;
                    $this->items[$iS]->exts = $this->items[$iS]->linkthumbnailpath;
                    $this->items[$iS]->numlinks = 0;
                    // We are in category view
                    $this->items[$iS]->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $this->items[$iS]->slug . '&Itemid=' . $this->itemId);
                    $this->items[$iS]->button =& $folderButton;
                    $this->items[$iS]->button->methodname = '';
                    $this->items[$iS]->display_icon_detail = 0;
                    $this->items[$iS]->display_icon_download = 0;
                    $this->items[$iS]->display_name = 0;
                    $this->items[$iS]->display_icon_vm = '';
                    $this->items[$iS]->start_cooliris = 0;
                    $this->items[$iS]->trash = 0;
                    $this->items[$iS]->publish_unpublish = 0;
                    $this->items[$iS]->approved_not_approved = 0;
                    $this->items[$iS]->enable_cooliris = 0;
                    $this->items[$iS]->overlib = 0;
                    $this->items[$iS]->display_icon_geo = 0;
                    $this->items[$iS]->display_icon_commentimg = 0;
                    $this->items[$iS]->type = 0;
                    $this->items[$iS]->camera_info = 0;
                    $this->items[$iS]->display_icon_extlink1 = 0;
                    $this->items[$iS]->display_icon_extlink2 = 0;
                    $this->items[$iS]->description = '';
                    $this->items[$iS]->altvalue = '';
                    $iS++;
                } else {
                    // There is no right to see the data but the object exists (because it was loaded from database
                    // Destroy it
                    unset($this->items[$iS]);
                }
            } else {
                // Back button to categories list if it exists
                if ($backLinkItemId != 0 && $display_categories_back_button == 1) {
                    $this->items[$iS] = new JObject();
                    $this->items[$iS]->cls = 'pg-box-backbtn';
                    $this->items[$iS]->link = JRoute::_($backLink);
                    $this->items[$iS]->title = JTEXT::_('COM_PHOCAGALLERY_CATEGORY_LIST');
                    $this->items[$iS]->item_type = "categorieslist";
                    $this->items[$iS]->linkthumbnailpath = PhocaGalleryImageFront::displayBackFolder('medium', 1);
                    $this->items[$iS]->extm = $this->items[$iS]->linkthumbnailpath;
                    $this->items[$iS]->exts = $this->items[$iS]->linkthumbnailpath;
                    $this->items[$iS]->numlinks = 0;
                    // We are in category view
                    $this->items[$iS]->button =& $folderButton;
                    $this->items[$iS]->button->methodname = '';
                    $this->items[$iS]->display_icon_detail = 0;
                    $this->items[$iS]->display_icon_download = 0;
                    $this->items[$iS]->display_name = 0;
                    $this->items[$iS]->display_icon_vm = '';
                    $this->items[$iS]->start_cooliris = 0;
                    $this->items[$iS]->trash = 0;
                    $this->items[$iS]->publish_unpublish = 0;
                    $this->items[$iS]->approved_not_approved = 0;
                    $this->items[$iS]->enable_cooliris = 0;
                    $this->items[$iS]->overlib = 0;
                    $this->items[$iS]->display_icon_geo = 0;
                    $this->items[$iS]->display_icon_commentimg = 0;
                    $this->items[$iS]->type = 0;
                    $this->items[$iS]->camera_info = 0;
                    $this->items[$iS]->display_icon_extlink1 = 0;
                    $this->items[$iS]->display_icon_extlink2 = 0;
                    $this->items[$iS]->description = '';
                    $this->items[$iS]->altvalue = '';
                    $iS++;
                }
            }
        }
        // ----------------------------------------
        // PARENT FOLDERS(II) or Back Button CATEGORIES VIEW IN CATEGORY VIEW
        // ----------------------------------------
        if ($this->tmpl['display_back_button_cv'] == 1 && $this->tmpl['display_categories_cv'] == 1) {
            if (!empty($parentCategory)) {
                $this->itemscv[$iCV] = clone $parentCategory;
                // USER RIGHT - ACCESS - - - - - - - - - - -
                // Should be the link to parentcategory displayed
                $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->itemscv[$iCV]->accessuserid, $this->itemscv[$iCV]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), $display_access_category);
                // Display Key Icon (in case we want to display unaccessable categories in list view)
                $rightDisplayKey = 1;
                if ($display_access_category == 1) {
                    // we simulate that we want not to display unaccessable categories
                    // so we get rightDisplayKey = 0 then the key will be displayed
                    if (!empty($parentCategory)) {
                        $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->itemscv[$iCV]->accessuserid, $this->itemscv[$iCV]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), 0);
                    }
                }
                // - - - - - - - - - - - - - - - - - - - - -
                if ($rightDisplay > 0) {
                    $this->itemscv[$iCV]->cls = 'pg-box-parentfolder-cv';
                    $this->itemscv[$iCV]->slug = $this->itemscv[$iCV]->id . ':' . $this->itemscv[$iCV]->alias;
                    $this->itemscv[$iCV]->item_type = "parentfoldercv";
                    $this->itemscv[$iCV]->linkthumbnailpath = PhocaGalleryImageFront::displayBackFolder('medium', $rightDisplayKey);
                    $this->itemscv[$iCV]->extm = $this->itemscv[$iCV]->linkthumbnailpath;
                    $this->itemscv[$iCV]->exts = $this->itemscv[$iCV]->linkthumbnailpath;
                    $this->itemscv[$iCV]->numlinks = 0;
                    // We are in category view
                    $this->itemscv[$iCV]->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $this->itemscv[$iCV]->slug . '&Itemid=' . $this->itemId);
                    $this->itemscv[$iCV]->type = 3;
                    $this->itemscv[$iCV]->altvalue = '';
                    $iCV++;
                } else {
                    // There is no right to see the data but the object exists (because it was loaded from database
                    // Destroy it
                    unset($this->itemscv[$iCV]);
                }
            } else {
                // Back button to categories list if it exists
                if ($backLinkItemId != 0 && $this->tmpl['display_categories_back_button_cv'] == 1) {
                    $this->itemscv[$iCV] = new JObject();
                    $this->itemscv[$iCV]->cls = 'pg-cvcsv-back';
                    $this->itemscv[$iCV]->link = $backLink;
                    $this->itemscv[$iCV]->title = JTEXT::_('COM_PHOCAGALLERY_CATEGORY_LIST');
                    $this->itemscv[$iCV]->item_type = "categorieslistcv";
                    $this->itemscv[$iCV]->linkthumbnailpath = PhocaGalleryImageFront::displayBackFolder('medium', 1);
                    $this->itemscv[$iCV]->extm = $this->itemscv[$iCV]->linkthumbnailpath;
                    $this->itemscv[$iCV]->exts = $this->itemscv[$iCV]->linkthumbnailpath;
                    $this->itemscv[$iCV]->numlinks = 0;
                    // We are in category view
                    $this->itemscv[$iCV]->link = JRoute::_($this->itemscv[$iCV]->link);
                    $this->itemscv[$iCV]->type = 3;
                    $this->itemscv[$iCV]->altvalue = '';
                    $iCV++;
                }
            }
        }
        // ----------------------------------------
        // SUB FOLDERS(1) STANDARD
        // ----------------------------------------
        // Display subcategories on every page
        if ($display_subcat_page == 1) {
            $subCategory = $this->get('subcategory');
            $totalSubCat = count($subCategory);
            if ((int) $this->tagId > 0) {
                $subCategory = array();
            }
            // No subcategories for tag searching
            if (!empty($subCategory)) {
                $this->items[$iS] =& $subCategory;
                for ($iSub = 0; $iSub < $totalSubCat; $iSub++) {
                    $this->items[$iS] =& $subCategory[$iSub];
                    // USER RIGHT - ACCESS - - - - - - - - - -
                    $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->items[$iS]->accessuserid, $this->items[$iS]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), $display_access_category);
                    // Display Key Icon (in case we want to display unaccessable categories in list view)
                    $rightDisplayKey = 1;
                    if ($display_access_category == 1) {
                        // we simulate that we want not to display unaccessable categories
                        // so we get rightDisplayKey = 0 then the key will be displayed
                        if (!empty($this->items[$iS])) {
                            $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->items[$iS]->accessuserid, $this->items[$iS]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), 0);
                        }
                    }
                    // - - - - - - - - - - - - - - - - - - - -
                    if ($rightDisplay > 0) {
                        $this->items[$iS]->cls = 'pg-box-subfolder';
                        $this->items[$iS]->slug = $this->items[$iS]->id . ':' . $this->items[$iS]->alias;
                        $this->items[$iS]->item_type = "subfolder";
                        $numlinks = $model->getCountItem($this->items[$iS]->id);
                        //Should be get from main subcategories query
                        if (isset($numlinks[0]) && $numlinks[0] > 0) {
                            $this->items[$iS]->numlinks = (int) $numlinks[0];
                        } else {
                            $this->items[$iS]->numlinks = 0;
                        }
                        $extImage = PhocaGalleryImage::isExtImage($this->items[$iS]->extid);
                        if ($extImage) {
                            $imagePic = new stdClass();
                            if ($this->tmpl['categoryimageordering'] != 10) {
                                $imagePic = PhocaGalleryImageFront::getRandomImageRecursive($this->items[$iS]->id, $this->categoryImageOrdering, 1);
                                $fileThumbnail = PhocaGalleryImageFront::displayCategoryExtImgOrFolder($imagePic->exts, $imagePic->extm, 'medium', $rightDisplayKey, 'display_category_icon_image');
                            } else {
                                $fileThumbnail = PhocaGalleryImageFront::displayCategoryExtImgOrFolder($this->items[$iS]->exts, $this->items[$iS]->extm, 'medium', $rightDisplayKey, 'display_category_icon_image');
                                $imagePic->extw = $this->items[$iS]->extw;
                                $imagePic->exth = $this->items[$iS]->exth;
                            }
                            // in case category is locked or no extm exists
                            $this->items[$iS]->linkthumbnailpath = $fileThumbnail->linkthumbnailpath;
                            $this->items[$iS]->extm = $fileThumbnail->extm;
                            $this->items[$iS]->exts = $fileThumbnail->exts;
                            $this->items[$iS]->exthswitch = $this->items[$iS]->extwswitch = 0;
                            if ($imagePic->extw != '') {
                                $extw = explode(',', $imagePic->extw);
                                $this->items[$iS]->extw = $extw[1];
                                $this->items[$iS]->extwswitch = $extw[0];
                            }
                            if ($imagePic->exth != '') {
                                $exth = explode(',', $imagePic->exth);
                                $this->items[$iS]->exth = $exth[1];
                                $this->items[$iS]->exthswitch = $exth[0];
                            }
                            $this->items[$iS]->extpic = $fileThumbnail->extpic;
                        } else {
                            if ($this->tmpl['categoryimageordering'] != 10) {
                                $randomImage = PhocaGalleryImageFront::getRandomImageRecursive($this->items[$iS]->id, $this->categoryImageOrdering);
                                $fileThumbnail = PhocaGalleryImageFront::displayCategoryImageOrFolder($randomImage, 'medium', $rightDisplayKey, 'display_category_icon_image');
                            } else {
                                $fileThumbnail = PhocaGalleryImageFront::displayCategoryImageOrFolder($this->items[$iS]->filename, 'medium', $rightDisplayKey, 'display_category_icon_image');
                            }
                            $this->items[$iS]->linkthumbnailpath = $fileThumbnail->rel;
                        }
                        $this->items[$iS]->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $this->items[$iS]->slug . '&Itemid=' . $this->itemId);
                        $this->items[$iS]->button =& $folderButton;
                        $this->items[$iS]->button->methodname = '';
                        $this->items[$iS]->display_icon_detail = 0;
                        $this->items[$iS]->display_icon_download = 0;
                        $this->items[$iS]->display_name = $this->tmpl['display_name'];
                        $this->items[$iS]->display_icon_vm = '';
                        $this->items[$iS]->start_cooliris = 0;
                        $this->items[$iS]->trash = 0;
                        $this->items[$iS]->publish_unpublish = 0;
                        $this->items[$iS]->approved_not_approved = 0;
                        $this->items[$iS]->enable_cooliris = 0;
                        $this->items[$iS]->overlib = 0;
                        $this->items[$iS]->display_icon_geo = 0;
                        $this->items[$iS]->type = 1;
                        $this->items[$iS]->camera_info = 0;
                        $this->items[$iS]->display_icon_extlink1 = 0;
                        $this->items[$iS]->display_icon_extlink2 = 0;
                        $this->items[$iS]->description = '';
                        $this->items[$iS]->display_icon_commentimg = 0;
                        $this->items[$iS]->altvalue = '';
                        $iS++;
                    } else {
                        // There is no right to see the data but the object exists (because it was loaded from database
                        // Destroy it
                        unset($this->items[$iS]);
                    }
                }
            }
        }
        // ----------------------------------------
        // SUB FOLDERS(II) or Back Button CATEGORIES VIEW IN CATEGORY VIEW
        // ----------------------------------------
        //display subcategories on every page
        if ($display_subcat_page_cv == 1 && $this->tmpl['display_categories_cv'] == 1) {
            $subCategory = $this->get('subcategory');
            $totalSubCat = count($subCategory);
            if ((int) $this->tagId > 0) {
                $subCategory = array();
            }
            // No subcategories for tag searching
            if (!empty($subCategory)) {
                $this->itemscv[$iCV] =& $subCategory;
                for ($iSub = 0; $iSub < $totalSubCat; $iSub++) {
                    $this->itemscv[$iCV] =& $subCategory[$iSub];
                    // USER RIGHT - ACCESS - - - - - - - - - -
                    $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->itemscv[$iCV]->accessuserid, $this->itemscv[$iCV]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), $display_access_category);
                    // Display Key Icon (in case we want to display unaccessable categories in list view)
                    $rightDisplayKey = 1;
                    if ($display_access_category == 1) {
                        // we simulate that we want not to display unaccessable categories
                        // so we get rightDisplayKey = 0 then the key will be displayed
                        if (!empty($this->itemscv[$iCV])) {
                            $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->itemscv[$iCV]->accessuserid, $this->itemscv[$iCV]->access, $this->tmpl['user']->getAuthorisedViewLevels(), $this->tmpl['user']->get('id', 0), 0);
                        }
                    }
                    // - - - - - - - - - - - - - - - - - - - -
                    if ($rightDisplay > 0) {
                        $this->itemscv[$iCV]->cls = 'pg-cvcsv-name';
                        $this->itemscv[$iCV]->slug = $this->itemscv[$iCV]->id . ':' . $this->itemscv[$iCV]->alias;
                        $this->itemscv[$iCV]->item_type = "subfoldercv";
                        $this->itemscv[$iCV]->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $this->itemscv[$iCV]->slug . '&Itemid=' . $this->itemId);
                        $this->itemscv[$iCV]->type = 4;
                        $numlinks = $model->getCountItem($this->itemscv[$iCV]->id);
                        //Should be get from main subcategories query
                        if (isset($numlinks[0]) && $numlinks[0] > 0) {
                            $this->itemscv[$iCV]->numlinks = (int) $numlinks[0];
                        } else {
                            $this->itemscv[$iCV]->numlinks = 0;
                        }
                        $extImage = PhocaGalleryImage::isExtImage($this->itemscv[$iCV]->extid);
                        if ($extImage) {
                            /*$imagePic		= new stdClass();
                            				if ($this->tmpl['categoryimageordering'] != 10) {
                            					$imagePic= PhocaGalleryImageFront::getRandomImageRecursive($this->itemscv[$iCV]->id, $this->categoryImageOrderingCV, 1);
                            					$fileThumbnail	= PhocaGalleryImageFront::displayCategoryExtImgOrFolder($imagePic->exts, $imagePic->extm, 'medium', $rightDisplayKey, 'display_category_icon_image');
                            				} else {
                            					$fileThumbnail	= PhocaGalleryImageFront::displayCategoryExtImgOrFolder($this->itemscv[$iCV]->exts,$this->itemscv[$iCV]->extm, 'medium', $rightDisplayKey, 'display_category_icon_image');
                            					$imagePic->extw = $this->itemscv[$iCV]->extw;
                            					$imagePic->exth = $this->itemscv[$iCV]->exth;
                            				}
                            		
                            				// in case category is locked or no extm exists
                            				$this->itemscv[$iCV]->linkthumbnailpath	= $fileThumbnail->linkthumbnailpath;
                            				$this->itemscv[$iCV]->extm	= $fileThumbnail->extm;
                            				$this->itemscv[$iCV]->exts	= $fileThumbnail->exts;
                            			
                            				$this->itemscv[$iCV]->exthswitch = $this->items[$iCV]->extwswitch = 0;
                            				if ($imagePic->extw != '') {
                            					$extw 						= explode(',',$imagePic->extw);
                            					$this->itemscv[$iCV]->extw		= $extw[1];
                            					$this->itemscv[$iCV]->extwswitch	= $extw[0];
                            				}
                            				if ($imagePic->exth != '') {
                            					$exth 				= explode(',',$imagePic->exth);
                            					$this->itemscv[$iCV]->exth		= $exth[1];
                            					$this->itemscv[$iCV]->exthswitch	= $exth[0];
                            				}*/
                            $this->itemscv[$iCV]->extpic = '';
                        } else {
                            /*if ($this->tmpl['categoryimageordering'] != 10) {
                            			$randomImage 	= PhocaGalleryImageFront::getRandomImageRecursive($this->itemscv[$iCV]->id, $this->categoryImageOrderingCV);
                            			$fileThumbnail 	= PhocaGalleryImageFront::displayCategoryImageOrFolder($randomImage, 'medium', $rightDisplayKey, 'display_category_icon_image_cv');
                            		} else {
                            			$fileThumbnail 	= PhocaGalleryImageFront::displayCategoryImageOrFolder($this->itemscv[$iCV]->filename, 'medium', $rightDisplayKey, 'display_category_icon_image_cv');
                            		}*/
                            $this->itemscv[$iCV]->linkthumbnailpath = '';
                            $this->itemscv[$iCV]->altvalue = '';
                        }
                        $iCV++;
                    } else {
                        // There is no right to see the data but the object exists (because it was loaded from database
                        // Destroy it
                        unset($this->itemscv[$iCV]);
                    }
                }
            }
        }
        // ----------------------------------------
        // IMAGES
        // ----------------------------------------
        // If user has rights to delete or publish or unpublish, unbublished items should be displayed
        if ($rightDisplayDelete == 1) {
            $images = $model->getData(1, $this->tagId);
            $this->tmpl['pagination'] = $model->getPagination(1, $this->tagId);
        } else {
            $images = $model->getData(0, $this->tagId);
            $this->tmpl['pagination'] = $model->getPagination(0, $this->tagId);
        }
        $this->tmpl['ordering'] = $model->getOrdering();
        $totalImg = count($images);
        if ($limitStart > 0) {
            $this->tmpl['limitstarturl'] = '&limitstart=' . $limitStart;
        } else {
            $this->tmpl['limitstarturl'] = '';
        }
        $this->tmpl['jakdatajs'] = array();
        $this->tmpl['display_icon_commentimg_box'] = 0;
        for ($iM = 0; $iM < $totalImg; $iM++) {
            $this->items[$iS] = $images[$iM];
            $this->items[$iS]->cls = 'pg-box-image';
            $this->items[$iS]->slug = $this->items[$iS]->id . ':' . $this->items[$iS]->alias;
            $this->items[$iS]->item_type = "image";
            $this->items[$iS]->linknr = '';
            //Def
            $extImage = PhocaGalleryImage::isExtImage($this->items[$iS]->extid);
            // Get file thumbnail or No Image
            $this->items[$iS]->exthswitch = $this->items[$iS]->extwswitch = 0;
            if ($this->items[$iS]->extm != '') {
                if ($this->items[$iS]->extw != '') {
                    $extw = explode(',', $this->items[$iS]->extw);
                    $this->items[$iS]->extw = $extw[1];
                    $this->items[$iS]->extwswitch = $extw[0];
                }
                if ($this->items[$iS]->exth != '') {
                    $exth = explode(',', $this->items[$iS]->exth);
                    $this->items[$iS]->exth = $exth[1];
                    $this->items[$iS]->exthswitch = $exth[0];
                }
                $this->items[$iS]->extpic = 1;
                $this->items[$iS]->linkthumbnailpath = '';
            } else {
                // Mansory
                $iFormat = 'medium';
                if ($this->tmpl['diff_thumb_height'] > 0) {
                    if ($this->items[$iS]->format == 2) {
                        $iFormat = 'medium1';
                        // by portraits in everycase (medium1 = medium * x2(height))
                    } else {
                        $m2 = mt_rand(0, 1);
                        if ($m2 == 1) {
                            $iFormat = 'medium1';
                        }
                    }
                }
                $this->items[$iS]->linkthumbnailpath = PhocaGalleryImageFront::displayCategoryImageOrNoImage($this->items[$iS]->filename, $iFormat);
            }
            if (isset($parentCategory->params)) {
                $this->items[$iS]->parentcategoryparams = $parentCategory->params;
            }
            // SWITCH IMAGE - Add the first Image as basic image
            if ($this->tmpl['switch_image'] == 1) {
                if ($basic_imageSelected == 0) {
                    if ((int) $this->tmpl['switch_width'] > 0 && (int) $this->tmpl['switch_height'] > 0 && $this->tmpl['switch_fixed_size'] == 1) {
                        $wHArray = array('id' => 'PhocaGalleryobjectPicture', 'border' => '0', 'width' => $this->tmpl['switch_width'], 'height' => $this->tmpl['switch_height']);
                        $wHString = ' id="PhocaGalleryobjectPicture"  border="0" width="' . $this->tmpl['switch_width'] . '" height="' . $this->tmpl['switch_height'] . '"';
                    } else {
                        $wHArray = array('id' => 'PhocaGalleryobjectPicture', 'border' => '0');
                        $wHString = ' id="PhocaGalleryobjectPicture"  border="0"';
                    }
                    if (isset($this->items[$iS]->extpic) && $this->items[$iS]->extpic != '') {
                        $this->tmpl['basic_image'] = JHtml::_('image', $this->items[$iS]->extl, '', $wHArray);
                    } else {
                        $this->tmpl['basic_image'] = JHtml::_('image', str_replace('phoca_thumb_m_', 'phoca_thumb_l_', $this->items[$iS]->linkthumbnailpath), '', $wHString);
                    }
                    $basic_imageSelected = 1;
                }
            }
            $thumbLink = PhocaGalleryFileThumbnail::getThumbnailName($this->items[$iS]->filename, 'large');
            $thumbLinkM = PhocaGalleryFileThumbnail::getThumbnailName($this->items[$iS]->filename, 'medium');
            $imgLinkOrig = JURI::base(true) . '/' . PhocaGalleryFile::getFileOriginal($this->items[$iS]->filename, 1);
            if ($this->tmpl['detail_window'] == 7) {
                $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $this->items[$iS]->catslug . '&id=' . $this->items[$iS]->slug . '&Itemid=' . $this->itemId);
            } else {
                $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $this->items[$iS]->catslug . '&id=' . $this->items[$iS]->slug . '&tmpl=component' . '&Itemid=' . $this->itemId);
            }
            $imgLink = $thumbLink->rel;
            if ($extImage) {
                $imgLink = $this->items[$iS]->extl;
                $imgLinkOrig = $this->items[$iS]->exto;
            }
            // Detail Window
            if ($this->tmpl['detail_window'] == 2) {
                $this->items[$iS]->link = $imgLink;
                $this->items[$iS]->link2 = $imgLink;
                $this->items[$iS]->linkother = $imgLink;
                $this->items[$iS]->linkorig = $imgLinkOrig;
            } else {
                if ($this->tmpl['detail_window'] == 3) {
                    $this->items[$iS]->link = $imgLink;
                    $this->items[$iS]->link2 = $imgLink;
                    $this->items[$iS]->linkother = $siteLink;
                    $this->items[$iS]->linkorig = $imgLinkOrig;
                } else {
                    if ($this->tmpl['detail_window'] == 5) {
                        $this->items[$iS]->link = $imgLink;
                        $this->items[$iS]->link2 = $siteLink;
                        $this->items[$iS]->linkother = $siteLink;
                        $this->items[$iS]->linkorig = $imgLinkOrig;
                    } else {
                        if ($this->tmpl['detail_window'] == 6) {
                            $this->items[$iS]->link = $imgLink;
                            $this->items[$iS]->link2 = $imgLink;
                            $this->items[$iS]->linkother = $siteLink;
                            $this->items[$iS]->linkorig = $imgLinkOrig;
                            // jak data js
                            switch ($this->tmpl['jakdescription']) {
                                case 0:
                                    $descriptionJakJs = '';
                                    break;
                                case 2:
                                    $descriptionJakJs = PhocaGalleryText::strTrimAll(addslashes($this->items[$iS]->description));
                                    break;
                                case 3:
                                    $descriptionJakJs = PhocaGalleryText::strTrimAll(addslashes($this->items[$iS]->title));
                                    if ($this->items[$iS]->description != '') {
                                        $descriptionJakJs .= '<br />' . PhocaGalleryText::strTrimAll(addslashes($this->items[$iS]->description));
                                    }
                                    break;
                                case 1:
                                default:
                                    $descriptionJakJs = PhocaGalleryText::strTrimAll(addslashes($this->items[$iS]->title));
                                    break;
                            }
                            $this->items[$iS]->linknr = $iM;
                            $this->tmpl['jakdatajs'][$iS] = "{alt: '" . PhocaGalleryText::strTrimAll(addslashes($this->items[$iS]->title)) . "',";
                            if ($descriptionJakJs != '') {
                                $this->tmpl['jakdatajs'][$iS] .= "description: '" . $descriptionJakJs . "',";
                            } else {
                                $this->tmpl['jakdatajs'][$iS] .= "description: ' ',";
                            }
                            if ($extImage) {
                                $this->tmpl['jakdatajs'][$iS] .= "small: {url: '" . $this->items[$iS]->extm . "'}," . "big: {url: '" . $this->items[$iS]->extl . "'} }";
                            } else {
                                $this->tmpl['jakdatajs'][$iS] .= "small: {url: '" . htmlentities(JURI::base(true) . '/' . PhocaGalleryText::strTrimAll(addslashes($thumbLinkM->rel))) . "'}," . "big: {url: '" . htmlentities(JURI::base(true) . '/' . PhocaGalleryText::strTrimAll(addslashes($imgLink))) . "'} }";
                            }
                        } else {
                            if ($this->tmpl['detail_window'] == 8) {
                                $this->items[$iS]->link = $imgLink;
                                $this->items[$iS]->link2 = $imgLink;
                                $this->items[$iS]->linkother = $imgLink;
                                $this->items[$iS]->linkorig = $imgLinkOrig;
                            } else {
                                if ($this->tmpl['detail_window'] == 9) {
                                    $this->items[$iS]->link = $siteLink;
                                    $this->items[$iS]->link2 = $siteLink;
                                    $this->items[$iS]->linkother = $siteLink;
                                    $this->items[$iS]->linkorig = $imgLinkOrig;
                                } else {
                                    if ($this->tmpl['detail_window'] == 10) {
                                        $this->items[$iS]->link = $imgLink;
                                        $this->items[$iS]->link2 = $imgLink;
                                        $this->items[$iS]->linkother = $siteLink;
                                        $this->items[$iS]->linkorig = $imgLinkOrig;
                                    } else {
                                        $this->items[$iS]->link = $siteLink;
                                        $this->items[$iS]->link2 = $siteLink;
                                        $this->items[$iS]->linkother = $siteLink;
                                        $this->items[$iS]->linkorig = $imgLinkOrig;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // Buttons, e.g. shadowbox:
            // button - click on image
            // button2 - click on zoom icon (cannot be the same as click on image because of duplicity of images)
            // buttonOther - other detail window like download, geotagging
            $this->items[$iS]->button =& $this->button;
            $this->items[$iS]->button2 =& $this->button2;
            $this->items[$iS]->buttonother =& $this->buttonother;
            $this->items[$iS]->display_icon_detail = $this->tmpl['display_icon_detail'];
            $this->items[$iS]->display_icon_download = $this->tmpl['display_icon_download'];
            $this->items[$iS]->display_name = $this->tmpl['display_name'];
            $this->items[$iS]->display_icon_vm = '';
            $this->items[$iS]->start_cooliris = $this->tmpl['start_cooliris'];
            $this->items[$iS]->type = 2;
            // Trash icon
            if ($this->tmpl['trash'] == 1) {
                $this->items[$iS]->trash = 1;
            } else {
                $this->items[$iS]->trash = 0;
            }
            // Publish Unpublish icon
            if ($this->tmpl['publish_unpublish'] == 1) {
                $this->items[$iS]->publish_unpublish = 1;
            } else {
                $this->items[$iS]->publish_unpublish = 0;
            }
            // Publish Unpublish icon
            if ($this->tmpl['approved_not_approved'] == 1) {
                $this->items[$iS]->approved_not_approved = 1;
            } else {
                $this->items[$iS]->approved_not_approved = 0;
            }
            // PICLENS
            if ($this->tmpl['enablecooliris']) {
                $this->items[$iS]->enable_cooliris = 1;
            } else {
                $this->items[$iS]->enable_cooliris = 0;
            }
            // 2. GEOTAGGING IMAGE
            // We have checked the category so if geotagging is enabled
            // and there is no geotagging data for category, then $this->tmpl['display_icon_geo'] = 0;
            // so we need to check it for the image too, we need to set the $this->tmpl['display_icon_geoimage'] for image only
            // we are in loop now
            $this->tmpl['display_icon_geoimagetmp'] = 0;
            if ($this->tmpl['display_icon_geoimage'] == 1) {
                $this->tmpl['display_icon_geoimagetmp'] = 1;
                if (isset($this->items[$iS]->latitude) && $this->items[$iS]->latitude != '' && $this->items[$iS]->latitude != 0 && isset($this->items[$iS]->longitude) && $this->items[$iS]->longitude != '' && $this->items[$iS]->longitude != 0) {
                } else {
                    $this->tmpl['display_icon_geoimagetmp'] = 0;
                }
            }
            // GEOTAGGING
            if ($this->tmpl['display_icon_geo'] == 1 || $this->tmpl['display_icon_geoimagetmp'] == 1) {
                $this->items[$iS]->display_icon_geo = 1;
                $this->tmpl['display_icon_geo_box'] = 1;
                // because of height of box
            } else {
                $this->items[$iS]->display_icon_geo = 0;
            }
            // Set it back because of loop
            $this->tmpl['display_icon_geoimagetmp'] = 0;
            // CAMERA INFO
            if ($this->tmpl['display_camera_info'] == 1) {
                $this->items[$iS]->camera_info = 1;
            } else {
                $this->items[$iS]->camera_info = 0;
            }
            // EXT LINK
            $this->items[$iS]->display_icon_extlink1 = 0;
            if (isset($this->items[$iS]->extlink1)) {
                $this->items[$iS]->extlink1 = explode("|", $this->items[$iS]->extlink1, 4);
                if (isset($this->items[$iS]->extlink1[0]) && $this->items[$iS]->extlink1[0] != '' && isset($this->items[$iS]->extlink1[1])) {
                    $this->items[$iS]->display_icon_extlink1 = 1;
                    $this->tmpl['display_icon_extlink1_box'] = 1;
                    // because of height of box
                    if (!isset($this->items[$iS]->extlink1[2])) {
                        $this->items[$iS]->extlink1[2] = '_self';
                    }
                    if (!isset($this->items[$iS]->extlink1[3]) || $this->items[$iS]->extlink1[3] == 1) {
                        $this->items[$iS]->extlink1[4] = JHtml::_('image', 'media/com_phocagallery/images/icon-extlink1.png', JText::_($this->items[$iS]->extlink1[1]));
                        $this->items[$iS]->extlink1[5] = '';
                    } else {
                        $this->items[$iS]->extlink1[4] = $this->items[$iS]->extlink1[1];
                        $this->items[$iS]->extlink1[5] = 'style="text-decoration:underline"';
                    }
                } else {
                    $this->items[$iS]->display_icon_extlink1 = 0;
                }
            }
            $this->items[$iS]->display_icon_extlink2 = 0;
            if (isset($this->items[$iS]->extlink2)) {
                $this->items[$iS]->extlink2 = explode("|", $this->items[$iS]->extlink2, 4);
                if (isset($this->items[$iS]->extlink2[0]) && $this->items[$iS]->extlink2[0] != '' && isset($this->items[$iS]->extlink2[1])) {
                    $this->items[$iS]->display_icon_extlink2 = 1;
                    $this->tmpl['display_icon_extlink2_box'] = 1;
                    // because of height of box
                    if (!isset($this->items[$iS]->extlink2[2])) {
                        $this->items[$iS]->extlink2[2] = '_self';
                    }
                    if (!isset($this->items[$iS]->extlink2[3]) || $this->items[$iS]->extlink2[3] == 1) {
                        $this->items[$iS]->extlink2[4] = JHtml::_('image', 'media/com_phocagallery/images/icon-extlink2.png', JText::_($this->items[$iS]->extlink2[1]));
                        $this->items[$iS]->extlink2[5] = '';
                    } else {
                        $this->items[$iS]->extlink2[4] = $this->items[$iS]->extlink2[1];
                        $this->items[$iS]->extlink2[5] = 'style="text-decoration:underline"';
                    }
                } else {
                    $this->items[$iS]->display_icon_extlink2 = 0;
                }
            }
            // OVERLIB
            if (!empty($this->items[$iS]->description)) {
                $divPadding = 'ph-ovrl1';
            } else {
                $divPadding = 'ph-ovrl2';
            }
            // Resize image in overlib by rate
            $wHOutput = array();
            if (isset($this->items[$iS]->extpic) && $this->items[$iS]->extpic != '') {
                if ((int) $this->tmpl['overlibimagerate'] > 0) {
                    $imgSize = @getimagesize($this->items[$iS]->extl);
                    $wHOutput = PhocaGalleryImage::getTransformImageArray($imgSize, $this->tmpl['overlibimagerate']);
                }
                $oImg = JHtml::_('image', $this->items[$iS]->extl, '', $wHOutput);
            } else {
                $thumbL = str_replace('phoca_thumb_m1_', 'phoca_thumb_m_', $this->items[$iS]->linkthumbnailpath);
                $thumbL = str_replace('phoca_thumb_m2_', 'phoca_thumb_m_', $thumbL);
                $thumbL = str_replace('phoca_thumb_m3_', 'phoca_thumb_m_', $thumbL);
                $thumbL = str_replace('phoca_thumb_m_', 'phoca_thumb_l_', $thumbL);
                if ((int) $this->tmpl['overlibimagerate'] > 0) {
                    $imgSize = @getimagesize($thumbL);
                    $wHOutput = PhocaGalleryImage::getTransformImageArray($imgSize, $this->tmpl['overlibimagerate']);
                }
                $thumbLI = str_replace('phoca_thumb_m1_', 'phoca_thumb_m_', $this->items[$iS]->linkthumbnailpath);
                $thumbLI = str_replace('phoca_thumb_m2_', 'phoca_thumb_m_', $thumbLI);
                $thumbLI = str_replace('phoca_thumb_m3_', 'phoca_thumb_m_', $thumbLI);
                $oImg = JHtml::_('image', $thumbL, '', $wHOutput);
            }
            switch ($enable_overlib) {
                case 1:
                case 4:
                    $uBy = '';
                    //Uploaded by ...
                    if ($enable_overlib == 4 && isset($this->items[$iS]->usernameno) && $this->items[$iS]->usernameno != '') {
                        $uBy = '<div>' . JText::_('COM_PHOCAGALLERY_UPLOADED_BY') . ' <strong>' . $this->items[$iS]->usernameno . '</strong></div>';
                    }
                    $this->items[$iS]->overlib = 1;
                    $this->items[$iS]->overlib_value = "\n\n" . "onmouseover=\"return overlib('" . htmlspecialchars(addslashes('<div class="pg-overlib"><center>' . $oImg . "</center></div>" . $uBy)) . "', CAPTION, '" . htmlspecialchars(addslashes($this->items[$iS]->title)) . "' ," . htmlspecialchars($this->tmpl['overlib_attributes']) . ");\"" . " onmouseout=\"return nd();\"" . "\n";
                    break;
                case 2:
                case 5:
                    $uBy = '';
                    //Uploaded by ...
                    if ($enable_overlib == 5 && isset($this->items[$iS]->usernameno) && $this->items[$iS]->usernameno != '') {
                        $uBy = '<div>' . JText::_('COM_PHOCAGALLERY_UPLOADED_BY') . ' <strong>' . $this->items[$iS]->usernameno . '</strong></div>';
                    }
                    $this->items[$iS]->overlib = 2;
                    $this->items[$iS]->description = str_replace('"', '\'', $this->items[$iS]->description);
                    $this->items[$iS]->description = str_replace("\n", '<br />', $this->items[$iS]->description);
                    $sA = array(utf8_encode(chr(11)), utf8_encode(chr(160)));
                    $eA = array("\t", "\n", "\r", "");
                    $this->items[$iS]->description = str_replace($sA, ' ', $this->items[$iS]->description);
                    $this->items[$iS]->description = str_replace($eA, '', $this->items[$iS]->description);
                    $this->items[$iS]->overlib_value = " onmouseover=\"return overlib('" . htmlspecialchars(addslashes('<div class="pg-overlib"><div class="' . $divPadding . '">' . $this->items[$iS]->description . '</div></div>' . $uBy)) . "', CAPTION, '" . htmlspecialchars(addslashes($this->items[$iS]->title)) . "', " . htmlspecialchars($this->tmpl['overlib_attributes']) . ");\"" . " onmouseout=\"return nd();\" ";
                    break;
                case 3:
                case 6:
                    $uBy = '';
                    //Uploaded by ...
                    if ($enable_overlib == 6 && isset($this->items[$iS]->usernameno) && $this->items[$iS]->usernameno != '') {
                        $uBy = '<div>' . JText::_('COM_PHOCAGALLERY_UPLOADED_BY') . ' <strong>' . $this->items[$iS]->usernameno . '</strong></div>';
                    }
                    $this->items[$iS]->overlib = 3;
                    $this->items[$iS]->description = str_replace('"', '\'', $this->items[$iS]->description);
                    $this->items[$iS]->description = str_replace("\n", '<br />', $this->items[$iS]->description);
                    $sA = array(utf8_encode(chr(11)), utf8_encode(chr(160)));
                    $eA = array("\t", "\n", "\r", "");
                    $this->items[$iS]->description = str_replace($sA, ' ', $this->items[$iS]->description);
                    $this->items[$iS]->description = str_replace($eA, '', $this->items[$iS]->description);
                    $this->items[$iS]->overlib_value = " onmouseover=\"return overlib('" . PhocaGalleryText::strTrimAll(htmlspecialchars(addslashes('<div class="pg-overlib"><div style="text-align:center"><center>' . $oImg . '</center></div><div class="' . $divPadding . '">' . $this->items[$iS]->description . '</div></div>' . $uBy))) . "', CAPTION, '" . htmlspecialchars(addslashes($this->items[$iS]->title)) . "', " . htmlspecialchars($this->tmpl['overlib_attributes']) . ");\"" . " onmouseout=\"return nd();\" ";
                    break;
                default:
                    $this->items[$iS]->overlib = 0;
                    $this->items[$iS]->overlib_value = '';
                    break;
            }
            // VirtueMart link
            if ($this->tmpl['display_icon_vm'] == 1) {
                phocagalleryimport('phocagallery.virtuemart.virtuemart');
                $vmLink = PhocaGalleryVirtueMart::getVmLink($this->items[$iS]->vmproductid, $errorMsg);
                if (!$vmLink) {
                    $this->items[$iS]->display_icon_vm = '';
                } else {
                    $this->items[$iS]->display_icon_vm = 1;
                    $this->items[$iS]->vmlink = $vmLink;
                    $this->tmpl['display_icon_vmbox'] = 1;
                    // because of height of box
                }
            } else {
                $this->items[$iS]->display_icon_vm = '';
            }
            // End VM Link
            // V O T E S - IMAGES
            if ((int) $this->tmpl['display_rating_img'] == 1) {
                $this->items[$iS]->votescountimg = 0;
                $this->items[$iS]->votesaverageimg = 0;
                $this->items[$iS]->voteswidthimg = 0;
                $votesStatistics = PhocaGalleryRateImage::getVotesStatistics((int) $this->items[$iS]->id);
                if (!empty($votesStatistics->count)) {
                    $this->items[$iS]->votescountimg = $votesStatistics->count;
                }
                if (!empty($votesStatistics->average)) {
                    $this->items[$iS]->votesaverageimg = $votesStatistics->average;
                    if ($this->items[$iS]->votesaverageimg > 0) {
                        $this->items[$iS]->votesaverageimg = round((double) $this->items[$iS]->votesaverageimg / 0.5) * 0.5;
                        $this->items[$iS]->voteswidthimg = 16 * $this->items[$iS]->votesaverageimg;
                    } else {
                        $this->items[$iS]->votesaverageimg = (int) 0;
                        // not float displaying
                    }
                }
            }
            $this->items[$iS]->display_icon_commentimg = 0;
            // C O M M E N T S - IMAGES
            if ((int) $this->tmpl['display_comment_img'] == 1 || (int) $this->tmpl['display_comment_img'] == 3) {
                $this->items[$iS]->display_icon_commentimg = 1;
                $this->tmpl['display_icon_commentimg_box'] = 1;
                // because of height of box
            }
            // COMMENTS IMAGES, masonry
            if ((int) $this->tmpl['display_comment_img'] == 2 || (int) $this->tmpl['display_comment_img'] == 3) {
                //PhocaGalleryCommentImage::renderCommentImageJS();
                $this->items[$iS]->allready_commented = 0;
                $this->items[$iS]->allready_commented = PhocaGalleryCommentImage::checkUserComment((int) $this->items[$iS]->id, (int) $this->tmpl['user']->id);
                $this->items[$iS]->comment_items = PhocaGalleryCommentImage::displayComment($this->items[$iS]->id);
            }
            // ALT VALUE
            $altValue = PhocaGalleryRenderFront::getAltValue($this->tmpl['altvalue'], $this->items[$iS]->title, $this->items[$iS]->description, $this->items[$iS]->metadesc);
            $this->items[$iS]->altvalue = $altValue;
            // TITLE TAG - Description Output in Title Tag
            $imgAlt = $imgTitle = '';
            // Some methods cannot use Alt because of conflicting with Title and popup methods
            if ($this->tmpl['detail_window'] == 3 || $this->tmpl['detail_window'] == 9 || $this->tmpl['detail_window'] == 10) {
                $imgAlt = $this->items[$iS]->altvalue;
                $imgTitle = $this->items[$iS]->title;
                if ($imgAlt == $imgTitle) {
                    $imgAlt = '';
                }
                $this->items[$iS]->oimgalt = $imgAlt;
            } else {
                $this->items[$iS]->oimgalt = $altValue;
            }
            // TITLE TAG - Detail
            if ($this->tmpl['detail_window'] == 9 || $this->tmpl['detail_window'] == 10) {
                $detailAlt = $this->items[$iS]->altvalue;
                $detailTitle = $this->items[$iS]->title;
                if ($detailAlt == $detailTitle) {
                    $detailAlt = '';
                }
            } else {
                $detailAlt = JText::_('COM_PHOCAGALLERY_IMAGE_DETAIL');
                $detailTitle = JText::_('COM_PHOCAGALLERY_IMAGE_DETAIL');
            }
            $this->items[$iS]->oimgaltdetail = $detailAlt;
            $this->items[$iS]->oimgtitledetail = $detailTitle;
            $titleDesc = '';
            if ($this->tmpl['display_title_description'] == 1) {
                $titleDesc .= $this->items[$iS]->title;
                if ($this->items[$iS]->description != '' && $titleDesc != '') {
                    $titleDesc .= ' - ';
                }
            }
            if ($this->tmpl['detail_window'] == 8 && $this->tmpl['displaydescriptiondetail'] == 1) {
                $this->items[$iS]->odesctitletag = strip_tags($titleDesc) . strip_tags($this->items[$iS]->description);
            } else {
                $this->items[$iS]->odesctitletag = strip_tags($imgTitle);
            }
            // Overlib class
            if ($this->items[$iS]->overlib == 0) {
                $this->items[$iS]->ooverlibclass = array('class' => 'pg-image');
            } else {
                $this->items[$iS]->ooverlibclass = array('class' => 'pimo pg-image');
            }
            // Tags
            $this->items[$iS]->otags = '';
            if ($this->tmpl['display_tags_links'] == 1 || $this->tmpl['display_tags_links'] == 3) {
                $this->items[$iS]->otags = PhocaGalleryTag::displayTags($this->items[$iS]->id);
                if ($this->items[$iS]->otags != '') {
                    $this->tmpl['displaying_tags_true'] = 1;
                }
            }
            $iS++;
        }
        // END IMAGES
        // Upload Form - - - - - - - - - - - - -
        // Set FTP form
        $ftp = !JClientHelper::hasCredentials('ftp');
        // PARAMS - Upload size
        $this->tmpl['uploadmaxsize'] = $this->params->get('upload_maxsize', 3000000);
        $sess = JFactory::getSession();
        $this->assignRef('session', $sess);
        //$this->assignRef('uploadmaxsize', $upload_maxsize);
        // END Upload Form - - - - - - - - - - - -
        // V O T E S - CATEGORY
        // Only registered (VOTES + COMMENTS)
        $this->tmpl['not_registered'] = true;
        $this->tmpl['name'] = '';
        if ($access > 0) {
            $this->tmpl['not_registered'] = false;
            $this->tmpl['name'] = $this->tmpl['user']->name;
        }
        // VOTES Statistics
        if ((int) $this->tmpl['display_rating'] == 1 && (int) $id > 0) {
            $this->tmpl['votescount'] = 0;
            $this->tmpl['votesaverage'] = 0;
            $this->tmpl['voteswidth'] = 0;
            $votesStatistics = PhocaGalleryRateCategory::getVotesStatistics((int) $id);
            if (!empty($votesStatistics->count)) {
                $this->tmpl['votescount'] = $votesStatistics->count;
            }
            if (!empty($votesStatistics->average)) {
                $this->tmpl['votesaverage'] = $votesStatistics->average;
                if ($this->tmpl['votesaverage'] > 0) {
                    $this->tmpl['votesaverage'] = round((double) $this->tmpl['votesaverage'] / 0.5) * 0.5;
                    $this->tmpl['voteswidth'] = 22 * $this->tmpl['votesaverage'];
                } else {
                    $this->tmpl['votesaverage'] = (int) 0;
                    // not float displaying
                }
            }
            if ((int) $this->tmpl['votescount'] > 1) {
                $this->tmpl['votestext'] = 'COM_PHOCAGALLERY_VOTES';
            } else {
                $this->tmpl['votestext'] = 'COM_PHOCAGALLERY_VOTE';
            }
            // Already rated?
            $this->tmpl['alreay_rated'] = PhocaGalleryRateCategory::checkUserVote((int) $id, (int) $this->tmpl['user']->id);
        }
        // COMMENTS
        if ((int) $this->tmpl['display_comment'] == 1 && (int) $id > 0) {
            $document->addScript(JURI::base(true) . '/media/com_phocagallery/js/comments.js');
            $document->addCustomTag(PhocaGalleryRenderFront::renderCommentJS((int) $this->tmpl['maxcommentchar']));
            $this->tmpl['already_commented'] = PhocaGalleryCommentCategory::checkUserComment((int) $id, (int) $this->tmpl['user']->id);
            $commentItem = PhocaGalleryCommentCategory::displaycomment((int) $id);
            $this->assignRef('commentitem', $commentItem);
        }
        // - - - - - - - - - - - - - - - -
        // TABS
        // - - - - - - - - - - - - - - - -
        $this->tmpl['displaytabs'] = 0;
        $this->tmpl['currenttab'] = 0;
        if ((int) $id > 0) {
            $displayTabs = 0;
            // R A T I N G
            if ((int) $this->tmpl['display_rating'] == 0) {
                $currentTab['rating'] = -1;
            } else {
                $currentTab['rating'] = $displayTabs;
                $displayTabs++;
            }
            // C O M M E N T S
            if ((int) $this->tmpl['display_comment'] == 0) {
                $currentTab['comment'] = -1;
            } else {
                $currentTab['comment'] = $displayTabs;
                $displayTabs++;
            }
            // S T A T I S T I C S
            if ((int) $this->tmpl['displaycategorystatistics'] == 0) {
                $currentTab['statistics'] = -1;
            } else {
                $currentTab['statistics'] = $displayTabs;
                $displayTabs++;
                $this->tmpl['displaymaincatstat'] = $this->params->get('display_main_cat_stat', 1);
                $this->tmpl['displaylastaddedcatstat'] = $this->params->get('display_lastadded_cat_stat', 1);
                $this->tmpl['displaymostviewedcatstat'] = $this->params->get('display_mostviewed_cat_stat', 1);
                $this->tmpl['countlastaddedcatstat'] = $this->params->get('count_lastadded_cat_stat', 3);
                $this->tmpl['countmostviewedcatstat'] = $this->params->get('count_mostviewed_cat_stat', 3);
                if ($this->tmpl['displaymaincatstat'] == 1) {
                    $numberImgP = $model->getCountImages($id, 1);
                    $this->tmpl['numberimgpub'] = $numberImgP->countimg;
                    $numberImgU = $model->getCountImages($id, 0);
                    $this->tmpl['numberimgunpub'] = $numberImgU->countimg;
                    $this->categoryViewed = $model->getHits($id);
                    $this->tmpl['categoryviewed'] = $this->categoryViewed->catviewed;
                }
                // M O S T   V I E W E D   I M A G E S
                //$this->tmpl['mostviewedimg'] = array();
                if ($this->tmpl['displaymostviewedcatstat'] == 1) {
                    $mostViewedImages = $model->getStatisticsImages($id, 'hits', 'DESC', $this->tmpl['countmostviewedcatstat']);
                    for ($i = 0; $i < count($mostViewedImages); $i++) {
                        $itemMVI =& $mostViewedImages[$i];
                        $itemMVI->button =& $this->button;
                        $itemMVI->button2 =& $this->button2;
                        $itemMVI->buttonother =& $this->buttonother;
                        $itemMVI->display_icon_detail = $this->tmpl['display_icon_detail'];
                        $itemMVI->display_name = $this->tmpl['display_name'];
                        $itemMVI->type = 2;
                        $altValue = PhocaGalleryRenderFront::getAltValue($this->tmpl['altvalue'], $itemMVI->title, $itemMVI->description, $itemMVI->metadesc);
                        $itemMVI->altvalue = $altValue;
                        $thumbLink = PhocaGalleryFileThumbnail::getThumbnailName($itemMVI->filename, 'large');
                        $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $this->category->slug . '&id=' . $itemMVI->slug . '&tmpl=component' . '&Itemid=' . $this->itemId);
                        $imgLink = JURI::base(true) . '/' . $thumbLink->rel;
                        switch ($this->tmpl['detail_window']) {
                            case 2:
                            case 3:
                            case 8:
                                $itemMVI->link = $imgLink;
                                break;
                            default:
                                $itemMVI->link = $siteLink;
                                break;
                        }
                        //$this->tmpl['mostviewedimg'][] = $itemMVI;
                        if ($itemMVI->extw != '') {
                            $extw = explode(',', $itemMVI->extw);
                            $itemMVI->extw = $extw[1];
                        }
                        if ($itemMVI->exth != '') {
                            $exth = explode(',', $itemMVI->exth);
                            $itemMVI->exth = $exth[1];
                        }
                    }
                    $this->tmpl['mostviewedimg'] = $mostViewedImages;
                }
                // L A S T   A D D E D   I M A G E S
                //$this->tmpl['lastaddedimg'] = array();
                if ($this->tmpl['displaylastaddedcatstat'] == 1) {
                    $lastAddedImages = $model->getStatisticsImages($id, 'date', 'DESC', $this->tmpl['countlastaddedcatstat']);
                    for ($i = 0; $i < count($lastAddedImages); $i++) {
                        $itemLAI =& $lastAddedImages[$i];
                        $itemLAI->link = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $this->category->slug . '&id=' . $itemLAI->slug . '&tmpl=component' . '&Itemid=' . $this->itemId);
                        $itemLAI->button =& $this->button;
                        $itemLAI->button2 =& $this->button2;
                        $itemLAI->buttonother =& $this->buttonother;
                        $itemLAI->display_icon_detail = $this->tmpl['display_icon_detail'];
                        $itemLAI->display_name = $this->tmpl['display_name'];
                        $itemLAI->type = 2;
                        $altValue = PhocaGalleryRenderFront::getAltValue($this->tmpl['altvalue'], $itemLAI->title, $itemLAI->description, $itemLAI->metadesc);
                        $itemLAI->altvalue = $altValue;
                        $thumbLink = PhocaGalleryFileThumbnail::getThumbnailName($itemLAI->filename, 'large');
                        $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $this->category->slug . '&id=' . $itemLAI->slug . '&tmpl=component' . '&Itemid=' . $this->itemId);
                        $imgLink = JURI::base(true) . '/' . $thumbLink->rel;
                        switch ($this->tmpl['detail_window']) {
                            case 2:
                            case 3:
                            case 8:
                                $itemLAI->link = $imgLink;
                                break;
                            default:
                                $itemLAI->link = $siteLink;
                                break;
                        }
                        //$this->tmpl['lastaddedimg'][] = $itemLAI;
                        if ($itemLAI->extw != '') {
                            $extw = explode(',', $itemLAI->extw);
                            $itemLAI->extw = $extw[1];
                        }
                        if ($itemLAI->exth != '') {
                            $exth = explode(',', $itemLAI->exth);
                            $itemLAI->exth = $exth[1];
                        }
                    }
                    $this->tmpl['lastaddedimg'] = $lastAddedImages;
                }
            }
            // G E O T A G G I N G
            if ((int) $this->tmpl['displaycategorygeotagging'] == 0) {
                $currentTab['geotagging'] = -1;
            } else {
                if ($this->map['longitude'] == '') {
                    $currentTab['geotagging'] = -1;
                } else {
                    if ($this->map['latitude'] == '') {
                        $currentTab['geotagging'] = -1;
                    } else {
                        $currentTab['geotagging'] = $displayTabs;
                        $displayTabs++;
                        $this->tmpl['googlemapsapikey'] = $this->params->get('google_maps_api_key', '');
                        $this->tmpl['categorymapwidth'] = $this->params->get('category_map_width', '');
                        $this->tmpl['categorymapheight'] = $this->params->get('category_map_height', 400);
                    }
                }
            }
            if ((int) $this->tmpl['displaycreatecat'] == 0) {
                $currentTab['createsubcategory'] = -1;
            } else {
                $currentTab['createsubcategory'] = $displayTabs;
                $displayTabs++;
            }
            // = = = = = = = = = =
            // U P L O A D
            // = = = = = = = = = =
            $this->tmpl['ftp'] = !JClientHelper::hasCredentials('ftp');
            // SEF problem
            $isThereQM = false;
            $isThereQM = preg_match("/\\?/i", $this->tmpl['action']);
            if ($isThereQM) {
                $amp = '&';
                // will be protected by htmlspecialchars
            } else {
                $amp = '?';
            }
            $isThereTab = false;
            $isThereTab = preg_match("/tab=/i", $this->tmpl['action']);
            if ((int) $this->tmpl['displayupload'] == 0) {
                $currentTab['upload'] = -1;
            } else {
                $currentTab['upload'] = $displayTabs;
                $displayTabs++;
            }
            if ((int) $this->tmpl['ytbupload'] == 0 || (int) $this->tmpl['displayupload'] == 0) {
                $currentTab['ytbupload'] = -1;
            } else {
                $currentTab['ytbupload'] = $displayTabs;
                $displayTabs++;
            }
            if ((int) $this->tmpl['enablemultiple'] < 1 || (int) $this->tmpl['displayupload'] == 0) {
                $currentTab['multipleupload'] = -1;
            } else {
                $currentTab['multipleupload'] = $displayTabs;
                $displayTabs++;
            }
            if ((int) $this->tmpl['enablejava'] < 1 || (int) $this->tmpl['displayupload'] == 0) {
                $currentTab['javaupload'] = -1;
            } else {
                $currentTab['javaupload'] = $displayTabs;
                $displayTabs++;
            }
            $this->tmpl['displaytabs'] = $displayTabs;
            $this->tmpl['currenttab'] = $currentTab;
            // - - - - - - - - - - -
            // Upload
            // - - - - - - - - - - -
            if ((int) $this->tmpl['displayupload'] == 1) {
                $sU = new PhocaGalleryFileUploadSingle();
                $sU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . 'task=upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['upload']);
                $sU->tab = $this->tmpl['currenttab']['upload'];
                $this->tmpl['su_output'] = $sU->getSingleUploadHTML(1);
                $this->tmpl['su_url'] = htmlspecialchars($this->tmpl['action'] . $amp . 'task=upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['upload']);
            }
            // - - - - - - - - - - -
            // Youtube Upload (single upload form can be used)
            // - - - - - - - - - - -
            if ((int) $this->tmpl['ytbupload'] == 1 && $this->tmpl['displayupload'] == 1) {
                $sYU = new PhocaGalleryFileUploadSingle();
                $sYU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . 'task=ytbupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['ytbupload']);
                $sYU->tab = $this->tmpl['currenttab']['ytbupload'];
                $this->tmpl['syu_output'] = $sYU->getSingleUploadHTML(1);
                $this->tmpl['syu_url'] = htmlspecialchars($this->tmpl['action'] . $amp . 'task=ytbupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['ytbupload']);
            }
            // - - - - - - - - - - -
            // Multiple Upload
            // - - - - - - - - - - -
            // Get infos from multiple upload
            $muFailed = $app->input->get('mufailed', '0', 'int');
            $muUploaded = $app->input->get('muuploaded', '0', 'int');
            $this->tmpl['mu_response_msg'] = $muUploadedMsg = '';
            if ($muUploaded > 0) {
                $muUploadedMsg = JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded;
            }
            if ($muFailed > 0) {
                $muFailedMsg = JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed;
            }
            if ($muFailed > 0 && $muUploaded > 0) {
                $this->tmpl['mu_response_msg'] = '<div class="alert alert-info">' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '<br />' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
            } else {
                if ($muFailed > 0 && $muUploaded == 0) {
                    $this->tmpl['mu_response_msg'] = '<div class="alert alert-error">' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
                } else {
                    if ($muFailed == 0 && $muUploaded > 0) {
                        $this->tmpl['mu_response_msg'] = '<div class="alert alert-success">' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '</div>';
                    } else {
                        $this->tmpl['mu_response_msg'] = '';
                    }
                }
            }
            if ((int) $this->tmpl['enablemultiple'] == 1 && (int) $this->tmpl['displayupload'] == 1) {
                PhocaGalleryFileUploadMultiple::renderMultipleUploadLibraries();
                $mU = new PhocaGalleryFileUploadMultiple();
                $mU->frontEnd = 1;
                $mU->method = $this->tmpl['multipleuploadmethod'];
                $mU->url = htmlspecialchars($this->tmpl['action'] . $amp . 'controller=category&task=multipleupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['multipleupload']);
                $mU->reload = htmlspecialchars($this->tmpl['action'] . $amp . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['multipleupload']);
                $mU->maxFileSize = PhocaGalleryFileUploadMultiple::getMultipleUploadSizeFormat($this->tmpl['uploadmaxsize']);
                $mU->chunkSize = '1mb';
                $mU->imageHeight = $this->tmpl['multipleresizeheight'];
                $mU->imageWidth = $this->tmpl['multipleresizewidth'];
                $mU->imageQuality = 100;
                $mU->renderMultipleUploadJS(0, $this->tmpl['multipleuploadchunk']);
                $this->tmpl['mu_output'] = $mU->getMultipleUploadHTML();
            }
            // - - - - - - - - - - -
            // Java Upload
            // - - - - - - - - - - -
            if ((int) $this->tmpl['enablejava'] == 1 && (int) $this->tmpl['displayupload'] == 1) {
                $jU = new PhocaGalleryFileUploadJava();
                $jU->width = $this->tmpl['javaboxwidth'];
                $jU->height = $this->tmpl['javaboxheight'];
                $jU->resizewidth = $this->tmpl['multipleresizewidth'];
                $jU->resizeheight = $this->tmpl['multipleresizeheight'];
                $jU->uploadmaxsize = $this->tmpl['uploadmaxsize'];
                $jU->returnUrl = $this->tmpl['action'] . $amp . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['javaupload'];
                $jU->url = $this->tmpl['action'] . $amp . 'controller=category&task=javaupload&amp;' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&amp;tab=' . $this->tmpl['currenttab']['javaupload'];
                $jU->source = JURI::root(true) . '/components/com_phocagallery/assets/jupload/wjhk.jupload.jar';
                $this->tmpl['ju_output'] = $jU->getJavaUploadHTML();
            }
        }
        $this->tmpl['dem'] = '<div style="text-align:right;color:#ccc;display:block">Powered by <a href="http://www.phoca.cz/phocagallery">Phoca Gallery</a></div>';
        // ADD STATISTICS
        if ((int) $id > 0) {
            $model->hit($id);
        }
        // ADD JAK DATA CSS style
        if ($this->tmpl['detail_window'] == 6) {
            $document->addCustomTag('<script type="text/javascript">' . 'var dataJakJs = [' . implode($this->tmpl['jakdatajs'], ',') . ']' . '</script>');
        }
        // Detail Window - will be popup or not
        if ($this->tmpl['detail_window'] == 7) {
            $this->tmpl['tmplcom'] = '';
            $this->tmpl['tmplcomcomments'] = '';
        } else {
            $this->tmpl['tmplcom'] = '&tmpl=component';
            $this->tmpl['tmplcomcomments'] = '&tmpl=component';
        }
        if ($this->tmpl['display_comment_nopup'] == 1) {
            $this->tmpl['tmplcomcomments'] = '';
        }
        $this->tmpl['boxsize'] = PhocaGalleryImage::setBoxSize($this->tmpl, 2);
        $this->tmpl['boxsizestat'] = PhocaGalleryImage::setBoxSize($this->tmpl, 3);
        $masBoxWidth = $this->tmpl['boxsize']['width'] + 20;
        // Masonry effect
        if ($this->tmpl['diff_thumb_height'] == 2) {
            $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/masonry/masonry.min.js');
            $document->addCustomTag('<script type="text/javascript">
			window.onload = function() {
			  var wall = new Masonry( document.getElementById(\'pg-msnr-container\'), {
				isFitWidth: true
			  });
			};
			</script>');
        }
        // CSS Specific
        $s = "\n" . '#phocagallery {' . "\n";
        if ($this->tmpl['phocagallery_center'] != '') {
            $s .= '   margin: 0 auto; text-align: center;' . "\n";
        }
        if ($this->tmpl['phocagallery_width'] != '') {
            $s .= '   width: ' . $this->tmpl['phocagallery_width'] . 'px;' . "\n";
        }
        $s .= '}' . "\n";
        if ($this->tmpl['phocagallery_center'] != '') {
            $s = "\n" . '#pg-msnr-container {' . "\n";
            $s .= '   margin: 0 auto;' . "\n";
            $s .= '}' . "\n";
        }
        $s .= '.pg-cv-box {' . "\n";
        if ($this->tmpl['diff_thumb_height'] > 0) {
        } else {
            $s .= '   height: ' . $this->tmpl['boxsize']['height'] . 'px;' . "\n";
        }
        $s .= '   width: ' . $this->tmpl['boxsize']['width'] . 'px;"' . "\n";
        $s .= '}' . "\n";
        $s .= '.pg-cv-box-stat {' . "\n";
        $s .= '   height: ' . $this->tmpl['boxsizestat']['height'] . 'px;' . "\n";
        $s .= '   width: ' . $this->tmpl['boxsizestat']['width'] . 'px;"' . "\n";
        $s .= '}' . "\n";
        $s .= '.pg-cv-box-img {' . "\n";
        $s .= '   height: ' . $this->tmpl['imageheight'] . 'px;' . "\n";
        $s .= '   width: ' . $this->tmpl['imagewidth'] . 'px;"' . "\n";
        $s .= '}' . "\n";
        $document->addCustomTag('<style type="text/css">' . $s . '</style>');
        $this->_prepareDocument();
        parent::display($tpl);
    }
Example #25
0
 public static function createFolder($folder, &$errorMsg)
 {
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $folder_permissions = $paramsC->get('folder_permissions', 0755);
     // Doesn't work on some servers
     //$folder_permissions = octdec((int)$folder_permissions);
     $path = PhocaGalleryPath::getPath();
     $folder = JPath::clean($path->image_abs . $folder);
     if (strlen($folder) > 0) {
         if (!JFolder::exists($folder) && !JFile::exists($folder)) {
             // Because of problems on some servers:
             // It is temporary solution
             switch ((int) $folder_permissions) {
                 case 777:
                     JFolder::create($folder, 0777);
                     break;
                 case 705:
                     JFolder::create($folder, 0705);
                     break;
                 case 666:
                     JFolder::create($folder, 0666);
                     break;
                 case 644:
                     JFolder::create($folder, 0644);
                     break;
                 case 755:
                 default:
                     JFolder::create($folder, 0755);
                     break;
             }
             //JFolder::create($folder, $folder_permissions );
             if (isset($folder)) {
                 $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
                 JFile::write($folder . DS . "index.html", $data);
             }
             // folder was not created
             if (!JFolder::exists($folder)) {
                 $errorMsg = "CreatingFolder";
                 return false;
             }
         } else {
             $errorMsg = "FolderExists";
             return false;
         }
     } else {
         $errorMsg = "FolderNameEmpty";
         return false;
     }
     return true;
 }
Example #26
0
 public static function createBgImage($data, &$errorMsg)
 {
     $params = JComponentHelper::getParams('com_phocagallery');
     $jfile_thumbs = $params->get('jfile_thumbs', 1);
     $jpeg_quality = $params->get('jpeg_quality', 85);
     $jpeg_quality = PhocaGalleryImage::getJpegQuality($jpeg_quality);
     $formatIcon = 'png';
     $path = PhocaGalleryPath::getPath();
     $fileIn = $fileOut = $path->image_abs_front . $data['image'] . '.' . $formatIcon;
     if ($fileIn !== '' && JFile::exists($fileIn)) {
         $memory = 8;
         $memoryLimitChanged = 0;
         $memory = (int) ini_get('memory_limit');
         if ($memory == 0) {
             $memory = 8;
         }
         // Try to increase memory
         if ($memory < 50) {
             ini_set('memory_limit', '50M');
             $memoryLimitChanged = 1;
         }
         $imageWidth = $data['iw'];
         $imageHeight = $data['ih'];
         $completeImageWidth = $imageWidth + 18;
         $completeImageHeight = $imageHeight + 18;
         $completeImageBackground = $data['sbgc'];
         $retangleColor = $data['ibgc'];
         $borderColor = $data['ibrdc'];
         $shadowColor = $data['iec'];
         $effect = $data['ie'];
         // shadow or glow
         $imgX = 6;
         $imgWX = $imageWidth + 5 + $imgX;
         // Image Width + space (padding) + Start Position
         $imgY = 6;
         $imgHY = $imageHeight + 5 + $imgY;
         $brdX = $imgX - 1;
         $brdWX = $imgWX + 1;
         $brdY = $imgY - 1;
         $brdHY = $imgHY + 1;
         // Crate an image
         $img = @imagecreatetruecolor($completeImageWidth, $completeImageHeight);
         if (!$img) {
             $errorMsg = 'ErrorNoImageCreateTruecolor';
             return false;
         }
         if ($completeImageBackground == '') {
             switch ($formatIcon) {
                 case 'jpg':
                 case 'jpeg':
                 case 'gif':
                     $completeImageBackground = '#ffffff';
                     break;
                 case 'png':
                     @imagealphablending($img, false);
                     imagefilledrectangle($img, 0, 0, $completeImageWidth, $completeImageHeight, imagecolorallocatealpha($img, 255, 255, 255, 127));
                     @imagealphablending($img, true);
                     break;
             }
         } else {
             $bGClr = PhocaGalleryUtils::htmlToRgb($completeImageBackground);
             imagefilledrectangle($img, 0, 0, $completeImageWidth, $completeImageHeight, imagecolorallocate($img, $bGClr[0], $bGClr[1], $bGClr[2]));
         }
         // Create Retangle
         if ($retangleColor != '') {
             $rtgClr = PhocaGalleryUtils::htmlToRgb($retangleColor);
             $retangle = imagecolorallocate($img, $rtgClr[0], $rtgClr[1], $rtgClr[2]);
         }
         // Create Border
         if ($borderColor != '') {
             $brdClr = PhocaGalleryUtils::htmlToRgb($borderColor);
             $border = imagecolorallocate($img, $brdClr[0], $brdClr[1], $brdClr[2]);
         }
         // Effect (shadow,glow)
         if ((int) $effect > 0) {
             if ($shadowColor != '') {
                 $shdClr = PhocaGalleryUtils::htmlToRgb($shadowColor);
                 if ((int) $effect == 3) {
                     $shdX = $brdX - 1;
                     $shdY = $brdY - 1;
                     $effectArray = array(55, 70, 85, 100, 115);
                 } else {
                     if ((int) $effect == 2) {
                         $shdX = $brdX + 3;
                         $shdY = $brdY + 3;
                         $effectArray = array(50, 70, 90, 110);
                     } else {
                         $shdX = $brdX + 3;
                         $shdY = $brdY + 3;
                         $effectArray = array(0, 0, 0, 0);
                     }
                 }
                 $shdWX = $brdWX + 1;
                 $shdHY = $brdHY + 1;
                 foreach ($effectArray as $key => $value) {
                     $effectImg = @imagecolorallocatealpha($img, $shdClr[0], $shdClr[1], $shdClr[2], $value);
                     if (!$effectImg) {
                         $errorMsg = 'ErrorNoImageColorAllocateAlpha';
                         return false;
                     }
                     imagerectangle($img, $shdX, $shdY, $shdWX, $shdHY, $effectImg);
                     if ((int) $effect == 3) {
                         $shdX--;
                         $shdY--;
                     } else {
                         if ((int) $effect == 2) {
                             $shdX++;
                             $shdY++;
                         } else {
                             //$shdX++;
                             //$shdY++;
                         }
                     }
                     $shdWX++;
                     $shdHY++;
                 }
             }
         }
         // Write Rectangle over the shadow
         if ($retangleColor != '') {
             imagefilledrectangle($img, $imgX, $imgY, $imgWX, $imgHY, $retangle);
         }
         if ($borderColor != '') {
             imagerectangle($img, $brdX, $brdY, $brdWX, $brdHY, $border);
         }
         switch ($formatIcon) {
             case 'jpg':
             case 'jpeg':
                 if (!function_exists('ImageJPEG')) {
                     $errorMsg = 'ErrorNoJPGFunction';
                     return false;
                 }
                 if ($jfile_thumbs == 1) {
                     ob_start();
                     if (!@ImageJPEG($img, NULL, $jpeg_quality)) {
                         ob_end_clean();
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                     $imgJPEGToWrite = ob_get_contents();
                     ob_end_clean();
                     if (!JFile::write($fileOut, $imgJPEGToWrite)) {
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                 } else {
                     if (!@ImageJPEG($img, $fileOut, $jpeg_quality)) {
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                 }
                 break;
             case 'png':
                 if (!function_exists('ImagePNG')) {
                     $errorMsg = 'ErrorNoPNGFunction';
                     return false;
                 }
                 @imagesavealpha($img, true);
                 if ($jfile_thumbs == 1) {
                     ob_start();
                     if (!@ImagePNG($img, NULL)) {
                         ob_end_clean();
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                     $imgPNGToWrite = ob_get_contents();
                     ob_end_clean();
                     if (!JFile::write($fileOut, $imgPNGToWrite)) {
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                 } else {
                     if (!@ImagePNG($img, $fileOut)) {
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                 }
                 break;
             case 'gif':
                 if (!function_exists('ImageGIF')) {
                     $errorMsg = 'ErrorNoGIFFunction';
                     return false;
                 }
                 if ($jfile_thumbs == 1) {
                     ob_start();
                     if (!@ImageGIF($img, NULL)) {
                         ob_end_clean();
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                     $imgGIFToWrite = ob_get_contents();
                     ob_end_clean();
                     if (!JFile::write($fileOut, $imgGIFToWrite)) {
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                 } else {
                     if (!@ImageGIF($img, $fileOut)) {
                         $errorMsg = 'ErrorWriteFile';
                         return false;
                     }
                 }
                 break;
             default:
                 $errorMsg = 'ErrorNotSupportedImage';
                 return false;
                 break;
         }
         // free memory
         ImageDestroy($img);
         // Original
         if ($memoryLimitChanged == 1) {
             $memoryString = $memory . 'M';
             ini_set('memory_limit', $memoryString);
         }
         return true;
         // Success
     }
     $errorMsg = 'Error2';
     return false;
 }
Example #27
0
File: path.php Project: 01J/furcom
 public static function getPath()
 {
     $instance = PhocaGalleryPath::getInstance();
     return $instance;
 }
Example #28
0
 public function getCSSPath($type, $rel = 0)
 {
     $paths = PhocaGalleryPath::getPath();
     if ($rel == 1) {
         if ($type == 1) {
             return $paths->media_css_rel . 'main/';
         } else {
             return $paths->media_css_rel . 'custom/';
         }
     } else {
         if ($type == 1) {
             return JPath::clean($paths->media_css_abs . 'main/');
         } else {
             return JPath::clean($paths->media_css_abs . 'custom/');
         }
     }
 }
Example #29
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document =& JFactory::getDocument();
     $uri =& JFactory::getURI();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $this->params =& $app->getParams();
     $user =& JFactory::getUser();
     $path = PhocaGalleryPath::getPath();
     $this->itemId = $app->input->get('Itemid', 0, 'int');
     $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
     $access = PhocaGalleryAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels);
     $this->tmpl['pi'] = 'media/com_phocagallery/images/';
     $this->tmpl['pp'] = 'index.php?option=com_phocagallery&view=user&controller=user';
     $this->tmpl['pl'] = 'index.php?option=com_users&view=login&return=' . base64_encode($this->tmpl['pp'] . '&Itemid=' . $this->itemId);
     // LIBRARY
     $library =& PhocaGalleryLibrary::getLibrary();
     //$libraries['pg-css-ie'] 			= $library->getLibrary('pg-css-ie');
     // Only registered users
     if (!$access) {
         $app->redirect(JRoute::_($this->tmpl['pl'], false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
         exit;
     }
     $this->tmpl['gallerymetakey'] = $this->params->get('gallery_metakey', '');
     $this->tmpl['gallerymetadesc'] = $this->params->get('gallery_metadesc', '');
     if ($this->tmpl['gallerymetakey'] != '') {
         $document->setMetaData('keywords', $this->tmpl['gallerymetakey']);
     }
     if ($this->tmpl['gallerymetadesc'] != '') {
         $document->setMetaData('description', $this->tmpl['gallerymetadesc']);
     }
     PhocaGalleryRenderFront::renderAllCSS();
     // = = = = = = = = = = =
     // PANE
     // = = = = = = = = = = =
     // - - - - - - - - - -
     // ALL TABS
     // - - - - - - - - - -
     // UCP is disabled (security reasons)
     if ((int) $this->params->get('enable_user_cp', 0) == 0) {
         $app->redirect(JURI::base(true), JText::_('COM_PHOCAGALLERY_UCP_DISABLED'));
         exit;
     }
     $this->tmpl['tab'] = $app->input->get('tab', 0, 'string');
     $this->tmpl['maxuploadchar'] = $this->params->get('max_upload_char', 1000);
     $this->tmpl['maxcreatecatchar'] = $this->params->get('max_create_cat_char', 1000);
     $this->tmpl['dp'] = PhocaGalleryRenderInfo::getPhocaIc((int) $this->params->get('display_phoca_info', 1));
     $this->tmpl['showpageheading'] = $this->params->get('show_page_heading', 1);
     $this->tmpl['javaboxwidth'] = $this->params->get('java_box_width', 480);
     $this->tmpl['javaboxheight'] = $this->params->get('java_box_height', 480);
     $this->tmpl['enableuploadavatar'] = $this->params->get('enable_upload_avatar', 1);
     $this->tmpl['uploadmaxsize'] = $this->params->get('upload_maxsize', 3145728);
     $this->tmpl['uploadmaxsizeread'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['uploadmaxsize']);
     $this->tmpl['uploadmaxreswidth'] = $this->params->get('upload_maxres_width', 3072);
     $this->tmpl['uploadmaxresheight'] = $this->params->get('upload_maxres_height', 2304);
     $this->tmpl['multipleuploadchunk'] = $this->params->get('multiple_upload_chunk', 0);
     $this->tmpl['displaytitleupload'] = $this->params->get('display_title_upload', 0);
     $this->tmpl['displaydescupload'] = $this->params->get('display_description_upload', 0);
     $this->tmpl['enablejava'] = $this->params->get('enable_java', -1);
     $this->tmpl['enablemultiple'] = $this->params->get('enable_multiple', 0);
     $this->tmpl['ytbupload'] = $this->params->get('youtube_upload', 0);
     $this->tmpl['multipleuploadmethod'] = $this->params->get('multiple_upload_method', 1);
     $this->tmpl['multipleresizewidth'] = $this->params->get('multiple_resize_width', -1);
     $this->tmpl['multipleresizeheight'] = $this->params->get('multiple_resize_height', -1);
     $this->tmpl['usersubcatcount'] = $this->params->get('user_subcat_count', 5);
     $this->tmpl['userimagesmaxspace'] = $this->params->get('user_images_max_size', 20971520);
     $this->tmpl['iepx'] = '<div style="font-size:1px;height:1px;margin:0px;padding:0px;">&nbsp;</div>';
     //Subcateogry
     $this->tmpl['parentid'] = $app->input->get('parentcategoryid', 0, 'int');
     $document->addScript(JURI::base(true) . '/media/com_phocagallery/js/comments.js');
     $document->addCustomTag(PhocaGalleryRenderFront::renderOnUploadJS());
     $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionCreateCatJS((int) $this->tmpl['maxcreatecatchar']));
     $document->addCustomTag(PhocaGalleryRenderFront::userTabOrdering());
     // SubCategory + Image
     $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionCreateSubCatJS((int) $this->tmpl['maxcreatecatchar']));
     $document->addCustomTag(PhocaGalleryRenderFront::saveOrderUserJS());
     $model = $this->getModel('user');
     $ownerMainCategory = $model->getOwnerMainCategory($user->id);
     $this->tmpl['usertab'] = 1;
     $this->tmpl['createcategory'] = 1;
     $this->tmpl['createsubcategory'] = 1;
     $this->tmpl['images'] = 1;
     $this->tmpl['displayupload'] = 1;
     // Tabs
     $displayTabs = 0;
     if ((int) $this->tmpl['usertab'] == 0) {
         $currentTab['user'] = -1;
     } else {
         $currentTab['user'] = $displayTabs;
         $displayTabs++;
     }
     if ((int) $this->tmpl['createcategory'] == 0) {
         $currentTab['createcategory'] = -1;
     } else {
         $currentTab['createcategory'] = $displayTabs;
         $displayTabs++;
     }
     if ((int) $this->tmpl['createsubcategory'] == 0) {
         $currentTab['createsubcategory'] = -1;
     } else {
         $currentTab['createsubcategory'] = $displayTabs;
         $displayTabs++;
     }
     if ((int) $this->tmpl['displayupload'] == 0) {
         $currentTab['images'] = -1;
     } else {
         $currentTab['images'] = $displayTabs;
         $displayTabs++;
     }
     $this->tmpl['displaytabs'] = $displayTabs;
     $this->tmpl['currenttab'] = $currentTab;
     // ACTION
     $this->tmpl['action'] = $uri->toString();
     $this->tmpl['ftp'] = !JClientHelper::hasCredentials('ftp');
     $this->assignRef('session', JFactory::getSession());
     // SEF problem
     $isThereQM = false;
     $isThereQM = preg_match("/\\?/i", $this->tmpl['action']);
     if ($isThereQM) {
         $amp = '&';
         // will be translated to htmlspecialchars
     } else {
         $amp = '?';
     }
     $this->tmpl['actionamp'] = $this->tmpl['action'] . $amp;
     $this->tmpl['istheretab'] = false;
     $this->tmpl['istheretab'] = preg_match("/tab=/i", $this->tmpl['action']);
     // EDIT - subcategory, image
     $this->tmpl['task'] = $app->input->get('task', '', 'string');
     $id = $app->input->get('id', '', 'string');
     $idAlias = $id;
     // - - - - - - - - - - -
     // USER (AVATAR)
     // - - - - - - - - - - -
     $this->tmpl['user'] = $user->name;
     $this->tmpl['username'] = $user->username;
     $this->tmpl['useravatarimg'] = JHtml::_('image', $this->tmpl['pi'] . 'phoca_thumb_m_no_image.png', '');
     $this->tmpl['useravatarapproved'] = 0;
     $userAvatar = $model->getUserAvatar($user->id);
     if ($userAvatar) {
         $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_m_' . $userAvatar->avatar;
         $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_m_' . $userAvatar->avatar;
         if (JFile::exists($pathAvatarAbs)) {
             $this->tmpl['useravatarimg'] = '<img src="' . JURI::base(true) . '/' . $pathAvatarRel . '?imagesid=' . md5(uniqid(time())) . '" alt="" />';
             $this->tmpl['useravatarapproved'] = $userAvatar->approved;
         }
     }
     if ($ownerMainCategory) {
         $this->tmpl['usermaincategory'] = $ownerMainCategory->title;
     } else {
         $this->tmpl['usermaincategory'] = JHtml::_('image', $this->tmpl['pi'] . 'icon-unpublish.png', JText::_('COM_PHOCAGALLERY_NOT_CREATED')) . ' (' . JText::_('COM_PHOCAGALLERY_NOT_CREATED') . ')';
     }
     $this->tmpl['usersubcategory'] = $model->getCountUserSubCat($user->id);
     $this->tmpl['usersubcategoryleft'] = (int) $this->tmpl['usersubcatcount'] - (int) $this->tmpl['usersubcategory'];
     if ((int) $this->tmpl['usersubcategoryleft'] < 0) {
         $this->tmpl['usersubcategoryleft'] = 0;
     }
     $this->tmpl['userimages'] = $model->getCountUserImage($user->id);
     $this->tmpl['userimagesspace'] = $model->getSumUserImage($user->id);
     $this->tmpl['userimagesspaceleft'] = (int) $this->tmpl['userimagesmaxspace'] - (int) $this->tmpl['userimagesspace'];
     if ((int) $this->tmpl['userimagesspaceleft'] < 0) {
         $this->tmpl['userimagesspaceleft'] = 0;
     }
     $this->tmpl['userimagesspace'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['userimagesspace']);
     $this->tmpl['userimagesspaceleft'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['userimagesspaceleft']);
     $this->tmpl['userimagesmaxspace'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['userimagesmaxspace']);
     // - - - - - - - - - - -
     // MAIN CATEGORY
     // - - - - - - - - - - -
     $ownerMainCategory = $model->getOwnerMainCategory($user->id);
     if (!empty($ownerMainCategory->id)) {
         if ((int) $ownerMainCategory->published == 1) {
             $this->tmpl['categorycreateoredithead'] = JText::_('COM_PHOCAGALLERY_MAIN_CATEGORY');
             $this->tmpl['categorycreateoredit'] = JText::_('COM_PHOCAGALLERY_EDIT');
             $this->tmpl['categorytitle'] = $ownerMainCategory->title;
             $this->tmpl['categoryapproved'] = $ownerMainCategory->approved;
             $this->tmpl['categorydescription'] = $ownerMainCategory->description;
             $this->tmpl['categorypublished'] = 1;
         } else {
             $this->tmpl['categorypublished'] = 0;
         }
     } else {
         $this->tmpl['categorycreateoredithead'] = JText::_('COM_PHOCAGALLERY_MAIN_CATEGORY');
         $this->tmpl['categorycreateoredit'] = JText::_('COM_PHOCAGALLERY_CREATE');
         $this->tmpl['categorytitle'] = '';
         $this->tmpl['categorydescription'] = '';
         $this->tmpl['categoryapproved'] = '';
         $this->tmpl['categorypublished'] = -1;
     }
     // - - - - - - - - - - -
     // SUBCATEGORY
     // - - - - - - - - - - -
     if (!empty($ownerMainCategory->id)) {
         // EDIT
         $this->tmpl['categorysubcatedit'] = $model->getCategory((int) $id, $user->id);
         $this->tmpl['displaysubcategory'] = 1;
         // Get All Data - Subcategories
         $this->tmpl['subcategoryitems'] = $model->getDataSubcat($user->id);
         $this->tmpl['subcategorytotal'] = count($this->tmpl['subcategoryitems']);
         $model->setTotalSubCat($this->tmpl['subcategorytotal']);
         $this->tmpl['subcategorypagination'] = $model->getPaginationSubCat($user->id);
         $this->tmpl['subcategoryitems'] = array_slice($this->tmpl['subcategoryitems'], (int) $this->tmpl['subcategorypagination']->limitstart, (int) $this->tmpl['subcategorypagination']->limit);
         $filter_state_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_state', 'filter_state_subcat', '', 'word');
         $filter_catid_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_catid', 'filter_catid_subcat', 0, 'int');
         $filter_order_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_order', 'filter_order_subcat', 'a.ordering', 'cmd');
         $filter_order_Dir_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_order_Dir', 'filter_order_Dir_subcat', '', 'word');
         $search_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.search', 'phocagallerysubcatsearch', '', 'string');
         if (strpos($search_subcat, '"') !== false) {
             $search_subcat = str_replace(array('=', '<'), '', $search_subcat);
         }
         $search_subcat = JString::strtolower($search_subcat);
         $categories = $model->getCategoryList($user->id);
         if (!empty($categories)) {
             $javascript = 'class="inputbox" onchange="document.phocagallerysubcatform.submit();"';
             $tree = array();
             $text = '';
             $tree = PhocaGalleryCategory::CategoryTreeOption($categories, $tree, 0, $text, -1);
             array_unshift($tree, JHtml::_('select.option', '0', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_CATEGORY') . ' -', 'value', 'text'));
             $lists_subcat['catid'] = JHtml::_('select.genericlist', $tree, 'filter_catid_subcat', $javascript, 'value', 'text', $filter_catid_subcat);
         }
         $this->tmpl['parentcategoryid'] = $filter_catid_subcat;
         // state filter
         //$lists['state']		= JHtml::_('grid.state',  $filter_state );
         $state_subcat[] = JHtml::_('select.option', '', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_STATE') . ' -');
         $state_subcat[] = JHtml::_('select.option', 'P', JText::_('COM_PHOCAGALLERY_PUBLISHED'));
         $state_subcat[] = JHtml::_('select.option', 'U', JText::_('COM_PHOCAGALLERY_UNPUBLISHED'));
         $lists_subcat['state'] = JHtml::_('select.genericlist', $state_subcat, 'filter_state_subcat', 'class="inputbox" size="1" onchange="document.phocagallerysubcatform.submit();"', 'value', 'text', $filter_state_subcat);
         // table ordering
         $lists_subcat['order_Dir'] = $filter_order_Dir_subcat;
         $lists_subcat['order'] = $filter_order_subcat;
         $this->tmpl['subcategoryordering'] = $lists_subcat['order'] == 'a.ordering';
         //Ordering allowed ?
         // search filter
         $lists_subcat['search'] = $search_subcat;
     } else {
         $this->tmpl['displaysubcategory'] = 0;
     }
     // - - - - - - - - - - -
     // IMAGES
     // - - - - - - - - - - -
     if (!empty($ownerMainCategory->id)) {
         $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $ownerMainCategory->id);
         // EDIT
         $this->tmpl['imageedit'] = $model->getImage((int) $id, $user->id);
         $this->tmpl['imageitems'] = $model->getDataImage($user->id);
         $this->tmpl['imagetotal'] = $model->getTotalImage($user->id);
         $this->tmpl['imagepagination'] = $model->getPaginationImage($user->id);
         $filter_state_image = $app->getUserStateFromRequest($this->_context_image . '.filter_state', 'filter_state_image', '', 'word');
         $filter_catid_image = $app->getUserStateFromRequest($this->_context_image . '.filter_catid', 'filter_catid_image', 0, 'int');
         $filter_order_image = $app->getUserStateFromRequest($this->_context_image . '.filter_order', 'filter_order_image', 'a.ordering', 'cmd');
         $filter_order_Dir_image = $app->getUserStateFromRequest($this->_context_image . '.filter_order_Dir', 'filter_order_Dir_image', '', 'word');
         $search_image = $app->getUserStateFromRequest($this->_context_image . '.search', 'phocagalleryimagesearch', '', 'string');
         if (strpos($search_image, '"') !== false) {
             $search_image = str_replace(array('=', '<'), '', $search_image);
         }
         $search_image = JString::strtolower($search_image);
         $categoriesImage = $model->getCategoryList($user->id);
         if (!empty($categoriesImage)) {
             $javascript = 'class="inputbox" size="1" onchange="document.phocagalleryimageform.submit();"';
             $tree = array();
             $text = '';
             $tree = PhocaGalleryCategory::CategoryTreeOption($categoriesImage, $tree, 0, $text, -1);
             array_unshift($tree, JHtml::_('select.option', '0', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_CATEGORY') . ' -', 'value', 'text'));
             $lists_image['catid'] = JHtml::_('select.genericlist', $tree, 'filter_catid_image', $javascript, 'value', 'text', $filter_catid_image);
         }
         // state filter
         $state_image[] = JHtml::_('select.option', '', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_STATE') . ' -');
         $state_image[] = JHtml::_('select.option', 'P', JText::_('COM_PHOCAGALLERY_FIELD_PUBLISHED_LABEL'));
         $state_image[] = JHtml::_('select.option', 'U', JText::_('COM_PHOCAGALLERY_FIELD_UNPUBLISHED_LABEL'));
         $lists_image['state'] = JHtml::_('select.genericlist', $state_image, 'filter_state_image', 'class="inputbox" size="1" onchange="document.phocagalleryimageform.submit();"', 'value', 'text', $filter_state_image);
         // table ordering
         $lists_image['order_Dir'] = $filter_order_Dir_image;
         $lists_image['order'] = $filter_order_image;
         $this->tmpl['imageordering'] = $lists_image['order'] == 'a.ordering';
         //Ordering allowed ?
         // search filter
         $lists_image['search'] = $search_image;
         $this->tmpl['catidimage'] = $filter_catid_image;
         // Upload
         $this->tmpl['displayupload'] = 0;
         // USER RIGHT - UPLOAD - - - - - - - - - - -
         // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
         $rightDisplayUpload = 0;
         // default is to null (all users cannot upload)
         if (!empty($catAccess)) {
             $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $catAccess->uploaduserid, 2, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
         }
         if ($rightDisplayUpload == 1) {
             $this->tmpl['displayupload'] = 1;
             $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionUploadJS((int) $this->tmpl['maxuploadchar']));
         }
         // - - - - - - - - - - - - - - - - - - - - -
         // USER RIGHT - ACCESS - - - - - - - - - - -
         $rightDisplay = 1;
         //default is set to 1 (all users can see the category)
         if (!empty($catAccess)) {
             $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $catAccess->accessuserid, 0, $user->getAuthorisedViewLevels(), $user->get('id', 0), 1);
         }
         if ($rightDisplay == 0) {
             $app->redirect(JRoute::_($this->tmpl['pl'], false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
             exit;
         }
         // - - - - - - - - - - - - - - - - - - - - -
         // = = = = = = = = = =
         // U P L O A D
         // = = = = = = = = = =
         // - - - - - - - - - - -
         // Upload
         // - - - - - - - - - - -
         if ((int) $this->tmpl['displayupload'] == 1) {
             $sU = new PhocaGalleryFileUploadSingle();
             $sU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . 'task=upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
             $sU->tab = $this->tmpl['currenttab']['images'];
             $this->tmpl['su_output'] = $sU->getSingleUploadHTML(1);
             $this->tmpl['su_url'] = htmlspecialchars($this->tmpl['action'] . $amp . 'task=upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
         }
         // - - - - - - - - - - -
         // Youtube Upload (single upload form can be used)
         // - - - - - - - - - - -
         if ((int) $this->tmpl['ytbupload'] > 0) {
             $sYU = new PhocaGalleryFileUploadSingle();
             $sYU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . 'task=ytbupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
             $sYU->tab = $this->tmpl['currenttab']['images'];
             $this->tmpl['syu_output'] = $sYU->getSingleUploadHTML(1);
             $this->tmpl['syu_url'] = htmlspecialchars($this->tmpl['action'] . $amp . 'task=ytbupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
         }
         // - - - - - - - - - - -
         // Multiple Upload
         // - - - - - - - - - - -
         // Get infos from multiple upload
         $muFailed = $app->input->get('mufailed', '0', 'int');
         $muUploaded = $app->input->get('muuploaded', '0', 'int');
         $this->tmpl['mu_response_msg'] = $muUploadedMsg = '';
         if ($muUploaded > 0) {
             $muUploadedMsg = JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded;
         }
         if ($muFailed > 0) {
             $muFailedMsg = JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed;
         }
         if ($muFailed > 0 && $muUploaded > 0) {
             $this->tmpl['mu_response_msg'] = '<div class="alert alert-info">' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '<br />' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
         } else {
             if ($muFailed > 0 && $muUploaded == 0) {
                 $this->tmpl['mu_response_msg'] = '<div class="alert alert-error">' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
             } else {
                 if ($muFailed == 0 && $muUploaded > 0) {
                     $this->tmpl['mu_response_msg'] = '<div class="alert alert-success">' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '</div>';
                 } else {
                     $this->tmpl['mu_response_msg'] = '';
                 }
             }
         }
         if ((int) $this->tmpl['enablemultiple'] == 1 && (int) $this->tmpl['displayupload'] == 1) {
             PhocaGalleryFileUploadMultiple::renderMultipleUploadLibraries();
             $mU = new PhocaGalleryFileUploadMultiple();
             $mU->frontEnd = 2;
             $mU->method = $this->tmpl['multipleuploadmethod'];
             $mU->url = htmlspecialchars($this->tmpl['action'] . $amp . 'controller=user&task=multipleupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images'] . '&catid=' . $this->tmpl['catidimage']);
             $mU->reload = htmlspecialchars($this->tmpl['action'] . $amp . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images']);
             $mU->maxFileSize = PhocaGalleryFileUploadMultiple::getMultipleUploadSizeFormat($this->tmpl['uploadmaxsize']);
             $mU->chunkSize = '1mb';
             $mU->imageHeight = $this->tmpl['multipleresizeheight'];
             $mU->imageWidth = $this->tmpl['multipleresizewidth'];
             $mU->imageQuality = 100;
             $mU->renderMultipleUploadJS(0, $this->tmpl['multipleuploadchunk']);
             $this->tmpl['mu_output'] = $mU->getMultipleUploadHTML();
         }
         // - - - - - - - - - - -
         // Java Upload
         // - - - - - - - - - - -
         if ((int) $this->tmpl['enablejava'] == 1 && (int) $this->tmpl['displayupload'] == 1) {
             $jU = new PhocaGalleryFileUploadJava();
             $jU->width = $this->tmpl['javaboxwidth'];
             $jU->height = $this->tmpl['javaboxheight'];
             $jU->resizewidth = $this->tmpl['multipleresizewidth'];
             $jU->resizeheight = $this->tmpl['multipleresizeheight'];
             $jU->uploadmaxsize = $this->tmpl['uploadmaxsize'];
             $jU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images']);
             $jU->url = htmlspecialchars($this->tmpl['action'] . $amp . 'controller=user&task=javaupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images'] . '&catid=' . $this->tmpl['catidimage']);
             $jU->source = JURI::root(true) . '/components/com_phocagallery/assets/jupload/wjhk.jupload.jar';
             $this->tmpl['ju_output'] = $jU->getJavaUploadHTML();
         }
     } else {
         $this->tmpl['displayupload'] = 0;
     }
     if (!empty($ownerMainCategory->id)) {
         $this->tmpl['ps'] = '&tab=' . $this->tmpl['currenttab']['createsubcategory'] . '&limitstartsubcat=' . $this->tmpl['subcategorypagination']->limitstart . '&limitstartimage=' . $this->tmpl['imagepagination']->limitstart;
     } else {
         $this->tmpl['ps'] = '&tab=' . $this->tmpl['currenttab']['createsubcategory'];
     }
     if (!empty($ownerMainCategory->id)) {
         $this->tmpl['psi'] = '&tab=' . $this->tmpl['currenttab']['images'] . '&limitstartsubcat=' . $this->tmpl['subcategorypagination']->limitstart . '&limitstartimage=' . $this->tmpl['imagepagination']->limitstart;
     } else {
         $this->tmpl['psi'] = '&tab=' . $this->tmpl['currenttab']['images'];
     }
     // ASIGN
     $this->assignRef('listssubcat', $lists_subcat);
     $this->assignRef('listsimage', $lists_image);
     //$this->assignRef( 'tmpl', $this->tmpl);
     //$this->assignRef( 'params', $this->params);
     $this->assignRef('session', JFactory::getSession());
     $this->_prepareDocument();
     parent::display($tpl);
 }
    function onPrepareContent(&$article, &$params, $limitstart)
    {
        $user =& JFactory::getUser();
        $gid = $user->get('aid', 0);
        $db =& JFactory::getDBO();
        $menu =& JSite::getMenu();
        $document =& JFactory::getDocument();
        // PARAMS - direct from Phoca Gallery Global configuration
        $component = 'com_phocagallery';
        $table =& JTable::getInstance('component');
        $table->loadByOption($component);
        $paramsC = new JParameter($table->params);
        // LIBRARY
        $library =& PhocaGalleryLibrary::getLibrary();
        $libraries['pg-css-sbox-plugin'] = $library->getLibrary('pg-css-sbox-plugin');
        $libraries['pg-css-pg-plugin'] = $library->getLibrary('pg-css-pg-plugin');
        $libraries['pg-css-ie'] = $library->getLibrary('pg-css-ie');
        $libraries['pg-group-shadowbox'] = $library->getLibrary('pg-group-shadowbox');
        $libraries['pg-group-highslide'] = $library->getLibrary('pg-group-highslide');
        $libraries['pg-overlib-group'] = $library->getLibrary('pg-overlib-group');
        // PicLens CSS and JS will be loaded only one time in the site (pg-pl-piclens)
        // BUT PicLens Category will be loaded everytime new category should be displayed on the site
        $libraries['pg-pl-piclens'] = $library->getLibrary('pg-pl-piclens');
        // Start Plugin
        $regex_one = '/({phocagallery\\s*)(.*?)(})/si';
        $regex_all = '/{phocagallery\\s*.*?}/si';
        $matches = array();
        $count_matches = preg_match_all($regex_all, $article->text, $matches, PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER);
        $cssPgPlugin = '';
        $cssSbox = '';
        // Start if count_matches
        if ($count_matches != 0) {
            // Start CSS
            $document->addStyleSheet(JURI::base(true) . '/components/com_phocagallery/assets/phocagallery.css');
            for ($i = 0; $i < $count_matches; $i++) {
                $this->_setPluginNumber();
                // Plugin variables
                $view = '';
                $catid = 0;
                $imageid = 0;
                $imagerandom = 0;
                $image_background_shadow = $paramsC->get('image_background_shadow', 'none');
                $limitstart = 0;
                $limitcount = 0;
                $switch_width = $paramsC->get('switch_width', 640);
                $switch_height = $paramsC->get('switch_height', 480);
                $basic_image_id = $paramsC->get('switch_image', 0);
                $enable_switch = 0;
                $display_name = $paramsC->get('display_name', 1);
                $display_icon_detail = $paramsC->get('display_icon_detail', 1);
                $display_icon_download = $paramsC->get('display_icon_download', 1);
                $detail_window = $paramsC->get('detail_window', 0);
                $detail_buttons = $paramsC->get('detail_buttons', 1);
                $hide_categories = $paramsC->get('hide_categories', '');
                $namefontsize = $paramsC->get('font_size_name', 12);
                $namenumchar = $paramsC->get('char_length_name', 11);
                $display_description = $paramsC->get('display_description_detail', 0);
                $description_height = $paramsC->get('description_detail_height', 16);
                $category_box_space = $paramsC->get('category_box_space', 0);
                // CSS
                $font_color = $paramsC->get('font_color', '#b36b00');
                $background_color = $paramsC->get('background_color', '#fcfcfc');
                $background_color_hover = $paramsC->get('background_color_hover', '#f5f5f5');
                $image_background_color = $paramsC->get('image_background_color', '#f5f5f5');
                $border_color = $paramsC->get('border_color', '#e8e8e8');
                $border_color_hover = $paramsC->get('border_color_hover', '#b36b00');
                $highslide_class = $paramsC->get('highslide_class', 'rounded-white');
                $highslide_opacity = $paramsC->get('highslide_opacity', 0);
                $highslide_outline_type = $paramsC->get('highslide_outline_type', 'rounded-white');
                $highslide_fullimg = $paramsC->get('highslide_fullimg', 0);
                $highslide_slideshow = $paramsC->get('highslide_slideshow', 1);
                $highslide_close_button = $paramsC->get('highslide_close_button', 0);
                $display_rating_img = $paramsC->get('display_rating_img', 0);
                $float = '';
                $enable_piclens = $paramsC->get('enable_piclens', 0);
                $enable_overlib = $paramsC->get('enable_oberlib', 0);
                // Image categories
                $img_cat = 1;
                $img_cat_size = 'small';
                // Get plugin parameters
                $phocagallery = $matches[0][$i][0];
                preg_match($regex_one, $phocagallery, $phocagallery_parts);
                $parts = explode("|", $phocagallery_parts[2]);
                $values_replace = array("/^'/", "/'\$/", "/^&#39;/", "/&#39;\$/", "/<br \\/>/");
                foreach ($parts as $key => $value) {
                    $values = explode("=", $value, 2);
                    foreach ($values_replace as $key2 => $values2) {
                        $values = preg_replace($values2, '', $values);
                    }
                    // Get plugin parameters from article
                    if ($values[0] == 'view') {
                        $view = $values[1];
                    } else {
                        if ($values[0] == 'categoryid') {
                            $catid = $values[1];
                        } else {
                            if ($values[0] == 'imageid') {
                                $imageid = $values[1];
                            } else {
                                if ($values[0] == 'imagerandom') {
                                    $imagerandom = $values[1];
                                } else {
                                    if ($values[0] == 'imageshadow') {
                                        $image_background_shadow = $values[1];
                                    } else {
                                        if ($values[0] == 'limitstart') {
                                            $limitstart = $values[1];
                                        } else {
                                            if ($values[0] == 'limitcount') {
                                                $limitcount = $values[1];
                                            } else {
                                                if ($values[0] == 'detail') {
                                                    $detail_window = $values[1];
                                                } else {
                                                    if ($values[0] == 'displayname') {
                                                        $display_name = $values[1];
                                                    } else {
                                                        if ($values[0] == 'displaydetail') {
                                                            $display_icon_detail = $values[1];
                                                        } else {
                                                            if ($values[0] == 'displaydownload') {
                                                                $display_icon_download = $values[1];
                                                            } else {
                                                                if ($values[0] == 'displaybuttons') {
                                                                    $detail_buttons = $values[1];
                                                                } else {
                                                                    if ($values[0] == 'displayratingimg') {
                                                                        $display_rating_img = $values[1];
                                                                    } else {
                                                                        if ($values[0] == 'namefontsize') {
                                                                            $namefontsize = $values[1];
                                                                        } else {
                                                                            if ($values[0] == 'namenumchar') {
                                                                                $namenumchar = $values[1];
                                                                            } else {
                                                                                if ($values[0] == 'displaydescription') {
                                                                                    $display_description = $values[1];
                                                                                } else {
                                                                                    if ($values[0] == 'descriptionheight') {
                                                                                        $description_height = $values[1];
                                                                                    } else {
                                                                                        if ($values[0] == 'hidecategories') {
                                                                                            $hide_categories = $values[1];
                                                                                        } else {
                                                                                            if ($values[0] == 'boxspace') {
                                                                                                $category_box_space = $values[1];
                                                                                            } else {
                                                                                                if ($values[0] == 'fontcolor') {
                                                                                                    $font_color = $values[1];
                                                                                                } else {
                                                                                                    if ($values[0] == 'bgcolor') {
                                                                                                        $background_color = $values[1];
                                                                                                    } else {
                                                                                                        if ($values[0] == 'bgcolorhover') {
                                                                                                            $background_color_hover = $values[1];
                                                                                                        } else {
                                                                                                            if ($values[0] == 'imagebgcolor') {
                                                                                                                $image_background_color = $values[1];
                                                                                                            } else {
                                                                                                                if ($values[0] == 'bordercolor') {
                                                                                                                    $border_color = $values[1];
                                                                                                                } else {
                                                                                                                    if ($values[0] == 'bordercolorhover') {
                                                                                                                        $border_color_hover = $values[1];
                                                                                                                    } else {
                                                                                                                        if ($values[0] == 'hsclass') {
                                                                                                                            $highslide_class = $values[1];
                                                                                                                        } else {
                                                                                                                            if ($values[0] == 'hsopacity') {
                                                                                                                                $highslide_opacity = $values[1];
                                                                                                                            } else {
                                                                                                                                if ($values[0] == 'hsoutlinetype') {
                                                                                                                                    $highslide_outline_type = $values[1];
                                                                                                                                } else {
                                                                                                                                    if ($values[0] == 'hsfullimg') {
                                                                                                                                        $highslide_fullimg = $values[1];
                                                                                                                                    } else {
                                                                                                                                        if ($values[0] == 'hsslideshow') {
                                                                                                                                            $highslide_slideshow = $values[1];
                                                                                                                                        } else {
                                                                                                                                            if ($values[0] == 'hsclosebutton') {
                                                                                                                                                $highslide_close_button = $values[1];
                                                                                                                                            } else {
                                                                                                                                                if ($values[0] == 'float') {
                                                                                                                                                    $float = $values[1];
                                                                                                                                                } else {
                                                                                                                                                    if ($values[0] == 'imagecategories') {
                                                                                                                                                        $img_cat = $values[1];
                                                                                                                                                    } else {
                                                                                                                                                        if ($values[0] == 'imagecategoriessize') {
                                                                                                                                                            $img_cat_size = $values[1];
                                                                                                                                                        } else {
                                                                                                                                                            if ($values[0] == 'switchwidth') {
                                                                                                                                                                $switch_width = $values[1];
                                                                                                                                                            } else {
                                                                                                                                                                if ($values[0] == 'switchheight') {
                                                                                                                                                                    $switch_height = $values[1];
                                                                                                                                                                } else {
                                                                                                                                                                    if ($values[0] == 'basicimageid') {
                                                                                                                                                                        $basic_image_id = $values[1];
                                                                                                                                                                    } else {
                                                                                                                                                                        if ($values[0] == 'enableswitch') {
                                                                                                                                                                            $enable_switch = $values[1];
                                                                                                                                                                        } else {
                                                                                                                                                                            if ($values[0] == 'piclens') {
                                                                                                                                                                                $enable_piclens = $values[1];
                                                                                                                                                                            } else {
                                                                                                                                                                                if ($values[0] == 'overlib') {
                                                                                                                                                                                    $enable_overlib = $values[1];
                                                                                                                                                                                }
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }
                                                                                                                                                            }
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // Every loop of plugin has own number
                // Add custom CSS for every image (every image can have other CSS, Hover doesn't work in IE6)
                $iCss = $this->_plugin_number;
                $cssPgPlugin .= " .pgplugin" . $iCss . " {border:1px solid {$border_color} ; background: {$background_color} ;}\n" . " .pgplugin" . $iCss . ":hover, .pgplugin" . $i . ".hover {border:1px solid {$border_color_hover} ; background: {$background_color_hover} ;}\n";
                // PARAMS - direct from Phoca Gallery Global configuration
                $component = 'com_phocagallery';
                $table =& JTable::getInstance('component');
                $table->loadByOption($component);
                $paramsC = new JParameter($table->params);
                $tmpl['formaticon'] = $paramsC->get('icon_format', 'gif');
                $medium_image_width = $paramsC->get('medium_image_width', 100);
                $medium_image_height = $paramsC->get('medium_image_height', 100);
                $popup_window_width = $paramsC->get('front_modal_box_width', 680);
                $popup_window_height = $paramsC->get('front_modal_box_height', 560);
                $small_image_width = $paramsC->get('small_image_width', 50);
                $small_image_height = $paramsC->get('small_image_height', 50);
                if ($display_description == 1) {
                    $popup_window_height = $popup_window_height + $description_height;
                }
                // Detail buttons in detail view
                if ($detail_buttons != 1) {
                    $popup_window_height = $popup_window_height - 45;
                }
                if ($display_rating_img == 1) {
                    $popup_window_height = $popup_window_height + 35;
                }
                $modal_box_overlay_color = $paramsC->get('modal_box_overlay_color', '#000000');
                $modal_box_overlay_opacity = $paramsC->get('modal_box_overlay_opacity', 0.3);
                $modal_box_border_color = $paramsC->get('modal_box_border_color', '#6b6b6b');
                $modal_box_border_width = $paramsC->get('modal_box_border_width', 2);
                $tmpl['olbgcolor'] = $paramsC->get('ol_bg_color', '#666666');
                $tmpl['olfgcolor'] = $paramsC->get('ol_fg_color', '#f6f6f6');
                $tmpl['oltfcolor'] = $paramsC->get('ol_tf_color', '#000000');
                $tmpl['olcfcolor'] = $paramsC->get('ol_cf_color', '#ffffff');
                $tmpl['overliboverlayopacity'] = $paramsC->get('overlib_overlay_opacity', 0.7);
                // Window
                // =======================================================
                // DIFFERENT METHODS OF DISPLAYING THE DETAIL VIEW
                // =======================================================
                // MODAL - will be displayed in case e.g. highslide or shadowbox too, because in there are more links
                JHTML::_('behavior.modal', 'a.modal-button');
                if ($cssSbox == '') {
                    $cssSbox .= " #sbox-window {background-color:" . $modal_box_border_color . ";padding:" . $modal_box_border_width . "px} \n" . " #sbox-overlay {background-color:" . $modal_box_overlay_color . ";} \n";
                }
                // BUTTON (IMAGE - standard, modal, shadowbox)
                $button = new JObject();
                $button->set('name', 'image');
                // BUTTON (ICON - standard, modal, shadowbox)
                $button2 = new JObject();
                $button2->set('name', 'icon');
                // BUTTON OTHER (geotagging, downloadlink, ...)
                $buttonOther = new JObject();
                $buttonOther->set('name', 'other');
                $tmpl['highslideonclick'] = '';
                // for using with highslide
                // -------------------------------------------------------
                // STANDARD POPUP
                // -------------------------------------------------------
                if ($detail_window == 1) {
                    $button->set('methodname', 'js-button');
                    $button->set('options', "window.open(this.href,'win2','width=" . $popup_window_width . ",height=" . $popup_window_height . ",menubar=no,resizable=yes'); return false;");
                    $button2->methodname =& $button->methodname;
                    $button2->options =& $button->options;
                    $buttonOther->methodname =& $button->methodname;
                    $buttonOther->options =& $button->options;
                } else {
                    if ($detail_window == 0 || $detail_window == 2) {
                        // Button
                        $button->set('modal', true);
                        $button->set('methodname', 'modal-button');
                        $button2->modal =& $button->modal;
                        $button2->methodname =& $button->methodname;
                        $buttonOther->modal =& $button->modal;
                        $buttonOther->methodname =& $button->methodname;
                        // Modal - Image only
                        if ($detail_window == 2) {
                            $button->set('options', "{handler: 'image', size: {x: 200, y: 150}, overlayOpacity: " . $modal_box_overlay_opacity . ", classWindow: 'phocagallery-random-window', classOverlay: 'phocagallery-random-overlay'}");
                            $button2->options =& $button->options;
                            $buttonOther->set('options', "{handler: 'iframe', size: {x: " . $popup_window_width . ", y: " . $popup_window_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . ", classWindow: 'phocagallery-random-window', classOverlay: 'phocagallery-random-overlay'}");
                            // Modal - Iframe
                        } else {
                            $button->set('options', "{handler: 'iframe', size: {x: " . $popup_window_width . ", y: " . $popup_window_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . ", classWindow: 'phocagallery-random-window', classOverlay: 'phocagallery-random-overlay'}");
                            $button2->options =& $button->options;
                            $buttonOther->options =& $button->options;
                        }
                    } else {
                        if ($detail_window == 3) {
                            // Random Number - because of more plugins on the site
                            $randName = 'PhocaGalleryPl' . $iCss;
                            $randName2 = 'PhocaGalleryPl2' . $iCss;
                            $sb_slideshow_delay = $paramsC->get('sb_slideshow_delay', 5);
                            $sb_lang = $paramsC->get('sb_lang', 'en');
                            $button->set('methodname', 'shadowbox-button-rim');
                            $button->set('options', "shadowbox[" . $randName . "];options={slideshowDelay:" . $sb_slideshow_delay . "}");
                            $button2->methodname =& $button->methodname;
                            $button2->set('options', "shadowbox[" . $randName2 . "];options={slideshowDelay:" . $sb_slideshow_delay . "}");
                            $buttonOther->set('modal', true);
                            $buttonOther->set('methodname', 'modal-button');
                            $buttonOther->set('options', "{handler: 'iframe', size: {x: " . $popup_window_width . ", y: " . $popup_window_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . ", classWindow: 'phocagallery-random-window', classOverlay: 'phocagallery-random-overlay'}");
                            $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/js/shadowbox/adapter/shadowbox-mootools.js');
                            $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/js/shadowbox/shadowbox.js');
                            if ($libraries['pg-group-shadowbox']->value == 0) {
                                $document->addCustomTag('<script type="text/javascript">
			Shadowbox.loadSkin("classic", "' . JURI::base(true) . '/components/com_phocagallery/assets/js/shadowbox/src/skin");
			Shadowbox.loadLanguage("' . $sb_lang . '", "' . JURI::base(true) . '/components/com_phocagallery/assets/js/shadowbox/src/lang");
			Shadowbox.loadPlayer(["img"], "' . JURI::base(true) . '/components/com_phocagallery/assets/js/shadowbox/src/player");
			window.onload = function(){
			Shadowbox.init();
			}
			</script>');
                                $library->setLibrary('pg-group-shadowbox', 1);
                            }
                        } else {
                            if ($detail_window == 4) {
                                $button->set('methodname', 'highslide');
                                $button2->methodname =& $button->methodname;
                                $buttonOther->methodname =& $button->methodname;
                                $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide-full.js');
                                $document->addStyleSheet(JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide.css');
                                if ($libraries['pg-group-highslide']->value == 0) {
                                    $document->addCustomTag(PhocaGalleryRenderFront::renderHighslideJSAll());
                                    $document->addCustomTag('<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="' . JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide-ie6.css" /><![endif]-->');
                                    $library->setLibrary('pg-group-highslide', 1);
                                }
                                $document->addCustomTag(PhocaGalleryRenderFront::renderHighslideJS('pl', $popup_window_width, $popup_window_height, $highslide_outline_type, $highslide_opacity));
                                $tmpl['highslideonclick'] = 'return hs.htmlExpand(this, phocaZoomPl )';
                            } else {
                                if ($detail_window == 5) {
                                    $button->set('methodname', 'highslide');
                                    $button2->methodname =& $button->methodname;
                                    $buttonOther->methodname =& $button->methodname;
                                    $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide-full.js');
                                    $document->addStyleSheet(JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide.css');
                                    if ($libraries['pg-group-highslide']->value == 0) {
                                        $document->addCustomTag(PhocaGalleryRenderFront::renderHighslideJSAll());
                                        $document->addCustomTag('<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="' . JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide-ie6.css" /><![endif]-->');
                                        $library->setLibrary('pg-group-highslide', 1);
                                    }
                                    $document->addCustomTag(PhocaGalleryRenderFront::renderHighslideJS('pl', $popup_window_width, $popup_window_height, $highslide_slideshow, $highslide_class, $highslide_outline_type, $highslide_opacity, $highslide_close_button));
                                    $tmpl['highslideonclick2'] = 'return hs.htmlExpand(this, phocaZoomPl )';
                                    $tmpl['highslideonclick'] = 'return hs.expand(this, phocaImageRI )';
                                    $tmpl['highslideonclick'] = PhocaGalleryRenderFront::renderHighslideJSImage('pl', $highslide_class, $highslide_outline_type, $highslide_opacity, $highslide_fullimg);
                                }
                            }
                        }
                    }
                }
                $folderButton = new JObject();
                $folderButton->set('name', 'image');
                $folderButton->set('options', "");
                // End open window parameters
                // ===============================
                // OUTPUT
                // ===============================
                $output = '';
                $output .= '<div class="phocagallery">' . "\n";
                //--------------------------
                // DISPLAYING OF CATEGORIES (link doesn't work if there is no menu link)
                //--------------------------
                $hideCat = trim($hide_categories);
                $hideCatArray = explode(';', $hide_categories);
                $hideCatSql = '';
                if (is_array($hideCatArray)) {
                    foreach ($hideCatArray as $value) {
                        $hideCatSql .= ' AND cc.id != ' . (int) trim($value) . ' ';
                    }
                }
                // by vogo
                $uniqueCatSql = '';
                if ($catid > 0) {
                    $uniqueCatSql = ' AND cc.id = ' . $catid . '';
                }
                if ($view == 'categories') {
                    //CATEGORIES
                    $queryc = 'SELECT cc.*, a.catid, COUNT(a.id) AS numlinks,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as slug' . ' FROM #__phocagallery_categories AS cc' . ' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id' . ' WHERE a.published = 1' . ' AND cc.published = 1' . $hideCatSql . $uniqueCatSql . ' GROUP BY cc.id' . ' ORDER BY cc.ordering';
                    //SUBCATEGORIES
                    $querysc = 'SELECT cc.title AS text, cc.id AS value, cc.parent_id as parentid' . ' FROM #__phocagallery_categories AS cc' . ' WHERE cc.published = 1' . ' ORDER BY cc.ordering';
                    $data_outcome = '';
                    $data_outcome_array = '';
                    $db->setQuery($queryc);
                    $outcome_data = $db->loadObjectList();
                    $db->setQuery($querysc);
                    $outcome_subcategories = $db->loadObjectList();
                    $tree = array();
                    $text = '';
                    $tree = PhocaGalleryRenderAdmin::CategoryTreeOption($outcome_subcategories, $tree, 0, $text, -1);
                    foreach ($tree as $key => $value) {
                        foreach ($outcome_data as $key2 => $value2) {
                            if ($value->value == $value2->id) {
                                $data_outcome = new JObject();
                                $data_outcome->id = $value2->id;
                                $data_outcome->parent_id = $value2->parent_id;
                                $data_outcome->title = $value->text;
                                $data_outcome->name = $value2->name;
                                $data_outcome->alias = $value2->alias;
                                $data_outcome->image = $value2->image;
                                $data_outcome->section = $value2->section;
                                $data_outcome->image_position = $value2->image_position;
                                $data_outcome->description = $value2->description;
                                $data_outcome->published = $value2->published;
                                $data_outcome->editor = $value2->editor;
                                $data_outcome->ordering = $value2->ordering;
                                $data_outcome->access = $value2->access;
                                $data_outcome->accessuserid = $value2->accessuserid;
                                $data_outcome->uploaduserid = $value2->uploaduserid;
                                $data_outcome->deleteuserid = $value2->deleteuserid;
                                $data_outcome->count = $value2->count;
                                $data_outcome->params = $value2->params;
                                $data_outcome->catid = $value2->catid;
                                $data_outcome->numlinks = $value2->numlinks;
                                $data_outcome->slug = $value2->slug;
                                $data_outcome->link = "";
                                $data_outcome->filename = "";
                                $data_outcome->linkthumbnailpath = "";
                                //FILENAME
                                $queryfn = 'SELECT filename AS filename FROM #__phocagallery WHERE catid=' . $value2->id . ' AND published=1 ORDER BY ordering LIMIT 1';
                                $db->setQuery($queryfn);
                                $outcome_filename = $db->loadObjectList();
                                $data_outcome->filename = $outcome_filename[0]->filename;
                                $data_outcome_array[] = $data_outcome;
                            }
                        }
                    }
                    if ($img_cat == 1) {
                        $medium_image_height = $medium_image_height + 18;
                        $medium_image_width = $medium_image_width + 18;
                        $small_image_width = $small_image_width + 18;
                        $small_image_height = $small_image_height + 18;
                        $output .= '<table border="0">';
                        foreach ($data_outcome_array as $category) {
                            // -------------------------------------------------------------- SEF PROBLEM
                            // Is there a Itemid for category
                            $items = $menu->getItems('link', 'index.php?option=com_phocagallery&view=category&id=' . $category->id);
                            $itemscat = $menu->getItems('link', 'index.php?option=com_phocagallery&view=categories');
                            if (isset($itemscat[0])) {
                                $itemid = $itemscat[0]->id;
                                $category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug . '&Itemid=' . $itemid);
                            } else {
                                if (isset($items[0])) {
                                    $itemid = $items[0]->id;
                                    $category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug . '&Itemid=' . $itemid);
                                } else {
                                    $itemid = 0;
                                    //$category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id='. $category->slug.'&Itemid='.$itemid );
                                    $category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug);
                                }
                            }
                            // ---------------------------------------------------------------------------------
                            $imgCatSizeHelper = 'small';
                            $mediumCSS = 'background: url(\'' . JURI::base(true) . '/components/com_phocagallery/assets/images/shadow1.' . $tmpl['formaticon'] . '\') 50% 50% no-repeat;height:' . $medium_image_height . 'px;width:' . $medium_image_width . 'px;';
                            $smallCSS = 'background: url(\'' . JURI::base(true) . '/components/com_phocagallery/assets/images/shadow3.' . $tmpl['formaticon'] . '\') 50% 50% no-repeat;height:' . $small_image_height . 'px;width:' . $small_image_width . 'px;';
                            switch ($img_cat_size) {
                                case 'mediumfoldershadow':
                                    $imageBg = $mediumCSS;
                                    $imgCatSizeHelper = 7;
                                    break;
                                case 'smallfoldershadow':
                                    $imageBg = $smallCSS;
                                    $imgCatSizeHelper = 6;
                                    break;
                                case 'mediumshadow':
                                    $imageBg = $mediumCSS;
                                    $imgCatSizeHelper = 5;
                                    break;
                                case 'smallshadow':
                                    $imageBg = $smallCSS;
                                    $imgCatSizeHelper = 4;
                                    break;
                                case 'mediumfolder':
                                    $imageBg = '';
                                    $imgCatSizeHelper = 3;
                                    break;
                                case 'smallfolder':
                                default:
                                    $imageBg = '';
                                    $imgCatSizeHelper = 2;
                                    break;
                                case 'medium':
                                    $imageBg = '';
                                    $imgCatSizeHelper = 1;
                                    break;
                                case 'small':
                                default:
                                    $imageBg = '';
                                    $imgCatSizeHelper = 0;
                                    break;
                            }
                            // Display Key Icon (in case we want to display unaccessable categories in list view)
                            $rightDisplayKey = 1;
                            // we simulate that we want not to display unaccessable categories
                            // so we get rightDisplayKey = 0 then the key will be displayed
                            if (isset($category)) {
                                $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $category->accessuserid, $category->access, $user->get('aid', 0), $user->get('id', 0), 0);
                            }
                            $file_thumbnail = PhocaGalleryImageFront::displayCategoriesImageOrFolder($category->filename, $imgCatSizeHelper, $rightDisplayKey);
                            $category->linkthumbnailpath = $file_thumbnail->rel;
                            //Output
                            $output .= '<tr>' . '<td align="center" valign="middle" style="' . $imageBg . '"><a href="' . $category->link . '">' . '<img src="' . $category->linkthumbnailpath . '" alt="' . $category->title . '" style="border:0" />' . '</a></td>' . '<td><a href="' . $category->link . '" class="category' . $params->get('pageclass_sfx') . '">' . $category->title . '</a>&nbsp;' . '<span class="small">(' . $category->numlinks . ')</span></td>' . '</tr>';
                        }
                        $output .= '</table>';
                    } else {
                        $output .= '<ul>';
                        foreach ($data_outcome_array as $category) {
                            // -------------------------------------------------------------- SEF PROBLEM
                            // Is there a Itemid for category
                            $items = $menu->getItems('link', 'index.php?option=com_phocagallery&view=category&id=' . $category->id);
                            $itemscat = $menu->getItems('link', 'index.php?option=com_phocagallery&view=categories');
                            if (isset($itemscat[0])) {
                                $itemid = $itemscat[0]->id;
                                $category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug . '&Itemid=' . $itemid);
                            } else {
                                if (isset($items[0])) {
                                    $itemid = $items[0]->id;
                                    $category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug . '&Itemid=' . $itemid);
                                } else {
                                    $itemid = 0;
                                    $category->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug);
                                }
                            }
                            // ---------------------------------------------------------------------------------
                            $output .= '<li>' . '<a href="' . $category->link . '" class="category' . $params->get('pageclass_sfx') . '">' . $category->title . '</a>&nbsp;<span class="small">(' . $category->numlinks . ')</span>' . '</li>';
                        }
                        $output .= '</ul>';
                    }
                }
                //-----------------------
                // DISPLAYING OF IMAGES
                //-----------------------
                if ($view == 'category') {
                    $where = '';
                    // Only one image
                    if ($imageid > 0) {
                        $where = ' AND id = ' . $imageid;
                    }
                    // Random image
                    if ($imagerandom == 1 && $catid > 0) {
                        $query = 'SELECT id' . ' FROM #__phocagallery' . ' WHERE catid = ' . (int) $catid . ' AND published = 1' . ' ORDER BY RAND()';
                        $db->setQuery($query);
                        $idQuery =& $db->loadObject();
                        if (!empty($idQuery)) {
                            $where = ' AND id = ' . $idQuery->id;
                        }
                    }
                    $limit = '';
                    // Count of images (LIMIT 0, 20)
                    if ($limitcount > 0) {
                        $limit = ' LIMIT ' . $limitstart . ', ' . $limitcount;
                    }
                    $query = 'SELECT *' . ' FROM #__phocagallery' . ' WHERE catid = ' . (int) $catid . ' AND published = 1' . $where . ' ORDER BY ordering' . $limit;
                    $db->setQuery($query);
                    $category =& $db->loadObjectList();
                    // current category info
                    $query = 'SELECT c.*,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as slug ' . ' FROM #__phocagallery_categories AS c' . ' WHERE c.id = ' . (int) $catid;
                    //	' AND c.section = "com_phocagallery"';
                    $db->setQuery($query, 0, 1);
                    $category_info = $db->loadObject();
                    // Output
                    foreach ($category as $image) {
                        // PicLens CATEGORY - loaded every time new category will be displayed on the site---------
                        if ((int) $enable_piclens > 0) {
                            $libName = 'pg-piclens-' . $image->catid;
                            $libraries[$libName] = $library->getLibrary($libName);
                            if ($libraries[$libName]->value == 0) {
                                $document->addCustomTag("<link id=\"phocagallerypiclens\" rel=\"alternate\" href=\"" . JURI::base(true) . "/images/phocagallery/" . $image->catid . ".rss\" type=\"application/rss+xml\" title=\"\" />");
                                $library->setLibrary($libName, 1);
                            }
                            // PicLens CSS - will be loaded only one time per site
                            $libraries[$libName] = $library->getLibrary('pg-pl-piclens');
                            if ($libraries['pg-pl-piclens']->value == 0) {
                                $document->addScript('http://lite.piclens.com/current/piclens.js');
                                $document->addCustomTag("<style type=\"text/css\">\n" . " .mbf-item { display: none; }\n" . " #phocagallery .mbf-item { display: none; }\n" . " </style>\n");
                                $library->setLibrary('pg-pl-piclens', 1);
                            }
                        }
                        // END PICLENS -----------------------------------------------------------------------------
                        $image->slug = $image->id . '-' . $image->alias;
                        // Get file thumbnail or No Image
                        $image->linkthumbnailpath = PhocaGalleryImageFront::displayImageOrNoImage($image->filename, 'medium');
                        $file_thumbnail = PhocaGalleryFileThumbnail::getThumbnailName($image->filename, 'medium');
                        $image->linkthumbnailpathabs = $file_thumbnail->abs;
                        // -------------------------------------------------------------- SEF PROBLEM
                        // Is there a Itemid for category
                        $items = $menu->getItems('link', 'index.php?option=com_phocagallery&view=category&id=' . $category_info->id);
                        $itemscat = $menu->getItems('link', 'index.php?option=com_phocagallery&view=categories');
                        if (isset($itemscat[0])) {
                            $itemid = $itemscat[0]->id;
                            $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category_info->slug . '&id=' . $image->slug . '&Itemid=' . $itemid . '&tmpl=component&detail=' . $detail_window . '&buttons=' . $detail_buttons);
                        } else {
                            if (isset($items[0])) {
                                $itemid = $items[0]->id;
                                $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category_info->slug . '&id=' . $image->slug . '&Itemid=' . $itemid . '&tmpl=component&detail=' . $detail_window . '&buttons=' . $detail_buttons);
                            } else {
                                $itemid = 0;
                                $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category_info->slug . '&id=' . $image->slug . '&tmpl=component&detail=' . $detail_window . '&buttons=' . $detail_buttons);
                            }
                        }
                        // ---------------------------------------------------------------------------------
                        // Different links for different actions: image, zoom icon, download icon
                        $thumbLink = PhocaGalleryFileThumbnail::getThumbnailName($image->filename, 'large');
                        $imgLinkOrig = JURI::base(true) . '/' . PhocaGalleryFile::getFileOriginal($image->filename, 1);
                        $imgLink = $thumbLink->rel;
                        if ($detail_window == 2) {
                            $image->link = $imgLink;
                            $image->link2 = $imgLink;
                            $image->linkother = $siteLink;
                            $image->linkorig = $imgLinkOrig;
                        } else {
                            if ($detail_window == 3) {
                                $image->link = $imgLink;
                                $image->link2 = $imgLink;
                                $image->linkother = $siteLink;
                                $image->linkorig = $imgLinkOrig;
                            } else {
                                if ($detail_window == 5) {
                                    $image->link = $imgLink;
                                    $image->link2 = $siteLink;
                                    $image->linkother = $siteLink;
                                    $image->linkorig = $imgLinkOrig;
                                } else {
                                    $image->link = $siteLink;
                                    $image->link2 = $siteLink;
                                    $image->linkother = $siteLink;
                                    $image->linkorig = $imgLinkOrig;
                                }
                            }
                        }
                        // Float
                        $float_code = '';
                        if ($float != '') {
                            $float_code = 'position:relative;float:' . $float . ';';
                        }
                        // Maximum size of module image is 100 x 100
                        jimport('joomla.filesystem.file');
                        $imageWidth['size'] = 100;
                        $imageHeight['size'] = 100;
                        $imageHeight['boxsize'] = 100;
                        $imageWidth['boxsize'] = 120;
                        $imageOrigHeight = 100;
                        $imageOrigWidth = 100;
                        if (JFile::exists($image->linkthumbnailpathabs)) {
                            list($width, $height) = GetImageSize($image->linkthumbnailpathabs);
                            $imageHeight = PhocaGalleryImage::correctSize($height, 100, 100, 0);
                            $imageWidth = PhocaGalleryImage::correctSize($width, 100, 120, 20);
                            $imageOrigHeight = $height;
                            $imageOrigWidth = $width;
                        }
                        $imageHeight['boxsize'] = PhocaGalleryImage::setBoxSize($imageHeight, $imageWidth, $display_name, $display_icon_detail, $display_icon_download, 0, 0, 0, 0, 0, 0, 0, 0, $category_box_space, $image_background_shadow, 0);
                        if ($image_background_shadow != 'none') {
                            $imageHeight['size'] = $imageHeight['size'] + 18;
                            $imageWidth['size'] = $imageWidth['size'] + 18;
                            $image_background_color = 'url(\'' . JURI::base(true) . '/components/com_phocagallery/assets/images/' . $image_background_shadow . '.' . $tmpl['formaticon'] . '\') 0 0 no-repeat;';
                        }
                        $output .= '<div class="phocagallery-box-file pgplugin' . $iCss . '" style="height:' . $imageHeight['boxsize'] . 'px; width:' . $imageWidth['boxsize'] . 'px;' . $float_code . '">' . "\n" . '<center>' . "\n" . '<div class="phocagallery-box-file-first" style="background: ' . $image_background_color . ';height:' . $imageHeight['size'] . 'px;width:' . $imageWidth['size'] . 'px;">' . "\n" . '<div class="phocagallery-box-file-second">' . "\n" . '<div class="phocagallery-box-file-third">' . "\n" . '<center>' . "\n" . '<a class="' . $button->methodname . '" title="' . $image->title . '" href="' . JRoute::_($image->link) . '"';
                        // DETAIL WINDOW
                        if ($detail_window == 1) {
                            $output .= ' onclick="' . $button->options . '"';
                        } else {
                            if ($detail_window == 4 || $detail_window == 5) {
                                $highSlideOnClick = str_replace('[phocahsfullimg]', $image->linkorig, $tmpl['highslideonclick']);
                                $output .= ' onclick="' . $highSlideOnClick . '"';
                            } else {
                                $output .= ' rel="' . $button->options . '"';
                            }
                        }
                        // Enable the switch image
                        if ($enable_switch == 1) {
                            $output .= ' onmouseover="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \'' . str_replace('phoca_thumb_m_', 'phoca_thumb_l_', JURI::root() . $image->linkthumbnailpath) . '\');" onmouseout="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \'' . str_replace('phoca_thumb_m_', 'phoca_thumb_l_', JURI::root() . $image->linkthumbnailpath) . '\');"';
                        } else {
                            // Overlib
                            if (!empty($image->description)) {
                                $divPadding = 'padding:5px;';
                            } else {
                                $divPadding = 'padding:0px;margin:0px;';
                            }
                            $document->addScript(JURI::base(true) . '/includes/js/overlib_mini.js');
                            $opacityPer = $opacityPer = (double) $tmpl['overliboverlayopacity'] * 100;
                            if ($libraries['pg-overlib-group']->value == 0) {
                                $document->addCustomTag("<style type=\"text/css\">\n" . ".bgPhocaClass{\r\n\t\t\t\t\t\t\t\tbackground:" . $tmpl['olbgcolor'] . ";\r\n\t\t\t\t\t\t\t\tfilter:alpha(opacity=" . $opacityPer . ");\r\n\t\t\t\t\t\t\t\topacity: " . $tmpl['overliboverlayopacity'] . ";\r\n\t\t\t\t\t\t\t\t-moz-opacity:" . $tmpl['overliboverlayopacity'] . ";\r\n\t\t\t\t\t\t\t\tz-index:1000;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t.fgPhocaClass{\r\n\t\t\t\t\t\t\t\tbackground:" . $tmpl['olfgcolor'] . ";\r\n\t\t\t\t\t\t\t\tfilter:alpha(opacity=100);\r\n\t\t\t\t\t\t\t\topacity: 1;\r\n\t\t\t\t\t\t\t\t-moz-opacity:1;\r\n\t\t\t\t\t\t\t\tz-index:1000;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t.fontPhocaClass{\r\n\t\t\t\t\t\t\t\tcolor:" . $tmpl['oltfcolor'] . ";\r\n\t\t\t\t\t\t\t\tz-index:1001;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t.capfontPhocaClass, .capfontclosePhocaClass{\r\n\t\t\t\t\t\t\t\tcolor:" . $tmpl['olcfcolor'] . ";\r\n\t\t\t\t\t\t\t\tfont-weight:bold;\r\n\t\t\t\t\t\t\t\tz-index:1001;\r\n\t\t\t\t\t\t\t\t}" . " </style>\n");
                                $library->setLibrary('pg-overlib-group', 1);
                            }
                            if ($enable_overlib == 1) {
                                $output .= " onmouseover=\"return overlib('" . htmlspecialchars(addslashes('<center>' . JHTML::_('image.site', str_replace('phoca_thumb_m_', 'phoca_thumb_l_', $image->linkthumbnailpath), '', '', '', $image->title) . "</center>")) . "', CAPTION, '" . $image->title . "', BELOW, RIGHT, BGCLASS,'bgPhocaClass', FGCOLOR, '" . $tmpl['olfgcolor'] . "', BGCOLOR, '" . $tmpl['olbgcolor'] . "', TEXTCOLOR, '" . $tmpl['oltfcolor'] . "', CAPCOLOR, '" . $tmpl['olcfcolor'] . "');\"" . " onmouseout=\"return nd();\" ";
                            } else {
                                if ($enable_overlib == 2) {
                                    $image->description = str_replace("\n", '<br />', $image->description);
                                    $output .= " onmouseover=\"return overlib('" . htmlspecialchars(addslashes('<div style="' . $divPadding . '">' . $image->description . '</div>')) . "', CAPTION, '" . $image->title . "', BELOW, RIGHT, CSSCLASS, TEXTFONTCLASS, 'fontPhocaClass', FGCLASS, 'fgPhocaClass', BGCLASS, 'bgPhocaClass', CAPTIONFONTCLASS,'capfontPhocaClass', CLOSEFONTCLASS, 'capfontclosePhocaClass');\"" . " onmouseout=\"return nd();\" ";
                                } else {
                                    if ($enable_overlib == 3) {
                                        $image->description = str_replace("\n", '<br />', $image->description);
                                        $output .= " onmouseover=\"return overlib('" . PhocaGalleryText::strTrimAll(htmlspecialchars(addslashes('<div style="text-align:center"><center>' . JHTML::_('image.site', str_replace('phoca_thumb_m_', 'phoca_thumb_l_', $image->linkthumbnailpath), '', '', '', $image->title) . '</center></div><div style="' . $divPadding . '">' . $image->description . '</div>'))) . "', CAPTION, '" . $image->title . "', BELOW, RIGHT, BGCLASS,'bgPhocaClass', FGCLASS,'fgPhocaClass', FGCOLOR, '" . $tmpl['olfgcolor'] . "', BGCOLOR, '" . $tmpl['olbgcolor'] . "', TEXTCOLOR, '" . $tmpl['oltfcolor'] . "', CAPCOLOR, '" . $tmpl['olcfcolor'] . "');\"" . " onmouseout=\"return nd();\" ";
                                    }
                                }
                            }
                        }
                        // End Overlib
                        $output .= ' >' . "\n";
                        $output .= '<img src="' . $image->linkthumbnailpath . '" alt="' . $image->title . '" />';
                        if ((int) $enable_piclens > 0) {
                            $output .= '<span class="mbf-item">#phocagallerypiclens ' . $image->catid . '-phocagallerypiclenscode-' . $image->filename . '</span>';
                        }
                        $output .= '</a>' . '</center>' . "\n" . '</div>' . "\n" . '</div>' . "\n" . '</div>' . "\n" . '</center>' . "\n";
                        if ($display_name == 1) {
                            $output .= '<div class="name" style="color: ' . $font_color . ' ;font-size:' . $namefontsize . 'px;margin-top:5px;text-align:center;">' . PhocaGalleryText::wordDelete($image->title, $namenumchar, '...') . '</div>';
                        }
                        if ($display_icon_detail == 1 || $display_icon_download == 1 || $enable_piclens == 2) {
                            $output .= '<div class="detail" style="text-align:right">';
                            if ($enable_piclens == 2) {
                                $output .= ' <a href="javascript:PicLensLite.start();" title="PicLens" ><img src="http://lite.piclens.com/images/PicLensButton.png" alt="PicLens" width="16" height="12" border="0" style="margin-bottom:2px" /></a>';
                            }
                            if ($display_icon_detail == 1) {
                                $output .= ' <a class="' . $button->methodname . '" title="' . JText::_('Image Detail') . '" href="' . JRoute::_($image->link2) . '"';
                                // Detail Window
                                if ($detail_window == 1) {
                                    $output .= ' onclick="' . $button->options . '"';
                                } else {
                                    if ($detail_window == 2) {
                                        $output .= ' rel="' . $button->options . '"';
                                    } else {
                                        if ($detail_window == 4) {
                                            $output .= ' onclick="' . $tmpl['highslideonclick'] . '"';
                                        } else {
                                            if ($detail_window == 5) {
                                                $output .= ' onclick="' . $tmpl['highslideonclick2'] . '"';
                                            } else {
                                                $output .= ' rel="' . $button2->options . '"';
                                            }
                                        }
                                    }
                                }
                                $output .= ' >';
                                $output .= '<img src="components/com_phocagallery/assets/images/icon-view.' . $tmpl['formaticon'] . '" alt="' . $image->title . '" />';
                                $output .= '</a>';
                            }
                            if ($display_icon_download == 1) {
                                $output .= ' <a class="' . $button->methodname . '" title="' . JText::_('Image Download') . '" href="' . JRoute::_($image->linkother . '&amp;phocadownload=1') . '"';
                                // Detail Window
                                if ($detail_window == 1) {
                                    $output .= ' onclick="' . $buttonOther->options . '"';
                                } else {
                                    if ($detail_window == 4) {
                                        $output .= ' onclick="' . $tmpl['highslideonclick'] . '"';
                                    } else {
                                        if ($detail_window == 5) {
                                            $output .= ' onclick="' . $tmpl['highslideonclick2'] . '"';
                                        } else {
                                            $output .= ' rel="' . $buttonOther->options . '"';
                                        }
                                    }
                                }
                                $output .= ' >';
                                $output .= '<img src="components/com_phocagallery/assets/images/icon-download.' . $tmpl['formaticon'] . '" alt="' . $image->title . '" />';
                                $output .= '</a>';
                            }
                            $output .= '</div>';
                            if ($float == '') {
                                $output .= '<div style="clear:both"> </div>';
                            }
                        }
                        $output .= '</div>';
                    }
                }
                //--------------------------
                // DISPLAYING OF SWITCHIMAGE
                //--------------------------
                if ($view == 'switchimage') {
                    $path = PhocaGalleryPath::getPath();
                    $waitImage = $path->image_rel . 'icon-switch.gif';
                    $basicImage = $path->image_rel . 'phoca_thumb_l_no_image.' . $tmpl['formaticon'];
                    if ($basic_image_id > 0) {
                        $query = 'SELECT *' . ' FROM #__phocagallery' . ' WHERE id = ' . (int) $basic_image_id;
                        $db->setQuery($query);
                        $basicImageArray =& $db->loadObject();
                        if (isset($basicImageArray->filename)) {
                            $fileBasicThumb = PhocaGalleryFileThumbnail::getThumbnailName($basicImageArray->filename, 'large');
                            $basicImage = $fileBasicThumb->rel;
                        } else {
                            $basicImage = '';
                        }
                    }
                    $switchHeight = $switch_height;
                    //$this->switchheight;
                    $switchCenterH = $switchHeight / 2 - 18;
                    $switchWidth = $switch_width;
                    //$this->switchwidth;
                    $switchCenterW = $switchWidth / 2 - 18;
                    $document->addCustomTag(PhocaGalleryRenderFront::switchImage($waitImage));
                    $switchHeight = $switchHeight + 5;
                    $output .= '<div><center class="main-switch-image" style="margin:0px;padding:7px 5px 7px 5px;margin-bottom:15px;"><table border="0" cellspacing="5" cellpadding="5" style="border:1px solid #c2c2c2;"><tr><td align="center" valign="middle" style="text-align:center;width:' . $switchWidth . 'px;height:' . $switchHeight . 'px; background: url(\'' . JURI::root() . 'components/com_phocagallery/assets/images/icon-switch.gif\') ' . $switchCenterW . 'px ' . $switchCenterH . 'px no-repeat;margin:0px;padding:0px;">
' . JHTML::_('image.site', $basicImage, '', '', '', '', ' id="PhocaGalleryobjectPicture"  border="0"') . '
</td></tr></table></center></div>';
                } else {
                    // Overlib
                }
                //--------------------------
                // DISPLAYING OF Clear Both
                //--------------------------
                if ($view == 'clearboth') {
                    $output .= '<div style="clear:both"> </div>';
                }
                if ($view == 'clearright') {
                    $output .= '<div style="clear:right"> </div>';
                }
                if ($view == 'clearleft') {
                    $output .= '<div style="clear:left"> </div>';
                }
                $output .= '</div>';
                if ($float == '') {
                    $output .= '<div style="clear:both"> </div>';
                }
                $article->text = preg_replace($regex_all, $output, $article->text, 1);
            }
            // CUSTOM CSS - For all items it will be the same
            if ($libraries['pg-css-sbox-plugin']->value == 0) {
                $document->addCustomTag("<style type=\"text/css\">\n" . $cssSbox . "\n" . " </style>\n");
                $library->setLibrary('pg-css-sbox-plugin', 1);
            }
            // All custom CSS tags will be added into one CSS area
            if ($libraries['pg-css-pg-plugin']->value == 0) {
                $document->addCustomTag("<style type=\"text/css\">\n" . $cssPgPlugin . "\n" . " </style>\n");
                $library->setLibrary('pg-css-pg-plugin', 1);
            }
            if ($libraries['pg-css-ie']->value == 0) {
                $document->addCustomTag("<!--[if lt IE 8]>\n<link rel=\"stylesheet\" href=\"" . JURI::base(true) . "/components/com_phocagallery/assets/phocagalleryieall.css\" type=\"text/css\" />\n<![endif]-->");
                $library->setLibrary('pg-css-ie', 1);
            }
        }
        // end if count_matches
        return true;
    }