Controller.php

Go to the documentation of this file.
00001 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002 /**
00003  * CodeIgniter
00004  *
00005  * An open source application development framework for PHP 4.3.2 or newer
00006  *
00007  * @package             CodeIgniter
00008  * @author              ExpressionEngine Dev Team
00009  * @copyright   Copyright (c) 2006, EllisLab, Inc.
00010  * @license             http://codeigniter.com/user_guide/license.html
00011  * @link                http://codeigniter.com
00012  * @since               Version 1.0
00013  * @filesource
00014  */
00015 
00016 // ------------------------------------------------------------------------
00017 
00018 /**
00019  * CodeIgniter Application Controller Class
00020  *
00021  * This class object is the super class the every library in
00022  * CodeIgniter will be assigned to.
00023  *
00024  * @package             CodeIgniter
00025  * @subpackage  Libraries
00026  * @category    Libraries
00027  * @author              ExpressionEngine Dev Team
00028  * @link                http://codeigniter.com/user_guide/general/controllers.html
00029  */
00030 class Controller extends CI_Base {
00031 
00032         var $_ci_scaffolding    = FALSE;
00033         var $_ci_scaff_table    = FALSE;
00034         
00035         /**
00036          * Constructor
00037          *
00038          * Calls the initialize() function
00039          */
00040         function Controller()
00041         {       
00042                 parent::CI_Base();
00043                 $this->_ci_initialize();
00044                 log_message('debug', "Controller Class Initialized");
00045         }
00046 
00047         // --------------------------------------------------------------------
00048 
00049         /**
00050          * Initialize
00051          *
00052          * Assigns all the bases classes loaded by the front controller to
00053          * variables in this class.  Also calls the autoload routine.
00054          *
00055          * @access      private
00056          * @return      void
00057          */
00058         function _ci_initialize()
00059         {
00060                 // Assign all the class objects that were instantiated by the
00061                 // front controller to local class variables so that CI can be
00062                 // run as one big super object.
00063                 $classes = array(
00064                                                         'config'        => 'Config',
00065                                                         'input'         => 'Input',
00066                                                         'benchmark'     => 'Benchmark',
00067                                                         'uri'           => 'URI',
00068                                                         'output'        => 'Output',
00069                                                         'lang'          => 'Language'
00070                                                         );
00071                 
00072                 foreach ($classes as $var => $class)
00073                 {
00074                         $this->$var =& load_class($class);
00075                 }
00076 
00077                 // In PHP 5 the Loader class is run as a discreet
00078                 // class.  In PHP 4 it extends the Controller
00079                 if (floor(phpversion()) >= 5)
00080                 {
00081                         $this->load =& load_class('Loader');
00082                         $this->load->_ci_autoloader();
00083                 }
00084                 else
00085                 {
00086                         $this->_ci_autoloader();
00087                         
00088                         // sync up the objects since PHP4 was working from a copy
00089                         foreach (array_keys(get_object_vars($this)) as $attribute)
00090             {
00091                 if (is_object($this->$attribute))
00092                 {
00093                     $this->load->$attribute =& $this->$attribute;
00094                 }
00095             }
00096                 }
00097         }
00098         
00099         // --------------------------------------------------------------------
00100         
00101         /**
00102          * Run Scaffolding
00103          *
00104          * @access      private
00105          * @return      void
00106          */     
00107         function _ci_scaffolding()
00108         {
00109                 if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
00110                 {
00111                         show_404('Scaffolding unavailable');
00112                 }
00113                 
00114                 $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
00115                 
00116                 require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
00117                 $scaff = new Scaffolding($this->_ci_scaff_table);
00118                 $scaff->$method();
00119         }
00120 
00121 
00122 }
00123 // END _Controller class
00124 
00125 /* End of file Controller.php */
00126 /* Location: ./system/libraries/Controller.php */