Пример #1
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     // Don't SEF URLs with "return" variable
     if (!empty($return)) {
         return $uri;
     }
     $title = array();
     $title[] = JoomSEF::_getMenuTitle(@$option, null, @$Itemid);
     if (isset($task)) {
         if ($task == 'register') {
             $title[] = JText::_('Register');
             unset($task);
         }
         /*if($task=='activate') {
           	$title[]=$vars['activation'];
           }*/
     }
     if (!empty($view)) {
         $title[] = JText::_($view);
     }
     if (!empty($layout)) {
         $title[] = JText::_($layout);
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $this->_createNonSefVars($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, @$task, null, null, @$lang, $this->nonSefVars);
     }
     return $newUri;
 }
Пример #2
0
 /**
  * Translates an internal Joomla URL to a humanly readible URL.
  *
  * @param   string   $url    Absolute or Relative URI to Joomla resource.
  * @param   boolean  $xhtml  Replace & by & for XML compilance.
  * @param   integer  $ssl    Secure state for the resolved URI.
  *                             1: Make URI secure using global secure site URI.
  *                             0: Leave URI in the same secure state as it was passed to the function.
  *                            -1: Make URI unsecure using the global unsecure site URI.
  *
  * @return  The translated humanly readible URL.
  * @since   11.1
  */
 public static function _($url, $xhtml = true, $ssl = null)
 {
     // Get the router.
     $app = JFactory::getApplication();
     $router = $app->getRouter();
     // Make sure that we have our router
     if (!$router) {
         return null;
     }
     if (strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
         return $url;
     }
     // Build route.
     $uri = $router->build($url);
     $url = $uri->toString(array('path', 'query', 'fragment'));
     // Replace spaces.
     $url = preg_replace('/\\s/u', '%20', $url);
     /*
      * Get the secure/unsecure URLs.
      *
      * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
      * https and need to set our secure URL to the current request URL, if not, and the scheme is
      * 'http', then we need to do a quick string manipulation to switch schemes.
      */
     // Make sure our URL path begins with a slash.
     if (!preg_match('#^/#', $url)) {
         $url = '/' . $url;
     }
     $host = $uri->getHost();
     $ssl = (int) $ssl;
     // Add host only if different than current
     $jUri =& JURI::getInstance();
     $curHost = JoomSEF::get('real_domain');
     if (is_null($curHost)) {
         $curHost = $jUri->getHost();
     }
     if ($host == $curHost) {
         $host = '';
     }
     if (strlen($host) || $ssl) {
         if (strlen($host)) {
             $prefix = $uri->toString(array('host', 'port'));
         } else {
             $prefix = $jUri->toString(array('host', 'port'));
         }
         if ($ssl) {
             $scheme = (int) $ssl === 1 ? 'https' : 'http';
         } else {
             $scheme = $jUri->getScheme();
         }
         // Build the URL
         $url = $scheme . '://' . $prefix . $url;
     }
     if ($xhtml) {
         $url = htmlspecialchars($url);
     }
     return $url;
 }
Пример #3
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     $title[] = JoomSEF::_getMenuTitleLang(@$option, $this->lang, @$Itemid);
     $newUri = $uri;
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang);
     }
     return $newUri;
 }
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     $profile_name = $this->getAiContactSafeProfileName($pf);
     if (strlen(trim($profile_name)) > 0) {
         $title[] = $profile_name;
     } else {
         $title[] = JoomSEF::_getMenuTitle(@$option, null, @$Itemid);
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang);
     }
     return $newUri;
 }
Пример #5
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $params = SEFTools::GetExtParams('com_content');
     $vars = $uri->getQuery(true);
     extract($vars);
     // Set title.
     $title = array();
     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
     if (!empty($tmpl)) {
         $title[] = $tmpl;
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $this->_createNonSefVars($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, $this->ignoreVars);
     }
     return $newUri;
 }
Пример #6
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $this->params =& SEFTools::getExtParams('com_banners');
     $vars = $uri->getQuery(true);
     extract($vars);
     $title[] = JoomSEF::_getMenuTitleLang(@$option, @$task, @$Itemid);
     switch (@$task) {
         case 'click':
             $title[] = $this->GetBannerName($id);
             unset($task);
             break;
     }
     $newUri = $uri;
     if (isset($this->lang)) {
         $lang = $this->lang;
     }
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, @$task, null, null, @$lang);
     }
     return $newUri;
 }
Пример #7
0
 function onAfterRender()
 {
     $db = JFactory::getDBO();
     if (JFactory::getApplication()->isAdmin()) {
         return;
     }
     if (JFactory::getApplication()->getCfg('sef') == 0) {
         return;
     }
     if (JRequest::getVar('tmpl') == 'component') {
         return;
     }
     if (JRequest::getVar('format', 'html') != 'html') {
         return;
     }
     $body = JResponse::getBody();
     $doc = new DomDocument("1.0");
     $doc->loadHTML($body);
     $xpath = new DomXPath($doc);
     $hrefs = $xpath->query("//a");
     foreach ($hrefs as $href) {
         $link = $href->getAttribute('href');
         if (JFactory::getURI()->isInternal($link) == false) {
             continue;
         }
         $link = substr($link, 1);
         if ($this->params->get('raw')) {
             $origurl = JoomSEF::_createUri(new JURI($link));
         } else {
             $origurl = JoomSEF::getNonSEFURL($link);
         }
         if (strlen($origurl)) {
             $href->setAttribute('class', 'link_tip');
             $href->setAttribute('title', $origurl);
         }
     }
     $body = $doc->saveHTML();
     JResponse::setBody($body);
 }
Пример #8
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $this->params =& SEFTools::getExtParams('com_search');
     $newUri = $uri;
     if (!(isset($task) ? @$task : null)) {
         $title[] = JoomSEF::_getMenuTitle($option, isset($task) ? $task : null);
         if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') {
             $title[] = $searchword;
         }
         if (count($title) > 0) {
             $this->_createNonSefVars($uri);
             if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') {
                 // Generate meta tags
                 $desc = array();
                 if (isset($searchword)) {
                     $desc[] = $searchword;
                 }
                 if (isset($searchphrase)) {
                     $desc[] = $searchphrase;
                 }
                 $this->metadesc = implode(', ', $desc);
                 unset($desc);
             }
             $metatags = $this->getMetaTags();
             $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], $this->nonSefVars, null, $metatags);
         }
     }
     return $newUri;
 }
