Esempio n. 1
0
 /**
  * Overloaded store function
  *
  * @param   boolean   $updateNulls  True to update null values as well.
  * @return  boolean   True on success, false otherwise
  * @since   1.5.7
  */
 public function store($updateNulls = false)
 {
     if (!parent::store($updateNulls)) {
         return false;
     }
     // If there aren't any sub categories there isn't anything to do anymore
     $cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, false);
     if (!count($cats)) {
         return true;
     }
     // Set state of all sub-categories
     // according to the settings of this category
     $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('published = ' . (int) $this->published)->where('cid IN (' . implode(',', $cats) . ')');
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Set 'in_hidden' of all sub-categories
     // according to hidden state of this category
     // (but only if there was a change of this state)
     if ($this->_hidden != $this->hidden && !$this->in_hidden || $this->_in_hidden != $this->in_hidden) {
         if ($this->hidden == 0 && $this->in_hidden == 0) {
             // If 'hidden' is 0 only the categories
             // which aren't set to hidden must be changed
             // because they form a hidden group themselves
             // anyway and have to stay hidden
             $cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, true);
         }
         $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('in_hidden = ' . (int) ($this->hidden || $this->in_hidden))->where('cid IN (' . implode(',', $cats) . ')');
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Method for retreiving categories allowed for a certain action
  *
  * @param   string  $action       Optional action to check the categories against
  * @param   int     $filter       Optional category ID which will be filtered out together with its sub-categories
  * @param   string  $searchstring Optional string for searching specific categories (name of category will be used for searching)
  * @param   int     $limitstart   Optional limit start parameter for database query
  * @return  array   A result set with an array of categories and indicator whether there are more results left on success, Exception object otherwise
  * @since   2.1
  */
 public function getAllowedCategories($action = null, $filter = null, $searchstring = '', $limitstart = 0, $current = 0)
 {
     JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/html');
     // Initialise variables
     $results = array('results' => array());
     $action2 = false;
     if ($action == 'joom.upload') {
         $action2 = 'joom.upload.inown';
     }
     if ($action == 'core.create') {
         $action2 = 'joom.create.inown';
     }
     if ($action == 'core.edit') {
         $action2 = 'core.edit.own';
     }
     $filtered = array();
     if ($filter) {
         $filtered = JoomHelper::getAllSubCategories($filter, true, true, true, false);
     }
     try {
         // Create the search query
         $query = $this->_db->getQuery(true)->select('cid, name, owner')->from($this->_db->qn(_JOOM_TABLE_CATEGORIES))->where('cid != 1')->order('lft');
         if ($searchstring) {
             $searchstring = $this->_db->q('%' . $searchstring . '%');
             $query->where('name LIKE ' . $searchstring);
         }
         // Load all results
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         // Check the results starting from limit start
         $count = count($result);
         $j = 0;
         if (!$limitstart && ($current == 0 || !$action || $action == 'core.create' && $this->_user->authorise($action, _JOOM_OPTION))) {
             $none = new stdclass();
             $none->cid = 0;
             $none->name = JText::_('COM_JOOMGALLERY_COMMON_NO_CATEGORY');
             $none->path = '';
             $none->none = true;
             $results['results'][$j] = $none;
             $j++;
         }
         for ($i = $limitstart; $i < $count; $i++) {
             if (in_array($result[$i]->cid, $filtered)) {
                 continue;
             }
             if ($result[$i]->cid != $current && $action && !$this->_user->authorise($action, _JOOM_OPTION . '.category.' . $result[$i]->cid) && (!$action2 || !$result[$i]->owner || $result[$i]->owner != $this->_user->get('id') || !$this->_user->authorise($action2, _JOOM_OPTION . '.category.' . $result[$i]->cid))) {
                 continue;
             }
             // Stop as soon as we have 10 results.
             // This check is done not earlier than at this point because
             // we want to know whether there is at least one more result.
             if ($j == 10) {
                 // If 'more' is set a 'More Results' link will be displayed in the view
                 $results['more'] = $i;
                 break;
             }
             $results['results'][$j] = $result[$i];
             $results['results'][$j]->path = JHtml::_('joomgallery.categorypath', $result[$i]->cid, false, ' &raquo; ', false, false, true);
             $j++;
         }
     } catch (JDatabaseException $e) {
         return $e;
     }
     return $results;
 }
Esempio n. 3
0
 /**
  * Function to check whether a category has to be hidden because of JoomGallery's
  * backend setting for 'jg_hideemptycats'.
  *
  * @param    int      catid
  * @return   boolean  True if category has to be hidden
  */
 protected function hideCategory($catid)
 {
     $hide = false;
     if ($this->getJConfig('jg_hideemptycats')) {
         $subcatids = JoomHelper::getAllSubCategories($catid, true, $this->getJConfig('jg_hideemptycats') == 1, true, $this->getConfig('showhidden') == 0);
         // If 'jg_hideemptycats' is set to 1 the root category will always be in $subcatids, so check check
         // whether there are images in it
         if (!count($subcatids) || count($subcatids) == 1 && $this->getJConfig('jg_hideemptycats') == 1 && $this->allcategories[$catid]->piccount == 0) {
             $hide = true;
         }
     }
     return $hide;
 }
