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:
22: App::uses('AppController', 'Controller');
23:
24: /**
25: * Static content controller
26: *
27: * Override this controller by placing a copy in controllers directory of an application
28: *
29: * @package Cake.Controller
30: * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
31: */
32: class PagesController extends AppController {
33:
34: /**
35: * Default helper
36: *
37: * @var array
38: */
39: public $helpers = array('Html', 'Session');
40:
41: /**
42: * This controller does not use a model
43: *
44: * @var array
45: */
46: public $uses = array();
47:
48: /**
49: * Displays a view
50: *
51: * @param mixed What page to display
52: * @return void
53: */
54: public function display() {
55: $path = func_get_args();
56:
57: $count = count($path);
58: if (!$count) {
59: $this->redirect('/');
60: }
61: $page = $subpage = $title_for_layout = null;
62:
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: }
76: