Guest User

Untitled

a guest
Jul 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. ## library/Lupi/Controller/Router/Route/DbRoute.php
  2.  
  3. <?php
  4.  
  5. class Lupi_Controller_Router_Route_DbRoute extends Zend_Controller_Router_Route_Abstract
  6. {
  7. public function match($path)
  8. {
  9. $uri = rtrim($path->getPathInfo(),'/');
  10. $routeKey = 'Route' . md5($uri);
  11. $cache = Zend_Registry::get('cache');
  12. $page = $cache->load($routeKey);
  13. if ($page === false) {
  14. error_log('miss: ' . $routeKey);
  15. $db = Zend_Db_Table_Abstract::getDefaultAdapter();
  16. $select = new Zend_Db_Select($db);
  17. $select->from('pages')
  18. ->join(array('ls' => 'view_scripts'),
  19. 'pages.layout_id = ls.id',
  20. array('layout'=> 'ls.filename'))
  21. ->join(array('vs' => 'view_scripts'),
  22. 'pages.view_id = vs.id',
  23. array('view' => 'vs.filename'))
  24. ->where('address = ?', $uri)
  25. ->where('enabled = ?', 1);
  26. $page = $db->fetchRow($select, array(), Zend_Db::FETCH_ASSOC);
  27. $cache->save($page, $routeKey);
  28. }
  29. $return = false;
  30. if($page !== false) {
  31. $return = array('module' => 'default',
  32. 'controller' => 'pages',
  33. 'action' => 'page',
  34. 'id' => $page['id'],
  35. 'layout' => $page['layout'],
  36. 'view' => $page['view'],
  37. 'title' => $page['title'],
  38. 'keywords' => $page['keywords'],
  39. 'description'=> $page['description'],
  40. 'author' => $page['author'],
  41. 'lastedit' => $page['lastedit'],
  42. 'body' => $page['body'],
  43. 'page_name' => $page['page_name']);
  44. }
  45. return $return;
  46. }
  47. public function assemble($data = array(), $reset = false, $encode = false)
  48. {
  49. return $this->_route;
  50. }
  51.  
  52. public static function getInstance(Zend_Config $config)
  53. {
  54. }
  55. }
Add Comment
Please, Sign In to add comment