admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * Code Igniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author Rick Ellis |
| 9 | * @copyright Copyright (c) 2006, pMachine, Inc. |
| 10 | * @license http://www.codeignitor.com/user_guide/license.html |
| 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * Code Igniter Application Controller Class |
| 20 | * |
| 21 | * This class object is the the super class the every library in |
| 22 | * Code Igniter will be assigned to. |
| 23 | * |
| 24 | * @package CodeIgniter |
| 25 | * @subpackage Libraries |
| 26 | * @category Libraries |
| 27 | * @author Rick Ellis |
| 28 | * @link http://www.codeigniter.com/user_guide/general/controllers.html |
| 29 | */ |
| 30 | class Controller extends CI_Base { |
| 31 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 32 | var $_ci_models = array(); |
| 33 | var $_ci_scaffolding = FALSE; |
| 34 | var $_ci_scaff_table = FALSE; |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 35 | var $_ci_last_handle = NULL; |
| 36 | var $_ci_last_params = NULL; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * Constructor |
| 40 | * |
| 41 | * Loads the base classes needed to run CI, and runs the "autoload" |
| 42 | * routine which loads the systems specified in the "autoload" config file. |
| 43 | */ |
| 44 | function Controller() |
| 45 | { |
| 46 | parent::CI_Base(); |
| 47 | |
| 48 | // Assign all the class objects that were instantiated by the |
| 49 | // front controller to local class variables so that CI can be |
| 50 | // run as one big super object. |
| 51 | $this->_ci_assign_core(); |
| 52 | |
| 53 | // Load everything specified in the autoload.php file |
| 54 | $this->load->_ci_autoloader($this->_ci_autoload()); |
| 55 | |
| 56 | // This allows anything loaded using $this->load (viwes, files, etc.) |
| 57 | // to become accessible from within the Controller class functions. |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 58 | foreach (get_object_vars($this) as $key => $var) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 59 | { |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 60 | if (is_object($var)) |
| 61 | { |
| 62 | $this->load->$key =& $this->$key; |
| 63 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 64 | } |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 65 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 66 | log_message('debug', "Controller Class Initialized"); |
| 67 | } |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 68 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 69 | // -------------------------------------------------------------------- |
| 70 | |
| 71 | /** |
| 72 | * Initialization Handler |
| 73 | * |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 74 | * Designed to be called from the class files themselves. |
| 75 | * See: http://www.codeigniter.com/user_guide/general/creating_libraries.html |
| 76 | * |
| 77 | * @access public |
| 78 | * @param string class name |
| 79 | * @param string variable name |
| 80 | * @param mixed any additional parameters |
| 81 | * @return void |
| 82 | */ |
| 83 | function init_class($class, $varname = '', $params = NULL) |
| 84 | { |
| 85 | // First figure out what variable we're going to |
| 86 | // use to instantiate the class to |
| 87 | if ($varname == '') |
| 88 | { |
| 89 | $varname = ( ! is_null($this->_ci_last_handle)) ? $this->_ci_last_handle : strtolower(str_replace('CI_', '', $class)); |
| 90 | } |
| 91 | |
| 92 | // Are there any parameters? |
| 93 | if ($params === NULL AND $this->_ci_last_params !== NULL) |
| 94 | { |
| 95 | $params = $this->_ci_last_params; |
| 96 | } |
| 97 | |
| 98 | // Instantiate the class |
| 99 | if ( ! is_null($params)) |
| 100 | { |
| 101 | $this->$varname = new $class($params); |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | $this->$varname = new $class; |
| 106 | } |
| 107 | |
| 108 | $this->_ci_last_params = NULL; |
| 109 | $this->_ci_last_handle = NULL; |
| 110 | } |
| 111 | |
| 112 | // -------------------------------------------------------------------- |
| 113 | |
| 114 | /** |
| 115 | * Initialization Handler |
| 116 | * |
| 117 | * This function loads the requested class. |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 118 | * |
| 119 | * @access private |
| 120 | * @param string the item that is being loaded |
| 121 | * @param mixed any additional parameters |
| 122 | * @return void |
| 123 | */ |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 124 | function _ci_init_class($class, $params = NULL) |
| 125 | { |
| 126 | // Prep the class name |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 127 | $class = strtolower(str_replace(EXT, '', $class)); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 128 | |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 129 | // These are used by $this->init_class() above. |
| 130 | // They lets us dynamically set the object name and pass parameters |
| 131 | $this->_ci_last_handle = $class; |
| 132 | $this->_ci_last_params = $params; |
| 133 | |
| 134 | // Does THIS file (Controller.php) contain an initialization |
| 135 | // function that maps to the requested class? |
| 136 | |
| 137 | $method = '_ci_init_'.$class; |
| 138 | |
| 139 | if (method_exists($this, $method)) |
| 140 | { |
| 141 | if (is_null($params)) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 142 | { |
| 143 | $this->$method(); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | $this->$method($params); |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | // We're done... |
| 151 | return TRUE; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 152 | } |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 153 | |
| 154 | // Lets search for the requested library file and load it. |
| 155 | // We'll assume that the file we load contains a call to |
| 156 | // $obj->init_class() so that the class can get instantiated. |
| 157 | // For backward compatibility we'll test for filenames that are |
| 158 | // both uppercase and lower. |
| 159 | |
| 160 | foreach (array(ucfirst($class), $class) as $filename) |
| 161 | { |
| 162 | for ($i = 1; $i < 3; $i++) |
| 163 | { |
| 164 | $path = ($i % 2) ? APPPATH : BASEPATH; |
| 165 | |
| 166 | if (file_exists($path.'libraries/'.$filename.EXT)) |
| 167 | { |
| 168 | include_once($path.'libraries/'.$filename.EXT); |
| 169 | return TRUE; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | } |
| 174 | |
| 175 | // If we got this far we were unable to find the requested class |
| 176 | log_message('error', "Unable to load the requested class: ".$class); |
| 177 | show_error("Unable to load the class: ".$class); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 178 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 179 | |
| 180 | // -------------------------------------------------------------------- |
| 181 | |
| 182 | /** |
| 183 | * Loads and instantiates the requested model class |
| 184 | * |
| 185 | * @access private |
| 186 | * @param string |
| 187 | * @return array |
| 188 | */ |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 189 | function _ci_init_model($model, $name = '', $db_conn = FALSE) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 190 | { |
| 191 | if ($name == '') |
| 192 | { |
| 193 | $name = $model; |
| 194 | } |
admin | b4473d4 | 2006-08-27 15:46:31 +0000 | [diff] [blame] | 195 | |
admin | 0d29605 | 2006-08-27 15:48:38 +0000 | [diff] [blame] | 196 | $obj =& get_instance(); |
| 197 | if (in_array($name, $obj->_ci_models)) |
admin | b4473d4 | 2006-08-27 15:46:31 +0000 | [diff] [blame] | 198 | { |
| 199 | return; |
| 200 | } |
| 201 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 202 | if (isset($this->$name)) |
| 203 | { |
| 204 | show_error('The model name you are loading is the name of a resource that is already being used: '.$name); |
| 205 | } |
| 206 | |
| 207 | $model = strtolower($model); |
| 208 | |
| 209 | if ( ! file_exists(APPPATH.'models/'.$model.EXT)) |
| 210 | { |
| 211 | show_error('Unable to locate the model you have specified: '.$model); |
| 212 | } |
| 213 | |
| 214 | if ($db_conn !== FALSE) |
| 215 | { |
| 216 | if ($db_conn === TRUE) |
| 217 | $db_conn = ''; |
| 218 | |
| 219 | $this->_ci_init_database($db_conn, FALSE, TRUE); |
| 220 | } |
| 221 | |
| 222 | if ( ! class_exists('Model')) |
| 223 | { |
| 224 | require_once(BASEPATH.'libraries/Model'.EXT); |
| 225 | } |
| 226 | |
| 227 | require_once(APPPATH.'models/'.$model.EXT); |
| 228 | |
| 229 | $model = ucfirst($model); |
| 230 | $this->$name = new $model(); |
| 231 | $this->_ci_models[] = $name; |
| 232 | $this->_ci_assign_to_models(); |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 233 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 234 | |
| 235 | // -------------------------------------------------------------------- |
| 236 | |
| 237 | /** |
| 238 | * Assign to Models |
| 239 | * |
| 240 | * Makes sure that anything loaded by the loader class (libraries, plugins, etc.) |
| 241 | * will be available to modles, if any exist. |
| 242 | * |
| 243 | * @access public |
| 244 | * @param object |
| 245 | * @return array |
| 246 | */ |
| 247 | function _ci_assign_to_models() |
| 248 | { |
| 249 | $obj =& get_instance(); |
| 250 | if (count($obj->_ci_models) == 0) |
| 251 | { |
| 252 | return; |
| 253 | } |
| 254 | foreach ($obj->_ci_models as $model) |
| 255 | { |
| 256 | $obj->$model->_assign_libraries(); |
| 257 | } |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 258 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 259 | |
| 260 | // -------------------------------------------------------------------- |
| 261 | |
| 262 | /** |
| 263 | * Auto-initialize Core Classes |
| 264 | * |
| 265 | * This initializes the core systems that are specified in the |
| 266 | * libraries/autoload.php file, as well as the systems specified in |
| 267 | * the $autoload class array above. |
| 268 | * |
| 269 | * It returns the "autoload" array so we can pass it to the Loader |
| 270 | * class since it needs to autoload plugins and helper files |
| 271 | * |
| 272 | * The config/autoload.php file contains an array that permits |
| 273 | * sub-systems to be loaded automatically. |
| 274 | * |
| 275 | * @access private |
| 276 | * @return array |
| 277 | */ |
| 278 | function _ci_autoload() |
| 279 | { |
| 280 | include_once(APPPATH.'config/autoload'.EXT); |
| 281 | |
| 282 | if ( ! isset($autoload)) |
| 283 | { |
| 284 | return FALSE; |
| 285 | } |
| 286 | |
| 287 | if (count($autoload['config']) > 0) |
| 288 | { |
| 289 | foreach ($autoload['config'] as $key => $val) |
| 290 | { |
| 291 | $this->config->load($val); |
| 292 | } |
| 293 | } |
| 294 | unset($autoload['config']); |
| 295 | |
admin | d48ef1c | 2006-09-21 06:22:05 +0000 | [diff] [blame] | 296 | // A little tweak to remain backward compatible |
| 297 | // The $autoload['core'] item was deprecated |
| 298 | if ( ! isset($autoload['libraries'])) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 299 | { |
admin | d48ef1c | 2006-09-21 06:22:05 +0000 | [diff] [blame] | 300 | $autoload['libraries'] = $autoload['core']; |
| 301 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 302 | } |
| 303 | |
admin | 6e00bab | 2006-09-26 08:13:06 +0000 | [diff] [blame^] | 304 | $exceptions = array('dbutil', 'dbexport'); |
| 305 | |
admin | d48ef1c | 2006-09-21 06:22:05 +0000 | [diff] [blame] | 306 | foreach ($autoload['libraries'] as $item) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 307 | { |
admin | 6e00bab | 2006-09-26 08:13:06 +0000 | [diff] [blame^] | 308 | if ( ! in_array($item, $exceptions)) |
| 309 | { |
| 310 | $this->_ci_init_class($item); |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | $this->_ci_init_dbextra($item); |
| 315 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 316 | } |
admin | d48ef1c | 2006-09-21 06:22:05 +0000 | [diff] [blame] | 317 | unset($autoload['libraries']); |
| 318 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 319 | return $autoload; |
| 320 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 321 | |
| 322 | // -------------------------------------------------------------------- |
| 323 | |
| 324 | /** |
| 325 | * Assign the core classes to the global $CI object |
| 326 | * |
| 327 | * By assigning all the classes instantiated by the front controller |
| 328 | * local class variables we enable everything to be accessible using |
| 329 | * $this->class->function() |
| 330 | * |
| 331 | * @access private |
| 332 | * @return void |
| 333 | */ |
| 334 | function _ci_assign_core() |
| 335 | { |
| 336 | foreach (array('Config', 'Input', 'Benchmark', 'URI', 'Output') as $val) |
| 337 | { |
| 338 | $class = strtolower($val); |
| 339 | $this->$class =& _load_class('CI_'.$val); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | $this->lang =& _load_class('CI_Language'); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 343 | |
| 344 | // In PHP 4 the Controller class is a child of CI_Loader. |
| 345 | // In PHP 5 we run it as its own class. |
| 346 | if (floor(phpversion()) >= 5) |
| 347 | { |
| 348 | $this->load = new CI_Loader(); |
| 349 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 350 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 351 | |
| 352 | // -------------------------------------------------------------------- |
| 353 | |
| 354 | /** |
| 355 | * Initialize Scaffolding |
| 356 | * |
| 357 | * This initializing function works a bit different than the |
| 358 | * others. It doesn't load the class. Instead, it simply |
| 359 | * sets a flag indicating that scaffolding is allowed to be |
| 360 | * used. The actual scaffolding function below is |
| 361 | * called by the front controller based on whether the |
| 362 | * second segment of the URL matches the "secret" scaffolding |
| 363 | * word stored in the application/config/routes.php |
| 364 | * |
| 365 | * @access private |
| 366 | * @param string the table to scaffold |
| 367 | * @return void |
| 368 | */ |
| 369 | function _ci_init_scaffolding($table = FALSE) |
| 370 | { |
| 371 | if ($table === FALSE) |
| 372 | { |
| 373 | show_error('You must include the name of the table you would like access when you initialize scaffolding'); |
| 374 | } |
| 375 | |
| 376 | $this->_ci_scaffolding = TRUE; |
| 377 | $this->_ci_scaff_table = $table; |
| 378 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 379 | |
| 380 | // -------------------------------------------------------------------- |
| 381 | |
| 382 | /** |
| 383 | * Initialize Database |
| 384 | * |
| 385 | * @access private |
| 386 | * @param mixed database connection values |
| 387 | * @param bool whether to return the object for multiple connections |
| 388 | * @return void |
| 389 | */ |
| 390 | function _ci_init_database($params = '', $return = FALSE, $active_record = FALSE) |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 391 | { |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 392 | if ($this->_ci_is_loaded('db') == TRUE AND $return == FALSE AND $active_record == FALSE) |
| 393 | { |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | // Load the DB config file if needed |
| 398 | if (is_string($params) AND strpos($params, '://') === FALSE) |
| 399 | { |
| 400 | include(APPPATH.'config/database'.EXT); |
| 401 | |
| 402 | $group = ($params == '') ? $active_group : $params; |
| 403 | |
| 404 | if ( ! isset($db[$group])) |
| 405 | { |
| 406 | show_error('You have specified an invalid database connection group: '.$group); |
| 407 | } |
| 408 | |
| 409 | $params = $db[$group]; |
| 410 | } |
| 411 | |
| 412 | // No DB specified yet? Beat them senseless... |
| 413 | if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '') |
| 414 | { |
| 415 | show_error('You have not selected a database type to connect to.'); |
| 416 | } |
| 417 | |
| 418 | // Load the DB classes. Note: Since the active record class is optional |
| 419 | // we need to dynamically create a class that extends proper parent class |
| 420 | // based on whether we're using the active record class or not. |
| 421 | // Kudos to Paul for discovering this clever use of eval() |
| 422 | |
| 423 | if ($active_record == TRUE) |
| 424 | { |
| 425 | $params['active_r'] = TRUE; |
| 426 | } |
| 427 | |
admin | 5808346 | 2006-09-24 17:58:27 +0000 | [diff] [blame] | 428 | require_once(BASEPATH.'database/DB_driver'.EXT); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 429 | |
| 430 | if ( ! isset($params['active_r']) OR $params['active_r'] == TRUE) |
| 431 | { |
admin | c9a8bab | 2006-09-24 20:28:33 +0000 | [diff] [blame] | 432 | require_once(BASEPATH.'database/DB_active_rec'.EXT); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 433 | |
| 434 | if ( ! class_exists('CI_DB')) |
| 435 | { |
| 436 | eval('class CI_DB extends CI_DB_active_record { }'); |
| 437 | } |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | if ( ! class_exists('CI_DB')) |
| 442 | { |
| 443 | eval('class CI_DB extends CI_DB_driver { }'); |
| 444 | } |
| 445 | } |
admin | c1fa074 | 2006-09-21 23:50:23 +0000 | [diff] [blame] | 446 | |
admin | 46563d5 | 2006-09-24 18:14:22 +0000 | [diff] [blame] | 447 | require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 448 | |
| 449 | // Instantiate the DB adapter |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 450 | $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 451 | $DB = new $driver($params); |
| 452 | |
| 453 | if ($return === TRUE) |
| 454 | { |
| 455 | return $DB; |
| 456 | } |
| 457 | |
| 458 | $obj =& get_instance(); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 459 | $obj->db =& $DB; |
| 460 | } |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 461 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 462 | // -------------------------------------------------------------------- |
| 463 | |
| 464 | /** |
admin | 6e00bab | 2006-09-26 08:13:06 +0000 | [diff] [blame^] | 465 | * Initialize Database Ancillary Classes |
| 466 | * |
| 467 | * @access private |
| 468 | * @param str class name |
| 469 | * @return void |
| 470 | */ |
| 471 | function _ci_init_dbextra($class) |
| 472 | { |
| 473 | $map = array('dbutil' => 'DB_utility', 'dbexport' => 'DB_export'); |
| 474 | require_once(BASEPATH.'database/'.$map[$class].EXT); |
| 475 | |
| 476 | $this->init_class('CI_'.$map[$class], $class); |
| 477 | } |
| 478 | |
| 479 | // -------------------------------------------------------------------- |
| 480 | |
| 481 | /** |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 482 | * Returns TRUE if a class is loaded, FALSE if not |
| 483 | * |
| 484 | * @access public |
| 485 | * @param string the class name |
| 486 | * @return bool |
| 487 | */ |
| 488 | function _ci_is_loaded($class) |
| 489 | { |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 490 | return ( ! isset($this->$class) OR ! is_object($this->$class)) ? FALSE : TRUE; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 491 | } |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 492 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 493 | // -------------------------------------------------------------------- |
| 494 | |
| 495 | /** |
| 496 | * Scaffolding |
| 497 | * |
| 498 | * Initializes the scaffolding. |
| 499 | * |
| 500 | * @access private |
| 501 | * @return void |
| 502 | */ |
| 503 | function _ci_scaffolding() |
| 504 | { |
| 505 | if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE) |
| 506 | { |
| 507 | show_404('Scaffolding unavailable'); |
| 508 | } |
| 509 | |
| 510 | if (class_exists('Scaffolding')) return; |
| 511 | |
| 512 | if ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'))) |
| 513 | { |
| 514 | $method = 'view'; |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | $method = $this->uri->segment(3); |
| 519 | } |
| 520 | |
| 521 | $this->_ci_init_database("", FALSE, TRUE); |
admin | 7981a9a | 2006-09-26 07:52:09 +0000 | [diff] [blame] | 522 | $this->_ci_init_class('pagination'); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 523 | require_once(BASEPATH.'scaffolding/Scaffolding'.EXT); |
| 524 | $this->scaff = new Scaffolding($this->_ci_scaff_table); |
| 525 | $this->scaff->$method(); |
| 526 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 527 | |
| 528 | } |
| 529 | // END _Controller class |
| 530 | ?> |