PagesController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Static content controller.
  4. *
  5. * This file will render views from views/pages/
  6. *
  7. * PHP 5
  8. *
  9. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. *
  12. * Licensed under The MIT License
  13. * Redistributions of files must retain the above copyright notice.
  14. *
  15. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link http://cakephp.org CakePHP(tm) Project
  17. * @package app.Controller
  18. * @since CakePHP(tm) v 0.2.9
  19. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  20. */
  21. App::uses('AppController', 'Controller');
  22. /**
  23. * Static content controller
  24. *
  25. * Override this controller by placing a copy in controllers directory of an application
  26. *
  27. * @package app.Controller
  28. * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
  29. */
  30. class PagesController extends AppController {
  31. /**
  32. * This controller does not use a model
  33. *
  34. * @var array
  35. */
  36. public $uses = array();
  37. /**
  38. * Displays a view
  39. *
  40. * @param string What page to display
  41. */
  42. public function display() {
  43. $path = func_get_args();
  44. $count = count($path);
  45. if (!$count) {
  46. $this->redirect('/');
  47. }
  48. $page = $subpage = $title = null;
  49. if (!empty($path[0])) {
  50. $page = $path[0];
  51. }
  52. if (!empty($path[1])) {
  53. $subpage = $path[1];
  54. }
  55. if (!empty($path[$count - 1])) {
  56. $title = Inflector::humanize($path[$count - 1]);
  57. }
  58. $this->set(compact('page', 'subpage'));
  59. $this->set('title_for_layout', $title);
  60. $this->render(implode('/', $path));
  61. }
  62. }