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_scaffolding = FALSE; |
| 33 | var $_ci_scaff_table = FALSE; |
| 34 | |
| 35 | /** |
| 36 | * Constructor |
| 37 | * |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 38 | * Calls the initialize() function |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 39 | */ |
| 40 | function Controller() |
| 41 | { |
| 42 | parent::CI_Base(); |
| 43 | |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 44 | $this->_ci_initialize(); |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 45 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 46 | log_message('debug', "Controller Class Initialized"); |
| 47 | } |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 48 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 49 | // -------------------------------------------------------------------- |
| 50 | |
| 51 | /** |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 52 | * Initialize |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 53 | * |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 54 | * Assigns all the bases classes loaded by the front controller to |
| 55 | * variables in this class. Also calls the autoload routine. |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 56 | * |
| 57 | * @access private |
| 58 | * @return void |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 59 | */ |
| 60 | function _ci_initialize() |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 61 | { |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 62 | // 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. |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 65 | foreach (array('Config', 'Input', 'Benchmark', 'URI', 'Output') as $val) |
| 66 | { |
| 67 | $class = strtolower($val); |
admin | 33de9a1 | 2006-09-28 06:50:16 +0000 | [diff] [blame] | 68 | $this->$class =& _load_class($val); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 69 | } |
| 70 | |
admin | 33de9a1 | 2006-09-28 06:50:16 +0000 | [diff] [blame] | 71 | $this->lang =& _load_class('Language'); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 72 | |
| 73 | // In PHP 4 the Controller class is a child of CI_Loader. |
| 74 | // In PHP 5 we run it as its own class. |
| 75 | if (floor(phpversion()) >= 5) |
| 76 | { |
| 77 | $this->load = new CI_Loader(); |
| 78 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 79 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 80 | |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 81 | // Load everything specified in the autoload.php file |
| 82 | $this->load->_ci_autoloader(); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 83 | |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 84 | // This allows anything loaded using $this->load (viwes, files, etc.) |
| 85 | // to become accessible from within the Controller class functions. |
| 86 | foreach (get_object_vars($this) as $key => $var) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 87 | { |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 88 | if (is_object($var)) |
| 89 | { |
| 90 | $this->load->$key =& $this->$key; |
| 91 | } |
| 92 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 93 | } |
admin | 8f0a8f6 | 2006-10-07 01:17:25 +0000 | [diff] [blame^] | 94 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 95 | |
| 96 | } |
| 97 | // END _Controller class |
| 98 | ?> |