blob: b2713b66027afc93805904af860428f15afcdc1b [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.
admine334c472006-10-21 19:44:22 +000010 * @license http://www.codeignitor.com/user_guide/license.html
adminb0dd10f2006-08-25 17:25:49 +000011 * @link http://www.codeigniter.com
12 * @since Version 1.3
13 * @filesource
14 */
admine334c472006-10-21 19:44:22 +000015
adminb0dd10f2006-08-25 17:25:49 +000016// ------------------------------------------------------------------------
17
18/**
19 * CI_BASE - For PHP 4
admine334c472006-10-21 19:44:22 +000020 *
admincf493902006-10-10 07:12:31 +000021 * This file is used only when Code Igniter is being run under PHP 4.
admine334c472006-10-21 19:44:22 +000022 *
23 * In order to allow CI to work under PHP 4 we had to make the Loader class
admin40037182006-10-11 19:16:58 +000024 * the parent of the Controller Base class. It's the only way we can
admine334c472006-10-21 19:44:22 +000025 * enable functions like $this->load->library('email') to instantiate
admincf493902006-10-10 07:12:31 +000026 * classes that can then be used within controllers as $this->email->send()
27 *
admine334c472006-10-21 19:44:22 +000028 * PHP 4 also has trouble referencing the CI super object within application
admincf493902006-10-10 07:12:31 +000029 * constructors since objects do not exist until the class is fully
30 * instantiated. Basically PHP 4 sucks...
31 *
admine334c472006-10-21 19:44:22 +000032 * Since PHP 5 doesn't suffer from this problem so we load one of
admin6871d952006-10-04 00:36:18 +000033 * two files based on the version of PHP being run.
admine334c472006-10-21 19:44:22 +000034 *
adminb0dd10f2006-08-25 17:25:49 +000035 * @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 {
admin40037182006-10-11 19:16:58 +000045 // This allows syntax like $this->load->foo() to work
adminb0dd10f2006-08-25 17:25:49 +000046 parent::CI_Loader();
47 $this->load =& $this;
admincf493902006-10-10 07:12:31 +000048
admin40037182006-10-11 19:16:58 +000049 // This allows resources used within controller constructors to work
admincf493902006-10-10 07:12:31 +000050 global $OBJ;
admin40037182006-10-11 19:16:58 +000051 $OBJ = $this->load; // Do NOT use a reference.
adminb0dd10f2006-08-25 17:25:49 +000052 }
53}
54
55function &get_instance()
56{
admincf493902006-10-10 07:12:31 +000057 global $CI, $OBJ;
adminb0dd10f2006-08-25 17:25:49 +000058
admine334c472006-10-21 19:44:22 +000059 if (is_object($CI))
admincf493902006-10-10 07:12:31 +000060 {
admincf493902006-10-10 07:12:31 +000061 return $CI;
62 }
63
64 return $OBJ->load;
adminb0dd10f2006-08-25 17:25:49 +000065}
66
67?>