Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame^] | 1 | <?php |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 18 | * |
| 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame^] | 27 | defined('BASEPATH') OR exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 28 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 29 | /** |
| 30 | * Loader Class |
| 31 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 32 | * Loads framework components. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 33 | * |
| 34 | * @package CodeIgniter |
| 35 | * @subpackage Libraries |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 36 | * @category Loader |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 37 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 38 | * @link http://codeigniter.com/user_guide/libraries/loader.html |
| 39 | */ |
| 40 | class CI_Loader { |
| 41 | |
| 42 | // All these are set automatically. Don't mess with them. |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 43 | /** |
| 44 | * Nesting level of the output buffering mechanism |
| 45 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 46 | * @var int |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 47 | */ |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 48 | protected $_ci_ob_level; |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 49 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 50 | /** |
| 51 | * List of paths to load views from |
| 52 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 53 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 54 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 55 | protected $_ci_view_paths = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 56 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 57 | /** |
| 58 | * List of paths to load libraries from |
| 59 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 60 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 61 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 62 | protected $_ci_library_paths = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 63 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 64 | /** |
| 65 | * List of paths to load models from |
| 66 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 67 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 68 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 69 | protected $_ci_model_paths = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 70 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 71 | /** |
| 72 | * List of paths to load helpers from |
| 73 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 74 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 75 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 76 | protected $_ci_helper_paths = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 77 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 78 | /** |
| 79 | * List of loaded base classes |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 80 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 81 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 82 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 83 | protected $_base_classes = array(); // Set by the controller class |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 84 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 85 | /** |
| 86 | * List of cached variables |
| 87 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 88 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 89 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 90 | protected $_ci_cached_vars = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 91 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 92 | /** |
| 93 | * List of loaded classes |
| 94 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 95 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 96 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 97 | protected $_ci_classes = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 98 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 99 | /** |
| 100 | * List of loaded files |
| 101 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 102 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 103 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 104 | protected $_ci_loaded_files = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 105 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 106 | /** |
| 107 | * List of loaded models |
| 108 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 109 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 110 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 111 | protected $_ci_models = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 112 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 113 | /** |
| 114 | * List of loaded helpers |
| 115 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 116 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 117 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 118 | protected $_ci_helpers = array(); |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 119 | |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 120 | /** |
| 121 | * List of class name mappings |
| 122 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 123 | * @var array |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 124 | */ |
Timothy Warren | 48a7fbb | 2012-04-23 11:58:16 -0400 | [diff] [blame] | 125 | protected $_ci_varmap = array( |
Timothy Warren | 40403d2 | 2012-04-19 16:38:50 -0400 | [diff] [blame] | 126 | 'unit_test' => 'unit', |
| 127 | 'user_agent' => 'agent' |
| 128 | ); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 129 | |
| 130 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 131 | * Class constructor |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 132 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 133 | * Sets component load paths gets the initial output buffering level. |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 134 | * |
| 135 | * @return void |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 136 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 137 | public function __construct() |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 138 | { |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 139 | $this->_ci_ob_level = ob_get_level(); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 140 | $this->_ci_library_paths = array(APPPATH, BASEPATH); |
| 141 | $this->_ci_helper_paths = array(APPPATH, BASEPATH); |
| 142 | $this->_ci_model_paths = array(APPPATH); |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 143 | $this->_ci_view_paths = array(VIEWPATH => TRUE); |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 144 | |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 145 | log_message('debug', 'Loader Class Initialized'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 146 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 147 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 148 | // -------------------------------------------------------------------- |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 149 | |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 150 | /** |
Shane Pearson | 6adfe63 | 2011-08-10 16:42:53 -0500 | [diff] [blame] | 151 | * Initialize the Loader |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 152 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 153 | * @used-by CI_Controller |
| 154 | * @uses CI_Loader::_ci_autoloader() |
| 155 | * @return object $this |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 156 | */ |
Shane Pearson | 6adfe63 | 2011-08-10 16:42:53 -0500 | [diff] [blame] | 157 | public function initialize() |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 158 | { |
Shane Pearson | 6adfe63 | 2011-08-10 16:42:53 -0500 | [diff] [blame] | 159 | $this->_ci_classes = array(); |
| 160 | $this->_ci_loaded_files = array(); |
| 161 | $this->_ci_models = array(); |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 162 | $this->_base_classes =& is_loaded(); |
Shane Pearson | 6adfe63 | 2011-08-10 16:42:53 -0500 | [diff] [blame] | 163 | |
| 164 | $this->_ci_autoloader(); |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 165 | return $this; |
| 166 | } |
| 167 | |
| 168 | // -------------------------------------------------------------------- |
| 169 | |
| 170 | /** |
| 171 | * Is Loaded |
| 172 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 173 | * A utility method to test if a class is in the self::$_ci_classes array. |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 174 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 175 | * @used-by Mainly used by Form Helper function _get_validation_object(). |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 176 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 177 | * @param string $class Class name to check for |
| 178 | * @return string|bool Class object name if loaded or FALSE |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 179 | */ |
| 180 | public function is_loaded($class) |
| 181 | { |
Andrey Andreev | 92ebfb6 | 2012-05-17 12:49:24 +0300 | [diff] [blame] | 182 | return isset($this->_ci_classes[$class]) ? $this->_ci_classes[$class] : FALSE; |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 186 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 187 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 188 | * Library Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 189 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 190 | * Loads and instantiates libraries. |
| 191 | * Designed to be called from application controllers. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 192 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 193 | * @param string $library Library name |
| 194 | * @param array $params Optional parameters to pass to the library class constructor |
| 195 | * @param string $object_name An optional object name to assign to |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 196 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 197 | */ |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 198 | public function library($library = '', $params = NULL, $object_name = NULL) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 199 | { |
Greg Aker | ce43396 | 2010-10-12 09:29:35 -0500 | [diff] [blame] | 200 | if (is_array($library)) |
| 201 | { |
Phil Sturgeon | 08b5169 | 2011-04-03 18:05:42 +0100 | [diff] [blame] | 202 | foreach ($library as $class) |
Greg Aker | ce43396 | 2010-10-12 09:29:35 -0500 | [diff] [blame] | 203 | { |
Kellas Reeves | 3c6e485 | 2011-02-09 11:57:56 -0600 | [diff] [blame] | 204 | $this->library($class, $params); |
Greg Aker | ce43396 | 2010-10-12 09:29:35 -0500 | [diff] [blame] | 205 | } |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 206 | |
Greg Aker | ce43396 | 2010-10-12 09:29:35 -0500 | [diff] [blame] | 207 | return; |
| 208 | } |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 209 | |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 210 | if ($library === '' OR isset($this->_base_classes[$library])) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 211 | { |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 212 | return; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 215 | if ( ! is_null($params) && ! is_array($params)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 216 | { |
| 217 | $params = NULL; |
| 218 | } |
| 219 | |
Kellas Reeves | 3c6e485 | 2011-02-09 11:57:56 -0600 | [diff] [blame] | 220 | $this->_ci_load_class($library, $params, $object_name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 224 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 225 | /** |
| 226 | * Model Loader |
| 227 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 228 | * Loads and instantiates libraries. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 229 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 230 | * @param string $model Model name |
| 231 | * @param string $name An optional object name to assign to |
| 232 | * @param bool $db_conn An optional database connection configuration to initialize |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 233 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 234 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 235 | public function model($model, $name = '', $db_conn = FALSE) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 236 | { |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 237 | if (empty($model)) |
| 238 | { |
| 239 | return; |
| 240 | } |
| 241 | elseif (is_array($model)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 242 | { |
Joel Limberg | 3cf174b | 2012-07-13 20:49:57 +0300 | [diff] [blame] | 243 | foreach ($model as $class) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 244 | { |
Joel Limberg | 3cf174b | 2012-07-13 20:49:57 +0300 | [diff] [blame] | 245 | $this->model($class); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 246 | } |
| 247 | return; |
| 248 | } |
| 249 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 250 | $path = ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 251 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 252 | // Is the model in a sub-folder? If so, parse out the filename and path. |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 253 | if (($last_slash = strrpos($model, '/')) !== FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 254 | { |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 255 | // The path is in front of the last slash |
Andrey Andreev | d47baab | 2012-01-09 16:56:46 +0200 | [diff] [blame] | 256 | $path = substr($model, 0, ++$last_slash); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 257 | |
| 258 | // And the model name behind it |
Andrey Andreev | d47baab | 2012-01-09 16:56:46 +0200 | [diff] [blame] | 259 | $model = substr($model, $last_slash); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 260 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 261 | |
Phil Sturgeon | 10d78f6 | 2012-06-04 14:41:53 -0500 | [diff] [blame] | 262 | if (empty($name)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 263 | { |
| 264 | $name = $model; |
| 265 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 266 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 267 | if (in_array($name, $this->_ci_models, TRUE)) |
| 268 | { |
| 269 | return; |
| 270 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 271 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 272 | $CI =& get_instance(); |
| 273 | if (isset($CI->$name)) |
| 274 | { |
| 275 | show_error('The model name you are loading is the name of a resource that is already being used: '.$name); |
| 276 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 277 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 278 | $model = strtolower($model); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 279 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 280 | foreach ($this->_ci_model_paths as $mod_path) |
| 281 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 282 | if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 283 | { |
| 284 | continue; |
| 285 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 286 | |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 287 | if ($db_conn !== FALSE && ! class_exists('CI_DB')) |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 288 | { |
| 289 | if ($db_conn === TRUE) |
Pascal Kriete | 287781e | 2010-11-10 15:43:49 -0500 | [diff] [blame] | 290 | { |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 291 | $db_conn = ''; |
Pascal Kriete | 287781e | 2010-11-10 15:43:49 -0500 | [diff] [blame] | 292 | } |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 293 | |
| 294 | $CI->load->database($db_conn, FALSE, TRUE); |
| 295 | } |
| 296 | |
Greg Aker | bce1348 | 2010-10-11 15:37:16 -0500 | [diff] [blame] | 297 | if ( ! class_exists('CI_Model')) |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 298 | { |
| 299 | load_class('Model', 'core'); |
| 300 | } |
| 301 | |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 302 | require_once($mod_path.'models/'.$path.$model.'.php'); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 303 | |
| 304 | $model = ucfirst($model); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 305 | $CI->$name = new $model(); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 306 | $this->_ci_models[] = $name; |
| 307 | return; |
| 308 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 309 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 310 | // couldn't find the model |
| 311 | show_error('Unable to locate the model you have specified: '.$model); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 312 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 313 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 314 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 315 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 316 | /** |
| 317 | * Database Loader |
| 318 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 319 | * @param mixed $params Database configuration options |
| 320 | * @param bool $return Whether to return the database object |
| 321 | * @param bool $query_builder Whether to enable Query Builder |
| 322 | * (overrides the configuration setting) |
| 323 | * |
| 324 | * @return void|object|bool Database object if $return is set to TRUE, |
| 325 | * FALSE on failure, void in any other case |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 326 | */ |
Jamie Rumbelow | 7efad20 | 2012-02-19 12:37:00 +0000 | [diff] [blame] | 327 | public function database($params = '', $return = FALSE, $query_builder = NULL) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 328 | { |
| 329 | // Grab the super object |
| 330 | $CI =& get_instance(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 331 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 332 | // Do we even need to load the database class? |
Andrey Andreev | 9d0ab04 | 2012-10-24 21:47:39 +0300 | [diff] [blame] | 333 | if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 334 | { |
| 335 | return FALSE; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 336 | } |
| 337 | |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 338 | require_once(BASEPATH.'database/DB.php'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 339 | |
| 340 | if ($return === TRUE) |
| 341 | { |
Jamie Rumbelow | 7efad20 | 2012-02-19 12:37:00 +0000 | [diff] [blame] | 342 | return DB($params, $query_builder); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 343 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 344 | |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 345 | // Initialize the db variable. Needed to prevent |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 346 | // reference errors with some configurations |
| 347 | $CI->db = ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 348 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 349 | // Load the DB class |
Jamie Rumbelow | 7efad20 | 2012-02-19 12:37:00 +0000 | [diff] [blame] | 350 | $CI->db =& DB($params, $query_builder); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 351 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 352 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 353 | // -------------------------------------------------------------------- |
| 354 | |
| 355 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 356 | * Load the Database Utilities Class |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 357 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 358 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 359 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 360 | public function dbutil() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 361 | { |
| 362 | if ( ! class_exists('CI_DB')) |
| 363 | { |
| 364 | $this->database(); |
| 365 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 366 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 367 | $CI =& get_instance(); |
| 368 | |
| 369 | // for backwards compatibility, load dbforge so we can extend dbutils off it |
| 370 | // this use is deprecated and strongly discouraged |
| 371 | $CI->load->dbforge(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 372 | |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 373 | require_once(BASEPATH.'database/DB_utility.php'); |
| 374 | require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 375 | $class = 'CI_DB_'.$CI->db->dbdriver.'_utility'; |
| 376 | |
Pascal Kriete | 5856002 | 2010-11-10 16:01:20 -0500 | [diff] [blame] | 377 | $CI->dbutil = new $class(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 378 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 379 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 380 | // -------------------------------------------------------------------- |
| 381 | |
| 382 | /** |
| 383 | * Load the Database Forge Class |
| 384 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 385 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 386 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 387 | public function dbforge() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 388 | { |
| 389 | if ( ! class_exists('CI_DB')) |
| 390 | { |
| 391 | $this->database(); |
| 392 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 393 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 394 | $CI =& get_instance(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 395 | |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 396 | require_once(BASEPATH.'database/DB_forge.php'); |
| 397 | require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 398 | $class = 'CI_DB_'.$CI->db->dbdriver.'_forge'; |
| 399 | |
| 400 | $CI->dbforge = new $class(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 401 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 402 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 403 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 404 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 405 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 406 | * View Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 407 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 408 | * Loads "view" files. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 409 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 410 | * @param string $view View name |
| 411 | * @param array $vars An associative array of data |
| 412 | * to be extracted for use in the view |
| 413 | * @param bool $return Whether to return the view output |
| 414 | * or leave it to the Output class |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 415 | * @return void |
| 416 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 417 | public function view($view, $vars = array(), $return = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 418 | { |
| 419 | return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)); |
| 420 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 421 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 422 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 423 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 424 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 425 | * Generic File Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 426 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 427 | * @param string $path File path |
| 428 | * @param bool $return Whether to return the file output |
| 429 | * @return void|string |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 430 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 431 | public function file($path, $return = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 432 | { |
| 433 | return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return)); |
| 434 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 435 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 436 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 437 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 438 | /** |
| 439 | * Set Variables |
| 440 | * |
| 441 | * Once variables are set they become available within |
| 442 | * the controller class and its "view" files. |
| 443 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 444 | * @param array|object|string $vars |
| 445 | * An associative array or object containing values |
| 446 | * to be set, or a value's name if string |
| 447 | * @param string $val Value to set, only used if $vars is a string |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 448 | * @return void |
| 449 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 450 | public function vars($vars = array(), $val = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 451 | { |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 452 | if ($val !== '' && is_string($vars)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 453 | { |
| 454 | $vars = array($vars => $val); |
| 455 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 456 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 457 | $vars = $this->_ci_object_to_array($vars); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 458 | |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 459 | if (is_array($vars) && count($vars) > 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 460 | { |
| 461 | foreach ($vars as $key => $val) |
| 462 | { |
| 463 | $this->_ci_cached_vars[$key] = $val; |
| 464 | } |
| 465 | } |
| 466 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 467 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 468 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 469 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 470 | /** |
Phil Sturgeon | 8731f64 | 2011-07-22 16:11:34 -0600 | [diff] [blame] | 471 | * Get Variable |
| 472 | * |
| 473 | * Check if a variable is set and retrieve it. |
| 474 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 475 | * @param string $key Variable name |
| 476 | * @return mixed The variable or NULL if not found |
Phil Sturgeon | 8731f64 | 2011-07-22 16:11:34 -0600 | [diff] [blame] | 477 | */ |
| 478 | public function get_var($key) |
| 479 | { |
| 480 | return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL; |
| 481 | } |
| 482 | |
| 483 | // -------------------------------------------------------------------- |
| 484 | |
| 485 | /** |
Shane Pearson | 81dd223 | 2011-11-18 20:49:35 -0600 | [diff] [blame] | 486 | * Get Variables |
| 487 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 488 | * Retrieves all loaded variables. |
Shane Pearson | 81dd223 | 2011-11-18 20:49:35 -0600 | [diff] [blame] | 489 | * |
| 490 | * @return array |
| 491 | */ |
| 492 | public function get_vars() |
| 493 | { |
| 494 | return $this->_ci_cached_vars; |
| 495 | } |
| 496 | |
| 497 | // -------------------------------------------------------------------- |
| 498 | |
| 499 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 500 | * Helper Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 501 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 502 | * @param string|string[] $helpers Helper name(s) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 503 | * @return void |
| 504 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 505 | public function helper($helpers = array()) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 506 | { |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 507 | foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 508 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 509 | if (isset($this->_ci_helpers[$helper])) |
| 510 | { |
| 511 | continue; |
| 512 | } |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 513 | |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 514 | $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 515 | |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 516 | // Is this a helper extension request? |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 517 | if (file_exists($ext_helper)) |
| 518 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 519 | $base_helper = BASEPATH.'helpers/'.$helper.'.php'; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 520 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 521 | if ( ! file_exists($base_helper)) |
| 522 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 523 | show_error('Unable to load the requested file: helpers/'.$helper.'.php'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 524 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 525 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 526 | include_once($ext_helper); |
| 527 | include_once($base_helper); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 528 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 529 | $this->_ci_helpers[$helper] = TRUE; |
| 530 | log_message('debug', 'Helper loaded: '.$helper); |
| 531 | continue; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 532 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 533 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 534 | // Try to load the helper |
| 535 | foreach ($this->_ci_helper_paths as $path) |
| 536 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 537 | if (file_exists($path.'helpers/'.$helper.'.php')) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 538 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 539 | include_once($path.'helpers/'.$helper.'.php'); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 540 | |
| 541 | $this->_ci_helpers[$helper] = TRUE; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 542 | log_message('debug', 'Helper loaded: '.$helper); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 543 | break; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 547 | // unable to load the helper |
| 548 | if ( ! isset($this->_ci_helpers[$helper])) |
| 549 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 550 | show_error('Unable to load the requested file: helpers/'.$helper.'.php'); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 551 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 552 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 553 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 554 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 555 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 556 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 557 | /** |
| 558 | * Load Helpers |
| 559 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 560 | * An alias for the helper() method in case the developer has |
| 561 | * written the plural form of it. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 562 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 563 | * @uses CI_Loader::helper() |
| 564 | * @param string|string[] $helpers Helper name(s) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 565 | * @return void |
| 566 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 567 | public function helpers($helpers = array()) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 568 | { |
| 569 | $this->helper($helpers); |
| 570 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 571 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 572 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 573 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 574 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 575 | * Language Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 576 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 577 | * Loads language files. |
| 578 | * |
| 579 | * @param string|string[] $files List of language file names to load |
| 580 | * @param string Language name |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 581 | * @return void |
| 582 | */ |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 583 | public function language($files = array(), $lang = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 584 | { |
| 585 | $CI =& get_instance(); |
| 586 | |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 587 | is_array($files) OR $files = array($files); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 588 | |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 589 | foreach ($files as $langfile) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 590 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 591 | $CI->lang->load($langfile, $lang); |
| 592 | } |
| 593 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 594 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 595 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 596 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 597 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 598 | * Config Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 599 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 600 | * Loads a config file (an alias for CI_Config::load()). |
| 601 | * |
| 602 | * @uses CI_Config::load() |
| 603 | * @param string $file Configuration file name |
| 604 | * @param bool $use_sections Whether configuration values should be loaded into their own section |
| 605 | * @param bool $fail_gracefully Whether to just return FALSE or display an error message |
| 606 | * @return bool TRUE if the file was loaded correctly or FALSE on failure |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 607 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 608 | public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 609 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 610 | $CI =& get_instance(); |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 611 | return $CI->config->load($file, $use_sections, $fail_gracefully); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | // -------------------------------------------------------------------- |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 615 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 616 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 617 | * Driver Loader |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 618 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 619 | * Loads a driver library. |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 620 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 621 | * @param string|string[] $library Driver name(s) |
| 622 | * @param array $params Optional parameters to pass to the driver |
| 623 | * @param string $object_name An optional object name to assign to |
| 624 | * |
| 625 | * @return void|object|bool Object or FALSE on failure if $library is a string |
| 626 | * and $object_name is set. void otherwise. |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 627 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 628 | public function driver($library = '', $params = NULL, $object_name = NULL) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 629 | { |
Christopher Guiney | b54d355 | 2012-03-10 08:38:10 -0800 | [diff] [blame] | 630 | if (is_array($library)) |
Christopher Guiney | 9929d6f | 2012-03-09 19:53:24 -0800 | [diff] [blame] | 631 | { |
Christopher Guiney | b54d355 | 2012-03-10 08:38:10 -0800 | [diff] [blame] | 632 | foreach ($library as $driver) |
Christopher Guiney | 9929d6f | 2012-03-09 19:53:24 -0800 | [diff] [blame] | 633 | { |
| 634 | $this->driver($driver); |
| 635 | } |
dchill42 | 0fc3be5 | 2012-08-27 20:54:23 -0400 | [diff] [blame] | 636 | return; |
Christopher Guiney | 9929d6f | 2012-03-09 19:53:24 -0800 | [diff] [blame] | 637 | } |
| 638 | |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 639 | if ($library === '') |
Tom Klingenberg | 6a15b2d | 2011-10-07 20:03:30 +0200 | [diff] [blame] | 640 | { |
| 641 | return FALSE; |
| 642 | } |
| 643 | |
Derek Jones | d5e0cb5 | 2010-03-09 20:20:46 -0600 | [diff] [blame] | 644 | // We can save the loader some time since Drivers will *always* be in a subfolder, |
| 645 | // and typically identically named to the library |
| 646 | if ( ! strpos($library, '/')) |
| 647 | { |
Greg Aker | d25e66a | 2010-03-28 01:07:09 -0500 | [diff] [blame] | 648 | $library = ucfirst($library).'/'.$library; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 649 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 650 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 651 | return $this->library($library, $params, $object_name); |
| 652 | } |
| 653 | |
| 654 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 655 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 656 | /** |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 657 | * Add Package Path |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 658 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 659 | * Prepends a parent path to the library, model, helper and config |
| 660 | * path arrays. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 661 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 662 | * @see CI_Loader::$_ci_library_paths |
| 663 | * @see CI_Loader::$_ci_model_paths |
| 664 | * @see CI_Loader::$_ci_helper_paths |
| 665 | * @see CI_Config::$_config_paths |
| 666 | * |
| 667 | * @param string $path Path to add |
| 668 | * @param bool $view_cascade (default: TRUE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 669 | * @return void |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 670 | */ |
Andrey Andreev | cce9180 | 2012-06-12 13:25:31 +0300 | [diff] [blame] | 671 | public function add_package_path($path, $view_cascade = TRUE) |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 672 | { |
Pascal Kriete | 6b6c274 | 2010-11-09 13:12:22 -0500 | [diff] [blame] | 673 | $path = rtrim($path, '/').'/'; |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 674 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 675 | array_unshift($this->_ci_library_paths, $path); |
| 676 | array_unshift($this->_ci_model_paths, $path); |
| 677 | array_unshift($this->_ci_helper_paths, $path); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 678 | |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 679 | $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths; |
| 680 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 681 | // Add config file path |
| 682 | $config =& $this->_ci_get_component('config'); |
Korri | 3684d34 | 2012-04-17 00:35:08 -0400 | [diff] [blame] | 683 | array_push($config->_config_paths, $path); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | // -------------------------------------------------------------------- |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 687 | |
| 688 | /** |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 689 | * Get Package Paths |
| 690 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 691 | * Return a list of all package paths. |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 692 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 693 | * @param bool $include_base Whether to include BASEPATH (default: TRUE) |
| 694 | * @return array |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 695 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 696 | public function get_package_paths($include_base = FALSE) |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 697 | { |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 698 | return ($include_base === TRUE) ? $this->_ci_library_paths : $this->_ci_model_paths; |
Phil Sturgeon | de3dbc3 | 2010-12-27 17:41:02 +0000 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | // -------------------------------------------------------------------- |
| 702 | |
| 703 | /** |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 704 | * Remove Package Path |
| 705 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 706 | * Remove a path from the library, model, helper and/or config |
| 707 | * path arrays if it exists. If no path is provided, the most recently |
| 708 | * added path will be removed removed. |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 709 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 710 | * @param string $path Path to remove |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 711 | * @return void |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 712 | */ |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 713 | public function remove_package_path($path = '') |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 714 | { |
| 715 | $config =& $this->_ci_get_component('config'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 716 | |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 717 | if ($path === '') |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 718 | { |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 719 | array_shift($this->_ci_library_paths); |
| 720 | array_shift($this->_ci_model_paths); |
| 721 | array_shift($this->_ci_helper_paths); |
| 722 | array_shift($this->_ci_view_paths); |
Korri | 3684d34 | 2012-04-17 00:35:08 -0400 | [diff] [blame] | 723 | array_pop($config->_config_paths); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 724 | } |
| 725 | else |
| 726 | { |
Pascal Kriete | 6b6c274 | 2010-11-09 13:12:22 -0500 | [diff] [blame] | 727 | $path = rtrim($path, '/').'/'; |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 728 | foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var) |
| 729 | { |
| 730 | if (($key = array_search($path, $this->{$var})) !== FALSE) |
| 731 | { |
| 732 | unset($this->{$var}[$key]); |
| 733 | } |
| 734 | } |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 735 | |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 736 | if (isset($this->_ci_view_paths[$path.'views/'])) |
| 737 | { |
| 738 | unset($this->_ci_view_paths[$path.'views/']); |
| 739 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 740 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 741 | if (($key = array_search($path, $config->_config_paths)) !== FALSE) |
| 742 | { |
| 743 | unset($config->_config_paths[$key]); |
| 744 | } |
| 745 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 746 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 747 | // make sure the application default paths are still in the array |
| 748 | $this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH))); |
| 749 | $this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH))); |
| 750 | $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH))); |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 751 | $this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE)); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 752 | $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH))); |
| 753 | } |
| 754 | |
| 755 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 756 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 757 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 758 | * Internal CI Data Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 759 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 760 | * Used to load views and files. |
| 761 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 762 | * Variables are prefixed with _ci_ to avoid symbol collision with |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 763 | * variables made available to view files. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 764 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 765 | * @used-by CI_Loader::view() |
| 766 | * @used-by CI_Loader::file() |
| 767 | * @param array $_ci_data Data to load |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 768 | * @return void |
| 769 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 770 | protected function _ci_load($_ci_data) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 771 | { |
| 772 | // Set the default data variables |
| 773 | foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val) |
| 774 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 775 | $$_ci_val = isset($_ci_data[$_ci_val]) ? $_ci_data[$_ci_val] : FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 776 | } |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 777 | |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 778 | $file_exists = FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 779 | |
| 780 | // Set the path to the requested file |
Alex Bilbie | 40bd2a7 | 2012-06-02 16:04:15 +0100 | [diff] [blame] | 781 | if (is_string($_ci_path) && $_ci_path !== '') |
Greg Aker | 8807be3 | 2011-04-21 13:06:15 -0500 | [diff] [blame] | 782 | { |
| 783 | $_ci_x = explode('/', $_ci_path); |
| 784 | $_ci_file = end($_ci_x); |
| 785 | } |
| 786 | else |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 787 | { |
| 788 | $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 789 | $_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view; |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 790 | |
Joe McFrederick | 64f470b | 2012-08-18 12:29:56 -0400 | [diff] [blame] | 791 | foreach ($this->_ci_view_paths as $_ci_view_file => $cascade) |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 792 | { |
Joe McFrederick | 64f470b | 2012-08-18 12:29:56 -0400 | [diff] [blame] | 793 | if (file_exists($_ci_view_file.$_ci_file)) |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 794 | { |
Joe McFrederick | 64f470b | 2012-08-18 12:29:56 -0400 | [diff] [blame] | 795 | $_ci_path = $_ci_view_file.$_ci_file; |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 796 | $file_exists = TRUE; |
| 797 | break; |
| 798 | } |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 799 | |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 800 | if ( ! $cascade) |
| 801 | { |
| 802 | break; |
David Behler | cda768a | 2011-08-14 23:52:48 +0200 | [diff] [blame] | 803 | } |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 804 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 805 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 806 | |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 807 | if ( ! $file_exists && ! file_exists($_ci_path)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 808 | { |
| 809 | show_error('Unable to load the requested file: '.$_ci_file); |
| 810 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 811 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 812 | // This allows anything loaded using $this->load (views, files, etc.) |
| 813 | // to become accessible from within the Controller and Model functions. |
Pascal Kriete | 89ace43 | 2010-11-10 15:49:10 -0500 | [diff] [blame] | 814 | $_ci_CI =& get_instance(); |
| 815 | foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 816 | { |
Pascal Kriete | 89ace43 | 2010-11-10 15:49:10 -0500 | [diff] [blame] | 817 | if ( ! isset($this->$_ci_key)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 818 | { |
Pascal Kriete | 89ace43 | 2010-11-10 15:49:10 -0500 | [diff] [blame] | 819 | $this->$_ci_key =& $_ci_CI->$_ci_key; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 820 | } |
| 821 | } |
| 822 | |
| 823 | /* |
| 824 | * Extract and cache variables |
| 825 | * |
vlakoff | 0250618 | 2012-07-03 07:28:50 +0200 | [diff] [blame] | 826 | * You can either set variables using the dedicated $this->load->vars() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 827 | * function or via the second parameter of this function. We'll merge |
| 828 | * the two types and cache them so that views that are embedded within |
| 829 | * other views can have access to these variables. |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 830 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 831 | if (is_array($_ci_vars)) |
| 832 | { |
| 833 | $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars); |
| 834 | } |
| 835 | extract($this->_ci_cached_vars); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 836 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 837 | /* |
| 838 | * Buffer the output |
| 839 | * |
| 840 | * We buffer the output for two reasons: |
| 841 | * 1. Speed. You get a significant speed boost. |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 842 | * 2. So that the final rendered template can be post-processed by |
dchill42 | 5628ba0 | 2012-08-08 12:05:45 -0400 | [diff] [blame] | 843 | * the output class. Why do we need post processing? For one thing, |
| 844 | * in order to show the elapsed page load time. Unless we can |
| 845 | * intercept the content right before it's sent to the browser and |
| 846 | * then stop the timer it won't be accurate. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 847 | */ |
| 848 | ob_start(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 849 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 850 | // If the PHP installation does not support short tags we'll |
| 851 | // do a little string replacement, changing the short tags |
| 852 | // to standard PHP echo statements. |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 853 | if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') === TRUE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 854 | { |
Andrey Andreev | d47baab | 2012-01-09 16:56:46 +0200 | [diff] [blame] | 855 | echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path)))); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 856 | } |
| 857 | else |
| 858 | { |
| 859 | include($_ci_path); // include() vs include_once() allows for multiple views with the same name |
| 860 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 861 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 862 | log_message('debug', 'File loaded: '.$_ci_path); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 863 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 864 | // Return the file data if requested |
| 865 | if ($_ci_return === TRUE) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 866 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 867 | $buffer = ob_get_contents(); |
| 868 | @ob_end_clean(); |
| 869 | return $buffer; |
| 870 | } |
| 871 | |
| 872 | /* |
| 873 | * Flush the buffer... or buff the flusher? |
| 874 | * |
| 875 | * In order to permit views to be nested within |
| 876 | * other views, we need to flush the content back out whenever |
| 877 | * we are beyond the first level of output buffering so that |
| 878 | * it can be seen and included properly by the first included |
| 879 | * template and any subsequent ones. Oy! |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 880 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 881 | if (ob_get_level() > $this->_ci_ob_level + 1) |
| 882 | { |
| 883 | ob_end_flush(); |
| 884 | } |
| 885 | else |
| 886 | { |
Greg Aker | 22f1a63 | 2010-11-10 15:34:35 -0600 | [diff] [blame] | 887 | $_ci_CI->output->append_output(ob_get_contents()); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 888 | @ob_end_clean(); |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | // -------------------------------------------------------------------- |
| 893 | |
| 894 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 895 | * Internal CI Class Loader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 896 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 897 | * @used-by CI_Loader::library() |
| 898 | * @uses CI_Loader::_ci_init_class() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 899 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 900 | * @param string $class Class name to load |
| 901 | * @param mixed $params Optional parameters to pass to the class constructor |
| 902 | * @param string $object_name Optional object name to assign to |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 903 | * @return void |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 904 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 905 | protected function _ci_load_class($class, $params = NULL, $object_name = NULL) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 906 | { |
| 907 | // Get the class name, and while we're at it trim any slashes. |
| 908 | // The directory path can be included as part of the class name, |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 909 | // but we don't want a leading slash |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 910 | $class = str_replace('.php', '', trim($class, '/')); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 911 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 912 | // Was the path included with the class name? |
| 913 | // We look for a slash to determine this |
| 914 | $subdir = ''; |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 915 | if (($last_slash = strrpos($class, '/')) !== FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 916 | { |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 917 | // Extract the path |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 918 | $subdir = substr($class, 0, ++$last_slash); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 919 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 920 | // Get the filename from the path |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 921 | $class = substr($class, $last_slash); |
dchill42 | 5628ba0 | 2012-08-08 12:05:45 -0400 | [diff] [blame] | 922 | |
| 923 | // Check for match and driver base class |
dchill42 | aee9265 | 2012-08-26 21:45:35 -0400 | [diff] [blame] | 924 | if (strtolower(trim($subdir, '/')) == strtolower($class) && ! class_exists('CI_Driver_Library')) |
dchill42 | 5628ba0 | 2012-08-08 12:05:45 -0400 | [diff] [blame] | 925 | { |
| 926 | // We aren't instantiating an object here, just making the base class available |
| 927 | require BASEPATH.'libraries/Driver.php'; |
| 928 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | // We'll test for both lowercase and capitalized versions of the file name |
| 932 | foreach (array(ucfirst($class), strtolower($class)) as $class) |
| 933 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 934 | $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 935 | |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 936 | // Is this a class extension request? |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 937 | if (file_exists($subclass)) |
| 938 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 939 | $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 940 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 941 | if ( ! file_exists($baseclass)) |
| 942 | { |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 943 | log_message('error', 'Unable to load the requested class: '.$class); |
| 944 | show_error('Unable to load the requested class: '.$class); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 945 | } |
| 946 | |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 947 | // Safety: Was the class already loaded by a previous call? |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 948 | if (in_array($subclass, $this->_ci_loaded_files)) |
| 949 | { |
| 950 | // Before we deem this to be a duplicate request, let's see |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 951 | // if a custom object name is being supplied. If so, we'll |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 952 | // return a new instance of the object |
| 953 | if ( ! is_null($object_name)) |
| 954 | { |
| 955 | $CI =& get_instance(); |
| 956 | if ( ! isset($CI->$object_name)) |
| 957 | { |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 958 | return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 959 | } |
| 960 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 961 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 962 | $is_duplicate = TRUE; |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 963 | log_message('debug', $class.' class already loaded. Second attempt ignored.'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 964 | return; |
| 965 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 966 | |
| 967 | include_once($baseclass); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 968 | include_once($subclass); |
| 969 | $this->_ci_loaded_files[] = $subclass; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 970 | |
| 971 | return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 972 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 973 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 974 | // Lets search for the requested library file and load it. |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 975 | $is_duplicate = FALSE; |
| 976 | foreach ($this->_ci_library_paths as $path) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 977 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 978 | $filepath = $path.'libraries/'.$subdir.$class.'.php'; |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 979 | |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 980 | // Does the file exist? No? Bummer... |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 981 | if ( ! file_exists($filepath)) |
| 982 | { |
| 983 | continue; |
| 984 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 985 | |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 986 | // Safety: Was the class already loaded by a previous call? |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 987 | if (in_array($filepath, $this->_ci_loaded_files)) |
| 988 | { |
| 989 | // Before we deem this to be a duplicate request, let's see |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 990 | // if a custom object name is being supplied. If so, we'll |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 991 | // return a new instance of the object |
| 992 | if ( ! is_null($object_name)) |
| 993 | { |
| 994 | $CI =& get_instance(); |
| 995 | if ( ! isset($CI->$object_name)) |
| 996 | { |
| 997 | return $this->_ci_init_class($class, '', $params, $object_name); |
| 998 | } |
| 999 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1000 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1001 | $is_duplicate = TRUE; |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 1002 | log_message('debug', $class.' class already loaded. Second attempt ignored.'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1003 | return; |
| 1004 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1005 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1006 | include_once($filepath); |
| 1007 | $this->_ci_loaded_files[] = $filepath; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1008 | return $this->_ci_init_class($class, '', $params, $object_name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1009 | } |
| 1010 | } // END FOREACH |
| 1011 | |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 1012 | // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 1013 | if ($subdir === '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1014 | { |
| 1015 | $path = strtolower($class).'/'.$class; |
dchill42 | 0fc3be5 | 2012-08-27 20:54:23 -0400 | [diff] [blame] | 1016 | return $this->_ci_load_class($path, $params, $object_name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1017 | } |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 1018 | elseif (ucfirst($subdir) != $subdir) |
dchill42 | aee9265 | 2012-08-26 21:45:35 -0400 | [diff] [blame] | 1019 | { |
| 1020 | // Lowercase subdir failed - retry capitalized |
| 1021 | $path = ucfirst($subdir).$class; |
dchill42 | 0fc3be5 | 2012-08-27 20:54:23 -0400 | [diff] [blame] | 1022 | return $this->_ci_load_class($path, $params, $object_name); |
dchill42 | aee9265 | 2012-08-26 21:45:35 -0400 | [diff] [blame] | 1023 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1024 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1025 | // If we got this far we were unable to find the requested class. |
| 1026 | // We do not issue errors if the load call failed due to a duplicate request |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 1027 | if ($is_duplicate === FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1028 | { |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 1029 | log_message('error', 'Unable to load the requested class: '.$class); |
| 1030 | show_error('Unable to load the requested class: '.$class); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1031 | } |
| 1032 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1033 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1034 | // -------------------------------------------------------------------- |
| 1035 | |
| 1036 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1037 | * Internal CI Class Instantiator |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1038 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1039 | * @used-by CI_Loader::_ci_load_class() |
| 1040 | * |
| 1041 | * @param string $class Class name |
| 1042 | * @param string $prefix Class name prefix |
| 1043 | * @param array|null|bool $config Optional configuration to pass to the class constructor: |
| 1044 | * FALSE to skip; |
| 1045 | * NULL to search in config paths; |
| 1046 | * array containing configuration data |
| 1047 | * @param string $object_name Optional object name to assign to |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1048 | * @return void |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1049 | */ |
Greg Aker | 0c9ee4a | 2011-04-20 09:40:17 -0500 | [diff] [blame] | 1050 | protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1051 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1052 | // Is there an associated config file for this class? Note: these should always be lowercase |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1053 | if ($config === NULL) |
| 1054 | { |
Eric Barnes | 5e16ec6 | 2011-01-04 17:25:23 -0500 | [diff] [blame] | 1055 | // Fetch the config paths containing any package paths |
| 1056 | $config_component = $this->_ci_get_component('config'); |
| 1057 | |
| 1058 | if (is_array($config_component->_config_paths)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1059 | { |
Eric Barnes | 5e16ec6 | 2011-01-04 17:25:23 -0500 | [diff] [blame] | 1060 | // Break on the first found file, thus package files |
| 1061 | // are not overridden by default paths |
| 1062 | foreach ($config_component->_config_paths as $path) |
| 1063 | { |
| 1064 | // We test for both uppercase and lowercase, for servers that |
joelcox | 1bfd9fa | 2011-01-16 18:49:39 +0100 | [diff] [blame] | 1065 | // are case-sensitive with regard to file names. Check for environment |
| 1066 | // first, global next |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1067 | if (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) |
joelcox | 1bfd9fa | 2011-01-16 18:49:39 +0100 | [diff] [blame] | 1068 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1069 | include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); |
joelcox | 1bfd9fa | 2011-01-16 18:49:39 +0100 | [diff] [blame] | 1070 | break; |
| 1071 | } |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1072 | elseif (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) |
joelcox | 1bfd9fa | 2011-01-16 18:49:39 +0100 | [diff] [blame] | 1073 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1074 | include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); |
joelcox | 1bfd9fa | 2011-01-16 18:49:39 +0100 | [diff] [blame] | 1075 | break; |
| 1076 | } |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1077 | elseif (file_exists($path.'config/'.strtolower($class).'.php')) |
Eric Barnes | 5e16ec6 | 2011-01-04 17:25:23 -0500 | [diff] [blame] | 1078 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1079 | include($path.'config/'.strtolower($class).'.php'); |
Eric Barnes | 5e16ec6 | 2011-01-04 17:25:23 -0500 | [diff] [blame] | 1080 | break; |
| 1081 | } |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1082 | elseif (file_exists($path.'config/'.ucfirst(strtolower($class)).'.php')) |
Eric Barnes | 5e16ec6 | 2011-01-04 17:25:23 -0500 | [diff] [blame] | 1083 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1084 | include($path.'config/'.ucfirst(strtolower($class)).'.php'); |
Eric Barnes | 5e16ec6 | 2011-01-04 17:25:23 -0500 | [diff] [blame] | 1085 | break; |
| 1086 | } |
| 1087 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1088 | } |
| 1089 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1090 | |
Alex Bilbie | ed944a3 | 2012-06-02 11:07:47 +0100 | [diff] [blame] | 1091 | if ($prefix === '') |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1092 | { |
| 1093 | if (class_exists('CI_'.$class)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1094 | { |
| 1095 | $name = 'CI_'.$class; |
| 1096 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1097 | elseif (class_exists(config_item('subclass_prefix').$class)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1098 | { |
| 1099 | $name = config_item('subclass_prefix').$class; |
| 1100 | } |
| 1101 | else |
| 1102 | { |
| 1103 | $name = $class; |
| 1104 | } |
| 1105 | } |
| 1106 | else |
| 1107 | { |
| 1108 | $name = $prefix.$class; |
| 1109 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1110 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1111 | // Is the class name valid? |
| 1112 | if ( ! class_exists($name)) |
| 1113 | { |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 1114 | log_message('error', 'Non-existent class: '.$name); |
jonnu | eee2df6 | 2012-07-16 13:06:16 +0100 | [diff] [blame] | 1115 | show_error('Non-existent class: '.$name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1116 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1117 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1118 | // Set the variable name we will assign the class to |
Andrey Andreev | d729735 | 2012-01-07 22:53:14 +0200 | [diff] [blame] | 1119 | // Was a custom class name supplied? If so we'll use it |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1120 | $class = strtolower($class); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1121 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1122 | if (is_null($object_name)) |
| 1123 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1124 | $classvar = isset($this->_ci_varmap[$class]) ? $this->_ci_varmap[$class] : $class; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1125 | } |
| 1126 | else |
| 1127 | { |
| 1128 | $classvar = $object_name; |
| 1129 | } |
| 1130 | |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1131 | // Save the class name and object name |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1132 | $this->_ci_classes[$class] = $classvar; |
| 1133 | |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1134 | // Instantiate the class |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1135 | $CI =& get_instance(); |
| 1136 | if ($config !== NULL) |
| 1137 | { |
| 1138 | $CI->$classvar = new $name($config); |
| 1139 | } |
| 1140 | else |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1141 | { |
Andrey Andreev | a11b16b | 2012-03-28 12:22:04 +0300 | [diff] [blame] | 1142 | $CI->$classvar = new $name(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1143 | } |
| 1144 | } |
| 1145 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1146 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1147 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1148 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1149 | * CI Autoloader |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1150 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1151 | * Loads component listed in the config/autoload.php file. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1152 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1153 | * @used-by CI_Loader::initialize() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1154 | * @return void |
| 1155 | */ |
Shane Pearson | 665baec | 2011-08-22 18:52:19 -0500 | [diff] [blame] | 1156 | protected function _ci_autoloader() |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1157 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1158 | if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) |
bubbafoley | 0ea0414 | 2011-03-17 14:55:41 -0500 | [diff] [blame] | 1159 | { |
Shane Pearson | 6adfe63 | 2011-08-10 16:42:53 -0500 | [diff] [blame] | 1160 | include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'); |
bubbafoley | 0ea0414 | 2011-03-17 14:55:41 -0500 | [diff] [blame] | 1161 | } |
| 1162 | else |
| 1163 | { |
Shane Pearson | 6adfe63 | 2011-08-10 16:42:53 -0500 | [diff] [blame] | 1164 | include(APPPATH.'config/autoload.php'); |
bubbafoley | 0ea0414 | 2011-03-17 14:55:41 -0500 | [diff] [blame] | 1165 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1166 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1167 | if ( ! isset($autoload)) |
| 1168 | { |
| 1169 | return FALSE; |
| 1170 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1171 | |
Phil Sturgeon | 9730c75 | 2010-12-15 10:50:15 +0000 | [diff] [blame] | 1172 | // Autoload packages |
| 1173 | if (isset($autoload['packages'])) |
| 1174 | { |
| 1175 | foreach ($autoload['packages'] as $package_path) |
| 1176 | { |
| 1177 | $this->add_package_path($package_path); |
| 1178 | } |
| 1179 | } |
| 1180 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1181 | // Load any custom config file |
| 1182 | if (count($autoload['config']) > 0) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1183 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1184 | $CI =& get_instance(); |
| 1185 | foreach ($autoload['config'] as $key => $val) |
| 1186 | { |
| 1187 | $CI->config->load($val); |
| 1188 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1189 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1190 | |
Derek Jones | c6da503 | 2010-03-09 20:44:27 -0600 | [diff] [blame] | 1191 | // Autoload helpers and languages |
| 1192 | foreach (array('helper', 'language') as $type) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1193 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1194 | if (isset($autoload[$type]) && count($autoload[$type]) > 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1195 | { |
| 1196 | $this->$type($autoload[$type]); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1197 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1200 | // Load libraries |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1201 | if (isset($autoload['libraries']) && count($autoload['libraries']) > 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1202 | { |
| 1203 | // Load the database driver. |
| 1204 | if (in_array('database', $autoload['libraries'])) |
| 1205 | { |
| 1206 | $this->database(); |
| 1207 | $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); |
| 1208 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1209 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1210 | // Load all other libraries |
| 1211 | foreach ($autoload['libraries'] as $item) |
| 1212 | { |
| 1213 | $this->library($item); |
| 1214 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1215 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1216 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 1217 | // Autoload drivers |
| 1218 | if (isset($autoload['drivers'])) |
| 1219 | { |
Darren Hill | ca3be1d | 2011-08-31 08:31:18 -0400 | [diff] [blame] | 1220 | foreach ($autoload['drivers'] as $item) |
| 1221 | { |
| 1222 | $this->driver($item); |
| 1223 | } |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 1224 | } |
| 1225 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1226 | // Autoload models |
| 1227 | if (isset($autoload['model'])) |
| 1228 | { |
| 1229 | $this->model($autoload['model']); |
| 1230 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1231 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1232 | |
| 1233 | // -------------------------------------------------------------------- |
| 1234 | |
| 1235 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1236 | * CI Object to Array translator |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1237 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1238 | * Takes an object as input and converts the class variables to |
| 1239 | * an associative array with key/value pairs. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1240 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1241 | * @param object $object Object data to translate |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1242 | * @return array |
| 1243 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 1244 | protected function _ci_object_to_array($object) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1245 | { |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1246 | return is_object($object) ? get_object_vars($object) : $object; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1247 | } |
| 1248 | |
| 1249 | // -------------------------------------------------------------------- |
| 1250 | |
| 1251 | /** |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1252 | * CI Component getter |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1253 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1254 | * Get a reference to a specific library or model. |
| 1255 | * |
| 1256 | * @param string $component Component name |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1257 | * @return bool |
| 1258 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 1259 | protected function &_ci_get_component($component) |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1260 | { |
Pascal Kriete | 89ace43 | 2010-11-10 15:49:10 -0500 | [diff] [blame] | 1261 | $CI =& get_instance(); |
| 1262 | return $CI->$component; |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1266 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1267 | /** |
| 1268 | * Prep filename |
| 1269 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1270 | * This function prepares filenames of various items to |
| 1271 | * make their loading more reliable. |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1272 | * |
Andrey Andreev | ed4b258 | 2012-10-27 17:46:52 +0300 | [diff] [blame] | 1273 | * @param string|string[] $filename Filename(s) |
| 1274 | * @param string $extension Filename extension |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1275 | * @return array |
| 1276 | */ |
Greg Aker | f5c8402 | 2011-04-19 17:13:03 -0500 | [diff] [blame] | 1277 | protected function _ci_prep_filename($filename, $extension) |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1278 | { |
| 1279 | if ( ! is_array($filename)) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1280 | { |
Andrey Andreev | d47baab | 2012-01-09 16:56:46 +0200 | [diff] [blame] | 1281 | return array(strtolower(str_replace(array($extension, '.php'), '', $filename).$extension)); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1282 | } |
| 1283 | else |
| 1284 | { |
| 1285 | foreach ($filename as $key => $val) |
| 1286 | { |
Andrey Andreev | d47baab | 2012-01-09 16:56:46 +0200 | [diff] [blame] | 1287 | $filename[$key] = strtolower(str_replace(array($extension, '.php'), '', $val).$extension); |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1288 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 1289 | |
Derek Jones | 32bf186 | 2010-03-02 13:46:07 -0600 | [diff] [blame] | 1290 | return $filename; |
| 1291 | } |
| 1292 | } |
Andrey Andreev | 94af355 | 2012-03-26 23:10:42 +0300 | [diff] [blame] | 1293 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | /* End of file Loader.php */ |
Andrey Andreev | 9438e26 | 2012-10-05 13:16:27 +0300 | [diff] [blame] | 1297 | /* Location: ./system/core/Loader.php */ |