pictcode / lib / Cake / Console / Templates / skel / Controller / PagesController.php @ 0b1b8047
履歴 | 表示 | アノテート | ダウンロード (1.406 KB)
1 | 635eef61 | spyder1211 | <?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 | * @return void
|
||
35 | * @throws NotFoundException When the view file could not be found
|
||
36 | * or MissingViewException in debug mode.
|
||
37 | */
|
||
38 | public function display() { |
||
39 | $path = func_get_args(); |
||
40 | |||
41 | $count = count($path); |
||
42 | if (!$count) { |
||
43 | return $this->redirect('/'); |
||
44 | } |
||
45 | $page = $subpage = $title_for_layout = null; |
||
46 | |||
47 | if (!empty($path[0])) { |
||
48 | $page = $path[0]; |
||
49 | } |
||
50 | if (!empty($path[1])) { |
||
51 | $subpage = $path[1]; |
||
52 | } |
||
53 | if (!empty($path[$count - 1])) { |
||
54 | $title_for_layout = Inflector::humanize($path[$count - 1]); |
||
55 | } |
||
56 | $this->set(compact('page', 'subpage', 'title_for_layout')); |
||
57 | |||
58 | try {
|
||
59 | $this->render(implode('/', $path)); |
||
60 | } catch (MissingViewException $e) { |
||
61 | if (Configure::read('debug')) { |
||
62 | throw $e; |
||
63 | } |
||
64 | throw new NotFoundException(); |
||
65 | } |
||
66 | } |
||
67 | } |