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