Esempio n. 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)
 {
     $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);
 }
Esempio n. 5
0
    /**
     * Creates a JavaScript tree with all sub-categories of a category
     *
     * @param   int     $rootcatid  The category ID
     * @param   string  $align      Alignment of the tree
     * @return  void
     * @since   1.5.0
     */
    public static function categoryTree($rootcatid, $align)
    {
        $ambit = JoomAmbit::getInstance();
        $config = JoomConfig::getInstance();
        $user = JFactory::getUser();
        $categories = $ambit->getCategoryStructure(true);
        // Check access rights settings
        $filter_cats = false;
        $restricted_hint = false;
        $restricted_cats = false;
        $root_access = false;
        if (!$config->get('jg_showrestrictedhint') && !$config->get('jg_showrestrictedcats')) {
            $filter_cats = true;
        } else {
            if ($config->get('jg_showrestrictedhint')) {
                $restricted_hint = true;
            }
            if ($config->get('jg_showrestrictedcats')) {
                $restricted_cats = true;
            }
        }
        // Array to hold the relevant sub-category objects
        $subcategories = array();
        // Array to hold the valid parent categories
        $validParentCats = array();
        $validParentCats[$rootcatid] = true;
        // Get all relevant subcategories
        $keys = array_keys($categories);
        $startindex = array_search($rootcatid, $keys);
        if ($startindex !== false) {
            $stopindex = count($categories);
            $root_access = in_array($categories[$rootcatid]->access, $user->getAuthorisedViewLevels()) && !$categories[$rootcatid]->protected;
            for ($j = $startindex + 1; $j < $stopindex; $j++) {
                $i = $keys[$j];
                $parentcat = $categories[$i]->parent_id;
                if (isset($validParentCats[$parentcat])) {
                    // Hide empty categories
                    $empty = false;
                    if ($config->get('jg_hideemptycats')) {
                        $subcatids = JoomHelper::getAllSubCategories($i, true, $config->get('jg_hideemptycats') == 1, true);
                        // If 'jg_hideemptycats' is set to 1 the root category will always be in $subcatids, so check whether there are images in it
                        if (!count($subcatids) || count($subcatids) == 1 && $config->get('jg_hideemptycats') == 1 && !$categories[$i]->piccount) {
                            $empty = true;
                        }
                    }
                    if ($categories[$i]->published && ($filter_cats == false || in_array($categories[$i]->access, $user->getAuthorisedViewLevels()) && ($parentcat == $rootcatid && $root_access || $parentcat != $rootcatid && $subcategories[$parentcat]->access)) && !$categories[$i]->hidden && (!$config->get('jg_hideemptycats') || !$empty)) {
                        $validParentCats[$i] = true;
                        $subcategories[$i] = clone $categories[$i];
                        if ($parentcat == $rootcatid && !$root_access || $parentcat != $rootcatid && !$subcategories[$parentcat]->access || !in_array($categories[$i]->access, $user->getAuthorisedViewLevels()) || $categories[$i]->protected) {
                            $subcategories[$i]->access = false;
                            if ($parentcat == $rootcatid && !$root_access || $parentcat != $rootcatid && !$subcategories[$parentcat]->access) {
                                $subcategories[$i]->protected = false;
                            }
                        }
                    }
                } else {
                    if ($parentcat == 0) {
                        // Branch has been processed completely
                        break;
                    }
                }
            }
        }
        // Show the treeview
        $count = count($subcategories);
        if (!$count) {
            return;
        }
        // If $align is 'jg_element_txt' we are displaying random thumbnails
        // or the thumbnail alignment is set to 'Use global'. In both cases
        // we have to take 'jg_ctalign' under consideration.
        if ($align == 'jg_element_txt') {
            switch ($config->get('jg_ctalign')) {
                case 0:
                    // Changing: $align is only 'jg_element_txt' if the thumbnail is aligned left
                    // Break omitted intentionally
                // Changing: $align is only 'jg_element_txt' if the thumbnail is aligned left
                // Break omitted intentionally
                case 1:
                    // Left
                    $align = 'jg_element_txt_l';
                    break;
                case 2:
                    // Right
                    $align = 'jg_element_txt_r';
                    break;
                case 3:
                    // Break omitted intentionally
                // Break omitted intentionally
                default:
                    // Centered
                    $align = 'jg_element_txt_c';
                    break;
            }
        }
        if ($align == 'jg_element_txt_l') {
            ?>
          <div class="jg_treeview_l">
<?php 
        } elseif ($align == 'jg_element_txt_r') {
            ?>
          <div class="jg_treeview_r">
<?php 
        } else {
            ?>
          <div class="jg_treeview_c">
<?php 
        }
        ?>
            <table>
              <tr>
                <td>
                  <script type="text/javascript" language="javascript">
                  <!--
                  // Create new dTree object
                  var jg_TreeView<?php 
        echo $rootcatid;
        ?>
 = new jg_dTree( <?php 
        echo "'" . "jg_TreeView" . $rootcatid . "'";
        ?>
,
                                                                          <?php 
        echo "'" . $ambit->getScript('dTree/img/') . "'";
        ?>
);
                  // dTree configuration
                  jg_TreeView<?php 
        echo $rootcatid;
        ?>
.config.useCookies = true;
                  jg_TreeView<?php 
        echo $rootcatid;
        ?>
.config.inOrder = true;
                  jg_TreeView<?php 
        echo $rootcatid;
        ?>
.config.useSelection = false;
                  // Add root node
                  jg_TreeView<?php 
        echo $rootcatid;
        ?>
.add( 0, -1, ' ', <?php 
        echo "'" . JRoute::_('index.php?view=gallery' . $rootcatid) . "'";
        ?>
, false);
                  // Add node to hold all subcategories
                  jg_TreeView<?php 
        echo $rootcatid;
        ?>
.add( <?php 
        echo $rootcatid;
        ?>
, 0, <?php 
        echo "'" . JText::_('COM_JOOMGALLERY_COMMON_SUBCATEGORIES', true) . "(" . $count . ")" . "'";
        ?>
,
                                                           <?php 
        echo $root_access ? "'" . JRoute::_('index.php?view=category&catid=' . $rootcatid) . "'" : "''";
        ?>
,
                                                           <?php 
        echo $root_access ? 'false' : 'true';
        ?>
 );
<?php 
        foreach ($subcategories as $category) {
            // Create sub-category name and sub-category link
            if ($filter_cats == false || $category->access || $category->protected) {
                // If the category is accessible create a link.
                // The link is also created if the category is password-protected, but only if its parent category is accessible.
                // The latter is ensured above by setting property 'protected' respectively.
                if ($category->access || $category->protected) {
                    $cat_name = addslashes(trim($category->name));
                    $cat_link = JRoute::_('index.php?view=category&catid=' . $category->cid);
                } else {
                    $cat_name = $restricted_cats == true ? addslashes(trim($category->name)) : JText::_('COM_JOOMGALLERY_COMMON_NO_ACCESS', true);
                    $cat_link = '';
                }
            }
            if ($restricted_hint == true) {
                if (!$category->access) {
                    if ($category->protected) {
                        $cat_name .= '<span class="jg_rm">' . self::icon('key.png', 'COM_JOOMGALLERY_COMMON_TIP_YOU_NOT_ACCESS_THIS_CATEGORY') . '</span>';
                    } else {
                        $cat_name .= '<span class="jg_rm">' . self::icon('group_key.png', 'COM_JOOMGALLERY_COMMON_TIP_YOU_NOT_ACCESS_THIS_CATEGORY') . '</span>';
                    }
                }
            }
            if ($config->get('jg_showcatasnew')) {
                $isnew = JoomHelper::checkNewCatg($category->cid);
            } else {
                $isnew = '';
            }
            $cat_name .= $isnew;
            // Add node
            if ($category->parent_id == $rootcatid) {
                ?>
                  jg_TreeView<?php 
                echo $rootcatid;
                ?>
.add(<?php 
                echo $category->cid;
                ?>
,
                                                          <?php 
                echo $rootcatid;
                ?>
,
                                                          <?php 
                echo "'" . $cat_name . "'";
                ?>
,
                                                          <?php 
                echo "'" . $cat_link . "'";
                ?>
,
                                                          <?php 
                echo $category->access ? 'false' : 'true';
                ?>
                                                          );
<?php 
            } else {
                ?>
                  jg_TreeView<?php 
                echo $rootcatid;
                ?>
.add(<?php 
                echo $category->cid;
                ?>
,
                                                          <?php 
                echo $category->parent_id;
                ?>
,
                                                          <?php 
                echo "'" . $cat_name . "'";
                ?>
,
                                                          <?php 
                echo "'" . $cat_link . "'";
                ?>
,
                                                          <?php 
                echo $category->access ? 'false' : 'true';
                ?>
                                                          );
<?php 
            }
        }
        ?>
                  document.write(jg_TreeView<?php 
        echo $rootcatid;
        ?>
);
                  -->
                  </script>
                </td>
              </tr>
            </table>
          </div>
<?php 
    }
