Routing update
This commit is contained in:
parent
d128dd950a
commit
135fde1f87
3 changed files with 69 additions and 112 deletions
|
|
@ -104,94 +104,62 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
|
||||
$router = $this->getResource('front')->getRouter();
|
||||
|
||||
// Set global lang param
|
||||
$router->setGlobalParam('lang', 'sv');
|
||||
|
||||
// Default route to default module
|
||||
$router->addRoute('default', new Zend_Controller_Router_Route(':lang/:controller/:action/*',
|
||||
array(
|
||||
'module' => 'default',
|
||||
'controller' => 'index',
|
||||
'action' => 'index'
|
||||
)));
|
||||
|
||||
// Allow "direct access" to index controller in default module
|
||||
$router->addRoute('default-default', new Zend_Controller_Router_Route(':lang/:action/*',
|
||||
array(
|
||||
'module' => 'default',
|
||||
'controller' => 'index',
|
||||
'action' => 'index'
|
||||
),
|
||||
array(
|
||||
'action' => '(about)'
|
||||
)));
|
||||
|
||||
|
||||
// Routes for blog module
|
||||
$router->addRoute('blog',new Zend_Controller_Router_Route(':lang/blog/:controller/:action/:id',array(
|
||||
'module' => 'blog',
|
||||
'controller' => 'index',
|
||||
'action' => 'index',
|
||||
'id' => ''
|
||||
)));
|
||||
$router->addRoute('blog-default',new Zend_Controller_Router_Route(':lang/blog/:action/:id',array(
|
||||
'module' => 'blog',
|
||||
'controller' => 'index',
|
||||
'action' => 'latest',
|
||||
'id' => ''
|
||||
),array(
|
||||
'action' => '(latest|read|readable)'
|
||||
)));
|
||||
|
||||
|
||||
// Route for admin?
|
||||
$router->addRoute('admin', new Zend_Controller_Router_Route(':lang/admin/:controller/:action',array(
|
||||
'module' => 'admin',
|
||||
'controller' => 'index',
|
||||
'action' => 'index'
|
||||
)));
|
||||
|
||||
|
||||
// Route for auth
|
||||
$router->addRoute('auth', new Zend_Controller_Router_Route(':lang/:action',array(
|
||||
'module' => 'default',
|
||||
'controller' => 'auth',
|
||||
),array(
|
||||
'action' => '(login|logout)'
|
||||
)));
|
||||
|
||||
/*
|
||||
* Default routes to the default module
|
||||
*/
|
||||
$router->addRoute('default', new Zend_Controller_Router_Route(':lang/:controller/:action',
|
||||
array(
|
||||
'lang' => 'sv',
|
||||
'module' => 'default',
|
||||
'controller' => 'index',
|
||||
'action' => 'index'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
/*
|
||||
* This route allows direct access to IndexController
|
||||
* without specifying "index" as controller.
|
||||
*
|
||||
* Allowed actions need to be specified!
|
||||
*/
|
||||
$router->addRoute('index', new Zend_Controller_Router_Route(
|
||||
':lang/:action',
|
||||
array(
|
||||
'lang' => 'sv',
|
||||
'module' => 'default',
|
||||
'controller' => 'index',
|
||||
'action' => 'index'
|
||||
),
|
||||
array(
|
||||
'action' => '(about)'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
/*
|
||||
* Route to the blog module
|
||||
* TODO: This prob. needs changing.
|
||||
*/
|
||||
$router->addRoute('blog', new Zend_Controller_Router_Route(
|
||||
':lang/blog/:action/:id',
|
||||
array(
|
||||
'lang' => 'sv',
|
||||
'module' => 'blog',
|
||||
'controller' => 'index',
|
||||
'action' => 'latest',
|
||||
'id' => ''
|
||||
),
|
||||
array(
|
||||
'lang' => '(en|sv)'
|
||||
)
|
||||
));
|
||||
|
||||
$router->addRoute('portfolio', new Zend_Controller_Router_Route(
|
||||
':lang/portfolio/:action',
|
||||
array(
|
||||
'lang' => 'sv',
|
||||
'module' => 'default',
|
||||
'controller' => 'portfolio',
|
||||
'action' => 'index'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$router->addRoute('admin', new Zend_Controller_Router_Route(
|
||||
':lang/admin/:action',
|
||||
array(
|
||||
'lang' => 'sv',
|
||||
'module' => 'blog',
|
||||
'controller' => 'index',
|
||||
'action' => 'latest'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$router->addRoute('auth', new Zend_Controller_Router_Route(
|
||||
':lang/:action',
|
||||
array(
|
||||
'lang' => 'sv',
|
||||
'module' => 'default',
|
||||
'controller' => 'auth',
|
||||
),
|
||||
array(
|
||||
'action' => '(login|logout)'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
|
||||
return $router;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@
|
|||
<navigation>
|
||||
<start>
|
||||
<label>u:home</label>
|
||||
<route>index</route>
|
||||
<route>default-default</route>
|
||||
<module>default</module>
|
||||
<controller>index</controller>
|
||||
</start>
|
||||
<blog>
|
||||
<label>u:blog</label>
|
||||
<route>blog</route>
|
||||
<route>blog-default</route>
|
||||
<module>blog</module>
|
||||
<controller>index</controller>
|
||||
<action>latest</action>
|
||||
<pages>
|
||||
<latest>
|
||||
<label>u:latest</label>
|
||||
<route>blog</route>
|
||||
<route>blog-default</route>
|
||||
<module>blog</module>
|
||||
<controller>index</controller>
|
||||
<action>latest</action>
|
||||
|
|
@ -25,23 +25,21 @@
|
|||
<label>u:archive</label>
|
||||
<route>blog</route>
|
||||
<module>blog</module>
|
||||
<controller>index</controller>
|
||||
<action>archive</action>
|
||||
<controller>archive</controller>
|
||||
<action>index</action>
|
||||
</archive>
|
||||
<others>
|
||||
<label>u:readable</label>
|
||||
<route>blog</route>
|
||||
<route>blog-default</route>
|
||||
<module>blog</module>
|
||||
<controller>index</controller>
|
||||
<action>readable</action>
|
||||
</others>
|
||||
<read>
|
||||
<label>u:read</label>
|
||||
<route>blog</route>
|
||||
<route>blog-default</route>
|
||||
<module>blog</module>
|
||||
<controller>index</controller>
|
||||
<action>read</action>
|
||||
<visible>1</visible>
|
||||
</read>
|
||||
</pages>
|
||||
</blog>
|
||||
|
|
@ -56,10 +54,13 @@
|
|||
|
||||
<about>
|
||||
<label>uw:about</label>
|
||||
<route>index</route>
|
||||
<route>default-default</route>
|
||||
<module>default</module>
|
||||
<controller>index</controller>
|
||||
<action>about</action>
|
||||
<params>
|
||||
<part>aboutf</part>
|
||||
</params>
|
||||
</about>
|
||||
</navigation>
|
||||
</config>
|
||||
|
|
@ -17,24 +17,12 @@ class Fiktiv_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract
|
|||
$config = $bootstrap->getApplication()->getOption('defaults');
|
||||
$lang = $config['lang'];
|
||||
|
||||
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
|
||||
$url = $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('url');
|
||||
//$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
|
||||
//$url = $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('url');
|
||||
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
|
||||
|
||||
$redirector->gotoUrlAndExit('/'.$lang);
|
||||
|
||||
$pos = strpos($url->url(), $baseUrl);
|
||||
|
||||
if (false === $pos) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
|
||||
$url = substr_replace($url->url(), $lang, $pos, strlen($baseUrl));
|
||||
}
|
||||
|
||||
//echo $url;
|
||||
$redirector->gotoSimpleAndExit('/sv/blog/archive');
|
||||
|
||||
}
|
||||
|
||||
if ($translate->isAvailable($lang)) {
|
||||
|
|
|
|||
Reference in a new issue