function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params) { $lnkAttrs['rel'] = 'prettyPhoto'; if ($group) { $lnkAttrs['rel'] .= '[' . $group . ']'; } $link = $lnkAttrs['href']; if ($this->isLink($link)) { $uri = new JURI($link); $uri->setVar('iframe', 'true'); if (!$uri->getVar('height')) { $uri->setVar('height', intval($params->get('lightbox_height'), 10)); } else { $height = $uri->getVar('height'); $uri->delVar('height'); $uri->setVar('height', $height); } if (!$uri->getVar('width')) { $uri->setVar('width', intval($params->get('lightbox_width'), 10)); } else { $width = $uri->getVar('width'); $uri->delVar('width'); $uri->setVar('width', $width); } $lnkAttrs['href'] = $uri->toString(); } return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params); }
static function _($plainURL) { $config = JFactory::getConfig(); $addSuffix = $config->get('sef_suffix', 0) == 1; $url = JRoute::_($plainURL); if ($addSuffix) { $uri = new JURI($plainURL); $format = $uri->getVar('format', 'html'); $format = strtolower($format); if (!in_array($format, array('html', 'raw'))) { // Save any query parameters if (strstr($url, '?')) { list($url, $qparams) = explode('?', $url, 2); $qparams = '?' . $qparams; } else { $qparams = ''; } // Remove the suffix $basename = basename($url); $exploded = explode(".", $basename); $extension = end($exploded); $realbase = basename($url, '.' . $extension); $url = str_replace($basename, $realbase, $url) . $qparams; // Add a format parameter $uri = new JURI($url); $uri->setVar('format', $format); $url = $uri->toString(); } } return $url; }
/** * * Ajax render to store in session */ public function ajaxGetRender() { /** load libraries for the system rener **/ JSNFactory::localimport('libraries.joomlashine.mode.rawmode'); JSNFactory::localimport('libraries.joomlashine.menu.menuitems'); /** get url **/ $render_url = JRequest::getVar('render_url', ''); $urlRender = base64_decode($render_url); $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin')); if ($render_url == '') { $urlRender = JSNDatabase::getDefaultPage()->link; } $currUri = new JURI($urlRender); if (!$currUri->hasVar('Itemid')) { $currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id); } $urlString = $currUri->toString(); $session->set('rawmode_render_url', base64_encode($urlString)); $parts = JString::parse_url($urlString); if (!empty($parts['query'])) { parse_str($parts['query'], $params); } else { $params = array(); } $jsntemplate = JSNFactory::getTemplate(); $jsnrawmode = JSNRawmode::getInstance($params); $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions()); $jsnrawmode->renderAll(); $session = JSession::getInstance('files', array('name' => 'jsnajaxgetrender')); $session->set('component', $jsnrawmode->getHTML('component')); $session->set('jsondata', $jsnrawmode->getScript('positions', 'JSON')); jexit('success'); }
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params) { $lnkAttrs['rel'] = 'sexylightbox'; if ($group) { $lnkAttrs['rel'] .= '[' . $group . ']'; } $link = $lnkAttrs['href']; $bgColor = $params->get('lightbox_bgColor'); if ($this->isLink($link)) { $uri = new JURI($link); $uri->setVar('TB_iframe', 'true'); $uri->setVar('height', intval($params->get('lightbox_height'), 10)); $uri->setVar('width', intval($params->get('lightbox_width'), 10)); if ($bgColor) { $uri->setVar('background', $bgColor); } $lnkAttrs['href'] = $uri->toString(); } else { if ($bgColor) { $uri = new JURI($link); $uri->setVar('background', $bgColor); $lnkAttrs['href'] = $uri->toString(); } } return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params); }
public static function getUri($layout = null) { $uri = new JURI('index.php?option=com_kunena&view=announcement'); if ($layout) { $uri->setVar('layout', $layout); } return $uri; }
public function testSetVar() { $this->object->setVar('somevar', 'somevalue'); $this->assertThat( $this->object->getVar('somevar'), $this->equalTo('somevalue') ); }
function getBlogItemLink($item) { if ($item->params->get('access-view')) { $link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language)); } else { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId); $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language)); $link = new JURI($link1); $link->setVar('return', base64_encode(urlencode($returnURL))); } return $link; }
function getObjectInfo($id, $language = null) { $db = JFactory::getDBO(); $article = null; $link = null; require_once JPATH_ROOT . '/components/com_content/helpers/route.php'; $query = $db->getQuery(true); // Select the required fields from the table. $query->select('a.id, a.title, a.created_by, a.access, a.alias, a.catid, a.language'); $query->from('#__content AS a'); // Join over the categories. $query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias'); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); $query->where('a.id = ' . (int) $id); $db->setQuery($query); $article = $db->loadObject(); if (!empty($article)) { $user = JFactory::getUser(); $article->slug = $article->alias ? $article->id . ':' . $article->alias : $article->id; $article->catslug = $article->category_alias ? $article->catid . ':' . $article->category_alias : $article->catid; $authorised = JAccess::getAuthorisedViewLevels($user->get('id')); $checkAccess = in_array($article->access, $authorised); if ($checkAccess) { $link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language)); } else { $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language)); $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $ItemId = $active->id; $link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $ItemId); $uri = new JURI($link); $uri->setVar('return', base64_encode($returnURL)); $link = $uri->toString(); } } $info = new JCommentsObjectInfo(); if (!empty($article)) { $info->category_id = $article->catid; $info->title = $article->title; $info->access = $article->access; $info->userid = $article->created_by; $info->link = $link; } return $info; }
public static function _($uri = null, $xhtml = true, $ssl = 0) { jimport('joomla.environment.uri'); if (!$uri) { $link = self::current(true); $link->delVar('Itemid'); $link->delVar('defaultmenu'); $link->delVar('language'); } else { if (is_numeric($uri)) { $item = self::$menu[intval($uri)]; return JRoute::_($item->link . "&Itemid={$item->id}"); } else { $link = new JURI((string) $uri); } } $query = $link->getQuery(true); $Itemid = self::_getItemID($query); $link->setVar('Itemid', $Itemid); return JRoute::_('index.php?' . $link->getQuery(), $xhtml, $ssl); }
protected function __construct($component, $componentParams, $article, $articleParams) { parent::__construct($component, $componentParams, $article, $articleParams); $this->isPublished = 0 != $this->_article->state; $this->titleLink = $this->_articleParams->get('link_titles') && $this->_articleParams->get('access-view') ? JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid)) : ''; $this->intro = $this->_article->introtext; if ($this->_articleParams->get('show_readmore') && $this->_article->readmore) { if (!$this->_articleParams->get('access-view')) { $this->readmore = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE'); } elseif ($this->readmore = $this->_article->alternative_readmore) { if ($this->_articleParams->get('show_readmore_title', 0) != 0) { $this->readmore .= JHtml::_('string.truncate', $this->_article->title, $this->_articleParams->get('readmore_limit')); } } elseif ($this->_articleParams->get('show_readmore_title', 0) == 0) { $this->readmore = JText::sprintf('COM_CONTENT_READ_MORE_TITLE'); } else { $this->readmore = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $this->_article->title, $this->_articleParams->get('readmore_limit')); } if ($this->_articleParams->get('access-view')) { $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid)); $this->readmoreLink = $link; } else { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId); $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid)); $link = new JURI($link1); $link->setVar('return', base64_encode($returnURL)); $this->readmoreLink = $link->__toString(); } } else { $this->readmore = ''; $this->readmoreLink = ''; } }
protected static function getRoute($view = 'search', $additionalFilters = array(), $queryOnly = false) { $uri = new JURI('index.php'); $uri->setVar('option', 'com_jsolrsearch'); $uri->setVar('view', $view); if ($queryOnly) { if (JURI::getInstance()->getVar('q')) { $uri->setVar('q', urlencode(JURI::getInstance()->getVar('q'))); } } else { foreach (JURI::getInstance()->getQuery(true) as $key => $value) { if ($value && $key != 'limitstart' && $key != 'task') { $uri->setVar($key, urlencode($value)); } } } foreach ($additionalFilters as $key => $value) { $uri->setVar($key, urlencode($value)); } if ($item = self::_findItem($view)) { $uri->setVar('Itemid', $item); } return $uri; }
/** * Gets the search url. * * @return JURI The search url. */ public function getURI() { $uri = new JURI("index.php"); $uri->setVar("option", "com_jsolrsearch"); $uri->setVar("view", "search"); $uri->setVar("Itemid", JRequest::getVar('Itemid')); if ($query = $this->buildQuery()) { $uri->setVar('q', urlencode($query)); } if ($this->getState('query.o', null)) { $uri->setVar('o', $this->getState('query.o')); } $vars = array('task', 'nq', 'oq', 'eq', 'aq', 'as'); foreach (JURI::getInstance()->getQuery(true) as $key => $value) { if (array_search($key, $vars) === false && !empty($value)) { $uri->setVar($key, $value); } } // add the filters. foreach (JFactory::getApplication()->input->get('as', array(), 'array') as $key => $value) { if (!empty($value)) { $uri->setVar($key, $value); } } // finally add the Itemid for basic search $uri->setVar('Itemid', \JSolr\Search\Factory::getSearchRoute()->getVar('Itemid')); return $uri; }
function onPrepareContent(&$article, &$params, $limitstart = 0) { require_once (JCOMMENTS_HELPERS . '/content.php'); // check whether plugin has been unpublished if (!JPluginHelper::isEnabled('content', 'jcomments')) { JCommentsContentPluginHelper::clear($article, true); return ''; } $app = JFactory::getApplication('site'); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); if (!isset($article->id) || ($option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories')) { return ''; } if (!isset($params) || $params == null) { jimport('joomla.html.parameter'); $params = new JParameter(''); } else if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) { return ''; } if ($view == 'frontpage' || $view == 'featured') { if ($this->params->get('show_frontpage', 1) == 0) { return ''; } } require_once (JCOMMENTS_BASE . '/jcomments.config.php'); require_once (JCOMMENTS_BASE . '/jcomments.class.php'); JCommentsContentPluginHelper::processForeignTags($article); $config = JCommentsFactory::getConfig(); $categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid); $commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled; $commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled; $commentsLocked = JCommentsContentPluginHelper::isLocked($article); if ($article->state == -1 && $this->params->get('enable_for_archived', 0) == 0) { $commentsLocked = true; } $config->set('comments_on', intval($commentsEnabled)); $config->set('comments_off', intval($commentsDisabled)); $config->set('comments_locked', intval($commentsLocked)); if ($view != 'article') { $user = JFactory::getUser(); if (JCOMMENTS_JVERSION == '1.5') { $checkAccess = $article->access <= $user->get('aid', 0); } else { $authorised = JAccess::getAuthorisedViewLevels($user->get('id')); $checkAccess = in_array($article->access, $authorised); } if ($checkAccess) { require_once(JPATH_ROOT . '/components/com_content/helpers/route.php'); if (JCOMMENTS_JVERSION == '1.5') { $readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid)); } else { $readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid)); } $readmore_register = 0; } else { if (JCOMMENTS_JVERSION == '1.5') { $readmore_link = JRoute::_('index.php?option=com_user&task=register'); } else { $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug)); $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId); $link = new JURI($link1); $link->setVar('return', base64_encode($returnURL)); $readmore_link = $link; } $readmore_register = 1; } // load template for comments & readmore links $tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false); $tmpl->load('tpl_links'); $tmpl->addVar('tpl_links', 'comments_link_style', ($readmore_register ? -1 : 1)); $tmpl->addVar('tpl_links', 'content-item', $article); $tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0))); $readmoreDisabled = false; if (($params->get('show_readmore') == 0) || (@$article->readmore == 0)) { $readmoreDisabled = true; } else if (@$article->readmore > 0) { $readmoreDisabled = false; } if ($this->params->get('readmore_link', 1) == 0) { $readmoreDisabled = true; } $tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled)); // don't fill any readmore variable if it disabled if (!$readmoreDisabled) { if ($readmore_register == 1) { $readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE'); } else if (isset($params) && $readmore = $params->get('readmore')) { $readmore_text = $readmore; } else { $readmore_text = JText::_('LINK_READ_MORE'); } $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link); $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text); $tmpl->addVar('tpl_links', 'link-readmore-title', $article->title); $tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link')); } $commentsDisabled = false; if ($config->getInt('comments_off', 0) == 1) { $commentsDisabled = true; } else if ($config->getInt('comments_on', 0) == 1) { $commentsDisabled = false; } $tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled)); $count = 0; // do not query comments count if comments disabled and link hidden if (!$commentsDisabled) { require_once (JCOMMENTS_MODELS . '/jcomments.php'); $anchor = ""; if ($this->params->get('comments_count', 1) != 0) { $acl = JCommentsFactory::getACL(); $options = array(); $options['object_id'] = (int) $article->id; $options['object_group'] = 'com_content'; $options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1; $count = JCommentsModel::getCommentsCount($options); $tmpl->addVar('tpl_links', 'comments-count', $count); $anchor = $count == 0 ? '#addcomment' : '#comments'; if ($count == 0) { $link_text = JText::_('LINK_ADD_COMMENT'); } else { if (JCOMMENTS_JVERSION == '1.5') { require_once (JCOMMENTS_LIBRARIES.'/joomlatune/language.tools.php'); $lang = JFactory::getLanguage(); $suffix = JoomlaTuneLanguageTools::getPluralSuffix($lang->getTag(), $count); $string = 'LINK_READ_COMMENTS'; $key = $string . '_' . $suffix; if (!$lang->hasKey($key)) { $key = $string; } $link_text = JText::sprintf($key, $count); } else { $link_text = JText::plural('LINK_READ_COMMENTS', $count); } } } else { $link_text = JText::_('LINK_ADD_COMMENT'); } $tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor); $tmpl->addVar('tpl_links', 'link-comment-text', $link_text); $tmpl->addVar('tpl_links', 'link-comments-class', $this->params->get('comments_css_class', 'comments-link')); } JCommentsContentPluginHelper::clear($article, true); // hide comments link if comments enabled but link disabled in plugin params if ((($this->params->get('comments_count', 1) == 0) || ($count == 0 && $this->params->get('add_comments', 1) == 0) || ($count == 0 && $readmore_register == 1)) && !$commentsDisabled) { $tmpl->addVar('tpl_links', 'comments_link_hidden', 1); } //links_position if ($this->params->get('links_position', 1) == 1) { $article->text .= $tmpl->renderTemplate('tpl_links'); } else { $article->text = $tmpl->renderTemplate('tpl_links') . $article->text; } $tmpl->freeTemplate('tpl_links'); if ($this->params->get('readmore_link', 1) == 1) { $article->readmore = 0; $article->readmore_link = ''; $article->readmore_register = false; } } else { if ($this->params->get('show_comments_event') == 'onPrepareContent') { $isEnabled = ($config->getInt('comments_on', 0) == 1) && ($config->getInt('comments_off', 0) == 0); if ($isEnabled && $view == 'article') { require_once (JCOMMENTS_BASE . '/jcomments.php'); $comments = JComments::show($article->id, 'com_content', $article->title); if (strpos($article->text, '{jcomments}') !== false) { $article->text = str_replace('{jcomments}', $comments, $article->text); } else { $article->text .= $comments; } } } JCommentsContentPluginHelper::clear($article, true); } return ''; }
/** * Return JUri object pointing to the Announcement task. * * @param string $layout */ public function getTaskUri($task = null) { $uri = new JURI('index.php?option=com_kunena&view=announcement'); if ($task) { $uri->setVar('task', $task); } if ($this->id) { $uri->setVar('id', $this->id); } if ($task) { $uri->setVar(JUtility::getToken(), 1); } return $uri; }
function _fixLangSwitcher($reqURI) { $isLangFilter = JPluginHelper::isEnabled("system", "languagefilter"); if (!$isLangFilter) { return $reqURI; } $uri = JFactory::getURI(); $app = JFactory::getApplication(); $router = $app->getRouter(); if ($app->isSite()) { // setup language data $mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false; $default_lang = JLanguageHelper::getLanguages('lang_code'); if ($mode_sef) { // Get the route path from the request. $path = JString::substr($uri->toString(), JString::strlen($uri->base())); // Apache mod_rewrite is Off //$path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10); $path = $app->getCfg('sef_rewrite') ? $path : JString::substr($path, 10); // Trim any spaces or slashes from the ends of the path and explode into segments. $path = JString::trim($path, '/ '); $parts = explode('/', $path); // The language segment is always at the beginning of the route path if it exists. $langcode = $uri->getVar('lang'); if (!empty($parts) && empty($langcode)) { $langcode = reset($parts); } //set to default language if (empty($langcode)) { //$langcode = $default_lang; // @since 4.0 we get default language from here $lang = JFactory::getLanguage(); $langcode = $lang->getDefault(); } //append language code to the request $reqURI = $reqURI . '/' . $langcode . '/'; } else { $langcode = $uri->getVar('lang', $default_lang); //append language code to the request $tmpURI = new JURI($reqURI); $tmpURI->setVar('lang', $langcode); $reqURI = $tmpURI->toString(); } } return $reqURI; }
function &getItem($index = 0, &$params) { global $mainframe; // Initialize some variables $user =& JFactory::getUser(); $dispatcher =& JDispatcher::getInstance(); $SiteName = $mainframe->getCfg('sitename'); $task = JRequest::getCmd('task'); $linkOn = null; $linkText = null; $item =& $this->items[$index]; $item->text = $item->introtext; // Get the page/component configuration and article parameters $item->params = clone $params; $aparams = new JParameter($item->attribs); // Merge article parameters into the page configuration $item->params->merge($aparams); // Process the content preparation plugins JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onPrepareContent', array(&$item, &$item->params, 0)); // Build the link and text of the readmore button if ($item->params->get('show_readmore') && @$item->readmore || $item->params->get('link_titles')) { // checks if the item is a public or registered/special item if ($item->access <= $user->get('aid', 0)) { //$item->readmore_link = JRoute::_("index.php?view=article&id=".$item->slug); $item->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid)); $item->readmore_register = false; } else { $item->readmore_link = JRoute::_("index.php?option=com_user&view=login"); $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid), false); $fullURL = new JURI($item->readmore_link); $fullURL->setVar('return', base64_encode($returnURL)); $item->readmore_link = $fullURL->toString(); $item->readmore_register = true; } } $item->event = new stdClass(); $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); return $item; }
static function _($url, $xhtml = false, $ssl = null, $d = false) { // skip any external urls if (strpos($url, "option") !== false && strpos($url, "option=com_fss") === false) { return JRoute::_($url, $xhtml, $ssl); } global $FSSRoute_debug; global $FSSRoute_menus; global $FSSRoute_access; self::$d = $d; // get any menu items for fss FSS_Helper::GetRouteMenus(); // Get the router $router = JFactory::getApplication()->getRouter(); // if the url dont start with index.php, we need to add the exisitng url to what we want if (substr($url, 0, 9) != "index.php") { //echo "Making FUll URL: $url<br>"; $url = self::_fullURL($router, $url); //echo "Resut : $url<br>"; } $uri = new JURI($url); // work out is we are in an Itemid already, if so, set it as the best match if ($uri->hasVar('Itemid')) { $bestmatch = $uri->getVar('Itemid'); } else { $bestmatch = ''; } $bestcount = 0; $uriquery = $uri->toString(array('query')); $urivars = FSSRoute::SplitURL($uriquery); $sourcevars = FSSRoute::SplitURL($url); // check through the menu item for the current url, and add any items to the new url that are missing if ($bestmatch && array_key_exists($bestmatch, $FSSRoute_menus)) { foreach ($FSSRoute_menus[$bestmatch] as $key => $value) { if (!array_key_exists($key, $urivars) && !array_key_exists($key, $sourcevars)) { $urivars[$key] = $value; } } } $current_access = 0; if (array_key_exists(FSS_Input::getInt('Itemid'), $FSSRoute_access)) { $current_access = $FSSRoute_access[FSS_Input::getInt('Itemid')]; } if ($d) { echo "Incoming Link : {$url}<br>"; echo "Cur Item ID : " . FSS_Input::getInt('Itemid') . "<br>"; //print_p($FSSRoute_menus); } foreach ($FSSRoute_menus as $id => $vars) { if ($d) { echo "{$id} => <Br>"; print_p($vars); } // need to check if the access level is the same if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) { if ($d) { echo "No Access<br>"; } continue; } $count = FSSRoute::MatchVars($urivars, $vars); if (FSS_Input::getInt('Itemid') == $id && $count > 0) { if ($d) { echo "Current ItemId: increase count<br>"; } $count++; } if ($d) { echo "Count: {$count}<br>"; } if ($count > $bestcount) { if ($d) { echo "New best match - {$id}<br>"; } $bestcount = $count; $bestmatch = $id; } } if ($bestcount == 0 && array_key_exists('view', $sourcevars) && substr($sourcevars['view'], 0, 6) == "admin_") { foreach ($FSSRoute_menus as $id => $item) { // need to check if the access level is the same if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) { continue; } if ($item['view'] == "admin") { $bestcount = 1; $bestmatch = $id; } } } // no match found, try to fallback on the main support menu id if ($bestcount == 0) { foreach ($FSSRoute_menus as $id => $item) { // need to check if the access level is the same if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) { continue; } if ($item['view'] == "main") { $bestcount = 1; $bestmatch = $id; } } } if ($bestcount == 0) { // still no match found, use any fss menu if (count($FSSRoute_menus) > 0) { foreach ($FSSRoute_menus as $id => $item) { // need to check if the access level is the same if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) { continue; } $bestcount = 1; $bestmatch = $id; break; } } } if ($d) { echo "Best Found : {$bestcount}, {$bestmatch}<br>"; } // sticky menu items if (FSS_Settings::get('sticky_menus_type')) { $cur_item_id = FSS_Input::GetInt("Itemid"); if ($cur_item_id > 0) { $sticky_ids = explode(";", FSS_Settings::get('sticky_menus')); if (FSS_Settings::get('sticky_menus_type') == 1 && in_array($cur_item_id, $sticky_ids) || FSS_Settings::get('sticky_menus_type') == 2 && !in_array($cur_item_id, $sticky_ids)) { $bestcount = 0; $uri->setVar('Itemid', $cur_item_id); } } } if ($bestcount > 0) { $uri->setVar('Itemid', $bestmatch); // we need to remove parameters that are in the main url as well as the sub one // wait till 2.2 for this change as it may break stuff } if ($d) { echo "Using : " . $uri->toString(array('path', 'query', 'fragment')) . "<br>"; } return JRoute::_($uri->toString(array('path', 'query', 'fragment')), $xhtml, $ssl); }
static function append_sid($hook, $url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL; $arrParams = array(); $arrExtra = array(); $anchor = ''; JForumHook::fixPage(); $config =& JFactory::getConfig(); if ($url == '.php') { $url = '/' . $config->getValue('config.phpbb_path') . '/index.php'; } // Assign sid if session id is not specified if ($session_id === false) { $session_id = $_SID; } //Clean the url and the params first if ($is_amp) { $url = str_replace('&', '&', $url); if (!is_array($params)) { $params = str_replace('&', '&', $params); } } $amp_delim = $is_amp ? '&' : '&'; $url_delim = strpos($url, '?') === false ? '?' : $amp_delim; // Process the parameters array if (is_array($params)) { foreach ($params as $key => $item) { if ($item === NULL) { continue; } if ($key == '#') { $anchor = '#' . $item; continue; } $arrParams[$key] = $item; } } else { if (strpos($params, '#') !== false) { list($params, $anchor) = explode('#', $params, 2); $anchor = '#' . $anchor; } parse_str($params, $arrParams); } //Process the extra array if (!empty($_EXTRA_URL)) { $extra = implode('&', $_EXTRA_URL); parse_str($extra, $arrExtra); } //Create the URL $uri = new JURI($url); $query = $uri->getQuery(true); $query = $query + $arrParams + $arrExtra; $uri->setQuery($query); //Set session id variable if ($session_id) { $uri->setVar('sid', $session_id); } //Set fragment if ($anchor) { $uri->setFragment($anchor); } $view = basename($uri->getPath(), '.php'); if (!$uri->getVar('rb_v') && $view != "style") { if (JRequest::getVar('rb_v') == 'adm') { if (strpos($url, $config->getValue('config.phpbb_path')) === false) { $view = 'adm'; } } if (stripos($url, $config->getValue('config.phpbb_path') . '/adm') !== false) { $view = 'adm'; } if ($view != 'index') { $uri->setVar('rb_v', $view); } } if ($view != 'style') { $url = 'index.php' . $uri->toString(array('query', 'fragment')); // {} getting lost in encoding $url = str_replace(array('%7B', '%7D'), array('{', '}'), $url); return urldecode(JURI::base() . JRoute::_($url, $is_amp)); } else { $url = 'style.php' . $uri->toString(array('query', 'fragment')); $url = str_replace(array('%7B', '%7D'), array('{', '}'), $url); return urldecode(JPATH_ROOT . '/' . $config->getValue('config.phpbb_path') . '/' . $url); } }
/** * setVar * * @param $name * @param $value * * @return void */ public function setVar($name, $value) { $this->uri->setVar($name, $value); }
function onPrepareContent(&$article, &$params, $limitstart = 0) { require_once JPATH_ROOT . '/components/com_jcomments/helpers/content.php'; // check whether plugin has been unpublished if (!JPluginHelper::isEnabled('content', 'jcomments')) { JCommentsContentPluginHelper::clear($article, true); return ''; } $app = JFactory::getApplication('site'); $option = $app->input->get('option'); $view = $app->input->get('view'); if (!isset($article->id) || $option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories') { return ''; } if (!isset($params) || $params == null) { $params = new JRegistry(''); } else { if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) { return ''; } } if ($view == 'frontpage' || $view == 'featured') { if ($this->params->get('show_frontpage', 1) == 0) { return ''; } } require_once JPATH_ROOT . '/components/com_jcomments/jcomments.class.php'; JCommentsContentPluginHelper::processForeignTags($article); $config = JCommentsFactory::getConfig(); $categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid); $commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled; $commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled; $commentsLocked = JCommentsContentPluginHelper::isLocked($article); $archivesState = 2; if (isset($article->state) && $article->state == $archivesState && $this->params->get('enable_for_archived', 0) == 0) { $commentsLocked = true; } $config->set('comments_on', intval($commentsEnabled)); $config->set('comments_off', intval($commentsDisabled)); $config->set('comments_locked', intval($commentsLocked)); if ($view != 'article') { $user = JFactory::getUser(); $authorised = JAccess::getAuthorisedViewLevels($user->get('id')); $checkAccess = in_array($article->access, $authorised); $slug = isset($article->slug) ? $article->slug : $article->id; $language = isset($article->language) ? $article->language : 0; require_once JPATH_ROOT . '/components/com_content/helpers/route.php'; if ($checkAccess) { $readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $article->catid, $language)); $readmore_register = 0; } else { $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $article->catid, $language)); $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId); $link = new JURI($link1); $link->setVar('return', base64_encode($returnURL)); $readmore_link = $link; $readmore_register = 1; } // load template for comments & readmore links $tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false); $tmpl->load('tpl_links'); $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1); $tmpl->addVar('tpl_links', 'content-item', $article); $tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0))); $readmoreDisabled = false; if ($params->get('show_readmore') == 0 || @$article->readmore == 0) { $readmoreDisabled = true; } else { if (@$article->readmore > 0) { $readmoreDisabled = false; } } if ($this->params->get('readmore_link', 1) == 0) { $readmoreDisabled = true; } $tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled)); // don't fill any readmore variable if it disabled if (!$readmoreDisabled) { if ($readmore_register == 1) { $readmore_text = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE'); } else { if (isset($params) && ($readmore = $params->get('readmore'))) { $readmore_text = $readmore; } else { if ($alternative_readmore = $article->alternative_readmore) { $readmore_text = trim($alternative_readmore); if ($params->get('show_readmore_title', 0) != 0) { $readmore_text .= ' ' . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit')); } } else { $readmore_text = JText::_('COM_CONTENT_READ_MORE_TITLE'); if ($params->get('show_readmore_title', 0) == 1) { $readmore_text = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit')); } } } } $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link); $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text); $tmpl->addVar('tpl_links', 'link-readmore-title', $article->title); $tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link')); } $commentsDisabled = false; if ($config->getInt('comments_off', 0) == 1) { $commentsDisabled = true; } else { if ($config->getInt('comments_on', 0) == 1) { $commentsDisabled = false; } } $tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled)); $count = 0; // do not query comments count if comments disabled and link hidden if (!$commentsDisabled) { require_once JPATH_ROOT . '/components/com_jcomments/models/jcomments.php'; $anchor = ""; if ($this->params->get('comments_count', 1) != 0) { $acl = JCommentsFactory::getACL(); $options = array(); $options['object_id'] = (int) $article->id; $options['object_group'] = 'com_content'; $options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1; $count = JCommentsModel::getCommentsCount($options); $tmpl->addVar('tpl_links', 'comments-count', $count); $anchor = $count == 0 ? '#addcomments' : '#comments'; if ($count == 0) { $link_text = JText::_('LINK_ADD_COMMENT'); } else { $link_text = JText::plural('LINK_READ_COMMENTS', $count); } } else { $link_text = JText::_('LINK_ADD_COMMENT'); } $tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor); $tmpl->addVar('tpl_links', 'link-comment-text', $link_text); $tmpl->addVar('tpl_links', 'link-comments-class', $this->params->get('comments_css_class', 'comments-link')); } JCommentsContentPluginHelper::clear($article, true); // hide comments link if comments enabled but link disabled in plugin params if (($this->params->get('comments_count', 1) == 0 || $count == 0 && $this->params->get('add_comments', 1) == 0 || $count == 0 && $readmore_register == 1) && !$commentsDisabled) { $tmpl->addVar('tpl_links', 'comments_link_hidden', 1); } //links_position if ($this->params->get('links_position', 1) == 1) { $article->text .= $tmpl->renderTemplate('tpl_links'); } else { $article->text = $tmpl->renderTemplate('tpl_links') . $article->text; } $tmpl->freeTemplate('tpl_links'); if ($this->params->get('readmore_link', 1) == 1) { $article->readmore = 0; $article->readmore_link = ''; $article->readmore_register = false; } } else { if ($this->params->get('show_comments_event') == 'onPrepareContent') { $isEnabled = $config->getInt('comments_on', 0) == 1 && $config->getInt('comments_off', 0) == 0; if ($isEnabled && $view == 'article') { require_once JPATH_ROOT . '/components/com_jcomments/jcomments.php'; $comments = JComments::show($article->id, 'com_content', $article->title); if (strpos($article->text, '{jcomments}') !== false) { $article->text = str_replace('{jcomments}', $comments, $article->text); } else { $article->text .= $comments; } } } JCommentsContentPluginHelper::clear($article, true); } return ''; }
function _isHomePage(&$uri, $altered = false) { $home_items = SEFTools::getHomeQueries(); $langs = JLanguageHelper::getLanguages('lang_code'); $config = SEFConfig::getConfig(); $Itemid = $uri->getVar('Itemid'); if (array_key_exists($Itemid, $home_items) && $uri->getPath() == 'index.php') { if ($config->langEnable) { if (strlen($uri->getVar('lang', '')) == 0) { $langTag = $home_items[$Itemid]->language; if (isset($langs[$langTag])) { $uri->setVar('lang', $langs[$langTag]->sef); } else { // Use current language $langTag = JFactory::getLanguage()->getTag(); if (isset($langs[$langTag])) { $uri->setVar('lang', $langs[$langTag]->sef); } } } } // Set the link queries if not already there if (!isset($home_items[$Itemid]->linkQuery)) { $link = new JURI($home_items[$Itemid]->link); $home_items[$Itemid]->linkQuery = $link->getQuery(true); $home_items[$Itemid]->normalizedQuery = null; // Normalize query if an extension is available $option = $link->getVar('option'); if (!is_null($option)) { $extFile = JPATH_ROOT . '/components/com_sef/sef_ext/' . $option . '.php'; if (file_exists($extFile)) { $class = 'SefExt_' . $option; if (!class_exists($class)) { require $extFile; } $sef_ext = new $class(); $link->setVar('Itemid', $Itemid); $sef_ext->beforeCreate($link); $link->delVar('Itemid'); $link->delVar('lang'); $home_items[$Itemid]->normalizedQuery = $link->getQuery(true); $sef_ext = null; } } } // The queries need to match 1:1 (except Itemid and lang(?)), not just the variables present in home item! $uriQuery = $uri->getQuery(true); if (array_key_exists('Itemid', $uriQuery)) { unset($uriQuery['Itemid']); } if (array_key_exists('lang', $uriQuery)) { unset($uriQuery['lang']); } // Check base link $same = $uriQuery == $home_items[$Itemid]->linkQuery; if (!$same && is_array($home_items[$Itemid]->normalizedQuery)) { // Check normalized link $same = $uriQuery == $home_items[$Itemid]->normalizedQuery; } return $same; } return false; }
/** * Display function */ public function display($tpl = null) { if (function_exists('error_reporting')) { error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT); } /** load libraries for the system rener **/ JSNFactory::localimport('libraries.joomlashine.mode.rawmode'); JSNFactory::localimport('libraries.joomlashine.menu.menuitems'); /** Assignment variables **/ $jsntemplate = JSNFactory::getTemplate(); $jsnmenuitems = JSNMenuitems::getInstance(); /** get url **/ $render_url = JRequest::getVar('render_url', ''); $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin')); if ($render_url == '' && $session->get('rawmode_render_url')) { $render_url = $session->get('rawmode_render_url'); } $urlRender = base64_decode($render_url); if ($render_url == '') { $urlRender = JSNDatabase::getDefaultPage()->link; } $currUri = new JURI($urlRender); if (!$currUri->hasVar('Itemid')) { $currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id); } $urlString = $currUri->toString(); $session->set('rawmode_render_url', base64_encode($urlString)); $parts = JString::parse_url($urlString); if (!empty($parts['query'])) { parse_str($parts['query'], $params); } else { $params = array(); } $jsnrawmode = JSNRawmode::getInstance($params); $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions()); $jsnrawmode->renderAll(); $this->assign('component', $jsnrawmode->getHTML('component')); $this->assign('modules', $jsnrawmode->getHTML('positions')); $this->assign('jsnmenuitems', $jsnmenuitems); $this->assign('urlRender', $urlRender); /** add toolbar buttons **/ $this->addToolBar(); /** add scripts and css **/ //$this->addMedia( $currUri->getVar('Itemid'), $urlString, array());//$jsnrawmode->getScript('positions', 'Array')); $this->addMedia($currUri->getVar('Itemid'), $urlString, $jsnrawmode->getScript('positions', 'Array')); return parent::display(); }
function build(&$uri) { $mainframe = JFactory::getApplication(); $config = JFactory::getConfig(); $sefConfig =& SEFConfig::getConfig(); $cache =& SEFCache::getInstance(); // trigger onSefStart patches $mainframe->triggerEvent('onSefStart'); $prevLang = ''; // for correct title translations // do not SEF URLs with tmpl=component if set to if (!$sefConfig->sefComponentUrls && $uri->getVar('tmpl') == 'component') { $mainframe->triggerEvent('onSefEnd'); return; } // check if this is site root; // if site is root, do not do anything else // except if we have to set language every time $vars = $uri->getQuery(true); if (empty($vars) && (!SEFTools::JoomFishInstalled() || !$sefConfig->alwaysUseLang)) { // trigger onSefEnd patches $mainframe->triggerEvent('onSefEnd'); $uri = new JURI(JURI::root()); return; } // check URL for junk if set to if ($sefConfig->checkJunkUrls) { $junkWords =& $sefConfig->getJunkWords(); $seferr = false; if (substr($uri->getVar('option', ''), 0, 4) != 'com_') { $seferr = true; } elseif (count($junkWords)) { $exclude =& $sefConfig->getJunkExclude(); foreach ($vars as $key => $val) { if (in_array($key, $exclude)) { continue; } // Check junk words foreach ($junkWords as $word) { if (is_string($val)) { if (strpos($val, $word) !== false) { $seferr = true; break; } } } if ($seferr) { break; } } } if ($seferr) { // trigger onSefEnd patches $mainframe->triggerEvent('onSefEnd'); // fix the path $path = $uri->getPath(); if ($path[0] != '/') { $path = JURI::base(true) . '/' . $path; $uri->setPath($path); } return; } } if (SEFTools::JoomFishInstalled()) { $lang = $uri->getVar('lang'); // if lang not set if (empty($lang)) { if ($sefConfig->alwaysUseLang) { // add lang variable if set to $uri->setVar('lang', SEFTools::getLangCode()); } else { // delete lang variable so it is not empty $uri->delVar('lang'); } } // get the URL's language and set it as global language (for correct translation) $lang = $uri->getVar('lang'); $code = ''; if (!empty($lang)) { $code = SEFTools::getLangLongCode($lang); if (!is_null($code)) { if ($code != SEFTools::getLangLongCode()) { $language = JFactory::getLanguage(); $prevLang = $language->setLanguage($code); $language->load(); } } } // set the live_site according to language if ($sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) { $u = JURI::getInstance(); $curdomain = $sefdomain = $u->getHost(); if (!empty($lang)) { if (isset($sefConfig->jfSubDomains[$lang])) { $sefdomain = $sefConfig->jfSubDomains[$lang]; //$uri->delVar('lang'); } } $config = JFactory::getConfig(); $config->set('joomfish.current_host', $curdomain); $config->set('joomfish.sef_host', $sefdomain); } } // if there are no variables and only single language is used $vars = $uri->getQuery(true); if (empty($vars) && !isset($lang)) { JoomSEF::_endSef($prevLang); return; } $option = $uri->getVar('option'); if (!is_null($option)) { $params =& SEFTools::getExtParams($option); // Check the stop rule $stopRule = trim($params->get('stopRule', '')); if ($stopRule != '') { if (preg_match('/' . $stopRule . '/', $uri->toString()) > 0) { // Don't SEF this URL $uri = JoomSEF::_createUri($uri); JoomSEF::_endSef($prevLang); return; } } $handling = $params->get('handling', '0'); switch ($handling) { // skipped extensions case '2': // Check homepage if (JoomSEF::_isHomePage($uri)) { $lang = $uri->getVar('lang'); if (empty($lang)) { $uri = new JURI('index.php'); } else { $uri = new JURI('index.php?lang=' . $lang); } } // Build URL $uri = JoomSEF::_createUri($uri); JoomSEF::_endSef($prevLang); return; // non-cached extensions // non-cached extensions case '1': $router = JoomSEF::get('sef.global.jrouter'); if (!empty($router)) { // Store language for later use $uriLang = $uri->getVar('lang'); $uri->delVar('lang'); // Check homepage if (JoomSEF::_isHomePage($uri)) { $url = 'index.php'; } else { $url = $uri->toString(); } // Build URL $uri = $router->build($url); // Add language if needed if (!is_null($uriLang)) { $route = $uri->getPath(); $route = JoomSEF::_addLangToRoute($route, $uriLang); $uri->setPath($route); } } JoomSEF::_endSef($prevLang); return; // default handler or basic rewriting // default handler or basic rewriting default: // if component has its own sef_ext plug-in included. // however, prefer own plugin if exists (added by Michal, 28.11.2006) $compExt = JPATH_ROOT . '/' . 'components' . '/' . $option . '/' . 'router.php'; $ownExt = JPATH_ROOT . '/' . 'components' . '/' . 'com_sef' . '/' . 'sef_ext' . '/' . $option . '.php'; // compatible extension build block if (file_exists($compExt) && !file_exists($ownExt) && $handling == '0') { // Check homepage if (JoomSEF::_isHomePage($uri)) { $lang = $uri->getVar('lang'); if (empty($lang)) { $uri = new JURI('index.php'); } else { $uri = new JURI('index.php?lang=' . $lang); } // Build URL $uri = JoomSEF::_createUri($uri); JoomSEF::_endSef($prevLang); return; } // load the plug-in file require_once $compExt; // Store the language for later use $uriLang = $uri->getVar('lang'); $uri->delVar('lang'); $app = JFactory::getApplication(); $menu =& JSite::getMenu(); $route = $uri->getPath(); $query = $uri->getQuery(true); $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']); $tmp = ''; $function = substr($component, 4) . 'BuildRoute'; $parts = $function($query); $total = count($parts); for ($i = 0; $i < $total; $i++) { $parts[$i] = str_replace(':', '-', $parts[$i]); } $result = implode('/', $parts); $tmp = $result != "" ? '/' . $result : ''; // build the application route $built = false; if (isset($query['Itemid']) && !empty($query['Itemid'])) { $item = $menu->getItem($query['Itemid']); if (is_object($item) && $query['option'] == $item->component) { $tmp = !empty($tmp) ? $item->route . $tmp : $item->route; $built = true; } } if (!$built) { $tmp = 'component/' . substr($query['option'], 4) . $tmp; } $route .= '/' . $tmp; if ($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/')) { if ($format = $uri->getVar('format', 'html')) { $route .= '.' . $format; $uri->delVar('format'); } } if ($app->getCfg('sef_rewrite')) { // transform the route $route = str_replace('index.php/', '', $route); } // Unset unneeded query information unset($query['Itemid']); unset($query['option']); // Add language to route if needed if (!is_null($uriLang)) { $route = JoomSEF::_addLangToRoute($route, $uriLang); } //Set query again in the URI $uri->setQuery($query); $uri->setPath($route); $uri = JoomSEF::_createUri($uri); JoomSEF::_endSef($prevLang); return; } else { if ($handling == '3') { // Basic rewriting $class = 'SefExt_Basic'; } else { if (file_exists($ownExt)) { $class = 'SefExt_' . $option; require_once $ownExt; if (!class_exists($class)) { $class = 'SefExt'; } } else { $class = 'SefExt'; } } $sef_ext = new $class(); // Let the extension change the url and options $sef_ext->beforeCreate($uri); // Ensure that the session IDs are removed // If set to $sid = $uri->getVar('sid'); if (!$sefConfig->dontRemoveSid) { $uri->delVar('sid'); } // Ensure that the mosmsg are removed. $mosmsg = $uri->getVar('mosmsg'); $uri->delVar('mosmsg'); // override Itemid if set to $override = $params->get('itemid', '0'); $overrideId = $params->get('overrideId', ''); if ($override != '0' && $overrideId != '') { $uri->setVar('Itemid', $overrideId); } // clean Itemid if desired // David: only if overriding is disabled if (isset($sefConfig->excludeSource) && $sefConfig->excludeSource && $override == '0') { $Itemid = $uri->getVar('Itemid'); $uri->delVar('Itemid'); } // Get nonsef and ignore vars from extension list($nonSefVars, $ignoreVars) = $sef_ext->getNonSefVars($uri); // Create array of all the non sef vars $nonSefVars = SEFTools::getNonSefVars($uri, $nonSefVars, $ignoreVars); // Create a copy of JURI object $uri2 = clone $uri; // Remove nonsef variables from our JURI copy $nonSefUrl = SEFTools::RemoveVariables($uri2, array_keys($nonSefVars)); // Check homepage if (JoomSEF::_isHomePage($uri2, true)) { $title = array(); $data = JoomSEF::_sefGetLocation($uri, $title, null, null, null, $uri->getVar('lang')); $uri = JoomSEF::_storeLocation($data); JoomSEF::_endSef($prevLang); return; } $url = JoomSEF::_uriToUrl($uri2); // try to get url from cache $sefUrl = false; if ($sefConfig->useCache) { $sefUrl = $cache->GetSefUrl($url); } if (!$sefConfig->useCache || !$sefUrl) { // check if the url is already saved in the database $sefUrl = $sef_ext->getSefUrlFromDatabase($uri2); if (is_string($sefUrl)) { // Backward compatibility $sefstring = $sefUrl; $sefUrl = new stdClass(); $sefUrl->sefurl = $sefstring; $sefUrl->sef = 1; } } if (!$sefUrl) { // rewrite the URL, creating new JURI object $data = $sef_ext->create($uri); if (is_object($data) && is_a($data, 'JURI')) { // Backwards compatibility $uri = $data; } else { $uri = JoomSEF::_storeLocation($data); } } else { // if SEF is disabled, don't SEF if (isset($sefUrl->sef) && !$sefUrl->sef) { $uri = JoomSEF::_createUri($uri); JoomSEF::_endSef($prevLang); return; } // Create new JURI object from $sefstring $url = JURI::root(); if (substr($url, -1) != '/') { $url .= '/'; } $url .= $sefUrl->sefurl; // Add nonSef part if set if (!empty($nonSefUrl)) { $url .= '?' . $nonSefUrl; } // Add fragment if set $fragment = $uri->getFragment(); if (!empty($fragment)) { $url .= '#' . $fragment; } $uri = new JURI($url); } // reconnect the sid to the url if (!empty($sid) && !$sefConfig->dontRemoveSid) { $uri->setVar('sid', $sid); } // reconnect mosmsg to the url if (!empty($mosmsg)) { $uri->setVar('mosmsg', $mosmsg); } // reconnect ItemID to the url // David: only if extension doesn't set its own Itemid through overrideId parameter if (isset($sefConfig->excludeSource) && $sefConfig->excludeSource && $sefConfig->reappendSource && $override == '0' && !empty($Itemid)) { $uri->setVar('Itemid', $Itemid); } // let the extension change the resulting SEF url $sef_ext->afterCreate($uri); } } } else { if (!is_null($uri->getVar('Itemid'))) { // there is only Itemid present - we must override the Ignore multiple sources option $oldIgnore = $sefConfig->ignoreSource; $sefConfig->ignoreSource = 0; $title = array(); $title[] = JoomSEF::_getMenuTitle(null, null, $uri->getVar('Itemid')); $data = JoomSEF::_sefGetLocation($uri, $title, null, null, null, $uri->getVar('lang')); $uri = JoomSEF::_storeLocation($data); $sefConfig->ignoreSource = $oldIgnore; } } JoomSEF::_endSef($prevLang); }
$url->addChild('lastmod', $date->format('Y-m-d')); $url->addChild('changefreq', 'daily'); $url->addChild('priority', '0.9'); // build menu map $db = JFactory::getDbo(); $q = $db->getQuery(true); $q->select("*")->from("#__menu")->where("id != 1")->where("published=1")->where("access=1"); $db->setQuery($q); $menus = $db->loadObjectList(); foreach ($menus as $menu) { if (!$menu->link) { continue; } // fix URI bugs $uri = new JURI($menu->link); $uri->setVar('Itemid', $menu->id); if ($app->getCfg('sef')) { $uri->setVar('layout', null); } $link = JRoute::_($uri->toString()); $host = str_replace('http://' . $_SERVER['HTTP_HOST'], '', JURI::root()); $link = str_replace($host, '', $link); $link = AK::_('uri.pathAddHost', $link); // set xml data $url = $xml->addChild('url'); $url->addChild('loc', $link); $url->addChild('lastmod', $date->format('Y-m-d')); $url->addChild('changefreq', 'weekly'); $url->addChild('priority', '0.8'); $exists_links[] = $link; }
function parse(&$uri) { $mainframe =& JFactory::getApplication(); // test for the backlink plugin to work correctly if (JPluginHelper::isEnabled('system', 'backlink')) { // && $uri->getQuery() ) { // commented out - causing problems $joomlaRequest = urldecode($_SERVER['REQUEST_URI']); $realRequest = $uri->toString(array('path', 'query')); if ($realRequest != $joomlaRequest) { $uri = new JURI($joomlaRequest); } } // store the old URI before we change it in case we will need it // for default Joomla SEF $oldUri = new JURI($uri->toString()); if (!SEFTools::JoomFishInstalled()) { $url_query = $uri->getQuery(); $host = explode(".", $uri->getHost()); $subdomain = array_shift($host); $db = JFactory::getDBO(); // Subdomain titlepage if ($uri->getPath() == '/' && empty($url_query) && empty($_POST)) { $query = "SELECT Itemid_titlepage FROM #__sef_subdomains WHERE subdomain = " . $db->quote($subdomain) . " LIMIT 1"; $db->setQuery($query); $Itemid = $db->loadResult(); if ($Itemid > 0) { $uri->setVar('Itemid', $Itemid); JoomSEF::set('real_domain', JFactory::getUri()->getHost()); JFactory::getUri()->setHost(implode(".", $host)); } } else { $query = "SELECT COUNT(*) FROM #__sef_subdomains WHERE subdomain = " . $db->quote($subdomain); $db->setQuery($query); $cnt = $db->loadResult(); if ($cnt) { JoomSEF::set('real_domain', JFactory::getUri()->getHost()); JFactory::getUri()->setHost(implode(".", $host)); } } } $sefConfig =& SEFConfig::getConfig(); // load patches JPluginHelper::importPlugin('sefpatch'); // trigger onSefLoad patches $mainframe->triggerEvent('onSefLoad'); // get path $path = $uri->getPath(); // remove basepath $path = substr_replace($path, '', 0, strlen(JURI::base(true))); // remove slashes $path = ltrim($path, '/'); // Redirect URL with / on the end to URL without / on the end if ($sefConfig->redirectSlash) { $request = $_SERVER["REQUEST_URI"]; $noBase = substr_replace($request, '', 0, strlen(JURI::base(true))); if ($request != "/" && $noBase != "/" && substr($request, -1) == '/') { $mainframe->redirect(rtrim($request, "/"), '', 'message'); JFactory::getApplication()->close(); } } // Redirect the index.php (need to check this before index.php removal) if ($sefConfig->fixIndexPhp && $path == 'index.php' && count($_POST) == 0) { $q = $uri->getQuery(true); if (count($q) == 0) { $newUrl = JURI::root(); if (substr($newUrl, -1) != '/') { $newUrl .= '/'; } $mainframe->redirect($newUrl, '', 'message', true); exit; } } // Try the 301 Alias redirect if (count($_POST) == 0) { JoomSEF::_parseAlias($path, $uri->getQuery(true)); } // Disable non-SEF redirect for index2.php links // EDIT: don't even parse index2.php links! if (substr($path, 0, 10) == 'index2.php') { //$sefConfig->nonSefRedirect = false; return $uri->getQuery(true); } // Redirect old /index.php/ links if set to if ($sefConfig->fixIndexPhp && substr($path, 0, 10) == 'index.php/' && count($_POST) == 0) { $newUrl = JURI::root(); if (substr($newUrl, -1) != '/') { $newUrl .= '/'; } $newUrl .= substr($path, 10); $mainframe->redirect($newUrl, '', 'message', true); exit; } // remove prefix (both index.php and index2.php) $path = preg_replace('/^index2?.php/i', '', $path); // remove slashes again to be sure there aren't any left $path = ltrim($path, '/'); // replace spaces with our replacement character // (mainly for '+' handling, but may be useful in some other situations too) $path = str_replace(' ', $sefConfig->replacement, $path); // set the route $uri->setPath($path); // host name handling if (SEFTools::JoomFishInstalled() && $sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN && !JPluginHelper::isEnabled('system', 'jfrouter')) { // different domains for languages handling $host = $uri->toString(array('host')); $host = trim($host, '/'); $code = null; foreach ($sefConfig->jfSubDomains as $langCode => $domain) { if ($host == $domain) { // if main language is not selected, use the first corresponding domain if ($sefConfig->mainLanguage == '0') { $code = $langCode; break; } else { if ($langCode == $sefConfig->mainLanguage) { $code = $langCode; break; } else { if (is_null($code)) { $code = $langCode; } } } } } // we found a matching domain if (!is_null($code)) { JRequest::setVar('lang', $code); $config =& JFactory::getConfig(); $config->set('joomsef.domain_lang', $code); } } // parse the url $vars = JoomSEF::_parseSefUrl($uri, $oldUri); // handle custom site name for extensions if (isset($vars['option'])) { $params =& SEFTools::getExtParams($vars['option']); $useSitename = $params->get('useSitename', '1'); $customSitename = trim($params->get('customSitename', '')); $config =& JFactory::getConfig(); if ($useSitename == '0') { // don't use site name $config->setValue('sitename', ''); } elseif (!empty($customSitename)) { // use custom site name $config->setValue('sitename', $customSitename); } } // trigger onSefUnload patches $mainframe->triggerEvent('onSefUnload'); return $vars; }
/** * Process the build uri query data based on custom defined rules * * @param JURI $uri The URI * * @return void */ protected function _processBuildRules($uri) { // Make sure any menu vars are used if no others are specified if ($this->_mode != JROUTER_MODE_SEF && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2) { $app = JApplication::getInstance('site'); $menu = $app->getMenu(); // Get the active menu item $itemid = $uri->getVar('Itemid'); $item = $menu->getItem($itemid); if ($item) { $uri->setQuery($item->query); } $uri->setVar('Itemid', $itemid); } // Process the attached build rules parent::_processBuildRules($uri); // Get the path data $route = $uri->getPath(); if ($this->_mode == JROUTER_MODE_SEF && $route) { $app = JApplication::getInstance('site'); if ($limitstart = $uri->getVar('limitstart')) { $uri->setVar('start', (int) $limitstart); $uri->delVar('limitstart'); } } $uri->setPath($route); }
</a> <?php $this->item = $item; echo JHTML::_('icon.edit', $item, $this->params, $this->access); ?> </td> <?php } else { ?> <td> <?php echo $this->escape($item->title) . ' : '; $link = JRoute::_('index.php?option=com_user&view=login'); $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid)); $fullURL = new JURI($link); $fullURL->setVar('return', base64_encode($returnURL)); $link = $fullURL->toString(); ?> <a href="<?php echo $link; ?> "><?php echo JText::_('Register to read more...'); ?> </a> </td> <?php } ?> <?php }
</div> <?php } ?> <?php if ($params->get('show_readmore', 1) && $row->readmore) { if ($params->get('access-view')) { $link = $row->link; } else { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId); $link = new JURI($link1); $link->setVar('return', base64_encode($row->link)); } ?> <?php if ($params->get('show_readmore', 1) == 1) { ?> <a class="btn TzReadmore<?php if ($params->get('tz_use_lightbox') == 1) { echo ' fancybox fancybox.iframe'; } ?> " href="<?php echo $link; ?>
} echo $this->item->introtext; ?> <?php if ($params->get('show_readmore') && $this->item->readmore) { if ($params->get('access-view')) { $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); } else { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId); $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); $link = new JURI($link1); $link->setVar('return', base64_encode($returnURL)); } ?> <a class="btn" href="<?php echo $link; ?> "> <?php if (!$params->get('access-view')) { echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE'); } elseif ($readmore = $this->item->alternative_readmore) { echo $readmore; if ($params->get('show_readmore_title', 0) != 0) { echo JHtml::_('string.truncate', $this->item->title, $params->get('readmore_limit')); } } elseif ($params->get('show_readmore_title', 0) == 0) {
/** * Using CURL get page source. * * @param string $url Link to get content * * @return string */ protected static function curlResponse($url) { $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false); $ch = curl_init($url); curl_setopt_array($ch, $options); $contents = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch); $header = curl_getinfo($ch); curl_close($ch); if ($err > 0) { exit('cUrl error number: ' . $err); } $response = new stdClass(); $response->contents = $contents; $response->redirect_url = $header['redirect_url']; if ($response->redirect_url != self::$_renderUrl and trim($response->redirect_url) != '') { $old_uri = new JURI(self::$_renderUrl); $redirect_uri = new JURI($response->redirect_url); if ($old_uri->hasVar('tp') and !$redirect_uri->hasVar('tp')) { $redirect_uri->setVar('tp', 1); } if ($old_uri->hasVar('jsntpl_position') and !$redirect_uri->hasVar('jsntpl_position')) { $redirect_uri->setVar('jsntpl_position', 1); } if ($old_uri->hasVar('secret_key') and !$redirect_uri->hasVar('secret_key')) { $config = JFactory::getConfig(); $secret = $config->get('secret'); $redirect_uri->setVar('secret_key', md5($secret)); } if ($old_uri->hasVar('Itemid') and !$redirect_uri->hasVar('Itemid')) { $redirect_uri->setVar('Itemid', $old_uri->getVar('Itemid')); } // Save redirect url self::$_renderUrl = $redirect_uri->toString(); $response = self::curlResponse(self::$_renderUrl); } return $response; }