blob: 9366b4588162337258069af067d21382c249044c [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.3
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * CI_BASE - For PHP 4
20 *
admincf493902006-10-10 07:12:31 +000021 * 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
admin7099a582006-10-10 17:47:59 +000024 * the parent of the Controller Base class. It's the only way we enabled
25 * 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 *
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
admin6871d952006-10-04 00:36:18 +000033 * two files based on the version of PHP being run.
adminb0dd10f2006-08-25 17:25:49 +000034 *
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 {
adminb0dd10f2006-08-25 17:25:49 +000045 parent::CI_Loader();
46 $this->load =& $this;
admincf493902006-10-10 07:12:31 +000047
48 global $OBJ;
adminb0dd10f2006-08-25 17:25:49 +000049 $OBJ = $this->load;
50 }
51}
52
53function &get_instance()
54{
admincf493902006-10-10 07:12:31 +000055 global $CI, $OBJ;
adminb0dd10f2006-08-25 17:25:49 +000056
admincf493902006-10-10 07:12:31 +000057 if (is_object($CI))
58 {
admincf493902006-10-10 07:12:31 +000059 return $CI;
60 }
61
62 return $OBJ->load;
adminb0dd10f2006-08-25 17:25:49 +000063}
64
65?>