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-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 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: /**
24: * Static content controller
25: *
26: * Override this controller by placing a copy in controllers directory of an application
27: *
28: * @package cake
29: * @subpackage cake.cake.libs.controller
30: * @link http://book.cakephp.org/view/958/The-Pages-Controller
31: */
32: class PagesController extends AppController {
33:
34: /**
35: * Controller name
36: *
37: * @var string
38: * @access public
39: */
40: var $name = 'Pages';
41:
42: /**
43: * Default helper
44: *
45: * @var array
46: * @access public
47: */
48: var $helpers = array('Html', 'Session');
49:
50: /**
51: * This controller does not use a model
52: *
53: * @var array
54: * @access public
55: */
56: var $uses = array();
57:
58: /**
59: * Displays a view
60: *
61: * @param mixed What page to display
62: * @access public
63: */
64: function display() {
65: $path = func_get_args();
66:
67: $count = count($path);
68: if (!$count) {
69: $this->redirect('/');
70: }
71: $page = $subpage = $title_for_layout = null;
72:
73: if (!empty($path[0])) {
74: $page = $path[0];
75: }
76: if (!empty($path[1])) {
77: $subpage = $path[1];
78: }
79: if (!empty($path[$count - 1])) {
80: $title_for_layout = Inflector::humanize($path[$count - 1]);
81: }
82: $this->set(compact('page', 'subpage', 'title_for_layout'));
83: $this->render(implode('/', $path));
84: }
85: }
86: