Esempio n. 1
0
 function route($link, $xhtml = true, $ssl = null)
 {
     if (false === strpos($link, 'index.php') && false === strpos($link, 'index2.php')) {
         $link = 'index.php?' . $link;
     }
     // Check core sef
     $sef = cmsFramework::getConfig('sef');
     $sef_rewrite = cmsFramework::getConfig('sef_rewrite');
     if (false === strpos($link, 'option=com_jreviews') && !$sef) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         if (false === strpos($url, 'http')) {
             $parsedUrl = parse_url(WWW_ROOT);
             $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
             $url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . $url;
         }
         return $url;
     } elseif (false === strpos($link, 'option=com_jreviews')) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         return $url;
     }
     // Fixes component menu urls with pagination and ordering parameters when core sef is enabled.
     $link = str_replace('//', '/', $link);
     if ($sef) {
         if (substr($link, 0, 10) === 'index.php') {
             $link = str_replace('/', '%2F', $link);
         }
         // Core sef doesn't know how to deal with colons, so we convert them to something else and then replace them again.
         $link = str_replace(_PARAM_CHAR, '*@*', $link);
         $sefUrl = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         $sefUrl = str_replace('%2A%40%2A', _PARAM_CHAR, $sefUrl);
         $sefUrl = str_replace('*@*', _PARAM_CHAR, $sefUrl);
         // For non sef links
         $link = $sefUrl;
     }
     if (false !== strpos($link, 'http')) {
         return $link;
     } else {
         $parsedUrl = parse_url(WWW_ROOT);
         $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
         $www_root = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . ($sef ? _DS : $parsedUrl['path']);
         return $www_root . ltrim($link, _DS);
     }
 }
Esempio n. 2
0
 function route($link, $xhtml = true, $ssl = null)
 {
     $menu_alias = '';
     if (false === strpos($link, 'index.php') && false === strpos($link, 'index2.php')) {
         $link = 'index.php?' . $link;
     }
     // Check core sef
     $sef = cmsFramework::getConfig('sef');
     $sef_rewrite = cmsFramework::getConfig('sef_rewrite');
     if (false === strpos($link, 'option=com_jreviews') && !$sef) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         if (false === strpos($url, 'http')) {
             $parsedUrl = parse_url(WWW_ROOT);
             $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
             $url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . $url;
         }
         return $url;
     } elseif (false === strpos($link, 'option=com_jreviews')) {
         $url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         return $url;
     }
     // Fixes component menu urls with pagination and ordering parameters when core sef is enabled.
     $link = str_replace('//', '/', $link);
     if ($sef) {
         $mod_rewrite = cmsFramework::getConfig('sef_rewrite');
         // Mod Rewrite is not enabled
         if (!$mod_rewrite) {
             preg_match('/Itemid=([0-9]+)/', $link, $matches);
             if (isset($matches[1]) && is_numeric($matches[1])) {
                 $link2 = 'index.php?option=com_jreviews&Itemid=' . $matches[1];
                 $menu_alias = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link2, $xhtml, $ssl) : JRoute::_($link2, $xhtml, $ssl);
                 strstr($menu_alias, 'index.php') and $menu_alias = str_replace('.html', '/', substr($menu_alias, strpos($menu_alias, 'index.php' . _DS) + 10));
                 $menu_alias .= '/';
                 $menu_alias = '/' . ltrim(array_shift(explode('?', $menu_alias)), '/');
             }
         }
         // Core sef doesn't know how to deal with colons, so we convert them to something else and then replace them again.
         $link = $nonsef_link = str_replace(_PARAM_CHAR, '*@*', $link);
         $sefUrl = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
         $sefUrl = str_replace('%2A%40%2A', _PARAM_CHAR, $sefUrl);
         $sefUrl = str_replace('*@*', _PARAM_CHAR, $sefUrl);
         // For non sef links
         if (!class_exists('shRouter')) {
             // Get rid of duplicate menu alias segments added by the JRoute function
             if (strstr($sefUrl, 'order:') || strstr($sefUrl, 'page:') || strstr($sefUrl, 'limit:')) {
                 $sefUrl = str_replace(array('/format:html/', '.html'), '/', $sefUrl);
             }
             // Get rid of duplicate menu alias segments added by the JRoute function
             if ($menu_alias != '' && $menu_alias != '/' && !$mod_rewrite) {
                 $sefUrl = str_replace($menu_alias, '--menuAlias--', $sefUrl, $count);
                 $sefUrl = str_replace(str_repeat('--menuAlias--', $count), $menu_alias, $sefUrl);
             }
         }
         $link = $sefUrl;
         // If it's not a JReviews menu url remove the suffix
         $nonsef_link = str_replace('&', '&', $nonsef_link);
         if (substr($nonsef_link, -5) == '.thtml' && !preg_match('/^index.php\\?option=com_jreviews&Itemid=([0-9]+)$/i', $nonsef_link)) {
             $link = str_replace('.html', '', $sefUrl);
         }
     }
     if (false !== strpos($link, 'http')) {
         return $link;
     } else {
         $parsedUrl = parse_url(WWW_ROOT);
         $port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
         $www_root = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . ($sef ? _DS : $parsedUrl['path']);
         return $www_root . ltrim($link, _DS);
     }
 }