示例#1
0
 /**
  * HTML view display method
  *
  * @access  public
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_DOWNLOADZIP_DOWNLOAD'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = JText::_('COM_JOOMGALLERY_DOWNLOADZIP_DOWNLOAD');
     $backtarget = JRoute::_('index.php?view=favourites');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_DOWNLOADZIP_BACK_TO_FAVOURITES');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $zipname = $this->_mainframe->getUserState('joom.favourites.zipname');
     if (!$zipname || !file_exists(JPath::clean(JPATH_ROOT . '/' . $zipname))) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false), JText::_('COM_JOOMGALLERY_DOWNLOADZIP_ZIPFILE_NOT_FOUND'), 'error');
     }
     $zipsize = filesize($zipname);
     if ($zipsize < 1000000) {
         $zipsize = round($zipsize, -3) / 1000;
         $zipsize_string = JText::sprintf('COM_JOOMGALLERY_FAVOURITES_ZIP_SIZEKB', $zipsize);
     } else {
         $zipsize = round($zipsize, -6) / 1000000;
         $zipsize_string = JText::sprintf('COM_JOOMGALLERY_FAVOURITES_ZIP_SIZEMB', $zipsize);
     }
     $this->assignRef('params', $params);
     $this->assignRef('zipname', $zipname);
     $this->assignRef('zipsize', $zipsize_string);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     parent::display($tpl);
 }
示例#2
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Header and footer
     JoomHelper::prepareParams($params);
     $backtarget = JRoute::_('index.php?view=gallery');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $type = JRequest::getCmd('type');
     switch ($type) {
         case 'lastcommented':
             $rows = $this->get('LastCommented');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_LAST_COMMENTED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
         case 'lastadded':
             $rows = $this->get('LastAdded');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_LAST_ADDED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
         case 'toprated':
             $rows = $this->get('TopRated');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_BEST_RATED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
         default:
             $rows = $this->get('MostViewed');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_MOST_VIEWED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
     }
     // Check whether this is the active menu item. This is a
     // special case in addition to code in constructor of parent class
     // because here we have to check the toplist type, too.
     if ($type == 'lastcommented' || $type == 'lastadded' || $type == 'toprated') {
         $active = $this->_mainframe->getMenu()->getActive();
         if (!$active || strpos($active->link, '&type=' . $type) === false) {
             // Get the default layout from the configuration
             if ($layout = $this->_config->get('jg_alternative_layout')) {
                 $this->setLayout($layout);
             }
         }
     }
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem($title);
     }
     // Check whether the (comments) data rows where delivered by a plugin
     if (isset($rows[0]->delivered_by_plugin) && $rows[0]->delivered_by_plugin) {
         $params->set('delivered_by_plugin', 1);
     }
     foreach ($rows as $key => $row) {
         $rows[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $row);
         $cropx = null;
         $cropy = null;
         $croppos = null;
         if ($this->_config->get('jg_dyncrop')) {
             $cropx = $this->_config->get('jg_dyncropwidth');
             $cropy = $this->_config->get('jg_dyncropheight');
             $croppos = $this->_config->get('jg_dyncropposition');
         }
         $rows[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $rows[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $row);
         } else {
             // Set the imgtitle by default
             $rows[$key]->atagtitle = 'title="' . $row->imgtitle . '"';
         }
         if ($this->_config->get('jg_showauthor')) {
             if ($row->imgauthor) {
                 $rows[$key]->authorowner = $row->imgauthor;
             } else {
                 if ($this->_config->get('jg_showowner')) {
                     $rows[$key]->authorowner = JHTML::_('joomgallery.displayname', $row->owner);
                 } else {
                     $rows[$key]->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                 }
             }
         }
         if (!$params->get('delivered_by_plugin')) {
             if ($type == 'lastcommented' && $this->_config->get('jg_showthiscomment')) {
                 if ($row->userid) {
                     $rows[$key]->cmtname = JHTML::_('joomgallery.displayname', $row->userid, false);
                 }
                 $cmttext = $row->cmttext;
                 $cmttext = JoomHelper::processText($cmttext);
                 if ($this->_config->get('jg_bbcodesupport')) {
                     $cmttext = JHTML::_('joomgallery.bbdecode', $cmttext);
                 }
                 if ($this->_config->get('jg_smiliesupport')) {
                     $smileys = JoomHelper::getSmileys();
                     foreach ($smileys as $i => $sm) {
                         $cmttext = str_replace($i, '<img src="' . $sm . '" border="0" alt="' . $i . '" title="' . $i . '" />', $cmttext);
                     }
                 }
                 $cmttext = stripslashes($cmttext);
                 $rows[$key]->processed_cmttext = $cmttext;
             }
         }
         // Show editor links for that image
         $rows[$key]->show_edit_icon = false;
         $rows[$key]->show_delete_icon = false;
         if ($this->_config->get('jg_showtoplisteditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $rows[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $rows[$key]->id) && $rows[$key]->owner && $rows[$key]->owner == $this->_user->get('id')) {
                 $rows[$key]->show_edit_icon = true;
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $rows[$key]->id)) {
                 $rows[$key]->show_delete_icon = true;
             }
         }
     }
     // Download Icon
     if ($this->_config->get('jg_download') && $this->_config->get('jg_showtoplistdownload')) {
         if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
             $params->set('show_download_icon', 1);
         } else {
             if ($this->_config->get('jg_download_hint')) {
                 $params->set('show_download_icon', -1);
             }
         }
     }
     // Favourites icon
     if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites') && $this->_config->get('jg_showtoplistfavourite')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_favourites_icon', 2);
             } else {
                 $params->set('show_favourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_favourites_icon', -2);
                 } else {
                     $params->set('show_favourites_icon', -1);
                 }
             }
         }
     }
     // Report icon
     if ($this->_config->get('jg_report_images') && $this->_config->get('jg_toplist_report_images')) {
         if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) {
             $params->set('show_report_icon', 1);
             JHTML::_('behavior.modal');
         } else {
             if ($this->_config->get('jg_report_hint')) {
                 $params->set('show_report_icon', -1);
             }
         }
     }
     // Set redirect url used in editor links to redirect back to favourites view after edit/delete
     $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString());
     $this->assignRef('params', $params);
     $this->assignRef('rows', $rows);
     $this->assignRef('title', $title);
     $this->assignRef('type', $type);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     parent::display($tpl);
 }
示例#3
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Prepare params for header and footer
     JoomHelper::prepareParams($params);
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     // Check whether this is the active menu item. This is a
     // special case in addition to code in constructor of parent class
     // because here we have to check the category ID, too.
     $active = $this->_mainframe->getMenu()->getActive();
     if (!$active || strpos($active->link, '&catid=' . JRequest::getInt('catid')) === false) {
         // Get the default layout from the configuration
         if ($layout = $this->_config->get('jg_alternative_layout')) {
             $this->setLayout($layout);
         }
     }
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Categories pagination
     if ($this->_config->get('jg_hideemptycats') == 2) {
         $totalcategories =& $this->get('TotalCategoriesWithoutEmpty');
     } else {
         $totalcategories = $this->get('TotalCategories');
     }
     // Calculation of the number of total pages
     $catperpage = $this->_config->get('jg_subperpage');
     if (!$catperpage) {
         $catperpage = 10;
     }
     $cattotalpages = floor($totalcategories / $catperpage);
     $offcut = $totalcategories % $catperpage;
     if ($offcut > 0) {
         $cattotalpages++;
     }
     $total = $totalcategories;
     $totalcategories = number_format($totalcategories, 0, ',', '.');
     // Get the current page
     $catpage = JRequest::getInt('catpage', 0);
     if ($catpage > $cattotalpages) {
         $catpage = $cattotalpages;
         if ($catpage <= 0) {
             $catpage = 1;
         }
     } else {
         if ($catpage < 1) {
             $catpage = 1;
         }
     }
     // Limitstart
     $limitstart = ($catpage - 1) * $catperpage;
     JRequest::setVar('catlimitstart', $limitstart);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/pagination.php';
     $this->catpagination = new JoomPagination($total, $limitstart, $catperpage, 'cat', 'subcategory');
     if ($cattotalpages > 1 && $totalcategories != 0) {
         if ($this->_config->get('jg_showpagenavsubs') <= 2) {
             $params->set('show_pagination_cat_top', 1);
         }
         if ($this->_config->get('jg_showpagenavsubs') >= 2) {
             $params->set('show_pagination_cat_bottom', 1);
         }
     }
     // Displaying of category number depends on pagination position
     if ($this->_config->get('jg_showsubcatcount')) {
         if ($this->_config->get('jg_showpagenavsubs') <= 2) {
             $params->set('show_count_cat_top', 1);
         }
         if ($this->_config->get('jg_showpagenavsubs') >= 2) {
             $params->set('show_count_cat_bottom', 1);
         }
     }
     // Images pagination
     $totalimages = $this->get('TotalImages');
     // Calculation of the number of total pages
     $perpage = $this->_config->get('jg_perpage');
     if (!$perpage) {
         $perpage = 10;
     }
     $totalpages = floor($totalimages / $perpage);
     $offcut = $totalimages % $perpage;
     if ($offcut > 0) {
         $totalpages++;
     }
     $total = $totalimages;
     $totalimages = number_format($totalimages, 0, ',', '.');
     // Get the current page
     $page = JRequest::getInt('page', 0);
     if ($page > $totalpages) {
         $page = $totalpages;
         if ($page <= 0) {
             $page = 1;
         }
     } else {
         if ($page < 1) {
             $page = 1;
         }
     }
     // Limitstart
     $limitstart = ($page - 1) * $perpage;
     $this->pagination = new JoomPagination($total, $limitstart, $perpage);
     // 'jg_detailpic_open' is not numeric if an OpenImage plugin was selected, thus we handle it like > 4
     if ($this->_config->get('jg_lightbox_slide_all') && (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 4)) {
         $params->set('show_all_in_popup', 1);
         JRequest::setVar('limitstart', -1);
         // We need all images of this category
         $images = $this->get('Images');
         $popup = array();
         $end = ($page - 1) * $perpage;
         $start = $page * $perpage;
         $popup['before'] = JHTML::_('joomgallery.popup', $images, 0, $end);
         $popup['after'] = JHTML::_('joomgallery.popup', $images, $start);
         $this->assignRef('popup', $popup);
         // Now we have to select the images according to the pagination
         $images = array_slice($images, $limitstart, $perpage);
     } else {
         JRequest::setVar('limitstart', $limitstart);
         JRequest::setVar('limit', $this->_config->get('jg_perpage'));
         $images = $this->get('Images');
     }
     if ($totalpages > 1 && $totalimages != 0) {
         if ($this->_config->get('jg_showpagenav') <= 2) {
             $params->set('show_pagination_img_top', 1);
         }
         if ($this->_config->get('jg_showpagenav') >= 2) {
             $params->set('show_pagination_img_bottom', 1);
         }
     }
     // Displaying of image number depends on pagination position
     if ($this->_config->get('jg_showpiccount')) {
         if ($this->_config->get('jg_showpagenav') <= 2) {
             $params->set('show_count_img_top', 1);
         }
         if ($this->_config->get('jg_showpagenav') >= 2) {
             $params->set('show_count_img_bottom', 1);
         }
     }
     $cat = $this->get('Category');
     if (isset($cat->protected)) {
         $this->cat = $cat;
         echo $this->loadTemplate('password');
         return;
     }
     $backlink = array();
     if ($cat->parent_id > 1) {
         // Sub-category -> parent category
         $backlink[0] = JRoute::_('index.php?view=category&catid=' . $cat->parent_id);
         $backlink[1] = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_CATEGORY');
     } else {
         // Category view -> gallery view
         $backlink[0] = JRoute::_('index.php?view=gallery');
         $backlink[1] = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     }
     // Meta data
     if ($cat->metadesc) {
         $this->_doc->setDescription($cat->metadesc);
     }
     if ($cat->metakey) {
         $this->_doc->setMetadata('keywords', $cat->metakey);
     }
     /*if($this->_mainframe->getCfg('MetaAuthor') == '1' && $cat->author)
       {
         $this->_doc->setMetaData('author', $cat->author);
       }*/
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs') || $this->_config->get('jg_showpathway')) {
         $parents = JoomHelper::getAllParentCategories($cat->cid);
     }
     $menus = $this->_mainframe->getMenu();
     $menu = $menus->getActive();
     if ($menu && array_key_exists('view', $menu->query) && $this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         switch ($menu->query['view']) {
             case '':
             case 'gallery':
                 foreach ($parents as $parent) {
                     $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid=' . $parent->cid);
                 }
                 $breadcrumbs->addItem($cat->name);
                 break;
             case 'category':
                 $skip = true;
                 foreach ($parents as $key => $parent) {
                     if ($skip) {
                         if ($key == $menu->query['catid']) {
                             $skip = false;
                         }
                     } else {
                         $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid=' . $parent->cid);
                     }
                 }
                 if (!$skip) {
                     $breadcrumbs->addItem($cat->name);
                 }
                 break;
             default:
                 break;
         }
     }
     /*if($this->_config->get('jg_completebreadcrumbs'))
         {
           $breadcrumbs  = &$this->_mainframe->getPathway();
     
           foreach($parents as $parent)
           {
             $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid='.$parent->cid);
           }
     
           $breadcrumbs->addItem($cat->name);
         }*/
     // JoomGallery Pathway
     $pathway = '';
     if ($this->_config->get('jg_showpathway')) {
         $pathway = '<a href="' . JRoute::_('index.php?view=gallery') . '" class="jg_pathitem">' . JText::_('COM_JOOMGALLERY_COMMON_HOME') . '</a> &raquo; ';
         foreach ($parents as $parent) {
             $pathway .= '<a href="' . JRoute::_('index.php?view=category&catid=' . $parent->cid) . '" class="jg_pathitem">' . $parent->name . '</a> &raquo; ';
         }
         $pathway .= $cat->name;
     }
     // Page title
     if ($this->_config->get('jg_pagetitle_cat')) {
         $pagetitle = JoomHelper::createPagetitle($this->_config->get('jg_pagetitle_cat'), $cat->name, '', $params->get('page_title') ? $params->get('page_title') : JText::_('COM_JOOMGALLERY_COMMON_GALLERY'));
         $this->_doc->setTitle($pagetitle);
     }
     // RSS feed
     if ($this->_config->get('jg_category_rss')) {
         $link = '&format=feed&limitstart=';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $this->_doc->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $this->_doc->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
         if ($this->_config->get('jg_category_rss_icon')) {
             $params->set('show_feed_icon', 1);
             $params->set('feed_url', JRoute::_($link . '&type=' . $this->_config->get('jg_category_rss_icon')));
         }
     }
     // Favourites icon for categories
     if ($this->_config->get('jg_allimagesofcategory') && $this->_config->get('jg_favourites')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_headerfavourites_icon', 2);
             } else {
                 $params->set('show_headerfavourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_headerfavourites_icon', -2);
                 } else {
                     $params->set('show_headerfavourites_icon', -1);
                 }
             }
         }
     }
     // Icon for quick upload
     if ($this->_config->get('jg_uploadiconcategory') && ($this->_user->authorise('joom.upload', _JOOM_OPTION . '.category.' . $cat->cid) || $cat->owner && $cat->owner == $this->_user->get('id') && $this->_user->authorise('joom.upload.inown', _JOOM_OPTION . '.category.' . $cat->cid))) {
         $params->set('show_upload_icon', 1);
         JHtml::_('behavior.modal');
     }
     // Get all sub-categories of the current category
     if ($this->_config->get('jg_hideemptycats') == 2) {
         // If the third alternative for hiding empty categories
         // is chosen ('Also those which contain empty sub-categories'),
         // we need additional code to exclude these categories.
         // (For the second alternative only the query in the model is modified.)
         $categories =& $this->get('CategoriesWithoutEmpty');
     } else {
         $categories = $this->get('Categories');
     }
     foreach ($categories as $key => $category) {
         $categories[$key]->isnew = '';
         if ($this->_config->get('jg_showcatasnew')) {
             // Check if an image in this category or in sub-categories is marked with 'new'
             $categories[$key]->isnew = JoomHelper::checkNewCatg($categories[$key]->cid);
         }
         // Count the images in category and sub-categories
         $imgshits = JoomHelper::getNumberOfImgHits($categories[$key]->cid);
         $categories[$key]->pictures = $imgshits[0];
         if ($categories[$key]->pictures == '1') {
             $categories[$key]->picorpics = 'COM_JOOMGALLERY_GALLERY_ONE_IMAGE';
         } else {
             $categories[$key]->picorpics = 'COM_JOOMGALLERY_GALLERY_IMAGES';
         }
         // Count the hits of all images in category and sub-categories
         $categories[$key]->totalhits = $imgshits[1];
         $category->thumb_src = null;
         $category->gallerycontainer = 'jg_subcatelem_cat';
         $category->photocontainer = 'jg_subcatelem_photo';
         $category->textcontainer = 'jg_subcatelem_txt';
         if ($this->_config->get('jg_showsubthumbs') > 0 && in_array($categories[$key]->access, $this->_user->getAuthorisedViewLevels())) {
             if ($this->_config->get('jg_showsubthumbs') == 2 || $this->_config->get('jg_showsubthumbs') == 3 && (!$categories[$key]->thumbnail || !isset($categories[$key]->id))) {
                 // Random choice of category/thumbnail
                 switch ($this->_config->get('jg_showrandomsubthumb')) {
                     // Only from current category
                     case 1:
                         $random_catid = $category->cid;
                         break;
                         // Only from sub-categories
                     // Only from sub-categories
                     case 2:
                         // Get array of all sub-categories without the current category
                         // Only with images
                         $allsubcats = JoomHelper::getAllSubCategories($category->cid, false);
                         if (count($allsubcats)) {
                             $random_catid = $allsubcats[mt_rand(0, count($allsubcats) - 1)];
                         } else {
                             $random_catid = 0;
                         }
                         break;
                         // From both
                     // From both
                     case 3:
                         // Get array of all sub-categories including the current category
                         // Only with images
                         $allsubcats = JoomHelper::getAllSubCategories($category->cid, true);
                         if (count($allsubcats)) {
                             $random_catid = $allsubcats[mt_rand(0, count($allsubcats) - 1)];
                         } else {
                             $random_catid = 0;
                         }
                         break;
                     default:
                         $random_catid = 0;
                         break;
                 }
                 // Random image, only if there are $randomcat(s)
                 if ($this->_config->get('jg_showrandomsubthumb') == 1 || $this->_config->get('jg_showrandomsubthumb') >= 2 && $random_catid != 0) {
                     $model = $this->getModel();
                     if ($row = $model->getRandomImage($category->cid, $random_catid)) {
                         $cropx = null;
                         $cropy = null;
                         $croppos = null;
                         if ($this->_config->get('jg_dyncrop')) {
                             $cropx = $this->_config->get('jg_dyncropwidth');
                             $cropy = $this->_config->get('jg_dyncropheight');
                             $croppos = $this->_config->get('jg_dyncropposition');
                         }
                         $categories[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
                         // Store the image id for later skipping the category view
                         if (isset($row->catid) && $categories[$key]->cid == $row->catid) {
                             $categories[$key]->dtlimgid = $row->id;
                         }
                     }
                 }
             } else {
                 // Check if there's a category thumbnail selected
                 // 'isset' checks whether it is a valid image which we are allowed to display
                 if ($categories[$key]->thumbnail && isset($categories[$key]->id)) {
                     $cropx = null;
                     $cropy = null;
                     $croppos = null;
                     if ($this->_config->get('jg_dyncrop')) {
                         $cropx = $this->_config->get('jg_dyncropwidth');
                         $cropy = $this->_config->get('jg_dyncropheight');
                         $croppos = $this->_config->get('jg_dyncropposition');
                     }
                     $categories[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $categories[$key], null, 0, true, $cropx, $cropy, $croppos);
                     if (!$categories[$key]->imghidden && isset($categories[$key]->catid) && $categories[$key]->cid == $categories[$key]->catid) {
                         // Store the image id for later skipping the category view
                         $categories[$key]->dtlimgid = $categories[$key]->id;
                     }
                     // Own choice of alignment
                     switch ($categories[$key]->img_position) {
                         // Left
                         case 0:
                             $categories[$key]->photocontainer = 'jg_subcatelem_photo_l';
                             $categories[$key]->textcontainer = 'jg_subcatelem_txt_l';
                             break;
                             // Right
                         // Right
                         case 1:
                             $categories[$key]->gallerycontainer = 'jg_subcatelem_cat_r';
                             $categories[$key]->photocontainer = 'jg_subcatelem_photo_r';
                             $categories[$key]->textcontainer = 'jg_subcatelem_txt_r';
                             break;
                             // Centered
                         // Centered
                         case 2:
                             $categories[$key]->photocontainer = 'jg_subcatelem_photo_c';
                             $categories[$key]->textcontainer = 'jg_subcatelem_txt_c';
                             break;
                         default:
                             // Use global settings: The default classes are used
                             if ($this->_config->get('jg_subcatthumbalign') != 1) {
                                 $gallerycontainer = 'jg_subcatelem_cat_r';
                             }
                             break;
                     }
                 }
             }
         }
         // Set the href url for the <a>-Tag, dependent on setting in
         // jg_skipcatview
         // link to category view or directly to detail view if the category
         // doesn't contain other categories
         if ($this->_config->get('jg_skipcatview')) {
             // Get subcategories from category
             $allsubcats = JoomHelper::getAllSubCategories($categories[$key]->cid, false);
             // Link to category view if there are any viewable subcategories
             // otherwise to detail view
             if (count($allsubcats)) {
                 $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
             } else {
                 // Try to set link to detail view
                 // get link with the help of model if
                 // 1) view of thumb in configuration deactivated
                 // 2) view of thumb activated but no thumb setted for category
                 if ($this->_config->get('jg_showsubthumbs') == 0 || $this->_config->get('jg_showsubthumbs') != 0 && !isset($categories[$key]->dtlimgid)) {
                     // Get the model
                     $categoryModel = $this->getModel();
                     // Get the id of image
                     $image = $categoryModel->getImageCat($categories[$key]->cid);
                     // Set the id of image for the link to detail view
                     if (isset($image)) {
                         $categories[$key]->dtlimgid = $image;
                     }
                 }
                 // Check the id of image setted before
                 if (isset($categories[$key]->dtlimgid)) {
                     // Set link to detail view
                     $categories[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $categories[$key]->dtlimgid);
                     // If category view is skipped we display the favourites icon for adding all images at the thumbnail.
                     // Calculations for that have already been done for the favourites icon in the header
                     $categories[$key]->show_favourites_icon = $params->get('show_headerfavourites_icon');
                 } else {
                     $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
                 }
             }
         } else {
             // Set link to category view if no skipping
             $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
         }
         // Icon for quick upload at sub-category thumbnail
         if ($this->_config->get('jg_uploadiconsubcat') && ($this->_user->authorise('joom.upload', _JOOM_OPTION . '.category.' . $category->cid) || $category->owner && $category->owner == $this->_user->get('id') && $this->_user->authorise('joom.upload.inown', _JOOM_OPTION . '.category.' . $category->cid))) {
             $categories[$key]->show_upload_icon = true;
             JHtml::_('behavior.modal');
         }
         $categories[$key]->event = new stdClass();
         // Additional HTML added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomAfterDisplayCatThumb', array($category->cid));
         $categories[$key]->event->afterDisplayCatThumb = trim(implode('', $results));
         /*// Additional icons added by plugins
           $results  = $this->_mainframe->triggerEvent('onJoomDisplayIcons', array('category.category', $category));
           $categories[$key]->event->icons                 = trim(implode('', $results));*/
     }
     // Download icon
     if ($this->_config->get('jg_download') && $this->_config->get('jg_showcategorydownload')) {
         if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
             $params->set('show_download_icon', 1);
         } else {
             if ($this->_config->get('jg_download_hint')) {
                 $params->set('show_download_icon', -1);
             }
         }
     }
     // Favourites icon
     if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites') && $this->_config->get('jg_showcategoryfavourite')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_favourites_icon', 2);
             } else {
                 $params->set('show_favourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_favourites_icon', -2);
                 } else {
                     $params->set('show_favourites_icon', -1);
                 }
             }
         }
     }
     // Report icon
     if ($this->_config->get('jg_report_images') && $this->_config->get('jg_category_report_images')) {
         if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) {
             $params->set('show_report_icon', 1);
             JHTML::_('behavior.modal');
         } else {
             if ($this->_config->get('jg_report_hint')) {
                 $params->set('show_report_icon', -1);
             }
         }
     }
     foreach ($images as $key => $image) {
         $cropx = null;
         $cropy = null;
         $croppos = null;
         if ($this->_config->get('jg_dyncrop')) {
             $cropx = $this->_config->get('jg_dyncropwidth');
             $cropy = $this->_config->get('jg_dyncropheight');
             $croppos = $this->_config->get('jg_dyncropposition');
             $images[$key]->imgwh = 'width="' . $cropx . '" height="' . $cropy . '"';
         } else {
             // Get dimensions for width and height attribute in img tag
             $imgwh = getimagesize($this->_ambit->getImg('thumb_path', $image));
             $images[$key]->imgwh = $imgwh[3];
         }
         $images[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $image, null, 0, true, $cropx, $cropy, $croppos);
         if ($this->_config->get('jg_showpicasnew')) {
             $images[$key]->isnew = JoomHelper::checkNew($image->imgdate, $this->_config->get('jg_daysnew'));
         }
         $images[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $image);
         if ($this->_config->get('jg_showauthor')) {
             if ($image->imgauthor) {
                 $images[$key]->authorowner = $image->imgauthor;
             } else {
                 if ($this->_config->get('jg_showowner')) {
                     $images[$key]->authorowner = JHTML::_('joomgallery.displayname', $image->owner);
                 } else {
                     $images[$key]->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                 }
             }
         }
         // Show editor links for that image
         $images[$key]->show_edit_icon = false;
         $images[$key]->show_delete_icon = false;
         if ($this->_config->get('jg_showcategoryeditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $images[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $images[$key]->id) && $images[$key]->owner && $images[$key]->owner == $this->_user->get('id')) {
                 $images[$key]->show_edit_icon = true;
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $images[$key]->id)) {
                 $images[$key]->show_delete_icon = true;
             }
         }
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $images[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $images[$key]);
         } else {
             // Set the imgtitle by default
             $images[$key]->atagtitle = 'title="' . $images[$key]->imgtitle . '"';
         }
         $images[$key]->event = new stdClass();
         // Additional HTML added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomAfterDisplayThumb', array($image->id));
         $images[$key]->event->afterDisplayThumb = trim(implode('', $results));
         // Additional icons added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomDisplayIcons', array('category.image', $image));
         $images[$key]->event->icons = trim(implode('', $results));
         // Check if there are any elements beside the image to be shown
         // if not deactivate the output of corresponding html tags in template
         // to avoid empty div/ul/li
         if (!$this->_config->get('jg_showtitle') && !$this->_config->get('jg_showpicasnew') && !$this->_config->get('jg_showhits') && !$this->_config->get('jg_showdownloads') && !$this->_config->get('jg_showauthor') && !$this->_config->get('jg_showcatcom') && !$this->_config->get('jg_showcatrate') && (!$this->_config->get('jg_showcatdescription') || $this->_config->get('jg_showcatdescription') && !$images[$key]->imgtext) && !$params->get('show_download_icon') && !$params->get('show_favourites_icon') && !$params->get('show_report_icon') && (!$this->_config->get('jg_showcategoryeditorlinks') || $this->_config->get('jg_showcategoryeditorlinks') && !$images[$key]->show_delete_icon && !$images[$key]->show_edit_icon) && !$images[$key]->event->afterDisplayThumb && !$images[$key]->event->icons) {
             $images[$key]->show_elems = false;
         } else {
             $images[$key]->show_elems = true;
         }
     }
     if ($this->_config->get('jg_cooliris') && count($images)) {
         $href = JRoute::_('index.php?view=category&catid=' . $cat->cid . '&page=' . $page . '&format=raw');
         $attribs = array('id' => 'gallery', 'type' => 'application/rss+xml', 'title' => 'Cooliris');
         $this->_doc->addHeadLink($href, 'alternate', 'rel', $attribs);
         if ($this->_config->get('jg_coolirislink')) {
             $this->_doc->addScript('http://lite.piclens.com/current/piclens.js');
         }
     }
     if ($this->_config->get('jg_usercatorder') && count($images)) {
         $orderby = $this->_mainframe->getUserStateFromRequest('joom.category.images.orderby', 'orderby');
         $orderdir = $this->_mainframe->getUserStateFromRequest('joom.category.images.orderdir', 'orderdir');
         // If subcategory navigation active insert current subcategory startpage
         if ($catpage > 1) {
             $sort_url = JRoute::_('index.php?view=category&catid=' . $cat->cid . '&catpage=' . $catpage) . JHTML::_('joomgallery.anchor', 'category');
         } else {
             $sort_url = JRoute::_('index.php?view=category&catid=' . $cat->cid) . JHTML::_('joomgallery.anchor', 'category');
         }
         $this->assignRef('sort_url', $sort_url);
         $this->assignRef('order_by', $orderby);
         $this->assignRef('order_dir', $orderdir);
     }
     // Set redirect url used in editor links to redirect back to favourites view after edit/delete
     $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString());
     $this->assignRef('params', $params);
     $this->assignRef('category', $cat);
     $this->assignRef('images', $images);
     $this->assignRef('categories', $categories);
     $this->assignRef('totalimages', $totalimages);
     $this->assignRef('totalpages', $totalpages);
     $this->assignRef('page', $page);
     $this->assignRef('totalcategories', $totalcategories);
     $this->assignRef('cattotalpages', $cattotalpages);
     $this->assignRef('catpage', $catpage);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backlink[0]);
     $this->assignRef('backtext', $backlink[1]);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     parent::display($tpl);
 }
