Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13532 anikendra 1
<?php
2
/**
3
 * Static content controller.
4
 *
5
 * This file will render views from views/pages/
6
 *
7
 * @link          http://cakephp.org CakePHP(tm) Project
8
 * @package       app.Controller
9
 * @since         CakePHP(tm) v 0.2.9
10
 */
11
 
12
App::uses('AppController', 'Controller');
13
 
14
/**
15
 * Static content controller
16
 *
17
 * Override this controller by placing a copy in controllers directory of an application
18
 *
19
 * @package       app.Controller
20
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
21
 */
22
class PagesController extends AppController {
23
 
24
/**
25
 * This controller does not use a model
26
 *
27
 * @var array
28
 */
29
	public $uses = array();
30
 
31
/**
32
 * Displays a view
33
 *
34
 * @param mixed What page to display
35
 * @return void
36
 * @throws NotFoundException When the view file could not be found
37
 *	or MissingViewException in debug mode.
38
 */
39
	public function display() {
40
		$path = func_get_args();
41
 
42
		$count = count($path);
43
		if (!$count) {
44
			return $this->redirect('/');
45
		}
46
		$page = $subpage = $title_for_layout = null;
47
 
48
		if (!empty($path[0])) {
49
			$page = $path[0];
50
		}
51
		if (!empty($path[1])) {
52
			$subpage = $path[1];
53
		}
54
		if (!empty($path[$count - 1])) {
55
			$title_for_layout = Inflector::humanize($path[$count - 1]);
56
		}
57
		$this->set(compact('page', 'subpage', 'title_for_layout'));
58
 
59
		try {
60
			$this->render(implode('/', $path));
61
		} catch (MissingViewException $e) {
62
			if (Configure::read('debug')) {
63
				throw $e;
64
			}
65
			throw new NotFoundException();
66
		}
67
	}
68
}