Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## library/Lupi/Controller/Router/Route/DbRoute.php
- <?php
- class Lupi_Controller_Router_Route_DbRoute extends Zend_Controller_Router_Route_Abstract
- {
- public function match($path)
- {
- $uri = rtrim($path->getPathInfo(),'/');
- $routeKey = 'Route' . md5($uri);
- $cache = Zend_Registry::get('cache');
- $page = $cache->load($routeKey);
- if ($page === false) {
- error_log('miss: ' . $routeKey);
- $db = Zend_Db_Table_Abstract::getDefaultAdapter();
- $select = new Zend_Db_Select($db);
- $select->from('pages')
- ->join(array('ls' => 'view_scripts'),
- 'pages.layout_id = ls.id',
- array('layout'=> 'ls.filename'))
- ->join(array('vs' => 'view_scripts'),
- 'pages.view_id = vs.id',
- array('view' => 'vs.filename'))
- ->where('address = ?', $uri)
- ->where('enabled = ?', 1);
- $page = $db->fetchRow($select, array(), Zend_Db::FETCH_ASSOC);
- $cache->save($page, $routeKey);
- }
- $return = false;
- if($page !== false) {
- $return = array('module' => 'default',
- 'controller' => 'pages',
- 'action' => 'page',
- 'id' => $page['id'],
- 'layout' => $page['layout'],
- 'view' => $page['view'],
- 'title' => $page['title'],
- 'keywords' => $page['keywords'],
- 'description'=> $page['description'],
- 'author' => $page['author'],
- 'lastedit' => $page['lastedit'],
- 'body' => $page['body'],
- 'page_name' => $page['page_name']);
- }
- return $return;
- }
- public function assemble($data = array(), $reset = false, $encode = false)
- {
- return $this->_route;
- }
- public static function getInstance(Zend_Config $config)
- {
- }
- }
Add Comment
Please, Sign In to add comment