示例#4
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     jimport('joomla.filesystem.file');
     $params = $this->_mainframe->getParams();
     // Prepare params for header and footer
     JoomHelper::prepareParams($params);
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $pathway = null;
     $params->set('show_header_backlink', 0);
     $params->set('show_footer_backlink', 0);
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Get number of all root categories
     if ($this->_config->get('jg_hideemptycats') == 2) {
         $total = $this->get('TotalWithoutEmpty');
     } else {
         $total = $this->get('Total');
     }
     // Calculation of the number of total pages
     $catperpage = $this->_config->get('jg_catperpage');
     if (!$catperpage) {
         $catperpage = 10;
     }
     $totalpages = floor($total / $catperpage);
     $offcut = $total % $catperpage;
     if ($offcut > 0) {
         $totalpages++;
     }
     $totalcategories = $total;
     $total = number_format($total, 0, ',', '.');
     // Get the current page
     $page = JRequest::getInt('page', 0);
     if ($page > $totalpages) {
         $page = $totalpages;
     }
     if ($page < 1) {
         $page = 1;
     }
     // Limitstart
     $limitstart = ($page - 1) * $catperpage;
     JRequest::setVar('limitstart', $limitstart);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/pagination.php';
     $this->pagination = new JoomPagination($totalcategories, $limitstart, $catperpage, '', 'gallery');
     if ($totalpages > 1 && $total != 0) {
         if ($this->_config->get('jg_showgallerypagenav') == 1 || $this->_config->get('jg_showgallerypagenav') == 2) {
             $params->set('show_pagination_top', 1);
         }
         if ($this->_config->get('jg_showgallerypagenav') == 2 || $this->_config->get('jg_showgallerypagenav') == 3) {
             $params->set('show_pagination_bottom', 1);
         }
     }
     // Displaying of category number depends on pagination position
     if ($this->_config->get('jg_showcatcount')) {
         if ($this->_config->get('jg_showgallerypagenav') <= 2) {
             $params->set('show_count_top', 1);
         }
         if ($this->_config->get('jg_showgallerypagenav') >= 2) {
             $params->set('show_count_bottom', 1);
         }
     }
     // Favourites icon for categories
     if ($this->_config->get('jg_allimagesofcategory') && $this->_config->get('jg_favourites')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_favourites_icon', 2);
             } else {
                 $params->set('show_favourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_favourites_icon', -2);
                 } else {
                     $params->set('show_favourites_icon', -1);
                 }
             }
         }
     }
     // Get all main categories of the gallery
     if ($this->_config->get('jg_hideemptycats') == 2) {
         // If the third alternative for hiding empty categories
         // is chosen ('Also those which contain empty sub-categories'),
         // we need additional code to exclude these categories.
         // (For the second alternative only the query in the model is modified.)
         $categories = $this->get('CategoriesWithoutEmpty');
     } else {
         $categories = $this->get('Categories');
     }
     $i = 0;
     foreach ($categories as $key => $category) {
         $categories[$key]->isnew = '';
         if ($this->_config->get('jg_showcatasnew')) {
             // Check if an image in this category or in sub-categories is marked with 'new'
             $categories[$key]->isnew = JoomHelper::checkNewCatg($categories[$key]->cid);
         }
         // Get number of images in category and sub-categories
         $imgshits = JoomHelper::getNumberOfImgHits($categories[$key]->cid);
         $categories[$key]->pictures = $imgshits[0];
         if ($categories[$key]->pictures == '1') {
             $categories[$key]->picorpics = 'COM_JOOMGALLERY_GALLERY_ONE_IMAGE';
         } else {
             $categories[$key]->picorpics = 'COM_JOOMGALLERY_GALLERY_IMAGES';
         }
         // Count the hits of all images in category and sub-categories
         $categories[$key]->totalhits = $imgshits[1];
         $category->thumb_src = null;
         $category->gallerycontainer = 'jg_element_gal';
         $category->photocontainer = 'jg_photo_container';
         $category->textcontainer = 'jg_element_txt';
         if ($this->_config->get('jg_showcatthumb') > 0 && in_array($categories[$key]->access, $this->_user->getAuthorisedViewLevels())) {
             if ($this->_config->get('jg_showcatthumb') == 1 || $this->_config->get('jg_showcatthumb') == 3 && (!$categories[$key]->thumbnail || !isset($categories[$key]->id))) {
                 // Random choice of category/thumbnail
                 switch ($this->_config->get('jg_showrandomcatthumb')) {
                     // Only from current category
                     case 1:
                         $random_catid = $categories[$key]->cid;
                         break;
                         // Only from sub-categories
                     // Only from sub-categories
                     case 2:
                         // Get array of all sub-categories without the current category
                         // Only with images
                         $allsubcats = JoomHelper::getAllSubCategories($categories[$key]->cid, false);
                         if (count($allsubcats)) {
                             $random_catid = $allsubcats[mt_rand(0, count($allsubcats) - 1)];
                         } else {
                             $random_catid = 0;
                         }
                         break;
                         // From both
                     // From both
                     case 3:
                         // Get array of all sub-categories including the current category
                         // Only with images
                         $allsubcats = JoomHelper::getAllSubCategories($categories[$key]->cid, true);
                         if (count($allsubcats)) {
                             $random_catid = $allsubcats[mt_rand(0, count($allsubcats) - 1)];
                         } else {
                             $random_catid = 0;
                         }
                         break;
                     default:
                         $random_catid = 0;
                         break;
                 }
                 // Random image, only if there are $randomcat(s)
                 if ($this->_config->get('jg_showrandomcatthumb') == 1 || $this->_config->get('jg_showrandomcatthumb') >= 2 && $random_catid != 0) {
                     $model = $this->getModel();
                     if ($row = $model->getRandomImage($categories[$key]->cid, $random_catid)) {
                         $cropx = null;
                         $cropy = null;
                         $croppos = null;
                         if ($this->_config->get('jg_dyncrop')) {
                             $cropx = $this->_config->get('jg_dyncropwidth');
                             $cropy = $this->_config->get('jg_dyncropheight');
                             $croppos = $this->_config->get('jg_dyncropposition');
                         }
                         $categories[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
                         if (isset($row->catid) && $categories[$key]->cid == $row->catid) {
                             // Store the image id for later skipping the category view
                             $categories[$key]->dtlimgid = $row->id;
                         }
                     }
                 }
                 // Thumbnail alignment of random thumbnails:
                 // The default classes are used except for the case that changing
                 // alignment is configured and we have to align right at the moment
                 if ($this->_config->get('jg_ctalign') == 0 && floor($i / $this->_config->get('jg_colcat')) % 2 == 0) {
                     $category->gallerycontainer = 'jg_element_gal_r';
                     $category->photocontainer = 'jg_photo_container_r';
                     $category->textcontainer = 'jg_element_txt_r';
                 }
             } else {
                 // Check if there's a category thumbnail selected
                 // 'isset' checks whether it is a valid image which we are allowed to display
                 if ($categories[$key]->thumbnail && isset($categories[$key]->id)) {
                     $cropx = null;
                     $cropy = null;
                     $croppos = null;
                     if ($this->_config->get('jg_dyncrop')) {
                         $cropx = $this->_config->get('jg_dyncropwidth');
                         $cropy = $this->_config->get('jg_dyncropheight');
                         $croppos = $this->_config->get('jg_dyncropposition');
                     }
                     $categories[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $categories[$key], null, 0, true, $cropx, $cropy, $croppos);
                     if (!$categories[$key]->imghidden && isset($categories[$key]->catid) && $categories[$key]->cid == $categories[$key]->catid) {
                         // Store the image id for later skipping the category view
                         $categories[$key]->dtlimgid = $categories[$key]->id;
                     }
                 }
                 // Thumbnail alignment for own choice of thumbnails
                 switch ($category->img_position) {
                     case 0:
                         // Left
                         $categories[$key]->photocontainer = 'jg_photo_container_l';
                         $categories[$key]->textcontainer = 'jg_element_txt_l';
                         break;
                     case 1:
                         // Right
                         $categories[$key]->photocontainer = 'jg_photo_container_r';
                         $categories[$key]->textcontainer = 'jg_element_txt_r';
                         break;
                     case 2:
                         // Centered
                         $categories[$key]->photocontainer = 'jg_photo_container_c';
                         $categories[$key]->textcontainer = 'jg_element_txt_c';
                         break;
                     default:
                         // Use global settings:
                         // The default classes are used except for the case that changing
                         // alignment is configured and we have to align right at the moment
                         if ($this->_config->get('jg_ctalign') == 0 && floor($i / $this->_config->get('jg_colcat')) % 2 == 0) {
                             $category->gallerycontainer = 'jg_element_gal_r';
                             $category->photocontainer = 'jg_photo_container_r';
                             $category->textcontainer = 'jg_element_txt_r';
                         }
                         break;
                 }
             }
         }
         // Set the href url for the <a>-Tag, dependent on setting in
         // jg_skipcatview
         // link to category view or directly to detail view if the category
         // doesn't contain other categories
         if ($this->_config->get('jg_skipcatview')) {
             // Get subcategories from category
             $allsubcats = JoomHelper::getAllSubCategories($categories[$key]->cid, false);
             // Link to category view if there are any viewable subcategories
             // otherwise to detail view
             if (count($allsubcats)) {
                 $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
             } else {
                 // Try to set link to detail view
                 // get link with the help of category model if
                 // 1) view of thumb in configuration deactivated
                 // 2) view of thumb activated but no thumb setted for category
                 if ($this->_config->get('jg_showcatthumb') == 0 || $this->_config->get('jg_showcatthumb') != 0 && !isset($categories[$key]->dtlimgid)) {
                     // Get the model to reach other models
                     $model = $this->getModel();
                     // Get the category model, set catid before instantation because
                     // it will be needed in the constructor
                     JRequest::setVar('catid', $categories[$key]->cid);
                     $categoryModel = $model->getInstance('category', 'joomgallerymodel');
                     // Get the id of image
                     $image = $categoryModel->getImageCat($categories[$key]->cid);
                     // Set the id of image for the link to detail view
                     if (isset($image)) {
                         $categories[$key]->dtlimgid = $image;
                     }
                 }
                 // Check the id of image setted before
                 if (isset($categories[$key]->dtlimgid)) {
                     // Set link to detail view
                     $categories[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $categories[$key]->dtlimgid);
                     // If category view is skipped we display the favourites icon for adding all images at the thumbnail.
                     $categories[$key]->show_favourites_icon = $params->get('show_favourites_icon');
                 } else {
                     $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
                 }
             }
         } else {
             // Set link to category view if no skipping
             $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
         }
         // Icon for quick upload at sub-category thumbnail
         if ($this->_config->get('jg_uploadicongallery') && ($this->_user->authorise('joom.upload', _JOOM_OPTION . '.category.' . $category->cid) || $category->owner && $category->owner == $this->_user->get('id') && $this->_user->authorise('joom.upload.inown', _JOOM_OPTION . '.category.' . $category->cid))) {
             $categories[$key]->show_upload_icon = true;
             JHtml::_('behavior.modal');
         }
         // Additional HTML added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomAfterDisplayCatThumb', array($category->cid));
         $categories[$key]->event = new stdClass();
         $categories[$key]->event->afterDisplayCatThumb = trim(implode('', $results));
         /*// Additional icons added by plugins
           $results  = $this->_mainframe->triggerEvent('onJoomDisplayIcons', array('category.category', $category));
           $categories[$key]->event->icons                 = trim(implode('', $results));*/
         $i++;
     }
     $this->assignRef('params', $params);
     $this->assignRef('rows', $categories);
     $this->assignRef('total', $total);
     $this->assignRef('totalpages', $totalpages);
     $this->assignRef('page', $page);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backlink[0]);
     $this->assignRef('backtext', $backlink[1]);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     // Include dTree script, dTree styles and treeview styles, if neccessary
     if ($this->_config->get('jg_showsubsingalleryview')) {
         $this->_doc->addStyleSheet($this->_ambit->getScript('dTree/css/jg_dtree.css'));
         $this->_doc->addStyleSheet($this->_ambit->getScript('dTree/css/jg_treeview.css'));
         $this->_doc->addScript($this->_ambit->getScript('dTree/js/jg_dtree.js'));
     }
     parent::display($tpl);
 }