Пример #9
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $this->_createNonSefVars($uri);
     $this->_prepareTexts();
     $title = array();
     $title[] = JoomSEF::_getMenuTitleLang(@$option, $lang, @$Itemid);
     if (!empty($view)) {
         if ($this->params->get('always_en', '0') == '1') {
             $title[] = self::$textsEn[strtoupper('COM_SEF_USERS_' . $view)];
         } else {
             $title[] = JText::_('COM_SEF_USERS_' . $view);
         }
     }
     if (!empty($layout)) {
         if ($this->params->get('always_en', '0') == '1') {
             $title[] = self::$textsEn[strtoupper('COM_SEF_USERS_' . $layout)];
         } else {
             $title[] = JText::_('COM_SEF_USERS_' . $layout);
         }
     }
     if (!empty($task)) {
         $tasks = explode('.', $task);
         if ($tasks[0] == 'profile') {
             if (isset($user_id)) {
                 $title[] = $this->GetUserName($user_id);
             }
         } else {
             if ($this->params->get('always_en', '0') == '1') {
                 $title[] = self::$textsEn[strtoupper('COM_SEF_USERS_' . $tasks[0])];
             } else {
                 $title[] = JText::_('COM_SEF_USERS_' . $tasks[0]);
             }
         }
         if (isset($tasks[1])) {
             if ($tasks[1] == 'remind') {
                 $tasks[1] = 'submit';
             }
             if ($this->params->get('always_en', '0') == '1') {
                 $title[] = self::$textsEn[strtoupper('COM_SEF_USERS_' . $tasks[1])];
             } else {
                 $title[] = JText::_('COM_SEF_USERS_' . $tasks[1]);
             }
             if (in_array($tasks[1], array('confirm', 'complete'))) {
                 if ($this->params->get('always_en', '0') == '1') {
                     $title[] = self::$textsEn['COM_SEF_USERS_SUBMIT'];
                 } else {
                     $title[] = JText::_('COM_SEF_USERS_SUBMIT');
                 }
             }
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars);
     }
     return $newUri;
 }
Пример #10
0
 function getHomeQueries($includeLang = true)
 {
     $menu =& JApplication::getMenu('site');
     $item =& $menu->getDefault();
     $link = $item->link;
     $uri = new JURI($link);
     // We need to adjust the URL according to the extension
     SEFTools::normalizeURI($uri);
     if ($includeLang) {
         $uri->setVar('lang', '');
     }
     $q = JoomSEF::_uriToUrl($uri);
     return array($q, $item->id);
 }
