/** * HTML view display method * * @param string $tpl The name of the template file to parse * @return void * @since 1.5.5 */ public function display($tpl = null) { $params = $this->_mainframe->getParams(); // Header and footer JoomHelper::prepareParams($params); $backtarget = JRoute::_('index.php?view=gallery'); //see above $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY'); // Get number of images and hits in gallery $numbers = JoomHelper::getNumberOfImgHits(); // Load modules at position 'top' $modules['top'] = JoomHelper::getRenderedModules('top'); if (count($modules['top'])) { $params->set('show_top_modules', 1); } // Load modules at position 'btm' $modules['btm'] = JoomHelper::getRenderedModules('btm'); if (count($modules['btm'])) { $params->set('show_btm_modules', 1); } $type = JRequest::getCmd('type'); switch ($type) { case 'lastcommented': $rows = $this->get('LastCommented'); $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_LAST_COMMENTED_IMAGE', $this->_config->get('jg_toplist')); $pathway = $title; break; case 'lastadded': $rows = $this->get('LastAdded'); $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_LAST_ADDED_IMAGE', $this->_config->get('jg_toplist')); $pathway = $title; break; case 'toprated': $rows = $this->get('TopRated'); $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_BEST_RATED_IMAGE', $this->_config->get('jg_toplist')); $pathway = $title; break; default: $rows = $this->get('MostViewed'); $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_MOST_VIEWED_IMAGE', $this->_config->get('jg_toplist')); $pathway = $title; break; } // Check whether this is the active menu item. This is a // special case in addition to code in constructor of parent class // because here we have to check the toplist type, too. if ($type == 'lastcommented' || $type == 'lastadded' || $type == 'toprated') { $active = $this->_mainframe->getMenu()->getActive(); if (!$active || strpos($active->link, '&type=' . $type) === false) { // Get the default layout from the configuration if ($layout = $this->_config->get('jg_alternative_layout')) { $this->setLayout($layout); } } } // Breadcrumbs if ($this->_config->get('jg_completebreadcrumbs')) { $breadcrumbs = $this->_mainframe->getPathway(); $breadcrumbs->addItem($title); } // Check whether the (comments) data rows where delivered by a plugin if (isset($rows[0]->delivered_by_plugin) && $rows[0]->delivered_by_plugin) { $params->set('delivered_by_plugin', 1); } foreach ($rows as $key => $row) { $rows[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $row); $cropx = null; $cropy = null; $croppos = null; if ($this->_config->get('jg_dyncrop')) { $cropx = $this->_config->get('jg_dyncropwidth'); $cropy = $this->_config->get('jg_dyncropheight'); $croppos = $this->_config->get('jg_dyncropposition'); } $rows[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos); // Set the title attribute in a tag with title and/or description of image // if a box is activated if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) { $rows[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $row); } else { // Set the imgtitle by default $rows[$key]->atagtitle = 'title="' . $row->imgtitle . '"'; } if ($this->_config->get('jg_showauthor')) { if ($row->imgauthor) { $rows[$key]->authorowner = $row->imgauthor; } else { if ($this->_config->get('jg_showowner')) { $rows[$key]->authorowner = JHTML::_('joomgallery.displayname', $row->owner); } else { $rows[$key]->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA'); } } } if (!$params->get('delivered_by_plugin')) { if ($type == 'lastcommented' && $this->_config->get('jg_showthiscomment')) { if ($row->userid) { $rows[$key]->cmtname = JHTML::_('joomgallery.displayname', $row->userid, false); } $cmttext = $row->cmttext; $cmttext = JoomHelper::processText($cmttext); if ($this->_config->get('jg_bbcodesupport')) { $cmttext = JHTML::_('joomgallery.bbdecode', $cmttext); } if ($this->_config->get('jg_smiliesupport')) { $smileys = JoomHelper::getSmileys(); foreach ($smileys as $i => $sm) { $cmttext = str_replace($i, '<img src="' . $sm . '" border="0" alt="' . $i . '" title="' . $i . '" />', $cmttext); } } $cmttext = stripslashes($cmttext); $rows[$key]->processed_cmttext = $cmttext; } } // Show editor links for that image $rows[$key]->show_edit_icon = false; $rows[$key]->show_delete_icon = false; if ($this->_config->get('jg_showtoplisteditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) { if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $rows[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $rows[$key]->id) && $rows[$key]->owner && $rows[$key]->owner == $this->_user->get('id')) { $rows[$key]->show_edit_icon = true; } if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $rows[$key]->id)) { $rows[$key]->show_delete_icon = true; } } } // Download Icon if ($this->_config->get('jg_download') && $this->_config->get('jg_showtoplistdownload')) { if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) { $params->set('show_download_icon', 1); } else { if ($this->_config->get('jg_download_hint')) { $params->set('show_download_icon', -1); } } } // Favourites icon if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites') && $this->_config->get('jg_showtoplistfavourite')) { if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) { if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) { $params->set('show_favourites_icon', 2); } else { $params->set('show_favourites_icon', 1); } } else { if ($this->_config->get('jg_favouritesshownotauth') == 1) { if ($this->_config->get('jg_usefavouritesforzip')) { $params->set('show_favourites_icon', -2); } else { $params->set('show_favourites_icon', -1); } } } } // Report icon if ($this->_config->get('jg_report_images') && $this->_config->get('jg_toplist_report_images')) { if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) { $params->set('show_report_icon', 1); JHTML::_('behavior.modal'); } else { if ($this->_config->get('jg_report_hint')) { $params->set('show_report_icon', -1); } } } // Set redirect url used in editor links to redirect back to favourites view after edit/delete $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString()); $this->assignRef('params', $params); $this->assignRef('rows', $rows); $this->assignRef('title', $title); $this->assignRef('type', $type); $this->assignRef('pathway', $pathway); $this->assignRef('modules', $modules); $this->assignRef('backtarget', $backtarget); $this->assignRef('backtext', $backtext); $this->assignRef('numberofpics', $numbers[0]); $this->assignRef('numberofhits', $numbers[1]); $this->assignRef('redirect', $redirect); parent::display($tpl); }
/** * 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> » '; foreach ($parents as $parent) { $pathway .= '<a href="' . JRoute::_('index.php?view=category&catid=' . $parent->cid) . '" class="jg_pathitem">' . $parent->name . '</a> » '; } $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 = ' '; } // 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 = ' '; } // 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 = ' '; } // 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('&', '&', $this->_ambit->getImg('img_url', $row)) . '",//image "' . $this->_ambit->getImg('thumb_url', $row) . '",//thumbnail "' . JoomHelper::fixForJS($row->imgtitle) . '",//linkTitle "' . str_replace('&', '&', $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(/\\&/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) ? '&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('&', '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('&', '&', $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); }
/** * Decode BB-tags, replace URL and shorten text * * @param $text * @param $newlength * @param $wrap * @param $more */ function decodetext($text, $newlength = 0, $wrap = 0, $more = 0) { // Remove whitespace at start and end of the text $text = trim($text); $newlength = $newlength != 0 ? $newlength - 1 : 0; $smileys = JoomHelper::getSmileys(); // Define replace tags $replace1 = array('[url]', '[/url]', '[email]', '[/email]'); $replace21 = array('[b]', '[i]', '[u]'); $replace22 = array('[/b]', '[/i]', '[/u]'); $replace2 = array_merge($replace21, $replace22); $replace3 = array('<b>', '<i>', '<u>', '</b>', '</i>', '</u>'); // Replace url and emailtags because we do not show them in our modules foreach ($replace1 as $replace) { $text = str_replace($replace, '', $text); } $textlength = strlen($text); // If text has to be in a range we abridge him if ($newlength > 0 && $newlength < $textlength) { $add = ''; // Replace simple html-tags with bb_code for ($i = 0; $i < count($replace3); $i++) { $text = str_replace($replace3[$i], $replace2[$i], $text); } // Replace smilies with shorttags or remove them if ($this->getJConfig('jg_smiliesupport')) { $count = 0; $smileshort = array(); foreach ($smileys as $i => $sm) { $text = str_replace($i, '{' . $count . '}', $text); $smileshort[$count]['short'] = $i; $smileshort[$count]['long'] = $sm; $count++; } } else { foreach ($smiley as $i => $sm) { $text = str_replace($i, "", $text); } } $textlength = strlen($text); } // Remove any html because it is too complicated to handle them if ($wrap > 0) { $text = strip_tags($text); $textlength = strlen($text); if ($wrap > 0 && $textlength > $wrap) { $text = wordwrap($text, $wrap, '<br />', true); } } // If wrap is activated count the containing <br /> // and add their length to $newlength if ($wrap > 0) { $countbrstr = substr($text, 0, $newlength); // Count the <br /> $countbr = substr_count($countbrstr, '<br />'); if ($countbr > 0) { $newlength = $newlength + $countbr * 6; } } $textlength = strlen($text); // Slice if needful if ($newlength != 0 && $textlength > $newlength + 1) { // Check a sliced <br /> if ($textlength - 6 > 0 && $newlength - 6 > 0) { $strposfound = strpos($text, '<br />', $newlength - 6); } else { $strposfound = 0; } if ($strposfound > 0 && $strposfound < $newlength) { // Slice before the begin of the <br /> $newlength = $strposfound; } else { // Check a sliced bbcode tag and shorten newlength foreach ($replace2 as $replace) { $replacelength = strlen($replace); if ($textlength > $newlength - $replacelength && $newlength - $replacelength > 0) { $strposfound = strpos($text, $replace, $newlength - $replacelength); } else { $strposfound = 0; } if ($strposfound > 0 && $strposfound < $newlength) { $newlength = $strposfound; break; } } // Check a sliced smilie tag and shorten newlength if (isset($smileshort)) { for ($i = 0; $i < count($smileshort); $i++) { $replacelength = strlen($i) + 2; if ($textlength > $newlength - $replacelength && $newlength - $replacelength > 0) { $strposfound = strpos($text, "{" . $i . "}", $newlength - $replacelength); } else { $strposfound = 0; } if ($strposfound > 0 && $strposfound < $newlength) { $newlength = $strposfound; break; } } } } // Slice the text $text = substr($text, 0, $newlength); } // Adding mising tags at the end of the text if ($this->getJConfig('jg_bbcodesupport')) { $prioarr = array(); // Build an array for the priority in replacing $countreplace = count($replace21); for ($i = 0; $i < $countreplace; $i++) { // Check if there is an unbalance // of opening and closing tags $countopen = substr_count($text, $replace21[$i]); $countclose = substr_count($text, $replace22[$i]); $diff = $countopen - $countclose; $found = -1; while ($diff > 0) { $found = strpos($text, $replace21[$i], $found + 1); // Add the closing tag $prioarr[$found] = $replace22[$i]; $diff--; } } if (count($prioarr)) { // Reverse the array to begin with the last element arsort($prioarr); foreach ($prioarr as $key => $value) { $add .= $value; } } } // Abridge text and add missing tags if (!empty($add)) { $text = $text . $add; } // If text was sliced add the ellipsis if ($newlength > 0 && $textlength > $newlength && $more == 0) { $text .= "..."; } // Decode bb_code or remove tags if ($this->getJConfig('jg_bbcodesupport')) { $text = JHTML::_('joomgallery.bbdecode', $text); } else { foreach ($replace2 as $replace) { $text = str_replace($replace, "", $text); } } // Decode smilies or remove them if ($this->getJConfig('jg_smiliesupport')) { foreach ($smileys as $i => $sm) { $text = str_replace($i, '<img src="' . $sm . '"' . ' alt="' . $i . '" />', $text); } if (isset($smileshort)) { for ($i = 0; $i < count($smileshort); $i++) { $text = str_replace('{' . $i . '}', '<img src="' . $smileshort[$i]['long'] . '" border="0" alt="' . $smileshort[$i]['short'] . '" title="' . $smileshort[$i]['short'] . '" />', $text); } } } else { foreach ($smileys as $i => $sm) { $text = str_replace($i, "", $text); } if (isset($smileshort)) { for ($i = 0; $i < count($smileshort); $i++) { $text = str_replace('{' . $i . '}', '', $text); } } } return $text; }
/** * Function to clean strings from smilies and bbCode. * * @param string $text * @return string $text cleaned text */ private function cleantext($text) { // Remove whitespace at start and end of the text $text = trim($text); $smiley = JoomHelper::getSmileys(); // Removing smilies foreach ($smiley as $i => $sm) { $text = str_replace($i, '', $text); } // Remove BBCode $BBCodes = array('[url]', '[/url]', '[email]', '[/email]', '[b]', '[i]', '[u]', '[/b]', '[/i]', '[/u]', '[URL]', '[/URL]', '[EMAIL]', '[/EMAIL]', '[B]', '[I]', '[U]', '[/B]', '[/I]', '[/U]'); foreach ($BBCodes as $replace) { $text = str_replace($replace, '', $text); } // Getting rid of further html code is done by the search component return $text; }