示例#5
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     if (!$this->_user->get('id') && !$this->_config->get('jg_showdetailpage')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_NOT_ALLOWED_VIEW_IMAGE'), 'notice');
     }
     if ((!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 0) && $this->_config->get('jg_disabledetailpage')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_DETAIL_MSG_NOT_ALLOWED_VIEW_DEFAULT_DETAIL_VIEW'), 'notice');
     }
     $images = $this->get('Images');
     $image = $this->get('Image');
     $slideshow = JRequest::getInt('slideshow');
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs') || $this->_config->get('jg_showpathway') || $this->_config->get('jg_pagetitle_detail')) {
         $parents = JoomHelper::getAllParentCategories($image->catid, true);
     }
     $menus = $this->_mainframe->getMenu();
     $menu = $menus->getActive();
     if ($menu && isset($menu->query['view']) && $menu->query['view'] != 'detail' && $this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         switch ($menu->query['view']) {
             case '':
             case 'gallery':
                 foreach ($parents as $parent) {
                     $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid=' . $parent->cid);
                 }
                 $breadcrumbs->addItem($image->imgtitle);
                 break;
             case 'category':
                 $skip = true;
                 foreach ($parents as $key => $parent) {
                     if ($skip) {
                         if ($key == $menu->query['catid']) {
                             $skip = false;
                         }
                     } else {
                         $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid=' . $parent->cid);
                     }
                 }
                 if (!$skip) {
                     $breadcrumbs->addItem($image->imgtitle);
                 }
                 break;
         }
     }
     // JoomGallery Pathway
     $pathway = null;
     if ($this->_config->get('jg_showpathway')) {
         $pathway = '<a href="' . JRoute::_('index.php?view=gallery') . '" class="jg_pathitem">' . JText::_('COM_JOOMGALLERY_COMMON_HOME') . '</a> &raquo; ';
         foreach ($parents as $parent) {
             $pathway .= '<a href="' . JRoute::_('index.php?view=category&catid=' . $parent->cid) . '" class="jg_pathitem">' . $parent->name . '</a> &raquo; ';
         }
         $pathway .= $image->imgtitle;
     }
     // Page Title
     if ($this->_config->get('jg_pagetitle_detail')) {
         $pagetitle = JoomHelper::createPagetitle($this->_config->get('jg_pagetitle_detail'), $parents[$image->catid]->name, $image->imgtitle, $params->get('page_title') ? $params->get('page_title') : JText::_('COM_JOOMGALLERY_COMMON_GALLERY'));
         $this->_doc->setTitle($pagetitle);
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     // Generate the backlink
     if ($this->_config->get('jg_skipcatview')) {
         $allsubcats = JoomHelper::getAllSubCategories($image->catid, false);
         // Link to category view if it include subcategories
         if (count($allsubcats)) {
             $backtarget = JRoute::_('index.php?view=category&catid=' . $image->catid);
             $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_CATEGORY');
         } else {
             // Get the parents including category itself if not read before
             if (!isset($parents)) {
                 $parents = JoomHelper::getAllParentCategories($image->catid, true);
             }
             if (count($parents) == 1) {
                 // Link to gallery view
                 $backtarget = JRoute::_('index.php?view=gallery');
                 $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
             } else {
                 // Link to parent of category
                 $backtarget = JRoute::_('index.php?view=category&catid=' . $parents[$image->catid]->parent_id);
                 $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_CATEGORY');
             }
         }
     } else {
         $backtarget = JRoute::_('index.php?view=category&catid=' . $image->catid);
         $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_CATEGORY');
     }
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     // Load modules at position 'detailbtm'
     $modules['detailbtm'] = JoomHelper::getRenderedModules('detailbtm');
     if (count($modules['detailbtm'])) {
         $params->set('show_detailbtm_modules', 1);
     }
     // Check whether this is the active menu item. This is a
     // special case in addition to code in constructor of parent class
     // because here we have to check the image ID, too.
     $active = $this->_mainframe->getMenu()->getActive();
     if (!$active || strpos($active->link, '&id=' . JRequest::getInt('id')) === false) {
         // Get the default layout from the configuration
         if ($layout = $this->_config->get('jg_alternative_layout')) {
             $this->setLayout($layout);
         }
     }
     // Meta data
     if ($image->metadesc) {
         $this->_doc->setDescription($image->metadesc);
     } elseif ($image->catmetadesc) {
         $this->_doc->setDescription($image->catmetadesc);
     }
     if ($image->metakey) {
         $this->_doc->setMetadata('keywords', $image->metakey);
     } elseif ($image->catmetakey) {
         $this->_doc->setMetadata('keywords', $image->catmetakey);
     }
     if ($this->_mainframe->getCfg('MetaAuthor') == '1' && $image->author && strcmp(JText::_('COM_JOOMGALLERY_COMMON_NO_DATA'), $image->author) != 0) {
         $this->_doc->setMetaData('author', $image->author);
     }
     // Set the title attribute in a tag with title and/or description of image
     // if a box is activated
     if ((!is_numeric($this->_config->get('jg_bigpic_open')) || $this->_config->get('jg_bigpic_open') > 1) && !$slideshow) {
         $image->atagtitle = JHTML::_('joomgallery.getTitleforATag', $image);
     } else {
         // Set the imgtitle by default
         $image->atagtitle = 'title="' . $image->imgtitle . '"';
     }
     // Accordion
     if ($this->_config->get('jg_showdetailaccordion')) {
         $toggler = 'class="joomgallery-toggler"';
         $slider = 'class="joomgallery-slider"';
         JHtml::_('behavior.framework', true);
         $accordionscript = 'window.addEvent(\'domready\', function(){
     new Fx.Accordion
     (
       $$(\'h4.joomgallery-toggler\'),
       $$(\'div.joomgallery-slider\'),
       {
         onActive: function(toggler, i)
         {
           toggler.addClass(\'joomgallery-toggler-down\');
           toggler.removeClass(\'joomgallery-toggler\');
         },
         onBackground: function(toggler, i)
         {
           toggler.addClass(\'joomgallery-toggler\');
           toggler.removeClass(\'joomgallery-toggler-down\');
         },
         duration         : ' . $this->_config->get('jg_accordionduration') . ',
         display          : ' . ($this->_config->get('jg_accordiondisplay') - 1) . ',
         initialDisplayFx : ' . $this->_config->get('jg_accordioninitialeffect') . ',
         opacity          : ' . $this->_config->get('jg_accordionopacity') . ',
         alwaysHide       : ' . $this->_config->get('jg_accordionalwayshide') . '
        });
     });';
         $this->_doc->addScriptDeclaration($accordionscript);
     } else {
         $toggler = '';
         $slider = '';
     }
     // Linked
     if (($this->_config->get('jg_bigpic') == 1 && $this->_user->get('id') || $this->_config->get('jg_bigpic_unreg') == 1 && !$this->_user->get('id')) && !$slideshow && $image->bigger_orig && (!$this->_config->get('jg_nameshields') || !$this->_config->get('jg_show_nameshields_unreg') && !$this->_user->get('id'))) {
         $params->set('image_linked', 1);
     }
     // Original size
     if ($image->orig_exists && $this->_config->get('jg_showoriginalfilesize') && !$slideshow) {
         $params->set('show_original_size', 1);
     }
     // Pagination
     if (isset($images[$image->position - 1]) && !$slideshow) {
         $params->set('show_previous_link', 1);
         $pagination['previous']['link'] = JRoute::_('index.php?view=detail&id=' . $images[$image->position - 1]->id) . JHTML::_('joomgallery.anchor');
         if ($this->_config->get('jg_showdetailnumberofpics')) {
             $params->set('show_previous_text', 1);
             $pagination['previous']['text'] = JText::sprintf('COM_JOOMGALLERY_DETAIL_IMG_IMAGE_OF_IMAGES', $image->position, count($images));
         }
     }
     if (isset($images[$image->position + 1]) && !$slideshow) {
         $params->set('show_next_link', 1);
         $pagination['next']['link'] = JRoute::_('index.php?view=detail&id=' . $images[$image->position + 1]->id) . JHTML::_('joomgallery.anchor');
         if ($this->_config->get('jg_showdetailnumberofpics')) {
             $params->set('show_next_text', 1);
             $pagination['next']['text'] = JText::sprintf('COM_JOOMGALLERY_DETAIL_IMG_IMAGE_OF_IMAGES', $image->position + 2, count($images));
         }
     }
     // Nametags
     if (!$slideshow && ($this->_config->get('jg_nameshields') && $this->_user->get('id') || $this->_config->get('jg_nameshields_unreg') && !$this->_user->get('id'))) {
         $nametags = $this->get('Nametags');
         if ($this->_user->get('id') || $nametags) {
             $params->set('show_nametags', 1);
             $this->assignRef('nametags', $nametags);
         }
         $already_tagged = false;
         foreach ($nametags as $nametag) {
             if ($nametag->nuserid == $this->_user->get('id')) {
                 $already_tagged = true;
                 break;
             }
         }
         if ($this->_config->get('jg_nameshields') && $this->_user->get('id') && !$slideshow && (!$already_tagged || $this->_config->get('jg_nameshields_others'))) {
             $params->set('show_movable_nametag', 1);
             $length = strlen($this->_user->get('username')) * $this->_config->get('jg_nameshields_width');
             $nametag = array();
             $nametag['length'] = $length;
             $nametag['name'] = $this->_user->get('username');
             $nametag['link'] = JRoute::_('index.php?task=nametags.save');
             $this->assignRef('nametag', $nametag);
             JHtml::_('behavior.framework');
             if ($this->_config->get('jg_nameshields_others')) {
                 JHTML::_('behavior.modal');
             }
         }
     }
     $script = '';
     // Slideshow
     if ($this->_config->get('jg_slideshow')) {
         $params->set('slideshow_enabled', 1);
         if ($slideshow) {
             JHtml::_('behavior.framework', true);
             $this->_doc->addStyleSheet($this->_ambit->getScript('smoothgallery/css/jd.gallery.css'));
             $this->_doc->addScript($this->_ambit->getScript('smoothgallery/scripts/jd.gallery.js'));
             // No include if standard effects 'fade/crossfade/fadebg' chosen
             switch ($this->_config->get('jg_slideshow_transition')) {
                 case 0:
                     $transition = 'fade';
                     break;
                 case 1:
                     $transition = 'fadeslideleft';
                     $this->_doc->addScript($this->_ambit->getScript('smoothgallery/scripts/jd.gallery.transitions.js'));
                     break;
                 case 2:
                     $transition = 'crossfade';
                     break;
                 case 3:
                     $transition = 'continuoushorizontal';
                     $this->_doc->addScript($this->_ambit->getScript('smoothgallery/scripts/jd.gallery.transitions.js'));
                     break;
                 case 4:
                     $transition = 'continuousvertical';
                     $this->_doc->addScript($this->_ambit->getScript('smoothgallery/scripts/jd.gallery.transitions.js'));
                     break;
                 case 5:
                     $transition = 'fadebg';
                     break;
                 default:
                     $transition = 'fade';
                     break;
             }
             // The slideshow needs an array of objects
             $script .= 'var photo = new Array();
               function joom_createphotoobject(image,thumbnail,linkTitle,link,title,description,number,date,hits,downloads,rating,filesizedtl,filesizeorg,author,detaillink) {
                 this.image = image;
                 this.thumbnail = thumbnail;
                 this.linkTitle = linkTitle;
                 this.link =link;
                 this.title = title;
                 this.description = description;
                 this.transition="' . $transition . '";
                 this.number=number;
                 this.date=date,
                 this.hits=hits,
                 this.downloads=downloads,
                 this.rating=rating,
                 this.filesizedtl=filesizedtl,
                 this.filesizeorg=filesizeorg,
                 this.author=author,
                 this.detaillink=detaillink
               }';
             $number = 0;
             $maxwidth = 0;
             $maxheight = 0;
             $imgstartidx = 0;
             foreach ($images as $row) {
                 // Description
                 if ($row->imgtext != '') {
                     $description = JoomHelper::fixForJS($row->imgtext);
                 } else {
                     $description = '&nbsp;';
                 }
                 // Date
                 if ($row->imgdate != '') {
                     $date = JHTML::_('date', $row->imgdate, JText::_('DATE_FORMAT_LC1'));
                 } else {
                     $date = '';
                 }
                 // Rating
                 $rating = addslashes(JHTML::_('joomgallery.rating', $row, true, 'jg_starrating_detail'));
                 // File size of detail image
                 if ($this->_config->get('jg_showdetailfilesize')) {
                     $filesizedtlhw = @filesize($this->_ambit->getImg('img_path', $row));
                     $filesizedtlhw = number_format($filesizedtlhw / 1024, 2, JText::_('COM_JOOMGALLERY_COMMON_DECIMAL_SEPARATOR'), JText::_('COM_JOOMGALLERY_COMMON_THOUSANDS_SEPARATOR'));
                     list($width, $height) = @getimagesize($this->_ambit->getImg('img_path', $row));
                     $filesizedtl = JText::sprintf('COM_JOOMGALLERY_COMMON_IMG_HW', $filesizedtlhw, $width, $height);
                 } else {
                     $filesizedtl = '&nbsp;';
                 }
                 // File size of original image
                 if ($this->_config->get('jg_showoriginalfilesize')) {
                     $filesizeorghw = @filesize($this->_ambit->getImg('orig_path', $row));
                     $filesizeorghw = number_format($filesizeorghw / 1024, 2, JText::_('COM_JOOMGALLERY_COMMON_DECIMAL_SEPARATOR'), JText::_('COM_JOOMGALLERY_COMMON_THOUSANDS_SEPARATOR'));
                     list($width, $height) = @getimagesize($this->_ambit->getImg('orig_path', $row));
                     $filesizeorg = JText::sprintf('COM_JOOMGALLERY_COMMON_IMG_HW', $filesizeorghw, $width, $height);
                 } else {
                     $filesizeorg = '&nbsp;';
                 }
                 // Author-owner
                 if ($this->_config->get('jg_showdetailauthor')) {
                     if ($row->imgauthor) {
                         $author = $row->imgauthor;
                     } else {
                         if ($this->_config->get('jg_showowner')) {
                             $author = JHTML::_('joomgallery.displayname', $row->imgowner, 'detail');
                         } else {
                             $author = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                         }
                     }
                 } else {
                     $author = '';
                 }
                 if ($this->_config->get('jg_slideshow_maxdimauto')) {
                     // Get dimensions of image for calculating the max. width/height
                     // of all images
                     $dimensions = getimagesize($this->_ambit->getImg('img_path', $row));
                     if ($dimensions[0] > $maxwidth) {
                         $maxwidth = $dimensions[0];
                     }
                     if ($dimensions[1] > $maxheight) {
                         $maxheight = $dimensions[1];
                     }
                 }
                 $script .= '
         photo[' . $number . '] = new joom_createphotoobject(
         "' . str_replace('&amp;', '&', $this->_ambit->getImg('img_url', $row)) . '",//image
         "' . $this->_ambit->getImg('thumb_url', $row) . '",//thumbnail
         "' . JoomHelper::fixForJS($row->imgtitle) . '",//linkTitle
         "' . str_replace('&amp;', '&', $this->_ambit->getImg('img_url', $row)) . '",//link
         "' . JoomHelper::fixForJS($row->imgtitle) . '",//title
         "' . $description . '",
         ' . $number . ',
         "' . $date . '",
         "' . $row->hits . '",
         "' . $row->downloads . '",
         "' . $rating . '",
         "' . $filesizedtl . '",
         "' . $filesizeorg . '",
         "' . str_replace(array("\r\n", "\r", "\n"), '', addcslashes($author, '"')) . '",
         "' . JHTML::_('joomgallery.openimage', 0, $row) . '"
       );';
                 // set start image index for slideshow
                 if ($row->id == $image->id) {
                     $imgstartidx = $number;
                 }
                 $number++;
             }
             if (!$this->_config->get('jg_slideshow_maxdimauto')) {
                 $maxwidth = $this->_config->get('jg_slideshow_width');
                 $maxheight = $this->_config->get('jg_slideshow_heigth');
             }
             $script .= 'var joom_slideshow=null;
                 function startGallery() {
                     joom_slideshow = new gallery($(\'jg_dtl_photo\'), {
                     timed: true,
                     delay: ' . $this->_config->get('jg_slideshow_timer') . ',
                     fadeDuration: ' . $this->_config->get('jg_slideshow_transtime') . ',
                     showArrows: ' . $this->_config->get('jg_slideshow_arrows') . ',
                     showCarousel: ' . $this->_config->get('jg_slideshow_carousel') . ',
                     textShowCarousel: \'' . JText::_('COM_JOOMGALLERY_DETAIL_SLIDESHOW_IMAGES', true) . '\',
                     showInfopane: ' . $this->_config->get('jg_slideshow_infopane') . ',
                     embedLinks: false,
                     manualData:photo,
                     preloader:false,
                     populateData:false,
                     maxWidth:' . $maxwidth . ',
                     maxHeight:' . $maxheight . ',
                     imgstartidx:' . $imgstartidx . ',
                     repeat: ' . $this->_config->get('jg_slideshow_repeat') . ',
                     repeattxt: \'' . JText::_('COM_JOOMGALLERY_DETAIL_SLIDESHOW_REPEAT', true) . '\'
                  });
                }
                window.addEvent(\'domready\', startGallery);
                function joom_stopslideshow() {
                  var url = photo[joom_slideshow.getCurrentIter()].detaillink + \'' . JHTML::_('joomgallery.anchor') . '\';
                  location.href = url.replace(/\\&amp;/g,\'&\');
                }
     ';
         } else {
             $script .= "function joom_startslideshow() {\n" . "  document.jg_slideshow_form.submit();\n" . "}\n";
         }
     }
     // Rightclick / Cursor navigation
     if ($this->_config->get('jg_disable_rightclick_detail')) {
         $script .= '
 var jg_photo_hover = 0;
 document.oncontextmenu = function() {
   if(jg_photo_hover==1) {
     return false;
   } else {
     return true;
   }
 }
 function joom_hover() {
   jg_photo_hover = (jg_photo_hover==1) ? 0 : 1;
 }';
     }
     if ($this->_config->get('jg_cursor_navigation') == 1) {
         $script .= 'document.onkeydown = joom_cursorchange;';
     }
     if ($script) {
         $this->_doc->addScriptDeclaration($script);
     }
     // MotionGallery
     if ($this->_config->get('jg_minis') && $this->_config->get('jg_motionminis') == 2) {
         $this->_doc->addScript($this->_ambit->getScript('motiongallery.js'));
         $script = "\n" . "   /***********************************************\n" . "   * CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)\n" . "   * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts\n" . "   * This notice must stay intact for legal use\n" . "   * Modified by Jscheuer1 for autowidth and optional starting positions\n" . "   ***********************************************/";
         $this->_doc->addScriptDeclaration($script);
         $custom = "  <!-- Do not edit IE conditional style below -->" . "\n" . "  <!--[if gte IE 5.5]>" . "\n" . "  <style type=\"text/css\">\n" . "     #motioncontainer {\n" . "       width:expression(Math.min(this.offsetWidth, maxwidth)+'px');\n" . "     }\n" . "  </style>\n" . "  <![endif]-->" . "\n" . "  <!-- End Conditional Style -->";
         $this->_doc->addCustomTag($custom);
     }
     // Icons
     if (!$slideshow) {
         // Zoom
         if ($image->bigger_orig) {
             if ($this->_config->get('jg_bigpic') == 1 && $this->_user->get('id') || $this->_config->get('jg_bigpic_unreg') == 1 && !$this->_user->get('id')) {
                 $params->set('show_zoom_icon', 1);
             } else {
                 if ($this->_config->get('jg_bigpic') == 1 && !$this->_user->get('id')) {
                     $params->set('show_zoom_icon', -1);
                 }
             }
         }
         // Download icon
         if ($this->_config->get('jg_download') && $this->_config->get('jg_showdetaildownload') && ($image->orig_exists || $this->_config->get('jg_downloadfile') != 1)) {
             if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
                 $params->set('show_download_icon', 1);
                 $params->set('download_link', JRoute::_('index.php?task=download&id=' . $image->id));
             } else {
                 if ($this->_config->get('jg_download_hint')) {
                     $params->set('show_download_icon', -1);
                 }
             }
         }
         // Nametags
         if ($this->_config->get('jg_nameshields') && $this->_user->get('id')) {
             if (!$this->_config->get('jg_nameshields_others')) {
                 if (!$already_tagged) {
                     $params->set('show_nametag_icon', 1);
                 } else {
                     $params->set('show_nametag_icon', 2);
                     $params->set('nametag_link', JRoute::_('index.php?task=nametags.remove&id=' . $image->id, false));
                 }
             } else {
                 $params->set('show_nametag_icon', 3);
             }
         } else {
             if ($this->_config->get('jg_nameshields') && !$this->_user->get('id') && $this->_config->get('jg_show_nameshields_unreg')) {
                 $params->set('show_nametag_icon', -1);
             }
         }
         // Favourites
         if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites')) {
             if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
                 $params->set('favourites_link', JRoute::_('index.php?task=favourites.addimage&id=' . $image->id));
                 if ($this->_config->get('jg_usefavouritesforzip') == 1 || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
                     $params->set('show_favourites_icon', 2);
                 } else {
                     $params->set('show_favourites_icon', 1);
                 }
             } else {
                 if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                     if ($this->_config->get('jg_usefavouritesforzip') == 1) {
                         $params->set('show_favourites_icon', -2);
                     } else {
                         $params->set('show_favourites_icon', -1);
                     }
                 }
             }
         }
         // Report
         if ($this->_config->get('jg_report_images') && $this->_config->get('jg_detail_report_images')) {
             if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) {
                 $params->set('show_report_icon', 1);
                 JHTML::_('behavior.modal');
             } else {
                 if ($this->_config->get('jg_report_hint')) {
                     $params->set('show_report_icon', -1);
                 }
             }
         }
         // Show editor links for that image
         if ($this->_config->get('jg_showdetaileditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $image->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $image->id) && $image->imgowner && $image->imgowner == $this->_user->get('id')) {
                 $params->set('show_edit_icon', 1);
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $image->id)) {
                 $params->set('show_delete_icon', 1);
             }
         }
     }
     $extra = '';
     if ($this->_config->get('jg_disable_rightclick_detail') == 1) {
         $extra = 'onmouseover="javascript:joom_hover();" onmouseout="javascript:joom_hover();"';
     }
     $event = new stdClass();
     if (!$slideshow) {
         if ($this->_config->get('jg_lightbox_slide_all')) {
             $params->set('show_all_in_popup', 1);
             $popup = array();
             $popup['before'] = JHTML::_('joomgallery.popup', $images, 0, $image->position, $params->get('image_linked') ? 'joomgalleryIcon' : null);
             $popup['after'] = JHTML::_('joomgallery.popup', $images, $image->position + 1, null, $params->get('image_linked') ? 'joomgalleryIcon' : null);
             $this->assignRef('popup', $popup);
         }
         // Pane
         // Load modules at position 'detailpane'
         $modules['detailpane'] = JoomHelper::getRenderedModules('detailpane');
         if (count($modules['detailpane'])) {
             $params->set('show_detailpane_modules', 1);
         }
         // Exif data
         if ($this->_config->get('jg_showexifdata') && $image->orig_exists && extension_loaded('exif') && function_exists('exif_read_data')) {
             $exifdata = $this->get('Exifdata');
             if ($exifdata) {
                 $params->set('show_exifdata', 1);
                 $this->assignRef('exifdata', $exifdata);
             }
         }
         // GeoTagging data
         if ($this->_config->get('jg_showgeotagging') && $image->orig_exists && extension_loaded('exif') && function_exists('exif_read_data')) {
             $mapdata_array = $this->get('Mapdata');
             if ($mapdata_array) {
                 $mapdata = '';
                 if (isset($mapdata_array['N'])) {
                     $mapdata .= $mapdata_array['N'];
                 } else {
                     if (isset($mapdata_array['S'])) {
                         $mapdata .= '-' . $mapdata_array['S'];
                     }
                 }
                 $mapdata .= ', ';
                 if (isset($mapdata_array['E'])) {
                     $mapdata .= $mapdata_array['E'];
                 } else {
                     if (isset($mapdata_array['W'])) {
                         $mapdata .= '-' . $mapdata_array['W'];
                     }
                 }
                 if ($mapdata) {
                     $params->set('show_map', 1);
                     $this->assignRef('mapdata', $mapdata);
                     $apikey = $this->_config->get('jg_geotaggingkey');
                     $this->_doc->addScript('http' . (JUri::getInstance()->isSSL() ? 's' : '') . '://maps.google.com/maps/api/js?sensor=false' . (!empty($apikey) ? '&amp;key=' . $apikey : ''));
                     JText::script('COM_JOOMGALLERY_DETAIL_MAPS_BROWSER_IS_INCOMPATIBLE');
                 }
             }
         }
         // IPTC data
         if ($this->_config->get('jg_showiptcdata') && $image->orig_exists) {
             $iptcdata = $this->get('Iptcdata');
             if ($iptcdata) {
                 $params->set('show_iptcdata', 1);
                 $this->assignRef('iptcdata', $iptcdata);
             }
         }
         // Rating
         if ($this->_config->get('jg_showrating')) {
             if ($this->_config->get('jg_votingonlyreg') && !$this->_user->get('id')) {
                 // Set voting_area to 3 to show only the message in template
                 $params->set('show_voting_area', 3);
                 $params->set('voting_message', JText::_('COM_JOOMGALLERY_DETAIL_LOGIN_FIRST'));
             } else {
                 if ($this->_config->get('jg_votingonlyreg') && $image->owner == $this->_user->get('id')) {
                     // Set voting_area to 3 to show only the message in template
                     $params->set('show_voting_area', 3);
                     $params->set('voting_message', JText::_('COM_JOOMGALLERY_DETAIL_RATING_NOT_ON_OWN_IMAGES'));
                 } else {
                     // Set to 1 will show the voting area
                     JHtml::_('behavior.framework');
                     $params->set('show_voting_area', 1);
                     $params->set('ajaxvoting', $this->_config->get('jg_ajaxrating'));
                     if ($this->_config->get('jg_ratingdisplaytype') == 0) {
                         // Set to 0 will show textual voting bar with radio buttons
                         $params->set('voting_display_type', 0);
                         $selected = floor($this->_config->get('jg_maxvoting') / 2) + 1;
                         $voting = '';
                         $options = array();
                         for ($i = 1; $i <= $this->_config->get('jg_maxvoting'); $i++) {
                             $options[] = JHTML::_('select.option', $i);
                             // Delete options text manually, because it defaults to the value in JHTML::_('select.option'... ) if left empty
                             $options[$i - 1]->text = '';
                         }
                         $voting .= JHTML::_('select.radiolist', $options, 'imgvote', null, 'value', 'text', $selected);
                         $maxvoting = $i - 1;
                         $this->assignRef('voting', $voting);
                         $this->assignRef('maxvoting', $maxvoting);
                     } else {
                         if ($this->_config->get('jg_ratingdisplaytype') == 1) {
                             // Set to 1 will show graphical voting bar with stars
                             $params->set('voting_display_type', 1);
                             $maxvoting = $this->_config->get('jg_maxvoting');
                             $this->assignRef('maxvoting', $maxvoting);
                         }
                     }
                 }
             }
         }
         if ($this->_config->get('jg_bbcodelink')) {
             $current_uri = JURI::getInstance(JURI::base());
             $current_host = $current_uri->toString(array('scheme', 'host', 'port'));
             $params->set('show_bbcode', 1);
             if ($this->_config->get('jg_bbcodelink') == 1 || $this->_config->get('jg_bbcodelink') == 3) {
                 // Ensure that the correct host and path is prepended
                 $uri = JFactory::getUri($image->img_src);
                 $uri->setHost($current_host);
                 $params->set('bbcode_img', str_replace(array('&', 'http://http://'), array('&amp;', 'http://'), $uri->toString()));
             }
             if ($this->_config->get('jg_bbcodelink') == 2 || $this->_config->get('jg_bbcodelink') == 3) {
                 $url = JRoute::_('index.php?view=detail&id=' . $image->id) . JHTML::_('joomgallery.anchor');
                 // Ensure that the correct host and path is prepended
                 $uri = JFactory::getUri($url);
                 $uri->setHost($current_host);
                 $params->set('bbcode_url', str_replace('&', '&amp;', $uri->toString()));
             }
         }
         if ($this->_config->get('jg_showcomment')) {
             $params->set('show_comments_block', 1);
             // Check whether user is allowed to comment
             if ($this->_config->get('jg_anoncomment') || !$this->_config->get('jg_anoncomment') && $this->_user->get('id')) {
                 $params->set('commenting_allowed', 1);
                 $plugins = $this->_mainframe->triggerEvent('onJoomGetCaptcha');
                 $event->captchas = implode('', $plugins);
                 $this->_doc->addScriptDeclaration('    var jg_use_code = ' . $params->get('use_easycaptcha', 0) . ';');
                 if ($this->_config->get('jg_bbcodesupport')) {
                     $params->set('bbcode_status', JText::_('COM_JOOMGALLERY_DETAIL_BBCODE_ON'));
                 } else {
                     $params->set('bbcode_status', JText::_('COM_JOOMGALLERY_DETAIL_BBCODE_OFF'));
                 }
                 if ($this->_config->get('jg_smiliesupport')) {
                     $params->set('smiley_support', 1);
                     $smileys = JoomHelper::getSmileys();
                     $this->assignRef('smileys', $smileys);
                 }
                 JText::script('COM_JOOMGALLERY_DETAIL_SENDTOFRIEND_ALERT_ENTER_NAME_EMAIL');
                 JText::script('COM_JOOMGALLERY_DETAIL_COMMENTS_ALERT_ENTER_COMMENT');
                 JText::script('COM_JOOMGALLERY_DETAIL_COMMENTS_ALERT_ENTER_CODE');
             }
             // Check whether user is allowed to read comments
             if ($this->_user->get('username') || !$this->_user->get('username') && $this->_config->get('jg_showcommentsunreg') == 0) {
                 $comments = $this->get('Comments');
                 if (!$comments) {
                     $params->set('no_comments_message', JText::_('COM_JOOMGALLERY_DETAIL_COMMENTS_NOT_EXISTING'));
                     if ($params->get('commenting_allowed')) {
                         $params->set('no_comments_message2', JText::_('COM_JOOMGALLERY_DETAIL_COMMENTS_WRITE_FIRST'));
                     }
                 } else {
                     $params->set('show_comments', 1);
                     // Manager logged?
                     if ($this->_user->authorise('core.manage', _JOOM_OPTION)) {
                         $params->set('manager_logged', 1);
                     }
                     foreach ($comments as $key => $comment) {
                         // Display author name or notice that the author is a guest
                         if ($comment->userid) {
                             $comments[$key]->author = JHTML::_('joomgallery.displayname', $comment->userid, 'comment');
                         } else {
                             if ($this->_config->get('jg_namedanoncomment')) {
                                 if ($comment->cmtname != JText::_('COM_JOOMGALLERY_COMMON_GUEST')) {
                                     $comments[$key]->author = JText::sprintf('COM_JOOMGALLERY_DETAIL_COMMENTS_GUEST_NAME', $comment->cmtname);
                                 } else {
                                     $comments[$key]->author = $comment->cmtname;
                                 }
                             } else {
                                 $comments[$key]->author = JText::_('COM_JOOMGALLERY_COMMON_GUEST');
                             }
                         }
                         // Process comment text
                         $text = $comment->cmttext;
                         $text = JoomHelper::processText($text);
                         if ($this->_config->get('jg_bbcodesupport')) {
                             $text = JHTML::_('joomgallery.bbdecode', $text);
                         }
                         if ($this->_config->get('jg_smiliesupport')) {
                             $smileys = JoomHelper::getSmileys();
                             foreach ($smileys as $i => $sm) {
                                 $text = str_replace($i, '<img src="' . $sm . '" border="0" alt="' . $i . '" title="' . $i . '" />', $text);
                             }
                         }
                         $comments[$key]->text = $text;
                     }
                     $this->assignRef('comments', $comments);
                 }
             } else {
                 $params->set('no_comments_message', JText::_('COM_JOOMGALLERY_DETAIL_COMMENTS_NOT_FOR_UNREG'));
             }
         }
         if ($this->_config->get('jg_send2friend')) {
             $params->set('show_send2friend_block', 1);
             if ($this->_user->get('id')) {
                 $params->set('show_send2friend_form', 1);
             } else {
                 $params->set('send2friend_message', JText::_('COM_JOOMGALLERY_DETAIL_LOGIN_FIRST'));
             }
         }
     }
     $icons = $this->_mainframe->triggerEvent('onJoomDisplayIcons', array('detail.image', $image));
     $event->icons = implode('', $icons);
     $afterDisplay = $this->_mainframe->triggerEvent('onJoomAfterDisplayDetailImage', array($image));
     $event->afterDisplay = implode('', $afterDisplay);
     // Set redirect url used in editor links to redirect back to favourites view after edit/delete
     $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString());
     $this->assignRef('params', $params);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('image', $image);
     $this->assignRef('images', $images);
     $this->assignRef('extra', $extra);
     $this->assignRef('slideshow', $slideshow);
     $this->assignRef('slider', $slider);
     $this->assignRef('toggler', $toggler);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('event', $event);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     $this->_doc->addScript($this->_ambit->getScript('detail.js'));
     parent::display($tpl);
 }
