blob: 0b34465a2caa98c403500e49fc5d4405858f834b [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
8 * @author Rick Ellis
9 * @copyright Copyright (c) 2006, EllisLab, Inc.
Derek Allard6838f002007-10-04 19:29:59 +000010 * @license http://www.codeigniter.com/user_guide/license.html
Derek Allardd2df9bc2007-04-15 17:41:17 +000011 * @link http://www.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 the every library in
22 * CodeIgniter 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
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();
87 }
88 }
89
90 // --------------------------------------------------------------------
91
92 /**
93 * Run Scaffolding
94 *
95 * @access private
96 * @return void
97 */
98 function _ci_scaffolding()
99 {
100 if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
101 {
102 show_404('Scaffolding unavailable');
103 }
104
105 $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
106
107 require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
108 $scaff = new Scaffolding($this->_ci_scaff_table);
109 $scaff->$method();
110 }
111
112
113}
114// END _Controller class
adminb0dd10f2006-08-25 17:25:49 +0000115?>