upgrade to codeigniter 1.7.2 for f12
[www-register-wizard.git] / libraries / Controller.php
1 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2 /**
3  * CodeIgniter
4  *
5  * An open source application development framework for PHP 4.3.2 or newer
6  *
7  * @package             CodeIgniter
8  * @author              ExpressionEngine Dev Team
9  * @copyright   Copyright (c) 2008 - 2009, EllisLab, Inc.
10  * @license             http://codeigniter.com/user_guide/license.html
11  * @link                http://codeigniter.com
12  * @since               Version 1.0
13  * @filesource
14  */
15
16 // ------------------------------------------------------------------------
17
18 /**
19  * CodeIgniter Application Controller Class
20  *
21  * This class object is the super class that every library in
22  * CodeIgniter will be assigned to.
23  *
24  * @package             CodeIgniter
25  * @subpackage  Libraries
26  * @category    Libraries
27  * @author              ExpressionEngine Dev Team
28  * @link                http://codeigniter.com/user_guide/general/controllers.html
29  */
30 class Controller extends CI_Base {
31
32         var $_ci_scaffolding    = FALSE;
33         var $_ci_scaff_table    = FALSE;
34         
35         /**
36          * Constructor
37          *
38          * Calls the initialize() function
39          */
40         function Controller()
41         {       
42                 parent::CI_Base();
43                 $this->_ci_initialize();
44                 log_message('debug', "Controller Class Initialized");
45         }
46
47         // --------------------------------------------------------------------
48
49         /**
50          * Initialize
51          *
52          * Assigns all the bases classes loaded by the front controller to
53          * variables in this class.  Also calls the autoload routine.
54          *
55          * @access      private
56          * @return      void
57          */
58         function _ci_initialize()
59         {
60                 // Assign all the class objects that were instantiated by the
61                 // front controller to local class variables so that CI can be
62                 // run as one big super object.
63                 $classes = array(
64                                                         'config'        => 'Config',
65                                                         'input'         => 'Input',
66                                                         'benchmark'     => 'Benchmark',
67                                                         'uri'           => 'URI',
68                                                         'output'        => 'Output',
69                                                         'lang'          => 'Language',
70                                                         'router'        => 'Router'
71                                                         );
72                 
73                 foreach ($classes as $var => $class)
74                 {
75                         $this->$var =& load_class($class);
76                 }
77
78                 // In PHP 5 the Loader class is run as a discreet
79                 // class.  In PHP 4 it extends the Controller
80                 if (floor(phpversion()) >= 5)
81                 {
82                         $this->load =& load_class('Loader');
83                         $this->load->_ci_autoloader();
84                 }
85                 else
86                 {
87                         $this->_ci_autoloader();
88                         
89                         // sync up the objects since PHP4 was working from a copy
90                         foreach (array_keys(get_object_vars($this)) as $attribute)
91                         {
92                                 if (is_object($this->$attribute))
93                                 {
94                                         $this->load->$attribute =& $this->$attribute;
95                                 }
96                         }
97                 }
98         }
99         
100         // --------------------------------------------------------------------
101         
102         /**
103          * Run Scaffolding
104          *
105          * @access      private
106          * @return      void
107          */     
108         function _ci_scaffolding()
109         {
110                 if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
111                 {
112                         show_404('Scaffolding unavailable');
113                 }
114                 
115                 $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
116                 
117                 require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
118                 $scaff = new Scaffolding($this->_ci_scaff_table);
119                 $scaff->$method();
120         }
121
122
123 }
124 // END _Controller class
125
126 /* End of file Controller.php */
127 /* Location: ./system/libraries/Controller.php */