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.3 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * CI_BASE - For PHP 4 |
| 20 | * |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 21 | * This file is used only when Code Igniter is being run under PHP 4. |
| 22 | * |
| 23 | * In order to allow CI to work under PHP 4 we had to make the Loader class |
admin | 4003718 | 2006-10-11 19:16:58 +0000 | [diff] [blame^] | 24 | * the parent of the Controller Base class. It's the only way we can |
admin | 7099a58 | 2006-10-10 17:47:59 +0000 | [diff] [blame] | 25 | * enable functions like $this->load->library('email') to instantiate |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 26 | * classes that can then be used within controllers as $this->email->send() |
| 27 | * |
| 28 | * PHP 4 also has trouble referencing the CI super object within application |
| 29 | * constructors since objects do not exist until the class is fully |
| 30 | * instantiated. Basically PHP 4 sucks... |
| 31 | * |
| 32 | * Since PHP 5 doesn't suffer from this problem so we load one of |
admin | 6871d95 | 2006-10-04 00:36:18 +0000 | [diff] [blame] | 33 | * two files based on the version of PHP being run. |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 34 | * |
| 35 | * @package CodeIgniter |
| 36 | * @subpackage codeigniter |
| 37 | * @category front-controller |
| 38 | * @author Rick Ellis |
| 39 | * @link http://www.codeigniter.com/user_guide/ |
| 40 | */ |
| 41 | class CI_Base extends CI_Loader { |
| 42 | |
| 43 | function CI_Base() |
| 44 | { |
admin | 4003718 | 2006-10-11 19:16:58 +0000 | [diff] [blame^] | 45 | // This allows syntax like $this->load->foo() to work |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 46 | parent::CI_Loader(); |
| 47 | $this->load =& $this; |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 48 | |
admin | 4003718 | 2006-10-11 19:16:58 +0000 | [diff] [blame^] | 49 | // This allows resources used within controller constructors to work |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 50 | global $OBJ; |
admin | 4003718 | 2006-10-11 19:16:58 +0000 | [diff] [blame^] | 51 | $OBJ = $this->load; // Do NOT use a reference. |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
| 55 | function &get_instance() |
| 56 | { |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 57 | global $CI, $OBJ; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 58 | |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 59 | if (is_object($CI)) |
| 60 | { |
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 61 | return $CI; |
| 62 | } |
| 63 | |
| 64 | return $OBJ->load; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | ?> |