Esempio n. 6
0
 /**
  * Get the categories from JoomGallery
  *
  * @param   object  $params     backend parameters
  * @param   string  $dberror    database error
  * @param   int     $module_id  the id of the module
  * @return  object  $jc_rows    category objects
  */
 public function getCats($params, &$dberror, $module_id)
 {
     // Read the parameters
     $this->getParams($params, $module_id);
     // Get JoomGallery styles
     $this->getPageHeader();
     // Create and include the dynamic css for default view
     // according to backend settings
     $this->renderCSS();
     $rootcat = $this->getConfig('rootcat');
     if ($rootcat > 1) {
         $catlist = JoomHelper::getAllSubCategories($rootcat, false, true, false, $this->getConfig('showhidden') ? false : true);
     }
     // Category filter
     $catblacklist = array();
     $blacklist_cats = $this->getConfig('blacklist_cats');
     if (!empty($blacklist_cats)) {
         $catblacklist_cfg = explode(',', $blacklist_cats);
         foreach ($catblacklist_cfg as $cat) {
             if (!in_array($cat, $catblacklist)) {
                 $catblacklist[] = $cat;
                 $catblacklist = array_merge($catblacklist, JoomHelper::getAllSubCategories($cat, false, true, false, $this->getConfig('showhidden') ? false : true));
             }
         }
     }
     $authorisedViewLevels = implode(',', $this->_user->getAuthorisedViewLevels());
     $query = $this->_db->getQuery(true)->select('ca.cid')->select('ca.name')->select('ca.description')->select('ca.catpath')->select('ca.alias')->select('ca.thumbnail')->select('ca.lft');
     if ($this->getConfig('showrate') || $this->getConfig('catmode') == 1) {
         $query->select('IF(SUM(jg.imgvotes) > 0, SUM(' . JoomHelper::getSQLRatingClause('jg') . ') / count(jg.id), 0) AS catrating, SUM(jg.imgvotes) AS catimgvotes');
     }
     if ($this->getConfig('showhits') || $this->getConfig('catmode') == 2) {
         $query->select('SUM(jg.hits) AS cathits');
     }
     $query->from(_JOOM_TABLE_CATEGORIES . ' AS ca')->innerJoin(_JOOM_TABLE_IMAGES . ' AS jg ON ca.cid = jg.catid')->where('ca.published = 1')->where('ca.access IN (' . $authorisedViewLevels . ')');
     // Inheritance of category access must be considered here
     $allowed_cids = array_keys($this->_ambit->getCategoryStructure());
     if (!empty($allowed_cids)) {
         $query->where('ca.cid IN (' . implode(',', $allowed_cids) . ')');
     }
     if (!$this->getConfig('showhidden')) {
         $query->where('ca.hidden    = 0')->where('ca.in_hidden = 0');
     }
     // Category filter
     if (count($catblacklist) > 0) {
         $query->where('ca.cid NOT IN (' . implode(',', $catblacklist) . ')');
     }
     // Root category
     if ($rootcat > 1) {
         if (count($catlist) > 0) {
             $query->where('ca.cid IN (' . implode(',', $catlist) . ')');
         } else {
             // No category will have cid = 0, just to have a query
             // with no result categories
             $query->where('ca.cid = 0');
         }
     }
     $query->where('jg.published = 1')->where('jg.approved  = 1')->where('jg.access IN (' . $authorisedViewLevels . ')');
     if (!$this->getConfig('showhidden')) {
         $query->where('jg.hidden    = 0');
     }
     switch ($this->getConfig('catmode')) {
         // Top rated
         case 1:
             $query->group('ca.cid')->order('catrating DESC');
             break;
             // Most viewed
         // Most viewed
         case 2:
             $query->group('ca.cid')->order('cathits DESC');
             break;
             // Random
         // Random
         case 3:
             $query->group('ca.cid')->order('rand()');
             break;
             // Alphabetical ascending
         // Alphabetical ascending
         case 4:
             $query->group('ca.cid')->order('ca.name ASC');
             break;
             // Alphabetical descending
         // Alphabetical descending
         case 5:
             $query->group('ca.cid')->order('ca.name DESC');
             break;
             // Ordering ascending
         // Ordering ascending
         case 6:
             $query->group('ca.cid')->order('ca.lft ASC');
             break;
             // Ordering descending
         // Ordering descending
         case 7:
             $query->group('ca.cid')->order('ca.lft DESC');
             break;
             // Default, last added
         // Default, last added
         default:
             $query->group('ca.cid DESC');
             break;
     }
     $this->_db->setQuery($query, 0, $this->getConfig('categorycount'));
     $dberror = '';
     try {
         $cat_rows = $this->_db->loadObjectList();
     } catch (RuntimeException $e) {
         $dberror = JText::_('MOD_JOOMCAT_DB_ERROR_LBL') . ': ' . $e->getMessage();
     }
     return isset($cat_rows) ? $cat_rows : null;
 }
