PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Cake/Controller/PagesController.php

https://bitbucket.org/udeshika/fake_twitter
PHP | 82 lines | 26 code | 8 blank | 48 comment | 4 complexity | 388e6c9d708c724af4ca7c516077c0da MD5 | raw file
  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/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. * Default helper
  39. *
  40. * @var array
  41. */
  42. public $helpers = array('Html', 'Session');
  43. /**
  44. * This controller does not use a model
  45. *
  46. * @var array
  47. */
  48. public $uses = array();
  49. /**
  50. * Displays a view
  51. *
  52. * @param mixed What page to display
  53. * @return void
  54. */
  55. public function display() {
  56. $path = func_get_args();
  57. $count = count($path);
  58. if (!$count) {
  59. $this->redirect('/');
  60. }
  61. $page = $subpage = $title_for_layout = null;
  62. if (!empty($path[0])) {
  63. $page = $path[0];
  64. }
  65. if (!empty($path[1])) {
  66. $subpage = $path[1];
  67. }
  68. if (!empty($path[$count - 1])) {
  69. $title_for_layout = Inflector::humanize($path[$count - 1]);
  70. }
  71. $this->set(compact('page', 'subpage', 'title_for_layout'));
  72. $this->render(implode('/', $path));
  73. }
  74. }