Пример #11
0
 function getNonSefVars(&$uri, $nonSefVars, $ignoreVars)
 {
     $mainframe = JFactory::getApplication();
     $sefConfig = SEFConfig::getConfig();
     // Get the parameters for this component
     if (!is_null($uri->getVar('option'))) {
         $params =& SEFTools::getExtParams($uri->getVar('option'));
     }
     // Build array of nonSef vars if set to
     $nonSef = array();
     if ($sefConfig->appendNonSef) {
         // Save the given nonsef vars
         $nonSef = $nonSefVars;
         // load the nonSEF vars from option parameters
         $paramNonSef = array();
         if (isset($params)) {
             $nsef = $params->get('customNonSef', '');
             if (!empty($nsef)) {
                 // Some variables are set, let's explode them
                 $paramNonSef = explode(';', $nsef);
             }
         }
         // get globally configured nonSEF vars
         $configNonSef = array();
         if (!empty($sefConfig->customNonSef)) {
             $configNonSef = explode(';', $sefConfig->customNonSef);
         }
         // Get nonSEF vars from variable filter test if set to
         $failedVars = array();
         // combine all the nonSEF vars arrays
         $nsefvars = array_merge($paramNonSef, $configNonSef, $failedVars);
         if (!empty($nsefvars)) {
             foreach ($nsefvars as $nsefvar) {
                 // add each variable, that isn't already set, and that is present in our URL
                 if (!isset($nonSef[$nsefvar]) && !is_null($uri->getVar($nsefvar))) {
                     $nonSef[$nsefvar] = $uri->getVar($nsefvar);
                 }
             }
         }
         // if $nonSefVars mixes with $GLOBALS['JOOMSEF_NONSEFVARS'], exclude the mixed vars
         // this is important to prevent duplicating params by adding JOOMSEF_NONSEFVARS to
         // $ignoreSefVars
         $gNonSef = JoomSEF::get('sef.global.nonsefvars');
         if (!empty($gNonSef)) {
             foreach (array_keys($gNonSef) as $key) {
                 if (isset($nonSef[$key])) {
                     unset($gNonSef[$key]);
                 }
             }
             JoomSEF::set('sef.global.nonsefvars', $gNonSef);
         }
     }
     // Combine nonSef and ignore vars
     if (!empty($ignoreVars)) {
         $nonSef = array_merge($nonSef, $ignoreVars);
     }
     // Globally add the Smart Search's highlight variable
     if (!is_null($uri->getVar('highlight'))) {
         $nonSef['highlight'] = $uri->getVar('highlight');
     }
     // If the component requests strict accept variables filtering, add the ones that don't match
     if (isset($params) && $params->get('acceptStrict', '0') == '1') {
         $acceptVars =& SEFTools::getExtAcceptVars($uri->getVar('option'));
         $uriVars = $uri->getQuery(true);
         if (count($acceptVars) > 0 && count($uriVars) > 0) {
             foreach ($uriVars as $name => $value) {
                 // Standard Joomla variables
                 if (in_array($name, array('option', 'Itemid', 'limit', 'limitstart', 'format', 'tmpl', 'lang'))) {
                     continue;
                 }
                 // Accepted variables
                 if (in_array($name, $acceptVars)) {
                     continue;
                 }
                 // Variable not accepted, add it to non-SEF
                 $nonSef[$name] = $value;
             }
         }
     }
     return $nonSef;
 }
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $database =& JFactory::getDBO();
     $this->params =& SEFTools::getExtParams('com_newsfeeds');
     $vars = $uri->getQuery(true);
     extract($vars);
     // JF translate extension.
     $jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
     $title = array();
     $title[] = JoomSEF::_getMenuTitle($option, @$this_task);
     if (@$view == 'category' && isset($id)) {
         $title[] = $this->getCategoryTitle($id, SEFTools::UseAlias($this->params, 'category_alias'));
     }
     if (@$view == "newsfeed") {
         if (!empty($catid)) {
             if ($this->params->get('show_category', '1')) {
                 $title[] = $this->getCategoryTitle($catid, SEFTools::UseAlias($this->params, 'category_alias'));
             }
         }
         if (empty($feedid)) {
             $feedid = $id;
         }
         $field = 'name';
         if (SEFTools::UseAlias($this->params, 'feed_alias')) {
             $field = 'alias';
         }
         $feedid = intval($feedid);
         $database->setQuery("SELECT `{$field}` AS `name` {$jfTranslate} FROM `#__newsfeeds` WHERE `id` = '{$feedid}'");
         $row = $database->loadObject();
         if (is_null($row)) {
             JoomSefLogger::Log("Newsfeed with ID {$feedid} could not be found.", $this, 'com_newsfeeds');
         } elseif (!empty($row->name)) {
             $name = $row->name;
             if ($this->params->get('feedid', '0')) {
                 $name = $feedid . '-' . $name;
             }
             $title[] = $name;
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], null, null, $metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
Пример #13
0
 function onContentAfterDelete($context, $item)
 {
     $context = explode(".", $context);
     $option = $context[0];
     JoomSEF::_removeURL($option, $item);
 }
Пример #14
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $vars = $uri->getQuery(true);
     extract($vars);
     $title[] = JoomSEF::_getMenuTitleLang($option, $this->lang, @$Itemid);
     switch (@$view) {
         case 'categories':
             break;
         case 'category':
             $catInfo = $this->getCategoryInfo($id);
             if ($catInfo === false) {
                 JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_weblinks');
             }
             if (is_array($catInfo->path)) {
                 $title = array_merge($title, $catInfo->path);
             }
             break;
         case 'form':
             if (isset($w_id)) {
                 $title = array_merge($title, $this->getWeblinkTitle(@$w_id));
             }
             break;
         case 'weblink':
             if (!empty($id)) {
                 $title = array_merge($title, $this->getWeblinkTitle($id));
             } else {
                 if ($this->params->get('always_en', '0') == '1') {
                     $title[] = 'Submit';
                 } else {
                     $title[] = JText::_('COM_SEF_SUBMIT');
                 }
             }
             break;
     }
     switch (@$task) {
         case 'weblink.go':
             if (!empty($id)) {
                 $title = array_merge($title, $this->getWeblinkTitle($id));
             } else {
                 if ($this->params->get('always_en', '0') == '1') {
                     $title[] = 'Submit';
                 } else {
                     $title[] = JText::_('COM_SEF_SUBMIT');
                 }
             }
             break;
         case 'new':
             $title[] = 'new' . $sefConfig->suffix;
             break;
         case 'weblink.edit':
             $title = array_merge($title, $this->getWeblinkTitle(@$w_id));
             if ($this->params->get('always_en', '0') == '1') {
                 $title[] = 'Edit';
             } else {
                 $title[] = JText::_('COM_SEF_EDIT');
             }
             if (@$return) {
                 $nonSefVars['return'] = $return;
             }
             break;
     }
     if (@$format) {
         if ($format == 'feed' && @$type) {
             $title[] = ucfirst($type);
         } else {
             $title[] = ucfirst($format);
         }
     }
     $newUri = $uri;
     if (count($title)) {
         // Generate meta tags
         $this->metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         if (isset($this->lang)) {
             $lang = $this->lang;
         }
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, @$nonSefVars, null, $this->metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
Пример #15
0
 /**
  * Inserts new SEF URL to database
  *
  */
 function _saveNewURL($Itemid, &$metadata, $priority, $temploc, $url, $check404 = false, $host = null, $sitemapParams = null)
 {
     $db =& JFactory::getDBO();
     // First try to find and recycle the trashed URL
     $query = "SELECT `id` FROM `#__sefurls` WHERE `origurl` = " . $db->Quote(html_entity_decode(urldecode($url))) . " AND `trashed` = '1'";
     if (!empty($Itemid)) {
         $query .= " AND `Itemid` = '{$Itemid}'";
     } else {
         $query .= " AND `Itemid` IS NULL";
     }
     $db->setQuery($query);
     $row = $db->loadObject();
     if (!is_null($row)) {
         // We've found trashed URL, let's reuse it
         $query = "UPDATE `#__sefurls` SET `sefurl` = " . $db->Quote($temploc) . ", `trashed` = '0' WHERE `id` = '{$row->id}' LIMIT 1";
         $db->setQuery($query);
         if (!$db->query()) {
             $msg = JText::_('Could not update the SEF URL in database');
             if (JDEBUG) {
                 $msg .= ': ' . $db->getErrorMsg();
             }
             JError::raiseError('JoomSEF Error', $msg);
         }
         // Remove any remaining same 404 URL
         $db->setQuery("DELETE FROM `#__sefurls` WHERE `sefurl` = " . $db->Quote($temploc) . " AND `origurl` = '' LIMIT 1");
         if (!$db->query()) {
             $msg = JText::_('Could not update the SEF URL in database');
             if (JDEBUG) {
                 $msg .= ': ' . $db->getErrorMsg();
             }
             JError::raiseError('JoomSEF Error', $msg);
         }
         return;
     }
     // No trashed URL found, try to find the 404 URL if set to
     if ($check404) {
         $query = "SELECT `id` FROM `#__sefurls` WHERE `sefurl` = " . $db->Quote($temploc) . " AND `origurl` = ''";
         $db->setQuery($query);
         $id = $db->loadResult();
         // if 404 exists, rewrite it to the new URL
         if (!is_null($id)) {
             // TODO: update meta tags
             $sqlId = !empty($Itemid) ? ", `Itemid` = '{$Itemid}'" : '';
             $query = "UPDATE `#__sefurls` SET `origurl` = " . $db->Quote(html_entity_decode(urldecode($url))) . "{$sqlId}, `priority` = " . $db->Quote($priority) . " WHERE `id` = '{$id}' LIMIT 1";
             $db->setQuery($query);
             // if error occured
             if (!$db->query()) {
                 $msg = JText::_('Could not update SEF URL in database');
                 if (JDEBUG) {
                     $msg .= ': ' . $db->getErrorMsg();
                 }
                 JError::raiseError('JoomSEF Error', $msg);
             }
             return;
         }
     }
     // No URL found
     $col = $val = '';
     if (!empty($Itemid)) {
         $col = ', `Itemid`';
         $val = ", '{$Itemid}'";
     }
     $metakeys = $metavals = '';
     if (is_array($metadata) && count($metadata) > 0) {
         foreach ($metadata as $metakey => $metaval) {
             $metakeys .= ", `{$metakey}`";
             $metavals .= ", " . $db->Quote($metaval);
         }
     }
     // get trace information if set to
     $sefConfig =& SEFConfig::getConfig();
     if (@$sefConfig->trace) {
         $traceinfo = $db->Quote(JoomSEF::_getDebugInfo($sefConfig->traceLevel));
     } else {
         $traceinfo = "NULL";
     }
     // Sitemap default values
     $sm_indexed = isset($sitemapParams['indexed']) ? $sitemapParams['indexed'] : ($sefConfig->sitemap_indexed ? 1 : 0);
     $sm_date = date('Y-m-d');
     $sm_frequency = isset($sitemapParams['frequency']) ? $sitemapParams['frequency'] : $sefConfig->sitemap_frequency;
     $sm_priority = isset($sitemapParams['priority']) ? $sitemapParams['priority'] : $sefConfig->sitemap_priority;
     $autolock = (int) $sefConfig->autolock_urls;
     $query = 'INSERT INTO `#__sefurls` (`sefurl`, `origurl`, `priority`' . $col . $metakeys . ', `trace`, `sm_indexed`, `sm_date`, `sm_frequency`, `sm_priority`, `locked`, `host`) ' . "VALUES (" . $db->Quote($temploc) . ", " . $db->Quote(html_entity_decode(urldecode($url))) . ", " . $db->Quote($priority) . $val . $metavals . ", " . $traceinfo . ", '{$sm_indexed}', '{$sm_date}', '{$sm_frequency}', '{$sm_priority}', '{$autolock}', '{$host}')";
     $db->setQuery($query);
     // if error occured
     if (!$db->query()) {
         $msg = JText::_('Could not save the SEF URL to database');
         if (JDEBUG) {
             $msg .= ': ' . $db->getErrorMsg();
         }
         JError::raiseError('JoomSEF Error', $msg);
     }
 }
Пример #16
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     if ($this->params->get('showMenuTitle', '1') == '1') {
         $title[] = JoomSEF::_getMenuTitleLang($uri->getVar('option'), @$lang, $uri->getVar('Itemid'));
     } else {
         $title[] = substr($uri->getVar('option'), 4);
     }
     $noAdd = array('option', 'lang', 'Itemid');
     foreach ($vars as $name => $value) {
         if (in_array($name, $noAdd)) {
             continue;
         }
         // Arrays support
         $this->_addValue($title, $value);
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang);
     }
     return $newUri;
 }
