PagesController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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-2011, 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-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link http://cakephp.org CakePHP(tm) Project
  17. * @package Cake.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 Cake.Controller
  28. * @link http://book.cakephp.org/view/958/The-Pages-Controller
  29. */
  30. class PagesController extends AppController {
  31. /**
  32. * Controller name
  33. *
  34. * @var string
  35. * @access public
  36. */
  37. public $name = 'Pages';
  38. /**
  39. * Default helper
  40. *
  41. * @var array
  42. * @access public
  43. */
  44. public $helpers = array('Html', 'Session');
  45. /**
  46. * This controller does not use a model
  47. *
  48. * @var array
  49. * @access public
  50. */
  51. public $uses = array();
  52. /**
  53. * Displays a view
  54. *
  55. * @param mixed What page to display
  56. * @return void
  57. */
  58. public function display() {
  59. $path = func_get_args();
  60. $count = count($path);
  61. if (!$count) {
  62. $this->redirect('/');
  63. }
  64. $page = $subpage = $title_for_layout = null;
  65. if (!empty($path[0])) {
  66. $page = $path[0];
  67. }
  68. if (!empty($path[1])) {
  69. $subpage = $path[1];
  70. }
  71. if (!empty($path[$count - 1])) {
  72. $title_for_layout = Inflector::humanize($path[$count - 1]);
  73. }
  74. $this->set(compact('page', 'subpage', 'title_for_layout'));
  75. $this->render(implode('/', $path));
  76. }
  77. }