pictcode / lib / Cake / Test / test_app / Controller / PagesController.php @ 48ae03cf
履歴 | 表示 | アノテート | ダウンロード (2.061 KB)
| 1 | 635eef61 | spyder1211 | <?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 Cake.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 Cake.Controller
|
||
| 29 | * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
|
||
| 30 | */
|
||
| 31 | class PagesController extends AppController { |
||
| 32 | |||
| 33 | /**
|
||
| 34 | * Default helper
|
||
| 35 | *
|
||
| 36 | * @var array
|
||
| 37 | */
|
||
| 38 | public $helpers = array('Html', 'Session'); |
||
| 39 | |||
| 40 | /**
|
||
| 41 | * This controller does not use a model
|
||
| 42 | *
|
||
| 43 | * @var array
|
||
| 44 | */
|
||
| 45 | public $uses = array(); |
||
| 46 | |||
| 47 | /**
|
||
| 48 | * Displays a view
|
||
| 49 | *
|
||
| 50 | * @param mixed What page to display
|
||
| 51 | * @return void
|
||
| 52 | * @throws NotFoundException When the view file could not be found
|
||
| 53 | * or MissingViewException in debug mode.
|
||
| 54 | */
|
||
| 55 | public function display() { |
||
| 56 | $path = func_get_args(); |
||
| 57 | |||
| 58 | $count = count($path); |
||
| 59 | if (!$count) { |
||
| 60 | return $this->redirect('/'); |
||
| 61 | } |
||
| 62 | $page = $subpage = $titleForLayout = null; |
||
| 63 | |||
| 64 | if (!empty($path[0])) { |
||
| 65 | $page = $path[0]; |
||
| 66 | } |
||
| 67 | if (!empty($path[1])) { |
||
| 68 | $subpage = $path[1]; |
||
| 69 | } |
||
| 70 | if (!empty($path[$count - 1])) { |
||
| 71 | $titleForLayout = Inflector::humanize($path[$count - 1]); |
||
| 72 | } |
||
| 73 | $this->set(array( |
||
| 74 | 'page' => $page, |
||
| 75 | 'subpage' => $subpage, |
||
| 76 | 'title_for_layout' => $titleForLayout |
||
| 77 | )); |
||
| 78 | |||
| 79 | try {
|
||
| 80 | $this->render(implode('/', $path)); |
||
| 81 | } catch (MissingViewException $e) { |
||
| 82 | if (Configure::read('debug')) { |
||
| 83 | throw $e; |
||
| 84 | } |
||
| 85 | throw new NotFoundException(); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | } |