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

/code/ryzom/tools/server/www/webtt/app/controllers/pages_controller.php

https://bitbucket.org/mattraykowski/ryzomcore_demoshard
PHP | 119 lines | 51 code | 12 blank | 56 comment | 11 complexity | 68b7e241d038c64785ba2e1adbaa3976 MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Static content controller.
  4. *
  5. * This file will render views from views/pages/
  6. *
  7. * PHP versions 4 and 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
  18. * @subpackage cake.cake.libs.controller
  19. * @since CakePHP(tm) v 0.2.9
  20. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  21. */
  22. /**
  23. * Static content controller
  24. *
  25. * Override this controller by placing a copy in controllers directory of an application
  26. *
  27. * @package cake
  28. * @subpackage cake.cake.libs.controller
  29. * @link http://book.cakephp.org/view/958/The-Pages-Controller
  30. */
  31. class PagesController extends AppController {
  32. /**
  33. * Controller name
  34. *
  35. * @var string
  36. * @access public
  37. */
  38. var $name = 'Pages';
  39. /**
  40. * Default helper
  41. *
  42. * @var array
  43. * @access public
  44. */
  45. var $helpers = array('Html', 'Session');
  46. /**
  47. * This controller does not use a model
  48. *
  49. * @var array
  50. * @access public
  51. */
  52. var $uses = array();
  53. /**
  54. * Displays a view
  55. *
  56. * @param mixed What page to display
  57. * @access public
  58. */
  59. function display() {
  60. $path = func_get_args();
  61. $count = count($path);
  62. if (!$count) {
  63. $this->redirect('/');
  64. }
  65. $page = $subpage = $title_for_layout = null;
  66. if (!empty($path[0])) {
  67. $page = $path[0];
  68. }
  69. if (!empty($path[1])) {
  70. $subpage = $path[1];
  71. }
  72. if (!empty($path[$count - 1])) {
  73. $title_for_layout = Inflector::humanize($path[$count - 1]);
  74. }
  75. $this->set(compact('page', 'subpage', 'title_for_layout'));
  76. $this->render(implode('/', $path));
  77. }
  78. function admin_display() {
  79. $path = func_get_args();
  80. /* if (isset($this->params['admin']))
  81. array_shift($path);*/
  82. if (!isset($path[0]) || $path[0] != 'admin') {
  83. //This adds admin to the beginning of the path so the pages controller will look in the 'admin' folder in pages directory
  84. $path = array_merge((array)'admin', $path);
  85. }
  86. $count = count($path);
  87. if (!$count) {
  88. $this->redirect('/');
  89. }
  90. $page = $subpage = $title_for_layout = null;
  91. if (!empty($path[0])) {
  92. $page = $path[0];
  93. }
  94. if (!empty($path[1])) {
  95. $subpage = $path[1];
  96. }
  97. if (!empty($path[$count - 1])) {
  98. $title_for_layout = Inflector::humanize($path[$count - 1]);
  99. }
  100. $this->set(compact('page', 'subpage', 'title_for_layout'));
  101. $this->render(implode('/', $path));
  102. }
  103. function beforeFilter() {
  104. parent::beforeFilter();
  105. $this->Auth->allow(array('display'));
  106. }
  107. }