blob: 938c46e4c7cfcf463b12ba480a9f54ce34f0c652 [file] [log] [blame]
adminb0dd10f2006-08-25 17:25:49 +00001<?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 */
30class Controller extends CI_Base {
31
adminb0dd10f2006-08-25 17:25:49 +000032 var $_ci_scaffolding = FALSE;
33 var $_ci_scaff_table = FALSE;
34
admin34f7f2d2006-10-10 08:06:42 +000035
36
adminb0dd10f2006-08-25 17:25:49 +000037 /**
38 * Constructor
39 *
admin8f0a8f62006-10-07 01:17:25 +000040 * Calls the initialize() function
adminb0dd10f2006-08-25 17:25:49 +000041 */
42 function Controller()
43 {
44 parent::CI_Base();
admin8f0a8f62006-10-07 01:17:25 +000045 $this->_ci_initialize();
adminb0dd10f2006-08-25 17:25:49 +000046 log_message('debug', "Controller Class Initialized");
47 }
admin8f0a8f62006-10-07 01:17:25 +000048
adminb0dd10f2006-08-25 17:25:49 +000049 // --------------------------------------------------------------------
50
51 /**
admin8f0a8f62006-10-07 01:17:25 +000052 * Initialize
adminb0dd10f2006-08-25 17:25:49 +000053 *
admin8f0a8f62006-10-07 01:17:25 +000054 * Assigns all the bases classes loaded by the front controller to
55 * variables in this class. Also calls the autoload routine.
adminb0dd10f2006-08-25 17:25:49 +000056 *
57 * @access private
58 * @return void
admin8f0a8f62006-10-07 01:17:25 +000059 */
60 function _ci_initialize()
adminb0dd10f2006-08-25 17:25:49 +000061 {
admin8f0a8f62006-10-07 01:17:25 +000062 // Assign all the class objects that were instantiated by the
63 // front controller to local class variables so that CI can be
64 // run as one big super object.
adminb3ab70b2006-10-07 03:07:29 +000065 $classes = array(
66 'config' => 'Config',
67 'input' => 'Input',
68 'benchmark' => 'Benchmark',
69 'uri' => 'URI',
70 'output' => 'Output',
71 'lang' => 'Language'
72 );
73
74 foreach ($classes as $var => $class)
adminb0dd10f2006-08-25 17:25:49 +000075 {
admin7099a582006-10-10 17:47:59 +000076 $this->$var =& load_class($class);
adminb0dd10f2006-08-25 17:25:49 +000077 }
78
adminb3ab70b2006-10-07 03:07:29 +000079
80 // In PHP 5 the Controller class is run as a discreet
81 // class. In PHP 4 it extends the Controller
adminb0dd10f2006-08-25 17:25:49 +000082 if (floor(phpversion()) >= 5)
83 {
84 $this->load = new CI_Loader();
admincf493902006-10-10 07:12:31 +000085 $this->load->_ci_autoloader();
adminb0dd10f2006-08-25 17:25:49 +000086 }
admincf493902006-10-10 07:12:31 +000087 else
adminb0dd10f2006-08-25 17:25:49 +000088 {
admincf493902006-10-10 07:12:31 +000089 $this->_ci_autoloader();
90 }
adminb0dd10f2006-08-25 17:25:49 +000091 }
admin8f0a8f62006-10-07 01:17:25 +000092
adminb3ab70b2006-10-07 03:07:29 +000093 // --------------------------------------------------------------------
94
95 /**
96 * Run Scaffolding
97 *
98 * @access private
admin88a8ad12006-10-07 03:16:32 +000099 * @return void
adminb3ab70b2006-10-07 03:07:29 +0000100 */
101 function _ci_scaffolding()
102 {
103 if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
104 {
105 show_404('Scaffolding unavailable');
106 }
107
108 $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
109
110 require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
111 $scaff = new Scaffolding($this->_ci_scaff_table);
112 $scaff->$method();
113 }
114
adminb0dd10f2006-08-25 17:25:49 +0000115
116}
117// END _Controller class
118?>