Esempio n. 7
0
 /**
  * Get the IDs of subcategories
  * @return string with catids
  */
 function getSubcategories()
 {
     $cats = array();
     $cats = explode(',', $this->getConfig('cats'));
     if (count($cats) == 0) {
         return '';
     }
     // Delete double values
     $cats = array_unique($cats);
     $subcats = array();
     // Iterate through array and call getAllSubCategories
     // in helper class of JoomGallery
     foreach ($cats as $cat) {
         if (!in_array($cat, $subcats)) {
             $subcats = array_merge($subcats, JoomHelper::getAllSubCategories($cat));
         }
     }
     $cats = array_merge($cats, $subcats);
     // Delete double values
     $cats = array_unique($cats);
     $catsstring = implode(',', $cats);
     return $catsstring;
 }
Esempio n. 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)
 {
     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);
 }
Esempio n. 9
0
 /**
  * Method to load the data of all images of the current category and its sub-categories
  *
  * @return  boolean   True on success, false otherwise
  * @since   1.5.7
  */
 protected function _loadAllImages()
 {
     // Let's load the data if it doesn't already exist
     if (empty($this->_allimages)) {
         $limit = JRequest::getInt('limit', 0);
         if (!$limit) {
             // RSS in category view is disabled
             return false;
         }
         if ($limit < 0) {
             // If $limit is negative all images will be loaded
             $limit = null;
         }
         $catids = JoomHelper::getAllSubCategories($this->_id, true);
         $authorisedViewLevels = implode(',', $this->_user->getAuthorisedViewLevels());
         $query = $this->_db->getQuery(true)->select('*, a.owner AS owner')->from(_JOOM_TABLE_IMAGES . ' AS a')->leftJoin(_JOOM_TABLE_CATEGORIES . ' AS c ON c.cid = a.catid')->where('c.cid       IN (' . implode(',', $catids) . ')')->where('a.published = 1')->where('a.approved  = 1')->where('a.hidden    = 0')->where('a.access    IN (' . $authorisedViewLevels . ')')->where('c.published = 1')->where('c.access    IN (' . $authorisedViewLevels . ')')->where('c.hidden    = 0')->order('a.imgdate DESC');
         if (!($rows = $this->_getList($query, 0, $limit))) {
             return false;
         }
         $this->_allimages = $rows;
     }
     return true;
 }