示例#6
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_SEARCH_RESULTS'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = JText::_('COM_JOOMGALLERY_SEARCH_RESULTS');
     $backtarget = JRoute::_('index.php?view=gallery');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $sstring = trim(JRequest::getVar('sstring'));
     $rows = array();
     if (!empty($sstring)) {
         $rows = $this->get('SearchResults');
     }
     foreach ($rows as $key => $row) {
         $rows[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $row);
         $cropx = null;
         $cropy = null;
         $croppos = null;
         if ($this->_config->get('jg_dyncrop')) {
             $cropx = $this->_config->get('jg_dyncropwidth');
             $cropy = $this->_config->get('jg_dyncropheight');
             $croppos = $this->_config->get('jg_dyncropposition');
         }
         $row->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $rows[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $row);
         } else {
             // Set the imgtitle by default
             $rows[$key]->atagtitle = 'title="' . $row->imgtitle . '"';
         }
         if ($this->_config->get('jg_showauthor')) {
             if ($row->imgauthor) {
                 $rows[$key]->authorowner = $row->imgauthor;
             } else {
                 if ($this->_config->get('jg_showowner')) {
                     $rows[$key]->authorowner = JHTML::_('joomgallery.displayname', $row->owner);
                 } else {
                     $rows[$key]->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                 }
             }
         }
         // Show editor links for that image
         $rows[$key]->show_edit_icon = false;
         $rows[$key]->show_delete_icon = false;
         if ($this->_config->get('jg_showsearcheditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $rows[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $rows[$key]->id) && $rows[$key]->owner && $rows[$key]->owner == $this->_user->get('id')) {
                 $rows[$key]->show_edit_icon = true;
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $rows[$key]->id)) {
                 $rows[$key]->show_delete_icon = true;
             }
         }
     }
     // Download icon
     if ($this->_config->get('jg_download') && $this->_config->get('jg_showsearchdownload')) {
         if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
             $params->set('show_download_icon', 1);
         } else {
             if ($this->_config->get('jg_download_hint')) {
                 $params->set('show_download_icon', -1);
             }
         }
     }
     // Favourites icon
     if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites') && $this->_config->get('jg_showsearchfavourite')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_favourites_icon', 2);
             } else {
                 $params->set('show_favourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_favourites_icon', -2);
                 } else {
                     $params->set('show_favourites_icon', -1);
                 }
             }
         }
     }
     // Report icon
     if ($this->_config->get('jg_report_images') && $this->_config->get('jg_search_report_images')) {
         if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) {
             $params->set('show_report_icon', 1);
             JHTML::_('behavior.modal');
         } else {
             if ($this->_config->get('jg_report_hint')) {
                 $params->set('show_report_icon', -1);
             }
         }
     }
     $uri = JFactory::getURI();
     $uri->setVar('sstring', $sstring);
     $redirect = '&redirect=' . base64_encode($uri->toString());
     $this->assignRef('params', $params);
     $this->assignRef('rows', $rows);
     $this->assignRef('sstring', $sstring);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     parent::display($tpl);
 }
