blob: c80097a1735a01f345689ecf4b61d639449e4843 [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
35 /**
36 * Constructor
37 *
admin8f0a8f62006-10-07 01:17:25 +000038 * Calls the initialize() function
adminb0dd10f2006-08-25 17:25:49 +000039 */
40 function Controller()
41 {
42 parent::CI_Base();
admin8f0a8f62006-10-07 01:17:25 +000043 $this->_ci_initialize();
adminb0dd10f2006-08-25 17:25:49 +000044 log_message('debug', "Controller Class Initialized");
45 }
admin8f0a8f62006-10-07 01:17:25 +000046
adminb0dd10f2006-08-25 17:25:49 +000047 // --------------------------------------------------------------------
48
49 /**
admin8f0a8f62006-10-07 01:17:25 +000050 * Initialize
adminb0dd10f2006-08-25 17:25:49 +000051 *
admin8f0a8f62006-10-07 01:17:25 +000052 * Assigns all the bases classes loaded by the front controller to
53 * variables in this class. Also calls the autoload routine.
adminb0dd10f2006-08-25 17:25:49 +000054 *
55 * @access private
56 * @return void
admin8f0a8f62006-10-07 01:17:25 +000057 */
58 function _ci_initialize()
adminb0dd10f2006-08-25 17:25:49 +000059 {
admin8f0a8f62006-10-07 01:17:25 +000060 // 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.
adminb3ab70b2006-10-07 03:07:29 +000063 $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)
adminb0dd10f2006-08-25 17:25:49 +000073 {
adminb3ab70b2006-10-07 03:07:29 +000074 $this->$var =& _load_class($class);
adminb0dd10f2006-08-25 17:25:49 +000075 }
76
adminb3ab70b2006-10-07 03:07:29 +000077
78 // In PHP 5 the Controller class is run as a discreet
79 // class. In PHP 4 it extends the Controller
adminb0dd10f2006-08-25 17:25:49 +000080 if (floor(phpversion()) >= 5)
81 {
82 $this->load = new CI_Loader();
admincf493902006-10-10 07:12:31 +000083 $this->load->_ci_use_instance = TRUE;
84 $this->load->_ci_autoloader();
adminb0dd10f2006-08-25 17:25:49 +000085 }
admincf493902006-10-10 07:12:31 +000086 else
adminb0dd10f2006-08-25 17:25:49 +000087 {
admincf493902006-10-10 07:12:31 +000088 $this->_ci_autoloader();
89 }
adminb0dd10f2006-08-25 17:25:49 +000090 }
admin8f0a8f62006-10-07 01:17:25 +000091
adminb3ab70b2006-10-07 03:07:29 +000092 // --------------------------------------------------------------------
93
94 /**
95 * Run Scaffolding
96 *
97 * @access private
admin88a8ad12006-10-07 03:16:32 +000098 * @return void
adminb3ab70b2006-10-07 03:07:29 +000099 */
100 function _ci_scaffolding()
101 {
102 if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
103 {
104 show_404('Scaffolding unavailable');
105 }
106
107 $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
108
109 require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
110 $scaff = new Scaffolding($this->_ci_scaff_table);
111 $scaff->$method();
112 }
113
adminb0dd10f2006-08-25 17:25:49 +0000114
115}
116// END _Controller class
117?>