/** * Method to display the category with images * only in case the category is accessable for the user who wants to see it * called from view.html.php */ function getCategory() { global $mainframe; // Load the Category data if ($this->_loadCategory()) { // Initialize some variables $user =& JFactory::getUser(); // Make sure the category is published if (!$this->_category->published) { JError::raiseError(404, JText::_("Resource Not Found")); return false; } // USER RIGHT - ACCESS ======================================= $rightDisplay = 1; //default is set to 1 (all users can see the category) if (isset($this->_category->params)) { $rightDisplay = PhocaGalleryHelper::getUserRight($this->_category->params, 'accessuserid', $this->_category->access, $user->get('aid', 0), $user->get('id', 0), 0); } if ($rightDisplay == 0) { $mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("ALERTNOTAUTH")); exit; } // ============================================================ } return $this->_category; }
function display($tpl = null) { global $mainframe; $document =& JFactory::getDocument(); $uri =& JFactory::getURI(); $menus =& JSite::getMenu(); $menu = $menus->getActive(); $params =& $mainframe->getParams(); $user =& JFactory::getUser(); // Only registered users if ($user->aid == 0) { $mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("ALERTNOTAUTH")); exit; } // CSS, JS JHTML::stylesheet('phocagallery.css', 'components/com_phocagallery/assets/'); $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]-->"); $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/js/comments.js'); //$id = JRequest::getVar('id', 0, '', 'int'); $tmpl['tab'] = JRequest::getVar('tab', 0, '', 'string'); $tmpl['formaticon'] = PhocaGalleryHelperFront::getFormatIcon(); $tmpl['displaytitleupload'] = $params->get('display_title_upload', 0); $tmpl['displaydescupload'] = $params->get('display_description_upload', 0); $tmpl['maxuploadchar'] = $params->get('max_upload_char', 1000); $tmpl['maxcreatecatchar'] = $params->get('max_create_cat_char', 1000); $display_phoca_info = $params->get('display_phoca_info', 1); $tmpl['phocainfocode'] = PhocaGalleryHelper::getPhocaInfoCode((int) $display_phoca_info); $tmpl['showpagetitle'] = $params->get('show_page_title', 1); // UCP is disabled (security reasons) $enable_user_cp = $params->get('enable_user_cp', 0); if ($enable_user_cp == 0) { $mainframe->redirect(JURI::base(true), JText::_("User Control Panel is disabled")); exit; } // PANE - CATEGORY EDIT | CREATE // MODEL - Get user's category $model = $this->getModel('user'); $userCategory = $model->getUserCategory($user->id); if (!empty($userCategory->categoryid)) { if ((int) $userCategory->categorypublished == 1) { $tmpl['createoredithead'] = JText::_('Edit Category'); $tmpl['createoredit'] = JText::_('Phoca Gallery Edit'); $tmpl['categorytitle'] = $userCategory->categorytitle; $tmpl['categorydescription'] = $userCategory->categorydescription; $tmpl['categorypublished'] = 1; } else { $tmpl['categorypublished'] = 0; } } else { $tmpl['createoredithead'] = JText::_('Create Category'); $tmpl['createoredit'] = JText::_('Phoca Gallery Create'); $tmpl['categorytitle'] = ''; $tmpl['categorydescription'] = ''; $tmpl['categorypublished'] = -1; } $document->addCustomTag(PhocaGalleryHelperRender::renderDescriptionCreateCatJS((int) $tmpl['maxcreatecatchar'])); // PANE - UPLOAD // Category Params if (!empty($userCategory->categoryid)) { $catParams = $model->getCategoryParams((int) $userCategory->categoryid); // =========================================================== // Upload $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 (isset($catParams->params)) { $rightDisplayUpload = PhocaGalleryHelper::getUserRight($catParams->params, 'uploaduserid', 1, $user->get('aid', 0), $user->get('id', 0), 0); } if ($rightDisplayUpload == 1) { $tmpl['displayupload'] = 1; $document->addCustomTag(PhocaGalleryHelperRender::renderDescriptionUploadJS((int) $tmpl['maxuploadchar'])); } // =========================================================== // USER RIGHT - ACCESS ======================================= $rightDisplay = 1; //default is set to 1 (all users can see the category) if (isset($catParams->params)) { $rightDisplay = PhocaGalleryHelper::getUserRight($catParams->params, 'accessuserid', 0, $user->get('aid', 0), $user->get('id', 0), 1); } if ($rightDisplay == 0) { $mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("ALERTNOTAUTH")); exit; } // =========================================================== // Upload Form ----------------------------------------------- // Set FTP form $ftp = !JClientHelper::hasCredentials('ftp'); // PARAMS - Upload size $tmpl['uploadmaxsize'] = $params->get('upload_maxsize', 3000000); $this->assignRef('session', JFactory::getSession()); // END Upload Form ------------------------------------------- } else { $tmpl['displayupload'] = 0; } $tmpl['createcategory'] = 1; // Tabs $displayTabs = 0; if ((int) $tmpl['createcategory'] == 0) { $currentTab['createcategory'] = -1; } else { $currentTab['createcategory'] = $displayTabs; $displayTabs++; } if ((int) $tmpl['displayupload'] == 0) { $currentTab['upload'] = -1; } else { $currentTab['upload'] = $displayTabs; $displayTabs++; } $tmpl['displaytabs'] = $displayTabs; $tmpl['currenttab'] = $currentTab; // ACTION $tmpl['action'] = $uri->toString(); // ASIGN $this->assignRef('tmpl', $tmpl); $this->assignRef('params', $params); $this->assignRef('session', JFactory::getSession()); parent::display($tpl); }
function display($tpl = null) { global $mainframe; $db =& JFactory::getDBO(); $model =& $this->getModel(); $document =& JFactory::getDocument(); $user =& JFactory::getUser(); $params =& $mainframe->getParams(); $tmpl = array(); $tmpl2 = array(); // CSS $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]-->"); $document->addStyleSheet(JURI::base(true) . '/components/com_phocagallery/assets/phocagallery.css'); // PARAMS $image_categories_size = $params->get('image_categories_size', 4); $hide_categories = $params->get('hide_categories', ''); $medium_image_width = $params->get('medium_image_width', 100); $medium_image_height = $params->get('medium_image_height', 100); $small_image_width = $params->get('small_image_width', 50); $small_image_height = $params->get('small_image_height', 50); $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; switch ($image_categories_size) { case 4: case 6: $tmpl['imagebg'] = 'background: url(\'' . JURI::base(true) . '/components/com_phocagallery/assets/images/shadow3.' . PhocaGalleryHelperFront::getFormatIcon() . '\') 50% 50% no-repeat;height:' . $small_image_height . 'px;width:' . $small_image_width . 'px;'; $tmpl['imagewidth'] = $small_image_width + 20; //Categories Detailed View break; case 5: case 7: $tmpl['imagebg'] = 'background: url(\'' . JURI::base(true) . '/components/com_phocagallery/assets/images/shadow1.' . PhocaGalleryHelperFront::getFormatIcon() . '\') 50% 50% no-repeat;height:' . $medium_image_height . 'px;width:' . $medium_image_width . 'px;'; $tmpl['imagewidth'] = $medium_image_width + 20; //Categories Detailed View break; case 1: case 3: $tmpl['imagebg'] = 'width:' . $medium_image_width . 'px;'; $tmpl['imagewidth'] = $medium_image_width + 20; //Categories Detailed View break; case 0: case 2: default: $tmpl['imagebg'] = 'width:' . $small_image_width . 'px;'; $tmpl['imagewidth'] = $small_image_width + 20; //Categories Detailed View break; } // PARAMS $tmpl['phocagallerywidth'] = $params->get('phocagallery_width', ''); $display_subcategories = $params->get('display_subcategories', 1); $display_empty_categories = $params->get('display_empty_categories', 0); $tmpl['categoriescolumns'] = $params->get('categories_columns', 1); $display_phoca_info = $params->get('display_phoca_info', 1); $tmpl['phocainfocode'] = PhocaGalleryHelper::getPhocaInfoCode((int) $display_phoca_info); $categories = $model->getData($display_subcategories, $display_empty_categories, $hide_categories); // PARMAS - Access Category - display category in category list, which user cannot access $display_access_category = $params->get('display_access_category', 1); // Add link and unset the categories which user cannot see (if it is enabled in params) $unSet = 0; // If it will be unseted while access view, we must sort the keys from category array - ACCESS foreach ($categories as $key => $category) { $categories[$key]->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $category->slug . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); // USER RIGHT - ACCESS ======================================= $rightDisplay = 1; if (isset($categories[$key]->params)) { $rightDisplay = PhocaGalleryHelper::getUserRight($categories[$key]->params, 'accessuserid', $category->access, $user->get('aid', 0), $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 (isset($categories[$key]->params)) { $rightDisplayKey = PhocaGalleryHelper::getUserRight($categories[$key]->params, 'accessuserid', $category->access, $user->get('aid', 0), $user->get('id', 0), 0); } } $file_thumbnail = PhocaGalleryHelperFront::displayFileOrNoImageCategories($category->filename, $image_categories_size, $rightDisplayKey); $categories[$key]->linkthumbnailpath = $file_thumbnail['rel']; if ($rightDisplay == 0) { unset($categories[$key]); $unSet = 1; } // ============================================================ } // ACCESS - in case we unset some category from the list, we must sort the array new if ($unSet == 1) { $categories = array_values($categories); } // PARAMS - Define image tag attributes if ($params->get('image') != -1) { $attribs['align'] = $params->get('image_align'); $attribs['hspace'] = 6; // Use the static HTML library to build the image tag $tmpl['image'] = JHTML::_('image', 'images/stories/' . $params->get('image'), JText::_('Phoca gallery'), $attribs); } // PARAMS - Display or hide image beside the category name $tmpl['displayimagecategories'] = $params->get('display_image_categories', 1); // ASSIGN $this->assignRef('tmpl', $tmpl); $this->assignRef('params', $params); $this->assignRef('categories', $categories); // PARAMS - GEO $display_categories_geotagging = $params->get('display_categories_geotagging', 0); if ($display_categories_geotagging == 1) { $tmpl2['categorieslng'] = $params->get('categories_lng', ''); $tmpl2['categorieslat'] = $params->get('categories_lat', ''); $tmpl2['categorieszoom'] = $params->get('categories_zoom', 2); $tmpl2['googlemapsapikey'] = $params->get('google_maps_api_key', ''); $tmpl2['categoriesmapwidth'] = $params->get('categories_map_width', 500); $tmpl2['categoriesmapheight'] = $params->get('categorires_map_height', 500); // if no lng and lat will be added, Phoca Gallery will try to find it in categories if ($tmpl2['categorieslat'] == '' || $tmpl2['categorieslng'] == '') { $latLng = PhocaGalleryHelper::findLatLngFromCategory($categories); $tmpl2['categorieslng'] = $latLng['lng']; $tmpl2['categorieslat'] = $latLng['lat']; } $this->assignRef('tmpl2', $tmpl2); parent::display('map'); } else { parent::display($tpl); } }
function display($tpl = null) { global $mainframe; $document =& JFactory::getDocument(); $uri =& JFactory::getURI(); $menus =& JSite::getMenu(); $menu = $menus->getActive(); $params =& $mainframe->getParams(); $user =& JFactory::getUser(); $limitStart = JRequest::getVar('limitstart', 0, '', 'int'); $id = JRequest::getVar('id', 0, '', 'int'); $tmpl['tab'] = JRequest::getVar('tab', 0, '', 'int'); $tmpl['formaticon'] = PhocaGalleryHelperFront::getFormatIcon(); // Limit start if ($limitStart > 0) { $tmpl['limitstarturl'] = '&limitstart=' . $limitStart; } else { $tmpl['limitstarturl'] = ''; } // PARAMS $tmpl['displaycatnametitle'] = $params->get('display_cat_name_title', 1); $display_cat_name_breadcrumbs = $params->get('display_cat_name_breadcrumbs', 1); $font_color = $params->get('font_color', '#b36b00'); $background_color = $params->get('background_color', '#fcfcfc'); $background_color_hover = $params->get('background_color_hover', '#f5f5f5'); $image_background_color = $params->get('image_background_color', '#f5f5f5'); $tmpl['displayimageshadow'] = $params->get('image_background_shadow', 'shadow1'); $border_color = $params->get('border_color', '#e8e8e8'); $border_color_hover = $params->get('border_color_hover', '#b36b00'); $tmpl['imagewidth'] = $params->get('medium_image_width', 100); $tmpl['imageheight'] = $params->get('medium_image_height', 100); $front_modal_box_width = $params->get('front_modal_box_width', 680); $front_modal_box_height = $params->get('front_modal_box_height', 560); $front_popup_window_width = $params->get('front_popup_window_width', 680); $front_popup_window_height = $params->get('front_popup_window_height', 560); $tmpl['olbgcolor'] = $params->get('ol_bg_color', '#666666'); $tmpl['olfgcolor'] = $params->get('ol_fg_color', '#f6f6f6'); $tmpl['oltfcolor'] = $params->get('ol_tf_color', '#000000'); $tmpl['olcfcolor'] = $params->get('ol_cf_color', '#ffffff'); $tmpl['overliboverlayopacity'] = $params->get('overlib_overlay_opacity', 0.7); $margin_box = $params->get('margin_box', 5); $padding_box = $params->get('padding_box', 5); $tmpl['maxuploadchar'] = $params->get('max_upload_char', 1000); $tmpl['maxcommentchar'] = $params->get('max_comment_char', 1000); $tmpl['commentwidth'] = $params->get('comment_width', 500); $tmpl['displayrating'] = $params->get('display_rating', 0); $tmpl['displaycomment'] = $params->get('display_comment', 0); $tmpl['displaycategorygeotagging'] = $params->get('display_category_geotagging', 0); $tmpl['displaycategorystatistics'] = $params->get('display_category_statistics', 0); // Used for Highslide JS (only image) $tmpl['displaydescriptiondetail'] = $params->get('display_description_detail', 0); $tmpl['displaytitleindescription'] = $params->get('display_title_description', 0); // PARAMS - Background shadow if ($tmpl['displayimageshadow'] != 'none') { $imageBgCSS = 'background: url(\'' . JURI::base(true) . '/components/com_phocagallery/assets/images/' . $tmpl['displayimageshadow'] . '.' . $tmpl['formaticon'] . '\') 0 0 no-repeat;'; } else { $imageBgCSS = 'background: ' . $image_background_color . ';'; } // CSS $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]-->"); $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/js/comments.js'); $document->addCustomTag(PhocaGalleryHelperRender::renderCategoryCSS($font_color, $background_color, $border_color, $imageBgCSS, $border_color_hover, $background_color_hover, $tmpl['olfgcolor'], $tmpl['olbgcolor'], $tmpl['oltfcolor'], $tmpl['olcfcolor'], $margin_box, $padding_box, $tmpl['overliboverlayopacity'])); $document->addCustomTag(PhocaGalleryHelperRender::renderIeHover()); // PARAMS $tmpl['phocagallerywidth'] = $params->get('phocagallery_width', ''); $display_description_detail = $params->get('display_description_detail', 0); $description_detail_height = $params->get('description_detail_height', 16); $tmpl['categoryboxspace'] = $params->get('category_box_space', 0); $tmpl['detailwindow'] = $params->get('detail_window', 0); // Description detail height if ($display_description_detail == 1) { $front_popup_window_height = $front_popup_window_height + $description_detail_height; } // PARAMS - Display Buttons (height will be smaller) $detail_buttons = $params->get('detail_buttons', 1); // Detail buttons in detail view if ($detail_buttons != 1) { $front_popup_window_height = $front_popup_window_height - 45; } // PARAMS $modal_box_overlay_color = $params->get('modal_box_overlay_color', '#000000'); $modal_box_overlay_opacity = $params->get('modal_box_overlay_opacity', 0.3); $modal_box_border_color = $params->get('modal_box_border_color', '#6b6b6b'); $modal_box_border_width = $params->get('modal_box_border_width', '2'); // ======================================================= // 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'); // CSS $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window {background-color:" . $modal_box_border_color . ";padding:" . $modal_box_border_width . "px} \n" . " #sbox-overlay {background-color:" . $modal_box_overlay_color . ";} \n" . " </style> \n"); // BUTTON (IMAGE - standard, modal, shadowbox) $button = new JObject(); $button->set('name', 'image'); // BUTTON OTHER (geotagging, downloadlink, ...) $buttonOther = new JObject(); $buttonOther->set('name', 'other'); $tmpl['highslideonclick'] = ''; // for using with highslide // ------------------------------------------------------- // STANDARD POPUP // ------------------------------------------------------- if ($tmpl['detailwindow'] == 1) { $button->set('methodname', 'js-button'); $button->set('options', "window.open(this.href,'win2','width=" . $front_popup_window_width . ",height=" . $front_popup_window_height . ",menubar=no,resizable=yes'); return false;"); $buttonOther->set('methodname', 'js-button'); $buttonOther->set('options', "window.open(this.href,'win2','width=" . $front_popup_window_width . ",height=" . $front_popup_window_height . ",menubar=no,resizable=yes'); return false;"); } else { if ($tmpl['detailwindow'] == 0 || $tmpl['detailwindow'] == 2) { // Button $button->set('modal', true); $button->set('methodname', 'modal-button'); $buttonOther->set('modal', true); $buttonOther->set('methodname', 'modal-button'); if ($tmpl['detailwindow'] == 2) { $button->set('options', "{handler: 'image', size: {x: 200, y: 150}, overlayOpacity: " . $modal_box_overlay_opacity . "}"); $buttonOther->set('options', "{handler: 'iframe', size: {x: " . $front_modal_box_width . ", y: " . $front_modal_box_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . "}"); } else { $button->set('options', "{handler: 'iframe', size: {x: " . $front_modal_box_width . ", y: " . $front_modal_box_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . "}"); $buttonOther->set('options', "{handler: 'iframe', size: {x: " . $front_modal_box_width . ", y: " . $front_modal_box_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . "}"); } } else { if ($tmpl['detailwindow'] == 3) { $sb_slideshow_delay = $params->get('sb_slideshow_delay', 5); $sb_lang = $params->get('sb_lang', 'en'); $button->set('methodname', 'shadowbox-button'); $button->set('options', "shadowbox[PhocaGallery];options={slideshowDelay:" . $sb_slideshow_delay . "}"); $buttonOther->set('modal', true); $buttonOther->set('methodname', 'modal-button'); $buttonOther->set('options', "{handler: 'iframe', size: {x: " . $front_modal_box_width . ", y: " . $front_modal_box_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . "}"); $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'); $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>'); } else { if ($tmpl['detailwindow'] == 4) { $button->set('methodname', 'highslide'); $document->addCustomTag('<script type="text/javascript" src="' . JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide-full.js"></script>' . "\n" . '<link rel="stylesheet" type="text/css" href="' . JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide.css"" />' . "\n"); $document->addCustomTag(PhocaGalleryHelperRender::renderHighslideJS($front_modal_box_width, $front_modal_box_height)); $tmpl['highslideonclick'] = 'return hs.htmlExpand(this, { contentId: \'detail\', objectType: \'iframe\', objectWidth: ' . $front_modal_box_width . ', objectHeight: ' . $front_modal_box_height . '} )'; } else { if ($tmpl['detailwindow'] == 5) { $button->set('methodname', 'highslide'); $buttonOther->set('modal', true); $buttonOther->set('methodname', 'modal-button'); $buttonOther->set('options', "{handler: 'iframe', size: {x: " . $front_modal_box_width . ", y: " . $front_modal_box_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . "}"); $document->addCustomTag('<script type="text/javascript" src="' . JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslide-full.js"></script>' . "\n" . '<link rel="stylesheet" type="text/css" href="' . JURI::base(true) . '/components/com_phocagallery/assets/js/highslide/highslideimage.css"" />' . "\n"); $document->addCustomTag(PhocaGalleryHelperRender::renderHighslideImageJS()); $tmpl['highslideonclick'] = 'return hs.expand(this)'; } } } } } $folderbutton = new JObject(); $folderbutton->set('name', 'image'); $folderbutton->set('options', ""); // End open window parameters // USER RIGHT - ACCESS ======================================= // We get the category id, there is an USER ACCES BEHAVIOUR $category = $this->get('category'); // function getCategory in Model // =========================================================== $total = $this->get('total'); $tmpl['pagination'] =& $this->get('pagination'); // CSS //$document->addStyleSheet(JURI::base(true).'/components/com_phocagallery/assets/phocagallery.css'); JHTML::stylesheet('phocagallery.css', 'components/com_phocagallery/assets/'); // PARAMS $tmpl['enablepiclens'] = $params->get('enable_piclens', 0); $tmpl['startpiclens'] = 0; // PICLENS if ($tmpl['enablepiclens'] == 1) { $tmpl['startpiclens'] = $params->get('start_piclens', 0); // CSS - PicLens START $document->addCustomTag(PhocaGalleryHelperRender::renderPicLens($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 = $params->get('display_subcat_page', 0); // On the first site subcategories will be displayed allways $get['start'] = JRequest::getVar('start', '', 'get', 'string'); 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 } // PARAMS - Display Back Buttons $display_back_button = $params->get('display_back_button', 1); $display_categories_back_button = $params->get('display_categories_back_button', 1); // PARAMS - Access Category - display category (subcategory folder or backbutton to not accessible cat $display_access_category = $params->get('display_access_category', 1); // Set page title per category if ($tmpl['displaycatnametitle'] == 1) { $document->setTitle($params->get('page_title') . ' - ' . $category->title); } else { $document->setTitle($params->get('page_title')); } // Breadcrumb display: // 0 - only menu link // 1 - menu link - category name // 2 - only category name $this->_addBreadCrumbs($category, isset($menu->query['id']) ? $menu->query['id'] : 0, $display_cat_name_breadcrumbs); // PARAMS - the whole page title with category or without category $tmpl['showpagetitle'] = $params->get('show_page_title', 1); // Define image tag attributes if (!empty($category->image)) { $attribs['align'] = '"' . $category->image_position . '"'; $attribs['hspace'] = '"6"'; // Use the static HTML library to build the image tag $tmpl['image'] = JHTML::_('image', 'images/stories/' . $category->image, JText::_('Phoca gallery'), $attribs); } // PARAMS- Display or hide name, icon detail link $tmpl['displayname'] = $params->get('display_name', 1); $tmpl['displayicondetail'] = $params->get('display_icon_detail', 1); $tmpl['displayicondownload'] = $params->get('display_icon_download', 0); $tmpl['displayiconfolder'] = $params->get('display_icon_folder', 0); $tmpl['displayiconvm'] = $params->get('display_icon_vm', 0); $tmpl['fontsizename'] = $params->get('font_size_name', 12); $tmpl['charlengthname'] = $params->get('char_length_name', 15); $display_phoca_info = $params->get('display_phoca_info', 1); $tmpl['displayicongeo'] = $params->get('display_icon_geotagging', 0); $tmpl['phocainfocode'] = PhocaGalleryHelper::getPhocaInfoCode((int) $display_phoca_info); // PARAMS - Switch Image $tmpl['switchimage'] = $params->get('switch_image', 0); $tmpl['switchheight'] = $params->get('switch_height', 480); $tmpl['switchwidth'] = $params->get('switch_width', 640); // Switch image JS $tmpl['basicimage'] = ''; if ($tmpl['switchimage'] == 1) { $imagePathFront = PhocaGalleryHelperFront::getPathSet(); $waitImage = $imagePathFront['front_image'] . 'icon-switch.gif'; $tmpl['basicimage'] = $imagePathFront['front_image'] . 'phoca_thumb_l_no_image.' . $tmpl['formaticon']; $document->addCustomTag(PhocaGalleryHelperFront::switchImage($waitImage)); $basicImageSelected = 0; // we have not selected the basic image yet } // PARAMS - Upload $tmpl['displaytitleupload'] = $params->get('display_title_upload', 0); $tmpl['displaydescupload'] = $params->get('display_description_upload', 0); // PARAMS - Overlib $enable_overlib = $params->get('enable_overlib', 0); // Overlib if ((int) $enable_overlib > 0) { $document->addCustomTag('<script type="text/javascript" src="' . JURI::root() . 'includes/js/overlib_mini.js"></script>'); } // MODEL $model =& $this->getModel(); // Category Params $catParams = $model->getCategoryParams((int) $id); // Trash $tmpl['trash'] = 0; $tmpl['publishunpublish'] = 0; // 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 (isset($catParams->params)) { $rightDisplayDelete = PhocaGalleryHelper::getUserRight($catParams->params, 'deleteuserid', 1, $user->get('aid', 0), $user->get('id', 0), 0); } if ($rightDisplayDelete == 1) { $tmpl['trash'] = 1; $tmpl['publishunpublish'] = 1; } // =========================================================== // Upload $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 (isset($catParams->params)) { $rightDisplayUpload = PhocaGalleryHelper::getUserRight($catParams->params, 'uploaduserid', 1, $user->get('aid', 0), $user->get('id', 0), 0); } if ($rightDisplayUpload == 1) { $tmpl['displayupload'] = 1; $document->addCustomTag(PhocaGalleryHelperRender::renderDescriptionUploadJS((int) $tmpl['maxuploadchar'])); } // =========================================================== // USER RIGHT - ACCESS ======================================= $rightDisplay = 1; //default is set to 1 (all users can see the category) if (isset($catParams->params)) { $rightDisplay = PhocaGalleryHelper::getUserRight($catParams->params, 'accessuserid', 0, $user->get('aid', 0), $user->get('id', 0), $display_access_category); } if ($rightDisplay == 0) { $mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("ALERTNOTAUTH")); exit; } // =========================================================== // GEOTAGGING if (isset($catParams->params)) { $longitude = PhocaGalleryHelper::getParamsArray($catParams->params, 'longitude'); $latitude = PhocaGalleryHelper::getParamsArray($catParams->params, 'latitude'); if (!isset($longitude[0]) || isset($longitude[0]) && ($longitude[0] == '' || $longitude[0] == 0)) { $tmpl['displayicongeo'] = 0; } if (!isset($latitude[0]) || isset($latitude[0]) && ($latitude[0] == '' || $latitude[0] == 0)) { $tmpl['displayicongeo'] = 0; } } else { $tmpl['displayicongeo'] = 0; } // If user has rights to delete or publish or unpublish, unbublished items should be displayed if ($rightDisplayDelete == 1) { $items = $model->getData($display_subcat_page, $display_back_button, $display_categories_back_button, $display_access_category, 1); } else { $items = $model->getData($display_subcat_page, $display_back_button, $display_categories_back_button, $display_access_category); } // BOXES $k = 0; $unSet = 0; // If it will be unseted while access view, we must sort the keys from category array - ACCESS for ($i = 0; $i < count($items); $i++) { $item =& $items[$i]; if (isset($item->item_type) && $item->item_type == "categorieslist") { $item->link = JRoute::_($item->link); $item->button =& $folderbutton; $item->button->methodname = ''; $item->displayicondetail = 0; $item->displayicondownload = 0; $item->displayiconfolder = 0; $item->displayname = 0; $item->displayiconvm = ''; $item->startpiclens = 0; $item->trash = 0; $item->publishunpublish = 0; $item->enable_piclens = 0; $item->overlib = 0; $item->displayicongeo = 0; $item->type = 0; } else { if (isset($item->item_type) && $item->item_type == "parentfolder") { $item->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $item->slug . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); $item->button =& $folderbutton; $item->button->methodname = ''; $item->displayicondetail = 0; $item->displayicondownload = 0; $item->displayiconfolder = 0; $item->displayname = 0; $item->displayiconvm = ''; $item->startpiclens = 0; $item->trash = 0; $item->publishunpublish = 0; $item->enable_piclens = 0; $item->overlib = 0; $item->displayicongeo = 0; $item->type = 0; } else { if (isset($item->item_type) && $item->item_type == "subfolder") { $item->link = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $item->slug . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); $item->button =& $folderbutton; $item->button->methodname = ''; $item->displayicondetail = 0; $item->displayicondownload = 0; $item->displayiconfolder = $tmpl['displayiconfolder']; $item->displayname = $tmpl['displayname']; $item->displayiconvm = ''; $item->startpiclens = 0; $item->trash = 0; $item->publishunpublish = 0; $item->enable_piclens = 0; $item->overlib = 0; $item->displayicongeo = 0; $item->type = 1; // $tmpl['displayname'] = 1; } else { // Add the first Image as basic image if ($tmpl['switchimage'] == 1) { if ($basicImageSelected == 0) { $tmpl['basicimage'] = $item->linkthumbnailpath; $basicImageSelected = 1; } } $thumbLink = PhocaGalleryHelper::getThumbnailName($item->filename, 'large'); $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category->slug . '&id=' . $item->slug . '&tmpl=component' . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); $imgLink = JURI::base(true) . str_replace('..', '', $thumbLink['rel']); if ($tmpl['detailwindow'] == 2) { $item->link = $imgLink; $item->linkother = $imgLink; } else { if ($tmpl['detailwindow'] == 3 || $tmpl['detailwindow'] == 5) { $item->link = $imgLink; $item->linkother = $siteLink; } else { $item->link = $siteLink; $item->linkother = $siteLink; } } $item->button =& $button; $item->buttonother =& $buttonOther; $item->displayicondetail = $tmpl['displayicondetail']; $item->displayicondownload = $tmpl['displayicondownload']; $item->displayiconfolder = 0; $item->displayname = $tmpl['displayname']; $item->displayiconvm = ''; $item->startpiclens = $tmpl['startpiclens']; $item->type = 2; // Trash icon if ($tmpl['trash'] == 1) { $item->trash = 1; } else { $item->trash = 0; } // Publish Unpublish icon if ($tmpl['publishunpublish'] == 1) { $item->publishunpublish = 1; } else { $item->publishunpublish = 0; } // PICLENS if ($tmpl['enablepiclens']) { $item->enable_piclens = 1; } else { $item->enable_piclens = 0; } // GEOTAGGING if ($tmpl['displayicongeo'] == 1) { $item->displayicongeo = 1; } else { $item->displayicongeo = 0; } // OVERLIB if ($enable_overlib == 1) { $item->overlib = 1; } else { if ($enable_overlib == 2) { $item->overlib = 2; } else { if ($enable_overlib == 3) { $item->overlib = 3; } else { $item->overlib = 0; } } } // VirtueMart link if ($tmpl['displayiconvm'] == 1) { $vmLinkError = false; $vmProductId = 0; if (isset($item->params) && $item->params != '') { $paramsArray = explode(';', $item->params); if (is_array($paramsArray)) { foreach ($paramsArray as $value) { $vmParam = preg_match("/vmproductid=/i", $value); if ($vmParam) { $vmProductId = str_replace('vmproductid=', '', $value); } } } } $vmLink = $model->getVmLink($vmProductId); $vmLinkError = preg_match("/Error/i", $vmLink); if ($vmLinkError) { $item->displayiconvm = ''; } else { $item->displayiconvm = 1; $item->vmlink = $vmLink; } } else { $item->displayiconvm = ''; } // End VM Link } } } } $item->odd = $k; $item->count = $i; $k = 1 - $k; // Upload Form ------------------------------------ /* JHTML::_('behavior.mootools'); $document->addScript('administrator/components/com_phocagallery/assets/upload/mediamanager.js'); $document->addStyleSheet('administrator/components/com_phocagallery/assets/upload/mediamanager.css'); */ // Set FTP form $ftp = !JClientHelper::hasCredentials('ftp'); // Set flash uploader if ftp password and login exists (will be not problems) //$stateFolder = 'phocagallery'; //$refreshSite = $uri->toString(); /* if (!$ftp) { if ($params->get('enable_flash', 1)) { PhocaGalleryHelperUpload::uploader('file-upload', array('onAllComplete' => 'function(){ window.location.href="'.$refreshSite.'"; }')); } } */ // PARAMS - Upload size $tmpl['uploadmaxsize'] = $params->get('upload_maxsize', 3000000); $this->assignRef('session', JFactory::getSession()); //$this->assignRef('uploadmaxsize', $upload_maxsize); // END Upload Form ------------------------------------ // Only registered (VOTES + COMMENTS) $tmpl['notregistered'] = true; $tmpl['username'] = ''; if ($user->aid > 0) { $tmpl['notregistered'] = false; $tmpl['username'] = $user->name; } // VOTES Statistics if ((int) $tmpl['displayrating'] == 1) { $tmpl['votescount'] = 0; $tmpl['votesaverage'] = 0; $tmpl['voteswidth'] = 0; $votesStatistics = $model->getVotesStatistics((int) $id); if (!empty($votesStatistics->count)) { $tmpl['votescount'] = $votesStatistics->count; } if (!empty($votesStatistics->average)) { $tmpl['votesaverage'] = $votesStatistics->average; if ($tmpl['votesaverage'] > 0) { $tmpl['votesaverage'] = round((double) $tmpl['votesaverage'] / 0.5) * 0.5; $tmpl['voteswidth'] = 22 * $tmpl['votesaverage']; } } if ((int) $tmpl['votescount'] > 1) { $tmpl['votestext'] = 'votes'; } else { $tmpl['votestext'] = 'vote'; } // Already rated? $tmpl['alreadyrated'] = $model->checkUserVote((int) $id, (int) $user->id); } // COMMENTS if ((int) $tmpl['displaycomment'] == 1) { $document->addCustomTag(PhocaGalleryHelperRender::renderCommentJS((int) $tmpl['maxcommentchar'])); $tmpl['alreadycommented'] = $model->checkUserComment((int) $id, (int) $user->id); $commentItem = $model->displayComment((int) $id); $this->assignRef('commentitem', $commentItem); } // GEOTAGGING $map = $model->getGeotagging($id); if ($map['geotitle'] == '') { $map['geotitle'] = $category->title; } // TABS $displayTabs = 0; // R A T I N G if ((int) $tmpl['displayrating'] == 0) { $currentTab['rating'] = -1; } else { $currentTab['rating'] = $displayTabs; $displayTabs++; } // C O M M E N T S if ((int) $tmpl['displaycomment'] == 0) { $currentTab['comment'] = -1; } else { $currentTab['comment'] = $displayTabs; $displayTabs++; } // S T A T I S T I C S if ((int) $tmpl['displaycategorystatistics'] == 0) { $currentTab['statistics'] = -1; } else { $currentTab['statistics'] = $displayTabs; $displayTabs++; $tmpl['displaymaincatstat'] = $params->get('display_main_cat_stat', 1); $tmpl['displaylastaddedcatstat'] = $params->get('display_lastadded_cat_stat', 1); $tmpl['displaymostviewedcatstat'] = $params->get('display_mostviewed_cat_stat', 1); $tmpl['countlastaddedcatstat'] = $params->get('count_lastadded_cat_stat', 3); $tmpl['countmostviewedcatstat'] = $params->get('count_mostviewed_cat_stat', 3); if ($tmpl['displaymaincatstat'] == 1) { $numberImgP = $model->getCountImages($id, 1); $tmpl['numberimgpub'] = $numberImgP->countimg; $numberImgU = $model->getCountImages($id, 0); $tmpl['numberimgunpub'] = $numberImgU->countimg; $categoryViewed = $model->getHits($id); $tmpl['categoryviewed'] = $categoryViewed->catviewed; } // MOST VIEWED IMAGES //$tmpl['mostviewedimg'] = array(); if ($tmpl['displaymostviewedcatstat'] == 1) { $mostViewedImages = $model->getStatisticsImages($id, 'hits', 'DESC', $tmpl['countmostviewedcatstat']); for ($i = 0; $i < count($mostViewedImages); $i++) { $itemMVI =& $mostViewedImages[$i]; $itemMVI->button =& $button; $itemMVI->buttonother =& $buttonOther; $itemMVI->displayicondetail = $tmpl['displayicondetail']; $itemMVI->displayname = $tmpl['displayname']; $itemMVI->type = 2; $thumbLink = PhocaGalleryHelper::getThumbnailName($itemMVI->filename, 'large'); $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category->slug . '&id=' . $itemMVI->slug . '&tmpl=component' . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); $imgLink = JURI::base(true) . str_replace('..', '', $thumbLink['rel']); if ($tmpl['detailwindow'] == 2) { $itemMVI->link = $imgLink; } else { $itemMVI->link = $siteLink; } //$tmpl['mostviewedimg'][] = $itemMVI; } $tmpl['mostviewedimg'] = $mostViewedImages; } // LAST ADDED IMAGES //$tmpl['lastaddedimg'] = array(); if ($tmpl['displaylastaddedcatstat'] == 1) { $lastAddedImages = $model->getStatisticsImages($id, 'date', 'DESC', $tmpl['countlastaddedcatstat']); for ($i = 0; $i < count($lastAddedImages); $i++) { $itemLAI =& $lastAddedImages[$i]; $itemLAI->link = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category->slug . '&id=' . $itemLAI->slug . '&tmpl=component' . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); $itemLAI->button =& $button; $itemLAI->buttonother =& $buttonOther; $itemLAI->displayicondetail = $tmpl['displayicondetail']; $itemLAI->displayname = $tmpl['displayname']; $itemLAI->type = 2; $thumbLink = PhocaGalleryHelper::getThumbnailName($itemLAI->filename, 'large'); $siteLink = JRoute::_('index.php?option=com_phocagallery&view=detail&catid=' . $category->slug . '&id=' . $itemLAI->slug . '&tmpl=component' . '&Itemid=' . JRequest::getVar('Itemid', 1, 'get', 'int')); $imgLink = JURI::base(true) . str_replace('..', '', $thumbLink['rel']); if ($tmpl['detailwindow'] == 2) { $itemLAI->link = $imgLink; } else { $itemLAI->link = $siteLink; } //$tmpl['lastaddedimg'][] = $itemLAI; } $tmpl['lastaddedimg'] = $lastAddedImages; } } // G E O T A G G I N G if ((int) $tmpl['displaycategorygeotagging'] == 0) { $currentTab['geotagging'] = -1; } else { $currentTab['geotagging'] = $displayTabs; $displayTabs++; $tmpl['googlemapsapikey'] = $params->get('google_maps_api_key', ''); $tmpl['categorymapwidth'] = $params->get('category_map_width', 500); $tmpl['categorymapheight'] = $params->get('category_map_height', 400); } // U P L O A D if ((int) $tmpl['displayupload'] == 0) { $currentTab['upload'] = -1; } else { $currentTab['upload'] = $displayTabs; $displayTabs++; } $tmpl['displaytabs'] = $displayTabs; $tmpl['currenttab'] = $currentTab; // ACTION $tmpl['action'] = $uri->toString(); // ADD STATISTICS $model->hit($id); // ASIGN $this->assignRef('tmpl', $tmpl); $this->assignRef('params', $params); $this->assignRef('map', $map); $this->assignRef('items', $items); $this->assignRef('category', $category); $this->assignRef('button', $button); $this->assignRef('buttonother', $buttonOther); parent::display($tpl); }
function _loadData() { global $mainframe; $user =& JFactory::getUser(); // Lets load the content if it doesn't already exist if (empty($this->_data)) { $query = 'SELECT p.*' . ' FROM #__phocagallery AS p' . ' WHERE p.id = ' . (int) $this->_id; $this->_db->setQuery($query); $items = $this->_db->loadObject(); // Access check - don't display the image if you have no access to this image (if user add own url) if (isset($items->catid)) { $query = 'SELECT cc.access as access, cc.params as params' . ' FROM #__phocagallery_categories AS cc' . ' WHERE cc.id = ' . (int) $items->catid; $this->_db->setQuery($query); $catid = $this->_db->loadObject(); // USER RIGHT - ACCESS ======================================= $rightDisplay = 0; if (isset($catid->params)) { $rightDisplay = PhocaGalleryHelper::getUserRight($catid->params, 'accessuserid', $catid->access, $user->get('aid', 0), $user->get('id', 0), 0); } if ($rightDisplay == 0) { $mainframe->redirect('index.php?option=com_user&view=login', JText::_("ALERTNOTAUTH")); exit; } // ============================================================ } //Select category if (!$this->_loadCategory()) { $this->_loadCategory(); } //Slugs - possible //$items->slugid = (int) $items->id . "-" . $items->alias; //$items->slugcatid = $this->_category->slug; // SLUG CATID /* $query = 'SELECT c.alias'. ' FROM #__phocagallery_categories AS c' . ' WHERE c.id = '. (int) $this->_category->id; $this->_db->setQuery($query); $catid_alias = $this->_db->loadObject(); */ if (isset($this->_category->slug) && $this->_category->slug != '') { $catid_slug = $this->_category->slug; } else { $catid_slug = (int) $this->_category->id; } // ---------- // SLUG ID /* $query = 'SELECT a.alias'. ' FROM #__phocagallery AS a' . ' WHERE a.id = '. (int) $this->_id; $this->_db->setQuery($query); $id_alias = $this->_db->loadObject(); */ if (isset($items->alias) && $items->alias != '') { $id_slug = (int) $this->_id . ':' . $items->alias; } else { $id_slug = (int) $this->_id . ':'; // Because of possible SEF problem } // ---------- //Javascript Slideshow buttons $reload_button = PhocaGalleryHelperFront::getGalleryReload((int) $this->_category->id, (int) $this->_id, $id_slug, $catid_slug); $close_button = PhocaGalleryHelperFront::getGalleryClose((int) $this->_category->id, (int) $this->_id, $id_slug, $catid_slug); $close_text = PhocaGalleryHelperFront::getGalleryCloseText((int) $this->_category->id, (int) $this->_id, $id_slug, $catid_slug); $next_button = PhocaGalleryHelperFront::getGalleryNext((int) $this->_category->id, (int) $this->_id); $prev_button = PhocaGalleryHelperFront::getGalleryPrevious((int) $this->_category->id, (int) $this->_id); $js_slideshow_data = PhocaGalleryHelperFront::getGalleryJsSlideshow((int) $this->_category->id, (int) $this->_id, (int) $this->_slideshow, $id_slug, $catid_slug); // Get file thumbnail or No Image $file_name_no = $items->filename; $file_name = PhocaGalleryHelperFront::getTitleFromFilenameWithExt($items->filename); $image_size = PhocaGalleryHelperFront::getImageSizePhoca($items->filename); $file_size = PhocaGalleryHelperFront::getFileSizePhoca($items->filename); $file_thumbnail = PhocaGalleryHelperFront::displayFileOrNoImage($items->filename, 'large'); $link_thumbnail_path = $file_thumbnail['rel']; $file = new JObject(); //slideshow $file->set('closebutton', $close_button); $file->set('reloadbutton', $reload_button); $file->set('nextbutton', $next_button); $file->set('prevbutton', $prev_button); $file->set('slideshowbutton', $js_slideshow_data['icons']); $file->set('slideshowfiles', $js_slideshow_data['files']); $file->set('slideshow', $this->_slideshow); //download $file->set('closetext', $close_text); $file->set('filenameno', $file_name_no); $file->set('filename', $file_name); $file->set('download', $this->_download); $file->set('filesize', $file_size); $file->set('imagesize', $image_size[0] . ' x ' . $image_size[1]); //all $file->set('linkthumbnailpath', $link_thumbnail_path); //description $file->set('description', $items->description); $file->set('params', $items->params); $file->set('title', $items->title); if (isset($file)) { $this->_data = $file; } else { $this->_data = ''; } return (bool) $this->_data; } return true; }
$button->set('modal', true); $button->set('methodname', 'modal-button'); $button->set('options', "{handler: 'iframe', size: {x: " . $front_popup_window_width . ", y: " . $front_popup_window_height . "}, overlayOpacity: " . $modal_box_overlay_opacity . ", classWindow: 'phocagallery-random-window', classOverlay: 'phocagallery-random-overlay'}"); $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocagallery-random-window {background-color:" . $modal_box_border_color . ";padding:" . $modal_box_border_width . "px} \n" . " #sbox-overlay.phocagallery-random-overlay {background-color:" . $modal_box_overlay_color . ";} \n" . " </style> \n"); } // ACCESS RIGHTS // All categories where the user has access $query = 'SELECT cc.title AS text, cc.id AS id, cc.parent_id as parentid, cc.alias as alias, cc.access as access, cc.params as params' . ' FROM #__phocagallery_categories AS cc' . ' RIGHT JOIN #__phocagallery AS img ON img.catid = cc.id' . ' WHERE cc.published = 1' . ' AND cc.access <= ' . $user->get('aid', 0) . ' ORDER BY img.date DESC'; $db->setQuery($query); $categories = $db->loadObjectList(); $unSet = 0; foreach ($categories as $key => $category) { // USER RIGHT - ACCESS ======================================= $rightDisplay = 1; if (isset($categories[$key]->params)) { $rightDisplay = PhocaGalleryHelper::getUserRight($categories[$key]->params, 'accessuserid', $category->access, $user->get('aid', 0), $user->get('id', 0), 0); } if ($rightDisplay == 0) { unset($categories[$key]); $unSet = 1; } // ============================================================ } if ($unSet == 1) { $categories = array_values($categories); } $allowedCategories = $categories; // From objects to array only $last_result = 0; $indx = 0; $allowedCategoriesArray = array();
function upload() { global $mainframe; // Check for request forgeries JRequest::checkToken('request') or jexit('Invalid Token'); // Set FTP credentials, if given jimport('joomla.client.helper'); $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); $user =& JFactory::getUser(); $path = PhocaGalleryHelper::getPathSet(); $file = JRequest::getVar('Filedata', '', 'files', 'array'); $folder = JRequest::getVar('folder', '', '', 'path'); $tab = JRequest::getVar('tab', 0, '', 'int'); $format = JRequest::getVar('format', 'html', '', 'cmd'); $return = JRequest::getVar('return-url', null, 'post', 'base64'); $viewBack = JRequest::getVar('viewback', '', '', ''); $err = null; $view = JRequest::getVar('view', '', 'get', '', JREQUEST_NOTRIM); $catid = JRequest::getVar('id', '', 'get', 'string', JREQUEST_NOTRIM); //$catid = JRequest::getVar( 'catid', '', 'post', 'string', JREQUEST_NOTRIM ); $Itemid = JRequest::getVar('Itemid', 0, '', 'int'); $limitStart = JRequest::getVar('limitstart', 0, '', 'int'); $paramsC = JComponentHelper::getParams('com_phocagallery'); $catidAlias = $catid; // for return // Set the limistart (TODO) if ($limitStart > 0) { $limitStartUrl = '&limitstart=' . $limitStart; } else { $limitStartUrl = ''; } // From which view the image is uploaded switch ($view) { case 'user': // UCP is disabled (security reasons) $enable_user_cp = $paramsC->get('enable_user_cp', 0); if ($enable_user_cp == 0) { $mainframe->redirect(JURI::base(true), JText::_("User Control Panel is disabled")); exit; } $return = JRoute::_('index.php?option=com_phocagallery&view=user&tab=' . $tab . '&Itemid=' . $Itemid, false); // Get user catid, we are not in the category, so we must find the catid $modelUser = $this->getModel('user'); $userCatId = $modelUser->getUserCategory($user->id); // User has no category, he (she) can create one if (!empty($userCatId->categoryid)) { $catid = $userCatId->categoryid; } else { $mainframe->redirect($return, JText::_('Error Uploading Phoca Gallery User Control Image')); exit; } break; case 'category': default: $return = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $catidAlias . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false); break; } $model = $this->getModel('category'); // USER RIGHT - UPLOAD ======================================== // 2, 2 means that user access will be ignored in function getUserRight for display Delete button $rightDisplayUpload = 0; $catParams = $model->getCategoryParams((int) $catid); if (isset($catParams->params)) { $rightDisplayUpload = PhocaGalleryHelper::getUserRight($catParams->params, 'uploaduserid', 2, 2, $user->get('id', 0), 0); } // ============================================================ // USER RIGHT - FOLDER ======================================== $rightFolder[0] = ''; if (isset($catParams->params)) { $rightFolder = PhocaGalleryHelper::getParamsArray($catParams->params, 'userfolder'); } // ============================================================ if ($rightDisplayUpload == 1) { if ($rightFolder[0] == '') { $mainframe->redirect($return, JText::_('User Folder Not Defined')); } if (!JFolder::exists($path['orig_abs_ds'] . $rightFolder[0] . DS)) { $mainframe->redirect($return, JText::_('Defined User Folder Does Not Exist')); } // Check if the size will be not over the category folder size jimport('joomla.filesystem.folder'); $path = PhocaGalleryHelper::getPathset(); $catPath = $path['orig_abs_ds'] . $rightFolder[0] . DS; $files = JFolder::files($catPath); // Get size of all images in the folder $allFileSize = 0; foreach ($files as $fileInFolder) { $fileSize = PhocaGalleryHelperFront::getFileSizePhoca($rightFolder[0] . DS . $fileInFolder, 0); $allFileSize = $allFileSize + (int) $fileSize; } // Get the size of all images include new uploaded image in Bytes if (isset($file['size'])) { $allFileSize = $allFileSize + (int) $file['size']; } $maxFolderSize = (int) $paramsC->get('cat_folder_maxsize', 20000000); if ($maxFolderSize > 0 && (int) $allFileSize > $maxFolderSize) { $mainframe->redirect($return, JText::_('WARNFILETOOLARGEFOLDER')); } // Make the filename safe if (isset($file['name'])) { $file['name'] = JFile::makeSafe($file['name']); } if (isset($file['name'])) { $filepath = JPath::clean($path['orig_abs_ds'] . $rightFolder[0] . DS . $file['name']); if (!PhocaGalleryHelperUpload::canUpload($file, $err)) { $mainframe->redirect($return, JText::_($err)); exit; } if (JFile::exists($filepath)) { $mainframe->redirect($return, JText::_('File already exists')); exit; } if (!JFile::upload($file['tmp_name'], $filepath)) { $mainframe->redirect($return, JText::_('Unable to upload file')); exit; } else { // Saving file name into database with relative path $file['name'] = $rightFolder[0] . '/' . $file['name']; PhocaGalleryController::save((int) $catid, $file['name'], $return); //$mainframe->redirect($return,JText::_('Upload complete')); //exit; } } else { $mainframe->redirect($return, JText::_('WARNFILETYPE')); exit; } } else { $mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("NOT AUTHORISED TO DO ACTION")); exit; } }