pages_controller.php
Go to the documentation of this file.00001 <?php 00002 /* SVN FILE: $Id: console_2libs_2templates_2skel_2controllers_2pages__controller_8php-source.html 580 2008-07-01 14:45:49Z gwoo $ */ 00003 /** 00004 * Static content controller. 00005 * 00006 * This file will render views from views/pages/ 00007 * 00008 * PHP versions 4 and 5 00009 * 00010 * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> 00011 * Copyright 2005-2008, Cake Software Foundation, Inc. 00012 * 1785 E. Sahara Avenue, Suite 490-204 00013 * Las Vegas, Nevada 89104 00014 * 00015 * Licensed under The MIT License 00016 * Redistributions of files must retain the above copyright notice. 00017 * 00018 * @filesource 00019 * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. 00020 * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project 00021 * @package cake 00022 * @subpackage cake.cake.libs.controller 00023 * @since CakePHP(tm) v 0.2.9 00024 * @version $Revision: 580 $ 00025 * @modifiedby $LastChangedBy: gwoo $ 00026 * @lastmodified $Date: 2008-07-01 09:45:49 -0500 (Tue, 01 Jul 2008) $ 00027 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 00028 */ 00029 /** 00030 * Static content controller 00031 * 00032 * Override this controller by placing a copy in controllers directory of an application 00033 * 00034 * @package cake 00035 * @subpackage cake.cake.libs.controller 00036 */ 00037 class PagesController extends AppController { 00038 /** 00039 * Controller name 00040 * 00041 * @var string 00042 * @access public 00043 */ 00044 var $name = 'Pages'; 00045 /** 00046 * Default helper 00047 * 00048 * @var array 00049 * @access public 00050 */ 00051 var $helpers = array('Html'); 00052 /** 00053 * This controller does not use a model 00054 * 00055 * @var array 00056 * @access public 00057 */ 00058 var $uses = array(); 00059 /** 00060 * Displays a view 00061 * 00062 * @param mixed What page to display 00063 * @access public 00064 */ 00065 function display() { 00066 $path = func_get_args(); 00067 00068 if (!count($path)) { 00069 $this->redirect('/'); 00070 } 00071 $count = count($path); 00072 $page = $subpage = $title = null; 00073 00074 if (!empty($path[0])) { 00075 $page = $path[0]; 00076 } 00077 if (!empty($path[1])) { 00078 $subpage = $path[1]; 00079 } 00080 if (!empty($path[$count - 1])) { 00081 $title = Inflector::humanize($path[$count - 1]); 00082 } 00083 $this->set(compact('page', 'subpage', 'title')); 00084 $this->render(join('/', $path)); 00085 } 00086 } 00087 00088 ?>