Esempio n. 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->_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);
 }
Esempio n. 11
0
 /**
  * Loads the data of all available categories from the database
  * and checks whether the categories are empty.
  * This method stores only the categories which aren't empty after that.
  *
  * @return  boolean True on success, false otherwise
  * @since   1.5.7
  */
 private function _loadCategoriesWithoutEmpty()
 {
     // Let's load the data if it doesn't already exist
     if (empty($this->_categorieswithoutempty)) {
         $query = $this->_buildQuery();
         if (!($cats = $this->_getList($query))) {
             return false;
         }
         foreach ($cats as $key => $cat) {
             // Get all sub-categories for each category which contain images
             $show_all = $this->_config->get('jg_showrestrictedcats');
             $subcategories = JoomHelper::getAllSubCategories($cat->cid, true, false, $show_all);
             if (!count($subcategories)) {
                 unset($cats[$key]);
             }
         }
         $this->_categorieswithoutempty = $cats;
         $this->_totalwithoutempty = count($cats);
     }
     return true;
 }
Esempio n. 12
0
 /**
  * Checks images of category and possibly sub-categories
  * and calls checkNew() to decide if NEW
  *
  * @param   string  $catids_values  IDs of categories ('x,y')
  * @return  string  HTML output of the new icon or empty string
  * @since   1.0.0
  */
 public static function checkNewCatg($cid)
 {
     $config = JoomConfig::getInstance();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $isnewcat = '';
     // Get all sub-categories including the current category
     $catids = JoomHelper::getAllSubCategories($cid, true);
     if (count($catids)) {
         // Implode array to a comma separated string if more than one element in array
         $catid_values = implode(',', $catids);
         // Search in db the categories in $catids_values
         $query = $db->getQuery(true)->select('MAX(imgdate)')->from(_JOOM_TABLE_IMAGES . ' AS a')->leftJoin(_JOOM_TABLE_CATEGORIES . ' AS c ON c.cid = a.catid')->where('a.catid IN (' . $catid_values . ')');
         $db->setQuery($query);
         $maxdate = $db->loadResult();
         if ($db->getErrorNum()) {
             JError::raiseWarning(500, $db->getErrorMsg());
         }
         // If maxdate = NULL no image found
         // Otherwise check the date to 'new'
         if ($maxdate) {
             $isnewcat = JoomHelper::checkNew($maxdate, $config->get('jg_catdaysnew'));
         }
     }
     // If no new found at all
     // Return empty string
     return $isnewcat;
 }