Пример #17
0
 function parse(&$siteRouter, &$uri)
 {
     // Call this function only once in the stack, so
     // we can use Joomla default router to parse
     if ($this->parsing) {
         return array();
     }
     $this->parsing = true;
     $mainframe =& JFactory::getApplication();
     JoomSEF::set('sef.global.meta', SEFTools::GetSEFGlobalMeta());
     // Restore global "Add suffix to URLs"
     $sefSuffix = JoomSEF::get('sef.global.orig_sef_suffix');
     $config = JFactory::getConfig();
     $config->set('sef_suffix', $sefSuffix);
     $vars = array();
     $vars = JoomSEF::parse($uri);
     $menu = $mainframe->getMenu('site');
     // Parsing done
     $this->parsing = false;
     // Fix the start variable
     $start = $uri->getVar('start');
     if (!is_null($start) && is_null($uri->getVar('limitstart'))) {
         $uri->delVar('start');
         $vars['limitstart'] = $start;
     }
     //Handle an empty URL (special case)
     if (empty($vars['Itemid']) && empty($vars['option'])) {
         //$item = $menu->getDefault();
         // Workaround until Joomla menu bug will be fixed
         $items = $menu->getItems(array('home', 'language'), array('1', '*'));
         $item = $items[0];
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         // set the information in the request
         $vars = $item->query;
         // get the itemid
         $vars['Itemid'] = $item->id;
         // set the active menu item
         $menu->setActive($vars['Itemid']);
         // set vars
         $this->setRequestVars($vars);
         $this->fixDocument($vars);
         return $vars;
     }
     // Get the item id, if it hasn't been set force it to null
     if (empty($vars['Itemid'])) {
         $vars['Itemid'] = JRequest::getInt('Itemid', null);
     }
     // Set vars
     $this->setVars($vars);
     $siteRouter->setVars($vars);
     // Make sure the Joomla router doesn't process URL any further
     $siteRouter->setMode(JROUTER_MODE_DONT_PARSE);
     // No option? Get the full information from the itemid
     if (empty($vars['option'])) {
         $item = $menu->getItem($this->getVar('Itemid'));
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         $vars = $vars + $item->query;
     }
     // Set the active menu item
     $menu->setActive($this->getVar('Itemid'));
     // Set base href
     //$this->setBaseHref($vars);
     // Set vars
     $this->setRequestVars($vars);
     $this->fixDocument($vars);
     return $vars;
 }
Пример #18
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     // Don't SEF opensearch links
     if (isset($format) && $format == 'opensearch') {
         return $uri;
     }
     $this->params =& SEFTools::getExtParams('com_search');
     $newUri = $uri;
     if (!(isset($task) ? @$task : null)) {
         $title[] = JoomSEF::_getMenuTitleLang($option, $lang, @$Itemid);
         if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') {
             $title[] = $searchword;
         }
         if (isset($view) && ($view != 'search' || $this->params->get('add_search', '0') == '1')) {
             $title[] = $view;
         }
         if (isset($format)) {
             $title[] = $format;
         }
         $this->_createNonSefVars($uri);
         if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') {
             // Generate meta tags
             $desc = array();
             if (isset($searchword)) {
                 $desc[] = $searchword;
             }
             if (isset($searchphrase)) {
                 $desc[] = $searchphrase;
             }
             $this->metadesc = implode(', ', $desc);
             unset($desc);
         }
         $metatags = $this->getMetaTags();
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $metatags, null, true);
     }
     return $newUri;
 }
Пример #19
0
 function CreateHomeLinks()
 {
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     $links = array();
     // Create array of links for each language
     $homes = SEFTools::getHomeQueries(false);
     if (!is_array($homes) || count($homes) == 0) {
         return;
     }
     // Three cases
     if (!$sefConfig->langEnable) {
         // No languages, find home link with All languages set
         foreach ($homes as $home) {
             if ($home->language == '*') {
                 $links[''] = array('orig' => $home->link, 'Itemid' => $home->id);
                 break;
             }
         }
     } else {
         if (JPluginHelper::isEnabled('system', 'falangdriver')) {
             // FaLang, find home link with All languages set and prepare links with lang= for all languages
             foreach ($homes as $home) {
                 if ($home->language == '*') {
                     // Prepare link with lang=
                     $link = JoomSEF::_uriToUrl(new JURI($home->link . '&lang='));
                     // Loop through languages and prepare links
                     $langs = JLanguageHelper::getLanguages('sef');
                     foreach ($langs as $sef => $lang) {
                         $links[$sef] = array('orig' => str_replace('&lang=', '&lang=' . $sef, $link), 'Itemid' => $home->id);
                     }
                     break;
                 }
             }
         } else {
             // Joomla native multilanguage, for each link with language set prepare a home link
             $langs = JLanguageHelper::getLanguages('lang_code');
             foreach ($homes as $home) {
                 if ($home->language != '*') {
                     // Get SEF code for language
                     if (isset($langs[$home->language])) {
                         $sef = $langs[$home->language]->sef;
                         // Prepare link with lang=
                         $link = JoomSEF::_uriToUrl(new JURI($home->link . '&lang=' . $sef));
                         $links[$sef] = array('orig' => $link, 'Itemid' => $home->id);
                     }
                 }
             }
         }
     }
     // Store the links in database if they don't already exist
     foreach ($links as $sef => $link) {
         $orig = $db->quote($link['orig']);
         $query = "SELECT `id` FROM `#__sefurls` WHERE `origurl` = {$orig} AND (`Itemid` IS NULL OR `Itemid` = '{$link['Itemid']}')";
         $db->setQuery($query);
         $id = $db->loadResult();
         if ($id) {
             continue;
         }
         $query = "INSERT INTO `#__sefurls` (`sefurl`, `origurl`, `Itemid`) VALUES ('{$sef}', {$orig}, '{$link['Itemid']}')";
         $db->setQuery($query);
         $db->query();
     }
 }
