PagesController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * Controller name
  33. *
  34. * @var string
  35. */
  36. public $name = 'Pages';
  37. /**
  38. * This controller does not use a model
  39. *
  40. * @var array
  41. */
  42. public $uses = array();
  43. /**
  44. * Displays a view
  45. *
  46. * @param mixed What page to display
  47. * @return void
  48. */
  49. public function display() {
  50. $path = func_get_args();
  51. $count = count($path);
  52. if (!$count) {
  53. $this->redirect('/');
  54. }
  55. $page = $subpage = $title_for_layout = null;
  56. if (!empty($path[0])) {
  57. $page = $path[0];
  58. }
  59. if (!empty($path[1])) {
  60. $subpage = $path[1];
  61. }
  62. if (!empty($path[$count - 1])) {
  63. $title_for_layout = Inflector::humanize($path[$count - 1]);
  64. }
  65. $this->set(compact('page', 'subpage', 'title_for_layout'));
  66. $this->render(implode('/', $path));
  67. }
  68. }