blob: 4957fc35e4a839c221a78c2c6b193c889a326973 [file] [log] [blame]
Derek Allardd2df9bc2007-04-15 17:41:17 +00001<?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
Derek Allard3d879d52008-01-18 19:41:32 +00008 * @author ExpressionEngine Dev Team
Derek Allardd2df9bc2007-04-15 17:41:17 +00009 * @copyright Copyright (c) 2006, EllisLab, Inc.
Derek Jones7a9193a2008-01-21 18:39:20 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
Derek Allardd2df9bc2007-04-15 17:41:17 +000012 * @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 the every library in
22 * CodeIgniter will be assigned to.
23 *
24 * @package CodeIgniter
25 * @subpackage Libraries
26 * @category Libraries
Derek Allard3d879d52008-01-18 19:41:32 +000027 * @author ExpressionEngine Dev Team
Derek Jones7a9193a2008-01-21 18:39:20 +000028 * @link http://codeigniter.com/user_guide/general/controllers.html
Derek Allardd2df9bc2007-04-15 17:41:17 +000029 */
30class 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 );
71
72 foreach ($classes as $var => $class)
73 {
74 $this->$var =& load_class($class);
75 }
76
77 // In PHP 5 the Loader class is run as a discreet
78 // class. In PHP 4 it extends the Controller
79 if (floor(phpversion()) >= 5)
80 {
81 $this->load =& load_class('Loader');
82 $this->load->_ci_autoloader();
83 }
84 else
85 {
86 $this->_ci_autoloader();
Derek Jonesc76a3742008-01-18 00:42:35 +000087
88 // sync up the objects since PHP4 was working from a copy
89 foreach (array_keys(get_object_vars($this)) as $attribute)
90 {
91 if (is_object($this->$attribute))
92 {
93 $this->load->$attribute =& $this->$attribute;
94 }
95 }
Derek Allardd2df9bc2007-04-15 17:41:17 +000096 }
97 }
98
99 // --------------------------------------------------------------------
100
101 /**
102 * Run Scaffolding
103 *
104 * @access private
105 * @return void
106 */
107 function _ci_scaffolding()
108 {
109 if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
110 {
111 show_404('Scaffolding unavailable');
112 }
113
Derek Allard73274992008-05-05 16:39:18 +0000114 $method = (! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
Derek Allardd2df9bc2007-04-15 17:41:17 +0000115
116 require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
117 $scaff = new Scaffolding($this->_ci_scaff_table);
118 $scaff->$method();
119 }
120
121
122}
123// END _Controller class
adminb0dd10f2006-08-25 17:25:49 +0000124?>