Пример #20
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $database =& JFactory::getDBO();
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     $title[] = JoomSEF::_getMenuTitleLang($option, $this->lang);
     switch (@$view) {
         case 'categories':
             break;
         case 'category':
             $catInfo = $this->getCategoryInfo($id);
             if ($catInfo === false) {
                 JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_newsfeeds');
             }
             if (is_array($catInfo->path)) {
                 $title = array_merge($title, $catInfo->path);
             }
             break;
         case 'newsfeed':
             $title = array_merge($title, $this->getFeedTitle($id));
             break;
     }
     if (isset($format)) {
         if ($format == 'feed' && isset($type)) {
             $title[] = $type;
         } else {
             $title[] = $format;
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $this->metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         if (isset($this->lang)) {
             $lang = $this->lang;
         }
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, null, $this->metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
Пример #21
0
 public function create(&$uri)
 {
     $this->metadesc = null;
     $this->cat_desc = null;
     $this->item_desc = null;
     $sefConfig =& SEFConfig::getConfig();
     $title = array();
     $vars = $uri->getQuery(true);
     extract($vars);
     $this->_createNonSefVars($uri);
     // Set title.
     $title[] = JoomSEF::_getMenuTitleLang(@$option, $this->lang, @$Itemid);
     switch (@$view) {
         case 'form':
             // 13.2.2012, dajo: Don't SEF
             return $uri;
             //$this->nonSefVars = array();
             //$this->nonSefVars["return"]=@$return;
             //if(isset($a_id)) {
             //    $title=array_merge($title,$this->_getArticle($a_id));
             //}
             //$title[] = JText::_('COM_SEF_FORM');
             //break;
         //$this->nonSefVars = array();
         //$this->nonSefVars["return"]=@$return;
         //if(isset($a_id)) {
         //    $title=array_merge($title,$this->_getArticle($a_id));
         //}
         //$title[] = JText::_('COM_SEF_FORM');
         //break;
         case 'featured':
             if (isset($format) && $format == "feed") {
                 @($title[] = $type);
             }
             $title = array_merge($title, $this->_processPagination($uri));
             break;
         case 'categories':
             break;
         case 'category':
             if (isset($id)) {
                 $catInfo = $this->getCategoryInfo($id);
                 if ($catInfo === false) {
                     JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_content');
                     return $uri;
                 }
                 if (is_array($catInfo->path) && count($catInfo->path) > 0) {
                     $title = array_merge($title, $catInfo->path);
                 }
             }
             if ($this->params->get('add_layout') == 2 || $this->params->get('add_layout') == 1 && $this->params->get('def_layout') != @$layout) {
                 @($title[] = $layout);
             }
             if (isset($format) && $format == "feed") {
                 @($title[] = $type);
             }
             $title = array_merge($title, $this->_processPagination($uri));
             break;
         case 'article':
             $articleInfo = $this->_getArticle($id);
             if (!$articleInfo) {
                 return $uri;
             }
             $title = array_merge($title, $articleInfo);
             $title = array_merge($title, $this->_processPagination($uri));
             break;
         case 'archive':
             if (!empty($year)) {
                 $title[] = $year;
             }
             if (!empty($month)) {
                 $title[] = $month;
             }
             $title = array_merge($title, $this->_processPagination($uri));
             break;
         default:
             switch (@$task) {
                 case 'article.add':
                     if (isset($catid)) {
                         $catInfo = $this->getCategoryInfo($catid);
                         if ($catInfo === false) {
                             JoomSefLogger::Log("Category with ID {$catid} could not be found.", $this, 'com_content');
                             return $uri;
                         }
                         if (is_array($catInfo->path) && count($catInfo->path) > 0) {
                             $title = array_merge($title, $catInfo->path);
                         }
                     }
                     if ($this->params->get('always_en', '0') == '1') {
                         $title[] = 'New';
                     } else {
                         $title[] = JText::_('COM_SEF_NEW');
                     }
                     break;
                 case 'article.edit':
                     if (isset($a_id)) {
                         $title = array_merge($title, $this->_getArticle($a_id));
                     }
                     if ($this->params->get('always_en', '0') == '1') {
                         $title[] = 'Edit';
                     } else {
                         $title[] = JText::_('COM_SEF_EDIT');
                     }
                     break;
                 default:
                     // Don't SEF
                     return $uri;
             }
             break;
     }
     // Handle printing
     if (isset($print) && intval($print) == 1) {
         if ($this->params->get('always_en', '0') == '1') {
             $title[] = 'Print';
         } else {
             $title[] = JText::_('JGLOBAL_PRINT');
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $this->metatags = $this->getMetaTags();
         if ($this->params->get('meta_titlepage', '0') == '1' && !empty($this->pageNumberText)) {
             // Add page number to page title
             if (!empty($this->metatags["metatitle"])) {
                 $this->metatags["metatitle"] .= ' - ' . $this->pageNumberText;
             } else {
                 $this->metatags["metatitle"] = (!empty($this->pageTitle) ? $this->pageTitle . ' - ' : '') . $this->pageNumberText;
             }
         }
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         if (isset($this->lang)) {
             $lang = $this->lang;
         }
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $this->metatags, $priority, true, null, $sitemap);
     }
     return $newUri;
 }
Пример #22
0
 function create(&$uri)
 {
     $this->metadesc = null;
     // Extract variables
     $vars = $uri->getQuery(true);
     extract($vars);
     $this->params = SEFTools::getExtParams('com_contact');
     $title[] = JoomSEF::_getMenuTitleLang(@$option, $this->lang, @$Itemid);
     if (isset($view)) {
         switch ($view) {
             case 'categories':
             case 'featured':
                 break;
             case 'category':
                 $catInfo = $this->getCategoryInfo($id);
                 if ($catInfo === false) {
                     JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_contact');
                 }
                 if (is_array($catInfo->path)) {
                     $title = array_merge($title, $catInfo->path);
                 }
                 break;
             case 'contact':
                 $title = array_merge($title, $this->getContactName($id));
                 break;
         }
     }
     if (!empty($format)) {
         if ($format == 'feed' && !empty($type)) {
             $title[] = $type;
         } elseif ($format == 'vcf') {
             $title[] = 'vCard';
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $this->metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         if (isset($this->lang)) {
             $lang = $this->lang;
         }
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, null, $this->metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
Пример #23
0
 function _checkBaseHref()
 {
     $sefConfig = SEFConfig::getConfig();
     $checkBaseHref = $sefConfig->check_base_href;
     // now we can set base href
     $document = JFactory::getDocument();
     if ($checkBaseHref == _COM_SEF_BASE_HOMEPAGE) {
         $uri = JURI::getInstance();
         $curUri = clone $uri;
         $domain = JoomSEF::get('real_domain');
         if ($domain) {
             $curUri->setHost($domain);
         }
         // dajo 10.9.2012: Make sure base ends with a slash
         $base = $curUri->toString(array('scheme', 'host', 'port')) . JURI::base(true);
         $base = rtrim($base, '/') . '/';
         $document->setBase($base);
     } elseif ($checkBaseHref == _COM_SEF_BASE_CURRENT) {
         $uri = JURI::getInstance();
         $curUri = clone $uri;
         $domain = JoomSEF::get('real_domain');
         if ($domain) {
             $curUri->setHost($domain);
         }
         $document->setBase(htmlspecialchars($curUri->toString(array('scheme', 'host', 'port', 'path'))));
     } elseif ($checkBaseHref == _COM_SEF_BASE_NONE) {
         $document->setBase('');
     } else {
         return;
     }
 }
Пример #24
0
           <input type="button" value="<?php 
echo JText::_('COM_SEF_ADD_META_TAG');
?>
" onclick="addMetaTag();" />
        </fieldset>
    </div>
    <div style="clear: both;"></div>
    
	<?php 
if (JRequest::getInt('viewmode') != 6) {
    echo JHtml::_('tabs.panel', JText::_('COM_SEF_SITEMAP'), 'sitemap-panel');
    JoomSEF::OnlyPaidVersion();
}
if (JRequest::getInt('viewmode') != 6) {
    echo JHtml::_('tabs.panel', JText::_('COM_SEF_INTERNAL_LINKS'), 'internal-panel');
    JoomSEF::OnlyPaidVersion();
}
echo JHtml::_('tabs.end');
?>

<input type="hidden" name="option" value="com_sef" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="sefurls" />
<input type="hidden" name="unchanged" value="<?php 
echo $this->sef->sefurl;
?>
" />
<input type="hidden" name="urlchanged" value="0" />
<input type="hidden" name="addtosefmoved" value="0" />
<input type="hidden" name="dateadd" value="<?php 
echo $this->sef->dateadd;
Пример #25
0
 function create(&$uri)
 {
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     // Don't SEF if no variables
     if (self::$is20 && is_null($uri->getVar('view'))) {
         return $uri;
     }
     // JF translate extension.
     $sefConfig =& SEFConfig::getConfig();
     $database =& JFactory::getDBO();
     $jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
     // load params
     $this->params = SEFTools::getExtParams('com_kunena');
     $catRewrite = true;
     $msgRewrite = true;
     $usrRewrite = true;
     /*if (isset($view) && ($view == 'category')) {
           $msgRewrite = false;
       }*/
     if ($msgRewrite || $catRewrite) {
         if ($catRewrite && !empty($catid)) {
             $categories = $this->GetCategories($catid);
             if (is_null($categories)) {
                 // Error, don't SEF
                 return $uri;
             }
         }
         if (isset($id)) {
             $msgID = $id;
         } elseif (isset($msg_id)) {
             $msgID = $msg_id;
         } elseif (isset($replyto)) {
             $msgID = $replyto;
         } elseif (isset($pid)) {
             $msgID = $pid;
         } else {
             $msgID = null;
         }
         if ($msgRewrite && !empty($msgID)) {
             if (isset($func) && $func == 'announcement') {
                 $msgTitle = $this->GetAnnouncementTitle($msgID);
             } else {
                 if (self::$is20) {
                     $msgTitle = $this->GetTopicTitle($msgID);
                 } else {
                     $msgTitle = $this->GetMessageTitle($msgID);
                 }
             }
             if (is_null($msgTitle)) {
                 // Error, don't SEF
                 return $uri;
             }
         }
     }
     // Set non-sef vars according to settings
     $this->_createNonSefVars($uri);
     // this needs to follow previous that use do
     if ($this->params->get('doExclude', true)) {
         unset($do);
     }
     // get user ID
     if ($usrRewrite && isset($userid)) {
         if ($this->params->get('userIdInsteadOfLogin', false)) {
             $usrTitle = 'user-' . $userid;
         } else {
             $query = "SELECT `username` FROM `#__users` WHERE `id` = {$userid}";
             $database->setQuery($query);
             $usrTitle = $database->loadResult();
         }
     }
     // use view if func not set
     if (!isset($func) && isset($view)) {
         $func = $view;
         unset($view);
     }
     // if task is not set, use do
     if (empty($task) && isset($func) && $func == 'post' && isset($do)) {
         $task = $do;
         unset($func);
         unset($do);
     }
     if (empty($task) && isset($func)) {
         $task = $func;
         unset($func);
     }
     // First subdir
     if (!empty($option) && !self::$is16) {
         $title[] = JoomSEF::_getMenuTitle($option, @$task, @$Itemid);
     } elseif (self::$is16) {
         $menuTitle = $this->getDefaultForumMenuTitle();
         if (!is_null($menuTitle)) {
             $title[] = $menuTitle;
         }
     }
     // Category
     if (isset($categories) && !empty($categories)) {
         $addCat = $this->params->get('categories', '2');
         if ($addCat == '2') {
             $title = array_merge($title, $categories);
         } else {
             if ($addCat == '1' || empty($msgID)) {
                 $title[] = $categories[count($categories) - 1];
             }
         }
     }
     // Announcement
     if (@$task == 'announcement') {
         $title[] = JText::_('Announcements');
     }
     // Topic
     if (isset($msgTitle) && !empty($msgTitle) && isset($task) && $task != 'showcat') {
         //$title[] = (!isset($do) && !isset($func)) ? $msgTitle.$sefConfig->suffix : $msgTitle;
         $title[] = $msgTitle;
     }
     if (isset($task) && in_array($task, array('search', 'advsearch'))) {
         if ($task == 'advsearch') {
             $title[] = JText::_('Advanced Search');
         } else {
             $title[] = JText::_($task);
         }
         if (isset($limitstart)) {
             unset($limitstart);
         }
         if (isset($limit)) {
             unset($limit);
         }
         unset($task);
     }
     if (isset($task) && $task == 'topics') {
         $title[] = $task;
         unset($task);
     }
     // Cleanout some views
     if (in_array(@$view, array('entrypage', 'category', 'topic', 'home'))) {
         unset($view);
     }
     // Cleanout some funcs
     if (in_array(@$func, array('showcat', 'view', 'announcement', 'entrypage', 'rules', 'category', 'topic', 'home'))) {
         unset($func);
     }
     // Cleanout some tasks
     if (in_array(@$task, array('showcat', 'view', 'announcement', 'entrypage', 'category', 'topic', 'home'))) {
         unset($task);
     }
     // View
     if (isset($view)) {
         $title[] = $view;
     }
     // JSON
     if (isset($task) && $task == 'json') {
         $title[] = $task;
         unset($task);
     }
     // Action
     if (isset($action)) {
         $title[] = $action;
         unset($action);
     }
     // User
     if (@$task == 'user') {
         if (empty($Itemid)) {
             $title[] = 'user';
         } else {
             $app = JFactory::getApplication();
             $menu = $app->getMenu('site');
             $item = $menu->getItem($Itemid);
             if (!is_object($item) || !isset($item->query['view']) || $item->query['view'] != 'user') {
                 $title[] = 'user';
             } else {
                 $title[] = 'profile';
             }
         }
         $task = null;
     }
     if (isset($usrTitle) && !empty($usrTitle)) {
         if (@$task == 'fbprofile') {
             $title[] = 'users';
             $task = null;
         } elseif (@$task == 'profile') {
             $title[] = 'profile';
             $task = null;
         } elseif (@$task == 'showprf') {
             $task = null;
         }
         $title[] = $usrTitle;
     }
     // Misc
     if (@$task == 'misc' && !empty($Itemid)) {
         // Use correct menu title
         $title[] = JoomSEF::_getMenuTitle(null, null, $Itemid);
         $task = null;
     }
     // Layout
     if (isset($layout)) {
         switch ($layout) {
             case 'reply':
                 if (isset($quote) && $quote) {
                     $layout = 'quote';
                 }
                 $title[] = $layout;
                 break;
             case 'list':
                 if ($uri->getVar('view') == 'category') {
                     $layout = 'index';
                     $title[] = $layout;
                 } else {
                     if ($uri->getVar('view') == 'user') {
                         $title[] = $layout;
                     }
                 }
                 break;
             case 'default':
                 // Don't add
                 break;
             default:
                 $title[] = $layout;
                 break;
         }
         unset($layout);
     }
     // Gallery
     if (isset($gallery)) {
         $title[] = $gallery;
     }
     // Func and do
     if (isset($do) || isset($func)) {
         if (isset($func)) {
             if ($func == 'search') {
                 $oper[] = 'do';
             }
             $oper[] = $func;
         }
         if (isset($do)) {
             $oper[] = $do;
         }
         $title[] = join('-', $oper) . $sefConfig->suffix;
     }
     // Fix some task texts
     if (isset($task)) {
         $task = str_replace(array('listcat', 'userlist'), array('categories', 'users'), $task);
     }
     // Mode
     if (isset($mode) && $mode == 'noreplies') {
         $title[] = $mode;
     }
     // Feeds
     if (isset($format)) {
         switch ($format) {
             case 'feed':
                 if (!isset($type)) {
                     $type = 'rss';
                 }
                 $title[] = $type;
                 break;
             case 'raw':
                 $title[] = $format;
                 break;
         }
     }
     // Page number
     if (isset($limitstart)) {
         // Limit should be set due to beforeCreate function, but to be sure
         if (!isset($limit)) {
             if (in_array($uri->getVar('view'), array('category', 'topics')) && isset(self::$kunenaConfig->threads_per_page)) {
                 $limit = self::$kunenaConfig->threads_per_page;
             } elseif ($uri->getVar('view') == 'user') {
                 $limit = self::$kunenaConfig->userlist_rows;
             } else {
                 $limit = self::$kunenaConfig->messages_per_page;
             }
         }
         $pageNum = intval($limitstart / $limit) + 1;
         $pagetext = strval($pageNum);
         if ($cnfPageText = $sefConfig->getPageText()) {
             $pagetext = str_replace('%s', $pageNum, $cnfPageText);
         }
         $title = array_merge($title, explode('/', $pagetext));
         //$title[] = $pagetext;
     }
     // Selection
     if (!empty($sel)) {
         if (isset($task) && $task == 'latest') {
             $num = $sel >= 24 ? $sel / 24 : $sel;
             $title[] = $task . '-' . $num;
             unset($task);
         } else {
             $title[] = $sel;
         }
     }
     if (isset($page) && $page > 1) {
         $pagetext = strval($page);
         if ($cnfPageText = $sefConfig->getPageText()) {
             $pagetext = str_replace('%s', $page, $cnfPageText);
         }
         $title[] = $pagetext;
     }
     // Task
     if (isset($task)) {
         $title[] = $task;
         unset($task);
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, @$limit, @$limitstart, @$lang, $this->nonSefVars, $this->ignoreVars, null, null, true);
     }
     return $newUri;
 }
Пример #26
0
 function create(&$uri)
 {
     // Extract variables
     $vars = $uri->getQuery(true);
     extract($vars);
     $title = array();
     $this->params = SEFTools::getExtParams('com_contact');
     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
     if (isset($view)) {
         switch ($view) {
             case 'contact':
                 $title = array_merge($title, $this->getContactName($id));
                 unset($view);
                 break;
             case 'category':
                 if (isset($catid)) {
                     $title[] = $this->getCategoryTitle($catid);
                 }
                 unset($view);
                 break;
         }
     }
     if (!empty($format) && $format == 'feed') {
         if (!empty($type)) {
             $title[] = $type;
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $metatags = $this->getMetaTags();
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, @$view, null, null, @$lang, null, null, $metatags, $priority, false, null, $sitemap);
     }
     return $newUri;
 }
Пример #27
0
 function create(&$uri)
 {
     $sefConfig =& SEFConfig::getConfig();
     $mainframe =& JFactory::getApplication();
     $this->params =& SEFTools::GetExtParams('com_content');
     $vars = $uri->getQuery(true);
     extract($vars);
     // Do not SEF URLs with exturl variable
     //if( !empty($exturl) )   return $string;
     // Do not SEF edit urls
     if (isset($task) && $task == 'edit') {
         return $uri;
     }
     // Set title.
     $title = array();
     switch (@$view) {
         case 'new':
         case 'edit':
             /*
             $title[] = getMenuTitle($option, $task, $Itemid, $string);
             $title[] = 'new' . $sefConfig->suffix;
             */
             break;
         case 'archive':
             $title[] = JText::_($view);
             if (!empty($year)) {
                 $title[] = $year;
             }
             if (!empty($month)) {
                 $title[] = $month;
             }
             break;
             /*
             case 'archivecategory':
             case 'archivesection': {
             if (eregi($task.".*id=".$id, $_SERVER['REQUEST_URI'])) break;
             }
             */
         /*
         case 'archivecategory':
         case 'archivesection': {
         if (eregi($task.".*id=".$id, $_SERVER['REQUEST_URI'])) break;
         }
         */
         default:
             if (isset($format)) {
                 if ($format == 'pdf') {
                     // wrong ID
                     if (intval($id) == 0) {
                         return $uri;
                     }
                     // create PDF
                     $title = $this->_getContentTitles(!empty($view) ? $view : 'article', $id);
                     if (count($title) === 0) {
                         $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     }
                     // Add Google News number if set to
                     if (@$view == 'article' && $this->params->get('googlenewsnum', '0') != '0') {
                         $i = count($title) - 1;
                         $title[$i] = $this->GoogleNews($title[$i], $id);
                     }
                     $title[] = JText::_('PDF');
                 } elseif ($format == 'feed') {
                     // Create feed
                     if (@$view != 'frontpage') {
                         // wrong ID
                         if (intval($id) == 0) {
                             return $uri;
                         }
                         $title = $this->_getContentTitles(!empty($view) ? $view : 'article', $id);
                         // Add Google News number if set to
                         if (@$view == 'article' && $this->params->get('googlenewsnum', '0') != '0') {
                             $i = count($title) - 1;
                             $title[$i] = $this->GoogleNews($title[$i], $id);
                         }
                     }
                     if (count($title) === 0 && empty($type)) {
                         $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     }
                     if (!empty($type)) {
                         $title[] = $type;
                     }
                 }
             } else {
                 if (isset($id)) {
                     // wrong ID
                     if (intval($id) == 0) {
                         return $uri;
                     }
                     $title = $this->_getContentTitles(@$view, @$id);
                     if (count($title) === 0) {
                         $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     }
                     // Add Google News number if set to
                     if (@$view == 'article' && $this->params->get('googlenewsnum', '0') != '0') {
                         $i = count($title) - 1;
                         $title[$i] = $this->GoogleNews($title[$i], $id);
                     }
                 } else {
                     $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid);
                     //$title[] = JText::_('Submit');
                 }
                 // Layout
                 $addLayout = $this->params->get('add_layout', '2');
                 if (isset($layout) && !empty($layout) && $addLayout != '0') {
                     if ($addLayout == '2') {
                         $defLayout = $this->params->get('def_layout', 'default');
                         if ($layout != $defLayout) {
                             $title[] = $layout;
                         }
                     } else {
                         $title[] = $layout;
                     }
                 }
                 if (isset($limitstart) && (!$sefConfig->appendNonSef || $this->params->get('pagination', '0') == '0')) {
                     $pagetext = null;
                     if (@$view == 'article') {
                         // Multipage article - get the correct page title
                         $page = $limitstart + 1;
                         if ($this->params->get('multipagetitles', '1') == '1') {
                             $pagetext = $this->_getPageTitle($limitstart);
                         }
                     } else {
                         // Is limit set?
                         if (!isset($limit)) {
                             // Try to get limit from menu parameters
                             $menu =& JSite::getMenu();
                             if (!isset($Itemid)) {
                                 // We need to find Itemid first
                                 $active =& $menu->getActive();
                                 $Itemid = $active->id;
                             }
                             $menuParams =& $menu->getParams($Itemid);
                             $leading = $menuParams->get('num_leading_articles', 1);
                             $intro = $menuParams->get('num_intro_articles', 4);
                             $links = $menuParams->get('num_links', 4);
                             if (isset($layout) && $layout == 'blog') {
                                 $limit = $leading + $intro;
                                 // + $links;
                             } else {
                                 $limit = $menuParams->get('display_num', $mainframe->getCfg('list_limit'));
                                 $limit = $mainframe->getUserStateFromRequest('com_content.' . $uri->getVar('layout', 'default') . '.limit', 'limit', $limit, 'int');
                             }
                         }
                         $page = intval($limitstart / $limit) + 1;
                     }
                     if (is_null($pagetext)) {
                         $pagetext = strval($page);
                         if ($cnfPageText = $sefConfig->getPageText()) {
                             $pagetext = str_replace('%s', $page, $cnfPageText);
                         }
                     }
                     $title = array_merge($title, explode('/', $pagetext));
                     //$title[] = $pagetext;
                 }
                 // show all
                 if (isset($showall) && $showall == 1) {
                     $title[] = JText::_('All Pages');
                 }
                 // print article
                 if (isset($print) && $print == 1) {
                     $title[] = JText::_('Print') . (!empty($page) ? '-' . ($page + 1) : '');
                 }
             }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         // Generate meta tags
         $metatags = $this->getMetaTags();
         if (isset($this->metatitle)) {
             $metatags['metatitle'] = $this->metatitle;
         }
         $this->_createNonSefVars($uri);
         $priority = $this->getPriority($uri);
         $sitemap = $this->getSitemapParams($uri);
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $metatags, $priority, true, null, $sitemap);
     }
     return $newUri;
 }
Пример #28
0
 public function create(&$uri)
 {
     $title = array();
     $vars = $uri->getQuery(true);
     $this->_createNonSefVars($uri);
     // Set menu title
     $title[] = JoomSEF::_getMenuTitle($uri->getVar('option'), $uri->getVar('task'), $uri->getVar('Itemid'));
     if (isset($vars['view'])) {
         switch ($vars['view']) {
             case 'tag':
                 if (isset($vars['id'])) {
                     $tag = $this->getTag($vars['id']);
                     if (is_null($tag)) {
                         JoomSefLogger::Log('Tag with ID ' . $vars['id'] . ' not set.', $this, 'com_tags');
                         return $uri;
                     }
                     $title[] = $tag;
                 }
                 break;
             default:
                 $title[] = $vars['view'];
                 break;
         }
     }
     $newUri = $uri;
     if (count($title) > 0) {
         $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, $uri->getVar('lang'), $this->nonSefVars, null, null, null, true);
     }
     return $newUri;
 }
Пример #29
0
 /**
  * Inserts new SEF URL to database
  *
  */
 function _saveNewURL($Itemid, &$metadata, $priority, $temploc, $url, $host, $sitemapParams)
 {
     $db =& JFactory::getDBO();
     $col = $val = '';
     if (!empty($Itemid)) {
         $col = ', `Itemid`';
         $val = ", '{$Itemid}'";
     }
     $metakeys = $metavals = '';
     if (is_array($metadata) && count($metadata) > 0) {
         foreach ($metadata as $metakey => $metaval) {
             $metakeys .= ", `{$metakey}`";
             $metavals .= ", '" . str_replace(array("\\", "'", ';'), array("\\\\", "\\'", "\\;"), $metaval) . "'";
         }
     }
     // get trace information if set to
     $sefConfig =& SEFConfig::getConfig();
     if (@$sefConfig->trace) {
         $traceinfo = $db->quote(JoomSEF::_getDebugInfo($sefConfig->traceLevel));
     } else {
         $traceinfo = "NULL";
     }
     // Sitemap default values
     $sm_indexed = isset($sitemapParams['indexed']) ? $sitemapParams['indexed'] : ($sefConfig->sitemap_indexed ? 1 : 0);
     $sm_date = date('Y-m-d');
     $sm_frequency = isset($sitemapParams['frequency']) ? $sitemapParams['frequency'] : $sefConfig->sitemap_frequency;
     $sm_priority = isset($sitemapParams['priority']) ? $sitemapParams['priority'] : $sefConfig->sitemap_priority;
     $autolock = (int) $sefConfig->autolock_urls;
     $query = 'INSERT INTO `#__sefurls` (`sefurl`, `origurl`, `priority`' . $col . $metakeys . ', `trace`, `sm_indexed`, `sm_date`, `sm_frequency`, `sm_priority`,`locked`,`host`) ' . "VALUES ('" . $temploc . "', " . $db->quote(html_entity_decode(urldecode($url))) . ", '{$priority}'" . $val . $metavals . ", " . $traceinfo . ", '{$sm_indexed}', '{$sm_date}', '{$sm_frequency}', '{$sm_priority}'," . $autolock . ",'" . $host . "')";
     $db->setQuery($query);
     // if error occured
     if (!$db->query()) {
         JError::raiseError('JoomSEF Error', JText::_('COM_SEF_ERROR_SEF_URL_STORE') . $db->getErrorMsg());
     }
 }
Пример #30
0
 function parse(&$uri)
 {
     $mainframe =& JFactory::getApplication();
     $sefConfig =& SEFConfig::getConfig();
     JoomSEF::set('sef.global.meta', SEFTools::GetSEFGlobalMeta());
     // Try to fix the missing question mark if set to
     if ($sefConfig->fixQuestionMark && count($_POST) == 0) {
         $url = $uri->toString();
         $newUrl = preg_replace('/^([^?&]*)&([^?]+=[^?]*)$/', '$1?$2', $url);
         if ($newUrl != $url) {
             // Redirect
             $mainframe->redirect($newUrl, '', 'message', true);
         }
     }
     $vars = array();
     $vars = JoomSEF::parse($uri);
     $menu =& JSite::getMenu(true);
     //Handle an empty URL (special case)
     if (empty($vars['Itemid']) && empty($vars['option'])) {
         $item = $menu->getDefault();
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         // set the information in the request
         $vars = $item->query;
         // get the itemid
         $vars['Itemid'] = $item->id;
         // set the active menu item
         $menu->setActive($vars['Itemid']);
         // set vars
         $this->setRequestVars($vars);
         $this->fixDocument($vars);
         return $vars;
     }
     // Get the item id, if it hasn't been set force it to null
     if (empty($vars['Itemid'])) {
         $vars['Itemid'] = JRequest::getInt('Itemid', null);
     }
     // Get the variables from the uri
     $this->setVars($vars);
     // No option? Get the full information from the itemid
     if (empty($vars['option'])) {
         $item = $menu->getItem($this->getVar('Itemid'));
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         $vars = $vars + $item->query;
     }
     // Set the active menu item
     $menu->setActive($this->getVar('Itemid'));
     // Set base href
     //$this->setBaseHref($vars);
     // Set vars
     $this->setRequestVars($vars);
     $this->fixDocument($vars);
     return $vars;
 }