Esempio n. 13
0
 /**
  * Called by the framework to get search results.
  *
  * @param    string    $text     Search pattern
  * @param    string    $phrase   Additional search criteria (exact, any, all)
  * @param    string    $ordering Additional search criteria for sorting results
  * @param    array     $areas    Areas to search in
  * @return   array     $rows     An array of search results
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     // Check, if search string is not empty
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     // Check, if JoomGallery is within the selected search areas
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     if (defined('_JG_SEARCH_DEBUG')) {
         $this->p->mark('SQL-Start');
     }
     // We need all allowed categories for this user to check category inheritance
     $allowed_cids = implode(',', array_keys($this->_jg_interface->getAmbit()->getCategoryStructure()));
     // Get allowed viewlevels for this user
     $authorisedViewLevels = implode(',', $user->getAuthorisedViewLevels());
     if (defined('_JG_SEARCH_DEBUG')) {
         $this->firephp->log($allowed_cids, 'allowed_cids');
     }
     if (empty($allowed_cids) || empty($authorisedViewLevels)) {
         return array();
     }
     $aliases = array('images' => 'jg', 'categories' => 'jgc');
     $this->plugins = JDispatcher::getInstance()->trigger('onJoomSearch', array($text, $aliases));
     switch ($this->_search_mode) {
         // Search mode is 'images'
         case 0:
         default:
             $imgquery = $db->getQuery(true)->select('jg.id, jg.catid, jg.imgtitle, jg.imgauthor, jg.imgtext, jg.hits')->select('jg.imgfilename, jg.imgthumbname, jg.owner AS imgowner')->select('jg.imgdate AS created, @is_comment:=0 AS iscomment')->select('jgc.cid, jgc.name, jgc.description, jgc.thumbnail, jgc.catpath')->select('@cmtid as cmtid, @cmtpic as cmtpic, @cmttext as cmttext')->select('u.name AS uname, u.username AS uusername')->from(_JOOM_TABLE_IMAGES . ' AS jg')->leftJoin(_JOOM_TABLE_CATEGORIES . ' AS jgc ON jg.catid = jgc.cid')->leftJoin('#__users AS u ON jg.owner = u.id');
             foreach ($this->plugins as $plugin) {
                 if (isset($plugin['images.leftjoin'])) {
                     $imgquery->leftJoin($plugin['images.leftjoin']);
                 }
             }
             $imgquery->where('(' . $this->getWhereClause($text, $phrase) . ')')->where('jg.published = 1')->where('jg.approved = 1')->where('jg.access IN (' . $authorisedViewLevels . ')')->where('jgc.published = 1')->where('jgc.exclude_search = 0')->where('jgc.cid IN (' . $allowed_cids . ')')->where('jgc.access IN (' . $authorisedViewLevels . ')');
             if (!$this->_search_hidden) {
                 $imgquery->where('jgc.hidden = 0')->where('jgc.in_hidden = 0')->where('jg.hidden = 0');
             }
             if (isset($this->_search_categories)) {
                 $imgquery->where('jgc.cid IN (' . implode(',', $this->_search_categories) . ')');
             }
             foreach ($this->plugins as $plugin) {
                 if (isset($plugin['images.where'])) {
                     $imgquery->where($plugin['images.where']);
                 }
             }
             $imgquery->group('jg.id');
             if ($this->_search_img_comment == 1) {
                 $cmtquery = $db->getQuery(true)->select('jg.id, jg.catid, jg.imgtitle, jg.imgauthor, jg.imgtext, jg.hits')->select('jg.imgfilename, jg.imgthumbname, jg.owner AS imgowner')->select('jg.imgdate AS created, @is_comment:=1 AS iscomment')->select('jgc.cid, jgc.name, jgc.description, jgc.thumbnail, jgc.catpath')->select('@cmtid as cmtid, @cmtpic as cmtpic, @cmttext as cmttext')->select('u.name AS uname, u.username AS uusername')->from(_JOOM_TABLE_COMMENTS . ' AS jgco')->leftJoin(_JOOM_TABLE_IMAGES . ' AS jg ON jgco.cmtpic = jg.id')->leftJoin(_JOOM_TABLE_CATEGORIES . ' AS jgc ON jg.catid = jgc.cid')->leftJoin('#__users AS u ON jg.owner = u.id')->where('(' . $this->getWhereClause($text, $phrase, true) . ')')->where('jg.published = 1')->where('jg.approved = 1')->where('jg.access IN (' . $authorisedViewLevels . ')')->where('jgc.published = 1')->where('jgc.exclude_search = 0')->where('jgc.cid IN (' . $allowed_cids . ')')->where('jgc.access IN (' . $authorisedViewLevels . ')')->where('jgco.published = 1')->where('jgco.approved  = 1');
                 if (!$this->_search_hidden) {
                     $cmtquery->where('jgc.hidden = 0')->where('jgc.in_hidden = 0')->where('jg.hidden = 0');
                 }
                 if (isset($this->_search_categories)) {
                     $cmtquery->where('jgc.cid IN (' . implode(',', $this->_search_categories) . ')');
                 }
                 // Comment following line to get all comments for a single image containing the search pattern
                 $cmtquery->group('jg.id');
                 // Combine images and comments query
                 // Not working yet, unionAll() seems to be still buggy
                 /*
                 $query = $db->getQuery(true)
                       ->unionAll($imgquery)
                       ->unionAll($cmtquery)
                       ->order($this->getOrderByClause($ordering));
                 */
                 $query = '(' . $imgquery->__toString() . ')' . ' UNION ALL (' . $cmtquery->__toString() . ') ORDER BY ' . $this->getOrderByClause($ordering);
             } else {
                 $imgquery->order($this->getOrderByClause($ordering));
                 $query = $imgquery;
             }
             break;
             // Search mode is 'categories'
         // Search mode is 'categories'
         case 1:
             $query = $db->getQuery(true)->select('jgc.cid, jgc.name, jgc.description, jgc.thumbnail, jgc.catpath')->select('jgc.owner AS catowner, jgc.level, jg.id, jg.catid, jg.imgtitle')->select('jg.imgauthor, jg.imgtext, jg.hits, jg.imgfilename, jg.imgthumbname')->select('u.name AS uname, u.username AS uusername')->from(_JOOM_TABLE_CATEGORIES . ' AS jgc')->leftJoin(_JOOM_TABLE_IMAGES . ' AS jg ON jgc.thumbnail = jg.id')->leftJoin('#__users AS u ON jgc.owner = u.id');
             foreach ($this->plugins as $plugin) {
                 if (isset($plugin['categories.leftjoin'])) {
                     $query->leftJoin($plugin['categories.leftjoin']);
                 }
             }
             $query->where('(' . $this->getWhereClause($text, $phrase, false, 'categories') . ')')->where('(jg.published = 1 OR ISNULL(jg.published))')->where('(jg.approved = 1 OR ISNULL(jg.approved))')->where('(jg.access IN (' . $authorisedViewLevels . ') OR ISNULL(jg.access))')->where('jgc.published = 1')->where('jgc.exclude_search = 0')->where('jgc.cid IN (' . $allowed_cids . ')')->where('jgc.access IN (' . $authorisedViewLevels . ')');
             if (!$this->_search_hidden) {
                 $query->where('jgc.hidden = 0')->where('jgc.in_hidden = 0');
             }
             if (isset($this->_search_categories)) {
                 $query->where('jgc.cid IN (' . implode(',', $this->_search_categories) . ')');
             }
             foreach ($this->plugins as $plugin) {
                 if (isset($plugin['categories.where'])) {
                     $query->where($plugin['categories.where']);
                 }
             }
             $query->group('jgc.cid')->order($this->getOrderByClause($ordering));
             break;
     }
     if (defined('_JG_SEARCH_DEBUG')) {
         if ($query instanceof JDatabaseQuery) {
             $this->firephp->log($query->__toString(), 'Query');
         } else {
             $this->firephp->log($query, 'Query');
         }
     }
     // Limit the result list
     if ($this->_search_limit > 0) {
         $db->setQuery($query, 0, $this->_search_limit);
     } else {
         $db->setQuery($query);
     }
     // Get the result list from database
     if (is_null($rows = $db->loadObjectList())) {
         return array();
     }
     if (defined('_JG_SEARCH_DEBUG')) {
         $this->p->mark('SQL-End');
     }
     // Load JoomGallery's styles
     $this->_jg_interface->getPageHeader();
     $initThumbQuery = true;
     foreach ($rows as $key => $row) {
         $rows[$key]->text = '';
         switch ($this->_search_mode) {
             // Search mode is images
             case 0:
             default:
                 $rows[$key]->title = $row->imgtitle;
                 $rows[$key]->href = $this->_jg_interface->getImageLink($row);
                 if ($this->_search_tmpl_overwrite == 1) {
                     $rows[$key]->joomgallerypicture = $this->_jg_interface->displayThumb($row, true, null, null, null, false);
                     $rows[$key]->joomgallerypicture = str_replace(' class="jg_catelem_photo"', '', $rows[$key]->joomgallerypicture);
                 }
                 break;
                 // Search mode is categories
             // Search mode is categories
             case 1:
                 $rows[$key]->title = $row->name;
                 $rows[$key]->href = JRoute::_('index.php?option=com_joomgallery&view=category&catid=' . $row->cid . $this->_jg_interface->getJoomId());
                 $rows[$key]->created = 0;
                 if ($this->_search_tmpl_overwrite == 1 && ($this->_jg_interface->getJConfig('jg_showcatthumb') > 0 && $row->level == 1 || $this->_jg_interface->getJConfig('jg_showsubthumbs') > 0 && $row->level > 1)) {
                     // A thumb should be shown
                     if ($row->thumbnail && $row->id && (($this->_jg_interface->getJConfig('jg_showcatthumb') == 2 || $this->_jg_interface->getJConfig('jg_showcatthumb') == 3) && $row->level == 1 || ($this->_jg_interface->getJConfig('jg_showsubthumbs') == 1 || $this->_jg_interface->getJConfig('jg_showsubthumbs') == 3) && $row->level > 1)) {
                         // Manual setting of category thumb
                         $rows[$key]->joomgallerypicture = $this->_jg_interface->displayThumb($row, true, null, null, null, false);
                     } else {
                         if (defined('_JG_SEARCH_DEBUG')) {
                             $this->p->mark('SubCats Start');
                         }
                         $allsubcats = JoomHelper::getAllSubCategories($row->cid, true, true, false, !$this->_search_hidden);
                         if (!empty($allsubcats)) {
                             if (defined('_JG_SEARCH_DEBUG')) {
                                 $this->p->mark('GetPic Start');
                             }
                             if ($initThumbQuery) {
                                 if ($query instanceof JDatabaseQuery) {
                                     $query->clear();
                                 } else {
                                     $query = $db->getQuery(true);
                                 }
                                 $query->select('jg.id, jg.catid, jg.imgtitle, jg.imgauthor, jg.imgtext, jg.hits, jg.imgfilename')->select('jg.imgthumbname, jg.imgdate AS created, jgc.cid, jgc.catpath')->from(_JOOM_TABLE_IMAGES . ' AS jg')->leftJoin(_JOOM_TABLE_CATEGORIES . ' AS jgc ON jg.catid = jgc.cid')->order($this->getOrderByClause($ordering, 0));
                                 $initThumbQuery = false;
                             }
                             $query->clear('where')->where('jg.catid IN (' . implode(',', $allsubcats) . ')')->where('jg.published = 1')->where('jg.approved = 1')->where('jg.access IN (' . $authorisedViewLevels . ')');
                             if (!$this->_search_hidden) {
                                 $query->where('jgc.hidden = 0')->where('jgc.in_hidden = 0')->where('jg.hidden = 0');
                             }
                             $db->setQuery($query, 0, 1);
                             $image_row = $db->loadObject();
                             if (defined('_JG_SEARCH_DEBUG')) {
                                 $this->p->mark('GetPic End');
                             }
                             if (isset($image_row)) {
                                 $rows[$key]->joomgallerypicture = $this->_jg_interface->displayThumb($image_row, true, null, null, null, false);
                             }
                         }
                     }
                     if (isset($rows[$key]->joomgallerypicture)) {
                         $rows[$key]->joomgallerypicture = str_replace(' class="jg_catelem_photo"', '', $rows[$key]->joomgallerypicture);
                     }
                 }
                 break;
         }
         $rows[$key]->section = JText::_('COM_JOOMGALLERY_COMMON_GALLERY') . ' / ' . $row->name;
         if ($this->_search_img_author == 1 && !empty($row->imgauthor)) {
             $rows[$key]->text .= JText::sprintf('COM_JOOMGALLERY_COMMON_AUTHOR_VAR', $row->imgauthor);
         }
         if ($this->_search_img_owner == 1 && !empty($row->imgowner)) {
             $rows[$key]->text .= !empty($rows[$key]->text) ? ' - ' : '';
             $rows[$key]->text .= JText::sprintf('PLG_SEARCH_JOOMGALLERY_OWNER_VAR', $this->_jg_interface->getJConfig('jg_realname') ? $row->uname : $row->uusername);
         }
         if ($this->_search_img_description == 1 && !empty($row->imgtext) && $row->iscomment == 0) {
             $rows[$key]->text .= !empty($rows[$key]->text) ? ' - ' : '';
             $rows[$key]->text .= JText::sprintf('COM_JOOMGALLERY_COMMON_DESCRIPTION_VAR', $row->imgtext);
         }
         if ($this->_search_img_comment == 1 && !empty($row->cmttext) && $row->iscomment == 1) {
             $rows[$key]->text .= !empty($rows[$key]->text) ? ' - ' : '';
             $rows[$key]->text .= JText::sprintf('COM_JOOMGALLERY_COMMON_COMMENTS_VAR', $this->cleantext($row->cmttext));
         }
         if ($this->_search_cat_owner == 1 && !empty($row->catowner)) {
             $rows[$key]->text .= !empty($rows[$key]->text) ? ' - ' : '';
             $rows[$key]->text .= JText::sprintf('PLG_SEARCH_JOOMGALLERY_OWNER_VAR', $this->_jg_interface->getJConfig('jg_realname') ? $row->uname : $row->uusername);
         }
         if ($this->_search_cat_description == 1 && !empty($row->description)) {
             $rows[$key]->text .= !empty($rows[$key]->text) ? ' - ' : '';
             $rows[$key]->text .= JText::sprintf('COM_JOOMGALLERY_COMMON_DESCRIPTION_VAR', $row->description);
         }
         $rows[$key]->browsernav = 2;
     }
     if (defined('_JG_SEARCH_DEBUG')) {
         $this->p->mark('SCRIPT-END');
         $this->firephp->log($this->p->getBuffer(), 'Profiler');
     }
     return $rows;
 }