29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-29 16:43:42 +00:00

Moved some code form base class to extended class to improve router flexibility

git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@9008 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
This commit is contained in:
Johan Janssens 2007-09-25 00:16:40 +00:00
parent 4f7bca6270
commit b4afbacde5
2 changed files with 12 additions and 16 deletions

View File

@ -37,24 +37,30 @@ class JRouterSite extends JRouter
{
$vars = array();
// Get the path
$path = $uri->getPath();
//Remove the suffix from the uri
if($this->_mode == JROUTER_MODE_SEF)
{
// Get the application
$app =& JFactory::getApplication();
// Get the path
$path = $uri->getPath();
if($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/'))
{
if($suffix = pathinfo($path, PATHINFO_EXTENSION))
{
$uri->setPath(str_replace('.'.$suffix, '', $path));
$path = str_replace('.'.$suffix, '', $path);
$vars['format'] = $suffix;
}
}
}
$path = substr_replace($path, '', 0, strlen(JURI::base(true))); //Remove basepath
$path = str_replace('index.php', '', $path); //Remove prefix
//Set the route
$uri->setPath(trim($path , '/'));
$vars += parent::parse($uri);
@ -63,7 +69,7 @@ class JRouterSite extends JRouter
function &build($url)
{
$uri =& parent::build($url);
$uri =& parent::build(JURI::base().$url);
// Get the path data
$route = $uri->getPath();

View File

@ -128,16 +128,6 @@ class JRouter extends JObject
{
$vars = array();
//Get the route
$path = $uri->getPath();
//Transform the route
$path = substr_replace($path, '', 0, strlen(JURI::base(true))); //Remove basepath
$path = str_replace('index.php', '', $path); //Remove prefix
//Set the route back
$uri->setPath(trim($path , '/'));
// Process the parsed variables based on custom defined rules
$vars = $this->_processParseRules($uri);
@ -381,7 +371,7 @@ class JRouter extends JObject
}
// Decompose link into url component parts
$uri = new JURI(JURI::base().$url);
$uri = new JURI($url);
return $uri;
}