PageRenderTime 59ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/libs/controller/pages_controller.php

https://github.com/v2ninad/nm_cake
PHP | 82 lines | 25 code | 7 blank | 50 comment | 4 complexity | 511319d5253385b298d1bf1b0c58968d MD5 | raw file
Possible License(s): GPL-2.0
  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-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link http://cakephp.org CakePHP(tm) Project
  17. * @package cake.libs.controller
  18. * @since CakePHP(tm) v 0.2.9
  19. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  20. */
  21. /**
  22. * Static content controller
  23. *
  24. * Override this controller by placing a copy in controllers directory of an application
  25. *
  26. * @package cake.libs.controller
  27. * @link http://book.cakephp.org/view/958/The-Pages-Controller
  28. */
  29. class PagesController extends AppController {
  30. /**
  31. * Controller name
  32. *
  33. * @var string
  34. * @access public
  35. */
  36. public $name = 'Pages';
  37. /**
  38. * Default helper
  39. *
  40. * @var array
  41. * @access public
  42. */
  43. public $helpers = array('Html', 'Session');
  44. /**
  45. * This controller does not use a model
  46. *
  47. * @var array
  48. * @access public
  49. */
  50. public $uses = array();
  51. /**
  52. * Displays a view
  53. *
  54. * @param mixed What page to display
  55. */
  56. public function display() {
  57. $path = func_get_args();
  58. $count = count($path);
  59. if (!$count) {
  60. $this->redirect('/');
  61. }
  62. $page = $subpage = $title_for_layout = null;
  63. if (!empty($path[0])) {
  64. $page = $path[0];
  65. }
  66. if (!empty($path[1])) {
  67. $subpage = $path[1];
  68. }
  69. if (!empty($path[$count - 1])) {
  70. $title_for_layout = Inflector::humanize($path[$count - 1]);
  71. }
  72. $this->set(compact('page', 'subpage', 'title_for_layout'));
  73. $this->render(implode('/', $path));
  74. }
  75. }