Archived
1
0
Fork 0

Routing update

This commit is contained in:
Fredric N 2010-10-02 14:11:38 +02:00
parent d128dd950a
commit 135fde1f87
3 changed files with 69 additions and 112 deletions

View file

@ -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;
}