統計
| ブランチ: | リビジョン:

pictcode / app / Controller / PagesController.php @ c69e6898

履歴 | 表示 | アノテート | ダウンロード (1.92 KB)

1
<?php
2
/**
3
 * Static content controller.
4
 *
5
 * This file will render views from views/pages/
6
 *
7
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
9
 *
10
 * Licensed under The MIT License
11
 * For full copyright and license information, please see the LICENSE.txt
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
15
 * @link          http://cakephp.org CakePHP(tm) Project
16
 * @package       app.Controller
17
 * @since         CakePHP(tm) v 0.2.9
18
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
19
 */
20

    
21
App::uses('AppController', 'Controller');
22

    
23
/**
24
 * Static content controller
25
 *
26
 * Override this controller by placing a copy in controllers directory of an application
27
 *
28
 * @package       app.Controller
29
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
30
 */
31
class PagesController extends AppController {
32

    
33
/**
34
 * This controller does not use a model
35
 *
36
 * @var array
37
 */
38
        public $uses = array();
39
        public $layout = 'bootstrap3';
40

    
41
/**
42
 * Displays a view
43
 *
44
 * @return void
45
 * @throws NotFoundException When the view file could not be found
46
 *        or MissingViewException in debug mode.
47
 */
48
        public function display() {
49
                $path = func_get_args();
50

    
51
                $count = count($path);
52
                if (!$count) {
53
                        return $this->redirect('/');
54
                }
55
                $page = $subpage = $title_for_layout = null;
56

    
57
                if (!empty($path[0])) {
58
                        $page = $path[0];
59
                }
60
                if (!empty($path[1])) {
61
                        $subpage = $path[1];
62
                }
63
                if (!empty($path[$count - 1])) {
64
                        $title_for_layout = Inflector::humanize($path[$count - 1]);
65
                }
66
                $this->set(compact('page', 'subpage', 'title_for_layout'));
67

    
68
                try {
69
                        $this->render(implode('/', $path));
70
                } catch (MissingViewException $e) {
71
                        if (Configure::read('debug')) {
72
                                throw $e;
73
                        }
74
                        throw new NotFoundException();
75
                }
76
        }
77
}