示例#7
0
 /**
  * HTML view display method
  *
  * @access  public
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 function display($tpl = null)
 {
     if (!$this->_config->get('jg_userspace')) {
         $msg = JText::_('JERROR_ALERTNOAUTHOR');
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), $msg, 'notice');
     }
     // Additional security check for unregistered users
     if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED'), 'notice');
     }
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL'), 'index.php?view=userpanel');
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_EDIT_EDIT_IMAGE'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = null;
     if ($this->_config->get('jg_showpathway')) {
         $pathway = '<a href="' . JRoute::_('index.php?view=userpanel') . '">' . JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL') . '</a>';
         $pathway .= ' &raquo; ' . JText::_('COM_JOOMGALLERY_EDIT_EDIT_IMAGE');
     }
     $backtarget = JRoute::_('index.php?view=userpanel');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_USER_PANEL');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $image = $this->get('Image');
     // Get the form and fill the fields
     $form = $this->get('Form');
     // Bind the data to the form
     $form->bind($image);
     // Set some form fields manually
     $form->setValue('imagelib', null, $image->thumb_url);
     // Get limitstart from request to set the correct limitstart (page) in userpanel when
     // leaving edit mode with save or cancel
     $limitstart = JRequest::getVar('limitstart', null);
     $slimitstart = $limitstart != null ? '&limitstart=' . (int) $limitstart : '';
     // Get redirect page, if any given by request
     $redirect = JRequest::getVar('redirect', null);
     $redirecturl = '';
     if ($redirect === null) {
         $redirect = '';
     } else {
         $redirecturl = base64_decode($redirect);
         if (!JURI::isInternal($redirecturl)) {
             $redirecturl = '';
             $redirect = '';
         } else {
             $redirect = '&redirect=' . $redirect;
         }
     }
     $this->assignRef('params', $params);
     $this->assignRef('form', $form);
     $this->assignRef('image', $image);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('slimitstart', $slimitstart);
     $this->assignRef('redirect', $redirect);
     $this->assignRef('redirecturl', $redirecturl);
     parent::display($tpl);
 }
示例#8
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     if (!$this->_config->get('jg_userspace')) {
         $msg = JText::_('JERROR_ALERTNOAUTHOR');
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), $msg, 'notice');
     }
     // Additional security check for unregistered users
     if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED'), 'notice');
     }
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL'), 'index.php?view=userpanel');
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_CATEGORIES'), 'index.php?view=usercategories');
         if (JRequest::getInt('catid')) {
             $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_EDITCATEGORY_MODIFY_CATEGORY'));
         } else {
             $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_NEW_CATEGORY'));
         }
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = null;
     if ($this->_config->get('jg_showpathway')) {
         $pathway = '<a href="' . JRoute::_('index.php?view=userpanel') . '">' . JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL') . '</a>';
         $pathway .= ' &raquo; <a href="' . JRoute::_('index.php?view=usercategories') . '">' . JText::_('COM_JOOMGALLERY_COMMON_CATEGORIES') . '</a>';
         if (JRequest::getInt('catid')) {
             $pathway .= ' &raquo; ' . JText::_('COM_JOOMGALLERY_EDITCATEGORY_MODIFY_CATEGORY');
         } else {
             $pathway .= ' &raquo; ' . JText::_('COM_JOOMGALLERY_COMMON_NEW_CATEGORY');
         }
     }
     $backtarget = JRoute::_('index.php?view=userpanel');
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_USER_PANEL');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     // Load the category data
     $category = $this->get('Category');
     // Get the form and fill the fields
     $form = $this->get('Form');
     // Set some additional field attributes
     // Category slect box
     if ($category->cid) {
         // Exclude current category id from select box
         $form->setFieldAttribute('parent_id', 'exclude', $category->cid);
     } else {
         // If we are creating a new category pre-select a valid
         // parent category in select box in order to fix the content
         // of the parent category box and of the ordering box
         // (if the user is allowed to create main categories
         // 0 is already a valid value for the category select box)
         if (!$this->_config->get('jg_disableunrequiredchecks') && !$this->_user->authorise('core.create', _JOOM_OPTION)) {
             $parent_cats = JoomHelper::getAuthorisedCategories('core.create');
             if (isset($parent_cats[0])) {
                 $category->parent_id = $parent_cats[0]->cid;
             } else {
                 $msg = JText::_('COM_JOOMGALLERY_EDITCATEGORY_ERROR_NO_AVAILABLE_PARENT_CATEGORIES');
                 $this->_mainframe->redirect(JRoute::_('index.php?view=usercategories', false), $msg, 'notice');
             }
         }
     }
     // Ordering box is not available if option for performance improvement has been enabled
     if (!$this->_config->get('jg_disableunrequiredchecks')) {
         // Set some additional attributes for the ordering select box
         $form->setFieldAttribute('ordering', 'originalOrder', $category->cid);
         $form->setFieldAttribute('ordering', 'originalParent', $category->parent_id == 1 ? 0 : $category->parent_id);
         $form->setFieldAttribute('ordering', 'orderings', base64_encode(serialize($this->getModel()->getOrderings($category->cid ? $category->parent_id : null))));
         // Perhaps there is a better way to set the field attribute
         $parent_field = $this->_findFieldByFieldName($form, 'parent_id');
         if ($parent_field !== false) {
             $form->setFieldAttribute('ordering', 'parent_id', $parent_field->id);
         }
     }
     // Thumbnail preview
     $imagelib_field = $this->_findFieldByFieldName($form, 'imagelib');
     // Set additional attribute for the thumbnail select box
     if ($imagelib_field !== false) {
         $form->setFieldAttribute('thumbnail', 'imagelib_id', $imagelib_field->id);
     }
     // Bind the data to the form
     $form->bind($category);
     // Set some form fields manually
     $form->setValue('imagelib', null, $category->catimage_src);
     // Get limitstart from request to set the correct limitstart (page) in usercategories when
     // leaving edit/new mode with save or cancel
     $limitstart = JRequest::getVar('limitstart', null);
     $slimitstart = $limitstart != null ? '&limitstart=' . (int) $limitstart : '';
     $this->assignRef('params', $params);
     $this->assignRef('form', $form);
     $this->assignRef('category', $category);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('slimitstart', $slimitstart);
     parent::display($tpl);
 }
示例#9
0
 /**
  * HTML view display method
  *
  * @access  public
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 function display($tpl = null)
 {
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem($this->output('MY'));
     }
     $params = $this->_mainframe->getParams();
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = $this->output('MY');
     $backtarget = JRoute::_('index.php?view=gallery');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $state = $this->get('State');
     $rows = $this->get('Favourites');
     foreach ($rows as $key => $row) {
         $row->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $row);
         $cropx = null;
         $cropy = null;
         $croppos = null;
         if ($this->_config->get('jg_dyncrop')) {
             $cropx = $this->_config->get('jg_dyncropwidth');
             $cropy = $this->_config->get('jg_dyncropheight');
             $croppos = $this->_config->get('jg_dyncropposition');
         }
         $row->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $rows[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $row);
         } else {
             // Set the imgtitle by default
             $rows[$key]->atagtitle = 'title="' . $row->imgtitle . '"';
         }
         if ($this->_config->get('jg_showauthor')) {
             if ($row->imgauthor) {
                 $row->authorowner = $row->imgauthor;
             } else {
                 if ($this->_config->get('jg_showowner')) {
                     $row->authorowner = JHTML::_('joomgallery.displayname', $row->imgowner);
                 } else {
                     $row->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                 }
             }
         }
         // Show editor links for that image
         $row->show_edit_icon = false;
         $row->show_delete_icon = false;
         if ($this->_config->get('jg_showfavouriteseditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $row->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $row->id) && $row->imgowner && $row->imgowner == $this->_user->get('id')) {
                 $row->show_edit_icon = true;
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $row->id)) {
                 $row->show_delete_icon = true;
             }
         }
     }
     // Download Icon
     if ($this->_config->get('jg_download') && $this->_config->get('jg_showfavouritesdownload')) {
         if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
             $params->set('show_download_icon', 1);
         } else {
             if ($this->_config->get('jg_download_hint')) {
                 $params->set('show_download_icon', -1);
             }
         }
     }
     // Set redirect url used in editor links to redirect back to favourites view after edit/delete
     $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString());
     $this->assignRef('params', $params);
     $this->assignRef('rows', $rows);
     $this->assignRef('state', $state);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     $layout = JRequest::getCmd('layout');
     if (!$layout && $this->get('Layout')) {
         $this->setLayout('list');
     }
     parent::display($tpl);
 }
示例#10
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     if (!$this->_config->get('jg_userspace')) {
         $msg = JText::_('JERROR_ALERTNOAUTHOR');
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), $msg, 'notice');
     }
     // Additional security check for unregistered users
     if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED'), 'notice');
     }
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $this->pathway = JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL');
     $this->backtarget = JRoute::_('index.php?view=gallery');
     $this->backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     $this->numberofpics = $numbers[0];
     $this->numberofhits = $numbers[1];
     // Load modules at position 'top'
     $this->modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($this->modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $this->modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($this->modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     // Display button 'Upload' only if there is at least
     // one category into which the user is allowed to upload
     if ($this->_config->get('jg_disableunrequiredchecks') || count(JoomHelper::getAuthorisedCategories('joom.upload'))) {
         $params->set('show_upload_button', 1);
     } else {
         $params->set('show_upload_button', 0);
     }
     // Display button 'Categories' if the current user is allowed
     // to create categories or if there are categories owned by him
     if ($this->_user->authorise('core.create', _JOOM_OPTION) || $this->_config->get('jg_disableunrequiredchecks') || count(JoomHelper::getAuthorisedCategories('core.create')) || count($this->get('Categories'))) {
         $params->set('show_categories_button', 1);
     } else {
         $params->set('show_categories_button', 0);
     }
     // Get data from the model
     $this->total = $this->get('Total');
     $this->state = $this->get('State');
     if ($this->state->get('list.start') >= $this->total) {
         // This may happen for instance when an image has been deleted on a page with just one entry
         $limitstart = $this->total > 0 && $this->total > $this->state->get('list.limit') ? floor(($this->total - 1) / $this->state->get('list.limit')) * $this->state->get('list.limit') : 0;
         $this->state->set('list.start', $limitstart);
     }
     $this->slimitstart = $this->state->get('list.start') > 0 ? '&limitstart=' . $this->state->get('list.start') : '';
     $this->items = $this->get('Images');
     $this->pagination = $this->get('Pagination');
     if (!$this->total) {
         if ($this->state->get('filter.inuse')) {
             $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_USERPANEL_MSG_NO_IMAGES_FOUND_MATCHING_YOUR_QUERY'));
         } else {
             // Guests cannot own any images
             if (!$this->_user->get('id')) {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_USERPANEL_GUESTS_CANNOT_OWN_IMAGES'));
             } else {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_USERPANEL_YOU_DO_NOT_HAVE_IMAGE'));
             }
         }
     }
     $this->lists = array();
     // Filter by type
     $options = array(JHTML::_('select.option', 0, JText::_('COM_JOOMGALLERY_COMMON_SELECT_STATE')), JHTML::_('select.option', 1, JText::_('COM_JOOMGALLERY_COMMON_OPTION_APPROVED_ONLY')), JHTML::_('select.option', 2, JText::_('COM_JOOMGALLERY_COMMON_OPTION_NOT_APPROVED_ONLY')), JHTML::_('select.option', 3, JText::_('COM_JOOMGALLERY_COMMON_OPTION_PUBLISHED_ONLY')), JHTML::_('select.option', 4, JText::_('COM_JOOMGALLERY_COMMON_OPTION_NOT_PUBLISHED_ONLY')));
     $this->lists['filter_state'] = JHTML::_('select.genericlist', $options, 'filter_state', 'class="inputbox" size="1" onchange="form.submit();"', 'value', 'text', $this->state->get('filter.state'));
     foreach ($this->items as $key => &$item) {
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $item->atagtitle = JHTML::_('joomgallery.getTitleforATag', $item);
         } else {
             // Set the imgtitle by default
             $item->atagtitle = 'title="' . $item->imgtitle . '"';
         }
         // Show editor links for that image
         $this->items[$key]->show_edit_icon = false;
         $this->items[$key]->show_delete_icon = false;
         if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $this->items[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $this->items[$key]->id) && $this->items[$key]->owner && $this->items[$key]->owner == $this->_user->get('id')) {
             $this->items[$key]->show_edit_icon = true;
         }
         if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $this->items[$key]->id)) {
             $this->items[$key]->show_delete_icon = true;
         }
     }
     $this->params = $params;
     parent::display($tpl);
 }
示例#11
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     if (!$this->_config->get('jg_userspace')) {
         $msg = JText::_('JERROR_ALERTNOAUTHOR');
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), $msg, 'notice');
     }
     // Additional security check for unregistered users
     if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED'), 'notice');
     }
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL'), 'index.php?view=userpanel');
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_CATEGORIES'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $this->pathway = null;
     if ($this->_config->get('jg_showpathway')) {
         $this->pathway = '<a href="' . JRoute::_('index.php?view=userpanel') . '">' . JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL') . '</a>';
         $this->pathway .= ' &raquo; ' . JText::_('COM_JOOMGALLERY_COMMON_CATEGORIES');
     }
     $this->backtarget = JRoute::_('index.php?view=userpanel');
     $this->backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_USER_PANEL');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     $this->numberofpics = $numbers[0];
     $this->numberofhits = $numbers[1];
     // Load modules at position 'top'
     $this->modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($this->modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $this->modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($this->modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     // Show upload quota
     if ($this->_config->get('jg_newpicnote') && $this->_user->get('id')) {
         $params->set('show_categories_notice', 1);
     }
     // Get data from the model
     $this->total = $this->get('Total');
     $this->state = $this->get('State');
     if ($this->state->get('list.start') >= $this->total) {
         // This may happen for instance when a category has been deleted on a page with just one entry
         $limitstart = $this->total > 0 && $this->total > $this->state->get('list.limit') ? floor(($this->total - 1) / $this->state->get('list.limit')) * $this->state->get('list.limit') : 0;
         $this->state->set('list.start', $limitstart);
     }
     $this->slimitstart = $this->state->get('list.start') > 0 ? '&limitstart=' . $this->state->get('list.start') : '';
     // Get data from the model
     $this->categoryNumber = $this->get('CategoryNumber');
     $this->items = $this->get('Categories');
     $this->pagination = $this->get('Pagination');
     // Enqueue a message in case no categories were found
     if (!$this->total) {
         if ($this->state->get('filter.inuse')) {
             $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_USERPANEL_MSG_NO_CATEGORIES_FOUND_MATCHING_YOUR_QUERY'));
         } else {
             // Guests cannot own any categories
             if (!$this->_user->get('id')) {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_USERCATEGORIES_GUESTS_CANNOT_OWN_CATEGORIES'));
             } else {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_USERCATEGORIES_YOU_NOT_HAVE_CATEGORY'));
             }
         }
     }
     // Show the button to create a new category only for users
     // with create permissions and who have not reached the limits
     if (($this->_user->authorise('core.create', _JOOM_OPTION) || $this->_config->get('jg_disableunrequiredchecks') || count(JoomHelper::getAuthorisedCategories('core.create'))) && $this->_config->get('jg_maxusercat') - $this->categoryNumber > 0) {
         $params->set('show_category_button', 1);
     }
     // Preprocess the list of items to find ordering divisions.
     foreach ($this->items as &$item) {
         $this->ordering[$item->parent_id][] = $item->cid;
     }
     $this->lists = array();
     // Filter by state
     $options = array(JHTML::_('select.option', 0, JText::_('COM_JOOMGALLERY_COMMON_SELECT_STATE')), JHTML::_('select.option', 1, JText::_('COM_JOOMGALLERY_COMMON_OPTION_PUBLISHED_ONLY')), JHTML::_('select.option', 2, JText::_('COM_JOOMGALLERY_COMMON_OPTION_NOT_PUBLISHED_ONLY')));
     $this->lists['filter_state'] = JHTML::_('select.genericlist', $options, 'filter_state', 'class="inputbox" size="1" onchange="form.submit();"', 'value', 'text', $this->state->get('filter.state'));
     $this->params = $params;
     parent::display($tpl);
 }
示例#12
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     if (!$this->_config->get('jg_userspace')) {
         $msg = JText::_('JERROR_ALERTNOAUTHOR');
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), $msg, 'notice');
     }
     // Additional security check for unregistered users
     if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED'), 'notice');
     }
     if (!$this->_config->get('jg_disableunrequiredchecks') && !count(JoomHelper::getAuthorisedCategories('joom.upload'))) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=userpanel', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_ALLOWED_TO_UPLOAD'), 'notice');
     }
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL'), 'index.php?view=userpanel');
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_UPLOAD_NEW_IMAGE'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = null;
     if ($this->_config->get('jg_showpathway')) {
         $pathway = '<a href="' . JRoute::_('index.php?view=userpanel') . '">' . JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL') . '</a>';
         $pathway .= ' &raquo; ' . JText::_('COM_JOOMGALLERY_COMMON_UPLOAD_NEW_IMAGE');
     }
     $backtarget = JRoute::_('index.php?view=gallery');
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $count = $this->get('ImageNumber');
     if ($count >= $this->_config->get('jg_maxuserimage')) {
         $timespan = $this->_config->get('jg_maxuserimage_timespan');
         $msg = JText::sprintf('COM_JOOMGALLERY_UPLOAD_OUTPUT_MAY_ADD_MAX_OF', $this->_config->get('jg_maxuserimage'), $timespan > 0 ? JText::plural('COM_JOOMGALLERY_UPLOAD_NEW_IMAGE_MAXCOUNT_TIMESPAN', $timespan) : '');
         $this->_mainframe->redirect(JRoute::_('index.php?view=userpanel', false), $msg, 'notice');
     }
     $inputcounter = $this->_config->get('jg_maxuserimage') - $count;
     $remainder = $inputcounter;
     if ($inputcounter > $this->_config->get('jg_maxuploadfields')) {
         $inputcounter = $this->_config->get('jg_maxuploadfields');
     }
     $this->assignRef('count', $count);
     $this->assignRef('remainder', $remainder);
     $this->assignRef('inputcounter', $inputcounter);
     $this->_doc->addScriptDeclaration('    var jg_inputcounter = ' . $inputcounter . ';');
     $this->assignRef('params', $params);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     JHtml::_('behavior.formvalidation');
     JHtml::_('behavior.tooltip');
     $this->uploads = array();
     $types = array('single', 'ajax', 'batch', 'java');
     $tab = $this->_mainframe->input->get('tab');
     $active_found = false;
     foreach ($types as $type) {
         if ($this->_config->get('jg_userupload' . $type)) {
             $this->uploads[$type] = array('title' => 'COM_JOOMGALLERY_UPLOAD_TAB_' . strtoupper($type) . '_UPLOAD', 'active' => false);
             if ($tab == $type) {
                 $this->uploads[$type]['active'] = true;
                 $active_found = true;
             }
         }
     }
     // One tab has to be active
     if (!$active_found && count($this->uploads)) {
         // Reset the array in order to be able to use the key of the first element
         reset($this->uploads);
         $this->uploads[key($this->uploads)]['active'] = true;
     }
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     $this->single_form = JForm::getInstance(_JOOM_OPTION . '.upload', 'upload');
     $this->ajax_form = JForm::getInstance(_JOOM_OPTION . '.ajaxupload', 'ajaxupload');
     $this->batch_form = JForm::getInstance(_JOOM_OPTION . '.batchupload', 'batchupload');
     $this->applet_form = JForm::getInstance(_JOOM_OPTION . '.jupload', 'jupload');
     $this->single_form->setFieldAttribute('arrscreenshot', 'quantity', $inputcounter);
     $this->_doc->addScriptDeclaration('    var jg_filenamewithjs = ' . ($this->_config->get('jg_filenamewithjs') ? 'true' : 'false') . ';');
     $this->_doc->addScript($this->_ambit->getScript('upload.js'));
     JText::script('COM_JOOMGALLERY_COMMON_ALERT_IMAGE_MUST_HAVE_TITLE');
     JText::script('COM_JOOMGALLERY_COMMON_ALERT_YOU_MUST_SELECT_ONE_IMAGE');
     JText::script('COM_JOOMGALLERY_COMMON_ALERT_WRONG_EXTENSION');
     JText::script('COM_JOOMGALLERY_COMMON_ALERT_WRONG_FILENAME');
     JText::script('COM_JOOMGALLERY_UPLOAD_ALERT_FILENAME_DOUBLE_ONE');
     JText::script('COM_JOOMGALLERY_UPLOAD_ALERT_FILENAME_DOUBLE_TWO');
     // AJAX Drag'n'Drop Upload
     if ($this->_config->get('jg_useruploadajax')) {
         $this->_doc->addStyleSheet($this->_ambit->getScript('fineuploader/fineuploader.css'));
         $this->_doc->addScript($this->_ambit->getScript('fineuploader/js/fineuploader' . (JFactory::getConfig()->get('debug') ? '' : '.min') . '.js'));
         $this->ajax_form->setFieldAttribute('ajaxupload', 'redirect', $this->getModel()->getRedirectUrlAfterUpload('ajax'));
     }
     if ($this->_config->get('jg_useorigfilename')) {
         $this->single_form->setFieldAttribute('imgtitle', 'required', 'false');
         $this->ajax_form->setFieldAttribute('imgtitle', 'required', 'false');
         $this->batch_form->setFieldAttribute('imgtitle', 'required', 'false');
         $this->applet_form->setFieldAttribute('imgtitle', 'required', 'false');
     }
     if (!$this->_config->get('jg_disableunrequiredchecks')) {
         // Set default user upload category
         $defaultUserUploadCategory = $this->get('DefaultUserUploadCategory');
         $this->single_form->setValue('catid', null, $defaultUserUploadCategory);
         $this->ajax_form->setValue('catid', null, $defaultUserUploadCategory);
         $this->batch_form->setValue('catid', null, $defaultUserUploadCategory);
         $this->applet_form->setValue('catid', null, $defaultUserUploadCategory);
     }
     parent::display($tpl);
 }