blob: 57b05ab3e49c63f6cb4054ecf60a7d074c223cf9 [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Derek Jones7f3719f2010-01-05 13:35:37 +00009 * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Loader Class
20 *
21 * Loads views and files
22 *
23 * @package CodeIgniter
24 * @subpackage Libraries
25 * @author ExpressionEngine Dev Team
26 * @category Loader
27 * @link http://codeigniter.com/user_guide/libraries/loader.html
28 */
29class CI_Loader {
30
31 // All these are set automatically. Don't mess with them.
32 var $_ci_ob_level;
33 var $_ci_view_path = '';
Derek Jones32bf1862010-03-02 13:46:07 -060034 var $_ci_library_paths = array();
35 var $_ci_model_paths = array();
36 var $_ci_helper_paths = array();
Derek Jones32bf1862010-03-02 13:46:07 -060037 var $_base_classes = array(); // Set by the controller class
Derek Allard2067d1a2008-11-13 22:59:24 +000038 var $_ci_cached_vars = array();
39 var $_ci_classes = array();
40 var $_ci_loaded_files = array();
41 var $_ci_models = array();
42 var $_ci_helpers = array();
Derek Allard2067d1a2008-11-13 22:59:24 +000043 var $_ci_varmap = array('unit_test' => 'unit', 'user_agent' => 'agent');
Barry Mienydd671972010-10-04 16:33:58 +020044
Derek Allard2067d1a2008-11-13 22:59:24 +000045
46 /**
47 * Constructor
48 *
49 * Sets the path to the view files and gets the initial output buffering level
50 *
51 * @access public
52 */
53 function CI_Loader()
Barry Mienydd671972010-10-04 16:33:58 +020054 {
Derek Allard2067d1a2008-11-13 22:59:24 +000055 $this->_ci_view_path = APPPATH.'views/';
56 $this->_ci_ob_level = ob_get_level();
Derek Jones32bf1862010-03-02 13:46:07 -060057 $this->_ci_library_paths = array(APPPATH, BASEPATH);
58 $this->_ci_helper_paths = array(APPPATH, BASEPATH);
59 $this->_ci_model_paths = array(APPPATH);
Barry Mienydd671972010-10-04 16:33:58 +020060
Derek Allard2067d1a2008-11-13 22:59:24 +000061 log_message('debug', "Loader Class Initialized");
62 }
Barry Mienydd671972010-10-04 16:33:58 +020063
Derek Allard2067d1a2008-11-13 22:59:24 +000064 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020065
Derek Allard2067d1a2008-11-13 22:59:24 +000066 /**
67 * Class Loader
68 *
69 * This function lets users load and instantiate classes.
70 * It is designed to be called from a user's app controllers.
71 *
72 * @access public
73 * @param string the name of the class
74 * @param mixed the optional parameters
75 * @param string an optional object name
76 * @return void
Barry Mienydd671972010-10-04 16:33:58 +020077 */
Derek Allard2067d1a2008-11-13 22:59:24 +000078 function library($library = '', $params = NULL, $object_name = NULL)
79 {
Greg Akerce433962010-10-12 09:29:35 -050080 if (is_array($library))
81 {
82 foreach($library as $read)
83 {
84 $this->library($read);
85 }
86
87 return;
88 }
89
Derek Jones32bf1862010-03-02 13:46:07 -060090 if ($library == '' OR isset($this->_base_classes[$library]))
Derek Allard2067d1a2008-11-13 22:59:24 +000091 {
92 return FALSE;
93 }
94
Derek Jones32bf1862010-03-02 13:46:07 -060095 if ( ! is_null($params) && ! is_array($params))
Derek Allard2067d1a2008-11-13 22:59:24 +000096 {
97 $params = NULL;
98 }
99
100 if (is_array($library))
101 {
102 foreach ($library as $class)
103 {
104 $this->_ci_load_class($class, $params, $object_name);
105 }
106 }
107 else
108 {
109 $this->_ci_load_class($library, $params, $object_name);
110 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000111 }
112
113 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200114
Derek Allard2067d1a2008-11-13 22:59:24 +0000115 /**
116 * Model Loader
117 *
118 * This function lets users load and instantiate models.
119 *
120 * @access public
121 * @param string the name of the class
122 * @param string name for the model
123 * @param bool database connection
124 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200125 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000126 function model($model, $name = '', $db_conn = FALSE)
Barry Mienydd671972010-10-04 16:33:58 +0200127 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000128 if (is_array($model))
129 {
130 foreach($model as $babe)
131 {
Barry Mienydd671972010-10-04 16:33:58 +0200132 $this->model($babe);
Derek Allard2067d1a2008-11-13 22:59:24 +0000133 }
134 return;
135 }
136
137 if ($model == '')
138 {
139 return;
140 }
Barry Mienydd671972010-10-04 16:33:58 +0200141
Derek Jones32bf1862010-03-02 13:46:07 -0600142 $path = '';
Barry Mienydd671972010-10-04 16:33:58 +0200143
Derek Allard2067d1a2008-11-13 22:59:24 +0000144 // Is the model in a sub-folder? If so, parse out the filename and path.
Derek Jones32bf1862010-03-02 13:46:07 -0600145 if (($last_slash = strrpos($model, '/')) !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000146 {
Derek Jones32bf1862010-03-02 13:46:07 -0600147 // The path is in front of the last slash
148 $path = substr($model, 0, $last_slash + 1);
149
150 // And the model name behind it
151 $model = substr($model, $last_slash + 1);
Derek Allard2067d1a2008-11-13 22:59:24 +0000152 }
Barry Mienydd671972010-10-04 16:33:58 +0200153
Derek Allard2067d1a2008-11-13 22:59:24 +0000154 if ($name == '')
155 {
156 $name = $model;
157 }
Barry Mienydd671972010-10-04 16:33:58 +0200158
Derek Allard2067d1a2008-11-13 22:59:24 +0000159 if (in_array($name, $this->_ci_models, TRUE))
160 {
161 return;
162 }
Barry Mienydd671972010-10-04 16:33:58 +0200163
Derek Allard2067d1a2008-11-13 22:59:24 +0000164 $CI =& get_instance();
165 if (isset($CI->$name))
166 {
167 show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
168 }
Barry Mienydd671972010-10-04 16:33:58 +0200169
Derek Allard2067d1a2008-11-13 22:59:24 +0000170 $model = strtolower($model);
Derek Allard2067d1a2008-11-13 22:59:24 +0000171
Derek Jones32bf1862010-03-02 13:46:07 -0600172 foreach ($this->_ci_model_paths as $mod_path)
173 {
174 if ( ! file_exists($mod_path.'models/'.$path.$model.EXT))
175 {
176 continue;
177 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000178
Derek Jones32bf1862010-03-02 13:46:07 -0600179 if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
180 {
181 if ($db_conn === TRUE)
Pascal Kriete287781e2010-11-10 15:43:49 -0500182 {
Derek Jones32bf1862010-03-02 13:46:07 -0600183 $db_conn = '';
Pascal Kriete287781e2010-11-10 15:43:49 -0500184 }
Derek Jones32bf1862010-03-02 13:46:07 -0600185
186 $CI->load->database($db_conn, FALSE, TRUE);
187 }
188
Greg Akerbce13482010-10-11 15:37:16 -0500189 if ( ! class_exists('CI_Model'))
Derek Jones32bf1862010-03-02 13:46:07 -0600190 {
191 load_class('Model', 'core');
192 }
193
194 require_once($mod_path.'models/'.$path.$model.EXT);
195
196 $model = ucfirst($model);
197
198 $CI->$name = new $model();
Derek Jones32bf1862010-03-02 13:46:07 -0600199
200 $this->_ci_models[] = $name;
201 return;
202 }
Barry Mienydd671972010-10-04 16:33:58 +0200203
Derek Jones32bf1862010-03-02 13:46:07 -0600204 // couldn't find the model
205 show_error('Unable to locate the model you have specified: '.$model);
Derek Allard2067d1a2008-11-13 22:59:24 +0000206 }
Barry Mienydd671972010-10-04 16:33:58 +0200207
Derek Allard2067d1a2008-11-13 22:59:24 +0000208 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200209
Derek Allard2067d1a2008-11-13 22:59:24 +0000210 /**
211 * Database Loader
212 *
213 * @access public
214 * @param string the DB credentials
215 * @param bool whether to return the DB object
216 * @param bool whether to enable active record (this allows us to override the config setting)
217 * @return object
Barry Mienydd671972010-10-04 16:33:58 +0200218 */
Derek Jonesffca6c22009-12-05 15:31:44 +0000219 function database($params = '', $return = FALSE, $active_record = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000220 {
221 // Grab the super object
222 $CI =& get_instance();
Barry Mienydd671972010-10-04 16:33:58 +0200223
Derek Allard2067d1a2008-11-13 22:59:24 +0000224 // Do we even need to load the database class?
Derek Jones9fb6dd12009-12-05 15:32:48 +0000225 if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
Derek Allard2067d1a2008-11-13 22:59:24 +0000226 {
227 return FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200228 }
229
Derek Allard2067d1a2008-11-13 22:59:24 +0000230 require_once(BASEPATH.'database/DB'.EXT);
231
232 if ($return === TRUE)
233 {
234 return DB($params, $active_record);
235 }
Barry Mienydd671972010-10-04 16:33:58 +0200236
237 // Initialize the db variable. Needed to prevent
Derek Allard2067d1a2008-11-13 22:59:24 +0000238 // reference errors with some configurations
239 $CI->db = '';
Barry Mienydd671972010-10-04 16:33:58 +0200240
Derek Allard2067d1a2008-11-13 22:59:24 +0000241 // Load the DB class
Barry Mienydd671972010-10-04 16:33:58 +0200242 $CI->db =& DB($params, $active_record);
Derek Allard2067d1a2008-11-13 22:59:24 +0000243 }
Barry Mienydd671972010-10-04 16:33:58 +0200244
Derek Allard2067d1a2008-11-13 22:59:24 +0000245 // --------------------------------------------------------------------
246
247 /**
248 * Load the Utilities Class
249 *
250 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200251 * @return string
252 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000253 function dbutil()
254 {
255 if ( ! class_exists('CI_DB'))
256 {
257 $this->database();
258 }
Barry Mienydd671972010-10-04 16:33:58 +0200259
Derek Allard2067d1a2008-11-13 22:59:24 +0000260 $CI =& get_instance();
261
262 // for backwards compatibility, load dbforge so we can extend dbutils off it
263 // this use is deprecated and strongly discouraged
264 $CI->load->dbforge();
Barry Mienydd671972010-10-04 16:33:58 +0200265
Derek Allard2067d1a2008-11-13 22:59:24 +0000266 require_once(BASEPATH.'database/DB_utility'.EXT);
267 require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility'.EXT);
268 $class = 'CI_DB_'.$CI->db->dbdriver.'_utility';
269
Derek Jonesf0a9b332009-07-29 14:19:18 +0000270 $CI->dbutil =& instantiate_class(new $class());
Derek Allard2067d1a2008-11-13 22:59:24 +0000271 }
Barry Mienydd671972010-10-04 16:33:58 +0200272
Derek Allard2067d1a2008-11-13 22:59:24 +0000273 // --------------------------------------------------------------------
274
275 /**
276 * Load the Database Forge Class
277 *
278 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200279 * @return string
280 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000281 function dbforge()
282 {
283 if ( ! class_exists('CI_DB'))
284 {
285 $this->database();
286 }
Barry Mienydd671972010-10-04 16:33:58 +0200287
Derek Allard2067d1a2008-11-13 22:59:24 +0000288 $CI =& get_instance();
Barry Mienydd671972010-10-04 16:33:58 +0200289
Derek Allard2067d1a2008-11-13 22:59:24 +0000290 require_once(BASEPATH.'database/DB_forge'.EXT);
291 require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT);
292 $class = 'CI_DB_'.$CI->db->dbdriver.'_forge';
293
294 $CI->dbforge = new $class();
Derek Allard2067d1a2008-11-13 22:59:24 +0000295 }
Barry Mienydd671972010-10-04 16:33:58 +0200296
Derek Allard2067d1a2008-11-13 22:59:24 +0000297 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200298
Derek Allard2067d1a2008-11-13 22:59:24 +0000299 /**
300 * Load View
301 *
302 * This function is used to load a "view" file. It has three parameters:
303 *
304 * 1. The name of the "view" file to be included.
305 * 2. An associative array of data to be extracted for use in the view.
306 * 3. TRUE/FALSE - whether to return the data or load it. In
307 * some cases it's advantageous to be able to return data so that
308 * a developer can process it in some way.
309 *
310 * @access public
311 * @param string
312 * @param array
313 * @param bool
314 * @return void
315 */
316 function view($view, $vars = array(), $return = FALSE)
317 {
318 return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
319 }
Barry Mienydd671972010-10-04 16:33:58 +0200320
Derek Allard2067d1a2008-11-13 22:59:24 +0000321 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200322
Derek Allard2067d1a2008-11-13 22:59:24 +0000323 /**
324 * Load File
325 *
326 * This is a generic file loader
327 *
328 * @access public
329 * @param string
330 * @param bool
331 * @return string
332 */
333 function file($path, $return = FALSE)
334 {
335 return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return));
336 }
Barry Mienydd671972010-10-04 16:33:58 +0200337
Derek Allard2067d1a2008-11-13 22:59:24 +0000338 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200339
Derek Allard2067d1a2008-11-13 22:59:24 +0000340 /**
341 * Set Variables
342 *
343 * Once variables are set they become available within
344 * the controller class and its "view" files.
345 *
346 * @access public
347 * @param array
348 * @return void
349 */
350 function vars($vars = array(), $val = '')
351 {
352 if ($val != '' AND is_string($vars))
353 {
354 $vars = array($vars => $val);
355 }
Barry Mienydd671972010-10-04 16:33:58 +0200356
Derek Allard2067d1a2008-11-13 22:59:24 +0000357 $vars = $this->_ci_object_to_array($vars);
Barry Mienydd671972010-10-04 16:33:58 +0200358
Derek Allard2067d1a2008-11-13 22:59:24 +0000359 if (is_array($vars) AND count($vars) > 0)
360 {
361 foreach ($vars as $key => $val)
362 {
363 $this->_ci_cached_vars[$key] = $val;
364 }
365 }
366 }
Barry Mienydd671972010-10-04 16:33:58 +0200367
Derek Allard2067d1a2008-11-13 22:59:24 +0000368 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200369
Derek Allard2067d1a2008-11-13 22:59:24 +0000370 /**
371 * Load Helper
372 *
373 * This function loads the specified helper file.
374 *
375 * @access public
376 * @param mixed
377 * @return void
378 */
379 function helper($helpers = array())
Barry Mienydd671972010-10-04 16:33:58 +0200380 {
Derek Jones32bf1862010-03-02 13:46:07 -0600381 foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
Barry Mienydd671972010-10-04 16:33:58 +0200382 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000383 if (isset($this->_ci_helpers[$helper]))
384 {
385 continue;
386 }
Derek Jones32bf1862010-03-02 13:46:07 -0600387
Derek Allard2067d1a2008-11-13 22:59:24 +0000388 $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.EXT;
389
Barry Mienydd671972010-10-04 16:33:58 +0200390 // Is this a helper extension request?
Derek Allard2067d1a2008-11-13 22:59:24 +0000391 if (file_exists($ext_helper))
392 {
393 $base_helper = BASEPATH.'helpers/'.$helper.EXT;
Barry Mienydd671972010-10-04 16:33:58 +0200394
Derek Allard2067d1a2008-11-13 22:59:24 +0000395 if ( ! file_exists($base_helper))
396 {
397 show_error('Unable to load the requested file: helpers/'.$helper.EXT);
398 }
Barry Mienydd671972010-10-04 16:33:58 +0200399
Derek Allard2067d1a2008-11-13 22:59:24 +0000400 include_once($ext_helper);
401 include_once($base_helper);
Barry Mienydd671972010-10-04 16:33:58 +0200402
Derek Jones32bf1862010-03-02 13:46:07 -0600403 $this->_ci_helpers[$helper] = TRUE;
404 log_message('debug', 'Helper loaded: '.$helper);
405 continue;
Derek Allard2067d1a2008-11-13 22:59:24 +0000406 }
Barry Mienydd671972010-10-04 16:33:58 +0200407
Derek Jones32bf1862010-03-02 13:46:07 -0600408 // Try to load the helper
409 foreach ($this->_ci_helper_paths as $path)
410 {
411 if (file_exists($path.'helpers/'.$helper.EXT))
Barry Mienydd671972010-10-04 16:33:58 +0200412 {
Derek Jones32bf1862010-03-02 13:46:07 -0600413 include_once($path.'helpers/'.$helper.EXT);
414
415 $this->_ci_helpers[$helper] = TRUE;
Barry Mienydd671972010-10-04 16:33:58 +0200416 log_message('debug', 'Helper loaded: '.$helper);
Derek Jones32bf1862010-03-02 13:46:07 -0600417 break;
Derek Allard2067d1a2008-11-13 22:59:24 +0000418 }
419 }
420
Derek Jones32bf1862010-03-02 13:46:07 -0600421 // unable to load the helper
422 if ( ! isset($this->_ci_helpers[$helper]))
423 {
Barry Mienydd671972010-10-04 16:33:58 +0200424 show_error('Unable to load the requested file: helpers/'.$helper.EXT);
Derek Jones32bf1862010-03-02 13:46:07 -0600425 }
Barry Mienydd671972010-10-04 16:33:58 +0200426 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000427 }
Barry Mienydd671972010-10-04 16:33:58 +0200428
Derek Allard2067d1a2008-11-13 22:59:24 +0000429 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200430
Derek Allard2067d1a2008-11-13 22:59:24 +0000431 /**
432 * Load Helpers
433 *
434 * This is simply an alias to the above function in case the
435 * user has written the plural form of this function.
436 *
437 * @access public
438 * @param array
439 * @return void
440 */
441 function helpers($helpers = array())
442 {
443 $this->helper($helpers);
444 }
Barry Mienydd671972010-10-04 16:33:58 +0200445
Derek Allard2067d1a2008-11-13 22:59:24 +0000446 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200447
Derek Allard2067d1a2008-11-13 22:59:24 +0000448 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000449 * Loads a language file
450 *
451 * @access public
452 * @param array
453 * @param string
454 * @return void
455 */
456 function language($file = array(), $lang = '')
457 {
458 $CI =& get_instance();
459
460 if ( ! is_array($file))
461 {
462 $file = array($file);
463 }
464
465 foreach ($file as $langfile)
Barry Mienydd671972010-10-04 16:33:58 +0200466 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000467 $CI->lang->load($langfile, $lang);
468 }
469 }
Barry Mienydd671972010-10-04 16:33:58 +0200470
Derek Allard2067d1a2008-11-13 22:59:24 +0000471 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200472
Derek Allard2067d1a2008-11-13 22:59:24 +0000473 /**
474 * Loads a config file
475 *
476 * @access public
477 * @param string
478 * @return void
479 */
480 function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
Barry Mienydd671972010-10-04 16:33:58 +0200481 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000482 $CI =& get_instance();
483 $CI->config->load($file, $use_sections, $fail_gracefully);
484 }
485
486 // --------------------------------------------------------------------
Derek Jones32bf1862010-03-02 13:46:07 -0600487
Derek Allard2067d1a2008-11-13 22:59:24 +0000488 /**
Derek Jones8dca0412010-03-05 13:01:44 -0600489 * Driver
490 *
491 * Loads a driver library
492 *
493 * @param string the name of the class
494 * @param mixed the optional parameters
495 * @param string an optional object name
496 * @return void
497 */
498 function driver($library = '', $params = NULL, $object_name = NULL)
499 {
500 if ( ! class_exists('CI_Driver_Library'))
501 {
502 // we aren't instantiating an object here, that'll be done by the Library itself
Derek Jonesd5e0cb52010-03-09 20:20:46 -0600503 require BASEPATH.'libraries/Driver'.EXT;
504 }
Barry Mienydd671972010-10-04 16:33:58 +0200505
Derek Jonesd5e0cb52010-03-09 20:20:46 -0600506 // We can save the loader some time since Drivers will *always* be in a subfolder,
507 // and typically identically named to the library
508 if ( ! strpos($library, '/'))
509 {
Greg Akerd25e66a2010-03-28 01:07:09 -0500510 $library = ucfirst($library).'/'.$library;
Derek Jones8dca0412010-03-05 13:01:44 -0600511 }
Barry Mienydd671972010-10-04 16:33:58 +0200512
Derek Jones8dca0412010-03-05 13:01:44 -0600513 return $this->library($library, $params, $object_name);
514 }
515
516 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200517
Derek Jones8dca0412010-03-05 13:01:44 -0600518 /**
Derek Jones32bf1862010-03-02 13:46:07 -0600519 * Add Package Path
Derek Allard2067d1a2008-11-13 22:59:24 +0000520 *
Derek Jones32bf1862010-03-02 13:46:07 -0600521 * Prepends a parent path to the library, model, helper, and config path arrays
Derek Allard2067d1a2008-11-13 22:59:24 +0000522 *
523 * @access public
524 * @param string
525 * @return void
Derek Jones32bf1862010-03-02 13:46:07 -0600526 */
527 function add_package_path($path)
528 {
Pascal Kriete6b6c2742010-11-09 13:12:22 -0500529 $path = rtrim($path, '/').'/';
530
Derek Jones32bf1862010-03-02 13:46:07 -0600531 array_unshift($this->_ci_library_paths, $path);
532 array_unshift($this->_ci_model_paths, $path);
533 array_unshift($this->_ci_helper_paths, $path);
Barry Mienydd671972010-10-04 16:33:58 +0200534
Derek Jones32bf1862010-03-02 13:46:07 -0600535 // Add config file path
536 $config =& $this->_ci_get_component('config');
537 array_unshift($config->_config_paths, $path);
Derek Allard2067d1a2008-11-13 22:59:24 +0000538 }
539
540 // --------------------------------------------------------------------
Derek Jones32bf1862010-03-02 13:46:07 -0600541
542 /**
543 * Remove Package Path
544 *
545 * Remove a path from the library, model, and helper path arrays if it exists
546 * If no path is provided, the most recently added path is removed.
547 *
548 * @access public
549 * @param type
550 * @return type
551 */
552 function remove_package_path($path = '', $remove_config_path = TRUE)
553 {
554 $config =& $this->_ci_get_component('config');
Barry Mienydd671972010-10-04 16:33:58 +0200555
Derek Jones32bf1862010-03-02 13:46:07 -0600556 if ($path == '')
557 {
558 $void = array_shift($this->_ci_library_paths);
559 $void = array_shift($this->_ci_model_paths);
560 $void = array_shift($this->_ci_helper_paths);
561 $void = array_shift($config->_config_paths);
562 }
563 else
564 {
Pascal Kriete6b6c2742010-11-09 13:12:22 -0500565 $path = rtrim($path, '/').'/';
566
Derek Jones32bf1862010-03-02 13:46:07 -0600567 foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var)
568 {
569 if (($key = array_search($path, $this->{$var})) !== FALSE)
570 {
571 unset($this->{$var}[$key]);
572 }
573 }
Barry Mienydd671972010-10-04 16:33:58 +0200574
Derek Jones32bf1862010-03-02 13:46:07 -0600575 if (($key = array_search($path, $config->_config_paths)) !== FALSE)
576 {
577 unset($config->_config_paths[$key]);
578 }
579 }
Barry Mienydd671972010-10-04 16:33:58 +0200580
Derek Jones32bf1862010-03-02 13:46:07 -0600581 // make sure the application default paths are still in the array
582 $this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH)));
583 $this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH)));
584 $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH)));
585 $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH)));
586 }
587
588 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200589
Derek Allard2067d1a2008-11-13 22:59:24 +0000590 /**
591 * Loader
592 *
593 * This function is used to load views and files.
594 * Variables are prefixed with _ci_ to avoid symbol collision with
595 * variables made available to view files
596 *
597 * @access private
598 * @param array
599 * @return void
600 */
601 function _ci_load($_ci_data)
602 {
603 // Set the default data variables
604 foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
605 {
606 $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
607 }
608
609 // Set the path to the requested file
610 if ($_ci_path == '')
611 {
612 $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
613 $_ci_file = ($_ci_ext == '') ? $_ci_view.EXT : $_ci_view;
614 $_ci_path = $this->_ci_view_path.$_ci_file;
615 }
616 else
617 {
618 $_ci_x = explode('/', $_ci_path);
619 $_ci_file = end($_ci_x);
620 }
Barry Mienydd671972010-10-04 16:33:58 +0200621
Derek Allard2067d1a2008-11-13 22:59:24 +0000622 if ( ! file_exists($_ci_path))
623 {
624 show_error('Unable to load the requested file: '.$_ci_file);
625 }
Barry Mienydd671972010-10-04 16:33:58 +0200626
Derek Allard2067d1a2008-11-13 22:59:24 +0000627 // This allows anything loaded using $this->load (views, files, etc.)
628 // to become accessible from within the Controller and Model functions.
Barry Mienydd671972010-10-04 16:33:58 +0200629
Pascal Kriete89ace432010-11-10 15:49:10 -0500630 $_ci_CI =& get_instance();
631 foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
Derek Allard2067d1a2008-11-13 22:59:24 +0000632 {
Pascal Kriete89ace432010-11-10 15:49:10 -0500633 if ( ! isset($this->$_ci_key))
Derek Allard2067d1a2008-11-13 22:59:24 +0000634 {
Pascal Kriete89ace432010-11-10 15:49:10 -0500635 $this->$_ci_key =& $_ci_CI->$_ci_key;
Derek Allard2067d1a2008-11-13 22:59:24 +0000636 }
637 }
638
639 /*
640 * Extract and cache variables
641 *
642 * You can either set variables using the dedicated $this->load_vars()
643 * function or via the second parameter of this function. We'll merge
644 * the two types and cache them so that views that are embedded within
645 * other views can have access to these variables.
Barry Mienydd671972010-10-04 16:33:58 +0200646 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000647 if (is_array($_ci_vars))
648 {
649 $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
650 }
651 extract($this->_ci_cached_vars);
Barry Mienydd671972010-10-04 16:33:58 +0200652
Derek Allard2067d1a2008-11-13 22:59:24 +0000653 /*
654 * Buffer the output
655 *
656 * We buffer the output for two reasons:
657 * 1. Speed. You get a significant speed boost.
658 * 2. So that the final rendered template can be
659 * post-processed by the output class. Why do we
660 * need post processing? For one thing, in order to
661 * show the elapsed page load time. Unless we
662 * can intercept the content right before it's sent to
663 * the browser and then stop the timer it won't be accurate.
664 */
665 ob_start();
Barry Mienydd671972010-10-04 16:33:58 +0200666
Derek Allard2067d1a2008-11-13 22:59:24 +0000667 // If the PHP installation does not support short tags we'll
668 // do a little string replacement, changing the short tags
669 // to standard PHP echo statements.
Barry Mienydd671972010-10-04 16:33:58 +0200670
Derek Allard2067d1a2008-11-13 22:59:24 +0000671 if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
672 {
673 echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
674 }
675 else
676 {
677 include($_ci_path); // include() vs include_once() allows for multiple views with the same name
678 }
Barry Mienydd671972010-10-04 16:33:58 +0200679
Derek Allard2067d1a2008-11-13 22:59:24 +0000680 log_message('debug', 'File loaded: '.$_ci_path);
Barry Mienydd671972010-10-04 16:33:58 +0200681
Derek Allard2067d1a2008-11-13 22:59:24 +0000682 // Return the file data if requested
683 if ($_ci_return === TRUE)
Barry Mienydd671972010-10-04 16:33:58 +0200684 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000685 $buffer = ob_get_contents();
686 @ob_end_clean();
687 return $buffer;
688 }
689
690 /*
691 * Flush the buffer... or buff the flusher?
692 *
693 * In order to permit views to be nested within
694 * other views, we need to flush the content back out whenever
695 * we are beyond the first level of output buffering so that
696 * it can be seen and included properly by the first included
697 * template and any subsequent ones. Oy!
698 *
Barry Mienydd671972010-10-04 16:33:58 +0200699 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000700 if (ob_get_level() > $this->_ci_ob_level + 1)
701 {
702 ob_end_flush();
703 }
704 else
705 {
706 // PHP 4 requires that we use a global
707 global $OUT;
708 $OUT->append_output(ob_get_contents());
709 @ob_end_clean();
710 }
711 }
712
713 // --------------------------------------------------------------------
714
715 /**
716 * Load class
717 *
718 * This function loads the requested class.
719 *
720 * @access private
Barry Mienydd671972010-10-04 16:33:58 +0200721 * @param string the item that is being loaded
Derek Allard2067d1a2008-11-13 22:59:24 +0000722 * @param mixed any additional parameters
723 * @param string an optional object name
Barry Mienydd671972010-10-04 16:33:58 +0200724 * @return void
Derek Allard2067d1a2008-11-13 22:59:24 +0000725 */
726 function _ci_load_class($class, $params = NULL, $object_name = NULL)
Barry Mienydd671972010-10-04 16:33:58 +0200727 {
728 // Get the class name, and while we're at it trim any slashes.
729 // The directory path can be included as part of the class name,
Derek Allard2067d1a2008-11-13 22:59:24 +0000730 // but we don't want a leading slash
731 $class = str_replace(EXT, '', trim($class, '/'));
Barry Mienydd671972010-10-04 16:33:58 +0200732
Derek Allard2067d1a2008-11-13 22:59:24 +0000733 // Was the path included with the class name?
734 // We look for a slash to determine this
735 $subdir = '';
Derek Jones32bf1862010-03-02 13:46:07 -0600736 if (($last_slash = strrpos($class, '/')) !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000737 {
Derek Jones32bf1862010-03-02 13:46:07 -0600738 // Extract the path
739 $subdir = substr($class, 0, $last_slash + 1);
Barry Mienydd671972010-10-04 16:33:58 +0200740
Derek Jones32bf1862010-03-02 13:46:07 -0600741 // Get the filename from the path
742 $class = substr($class, $last_slash + 1);
Derek Allard2067d1a2008-11-13 22:59:24 +0000743 }
744
745 // We'll test for both lowercase and capitalized versions of the file name
746 foreach (array(ucfirst($class), strtolower($class)) as $class)
747 {
748 $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT;
749
Barry Mienydd671972010-10-04 16:33:58 +0200750 // Is this a class extension request?
Derek Allard2067d1a2008-11-13 22:59:24 +0000751 if (file_exists($subclass))
752 {
753 $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT;
Barry Mienydd671972010-10-04 16:33:58 +0200754
Derek Allard2067d1a2008-11-13 22:59:24 +0000755 if ( ! file_exists($baseclass))
756 {
757 log_message('error', "Unable to load the requested class: ".$class);
758 show_error("Unable to load the requested class: ".$class);
759 }
760
761 // Safety: Was the class already loaded by a previous call?
762 if (in_array($subclass, $this->_ci_loaded_files))
763 {
764 // Before we deem this to be a duplicate request, let's see
765 // if a custom object name is being supplied. If so, we'll
766 // return a new instance of the object
767 if ( ! is_null($object_name))
768 {
769 $CI =& get_instance();
770 if ( ! isset($CI->$object_name))
771 {
Barry Mienydd671972010-10-04 16:33:58 +0200772 return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
Derek Allard2067d1a2008-11-13 22:59:24 +0000773 }
774 }
Barry Mienydd671972010-10-04 16:33:58 +0200775
Derek Allard2067d1a2008-11-13 22:59:24 +0000776 $is_duplicate = TRUE;
777 log_message('debug', $class." class already loaded. Second attempt ignored.");
778 return;
779 }
Barry Mienydd671972010-10-04 16:33:58 +0200780
781 include_once($baseclass);
Derek Allard2067d1a2008-11-13 22:59:24 +0000782 include_once($subclass);
783 $this->_ci_loaded_files[] = $subclass;
Barry Mienydd671972010-10-04 16:33:58 +0200784
785 return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
Derek Allard2067d1a2008-11-13 22:59:24 +0000786 }
Barry Mienydd671972010-10-04 16:33:58 +0200787
Derek Allard2067d1a2008-11-13 22:59:24 +0000788 // Lets search for the requested library file and load it.
Derek Jones32bf1862010-03-02 13:46:07 -0600789 $is_duplicate = FALSE;
790 foreach ($this->_ci_library_paths as $path)
Derek Allard2067d1a2008-11-13 22:59:24 +0000791 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000792 $filepath = $path.'libraries/'.$subdir.$class.EXT;
Derek Jones32bf1862010-03-02 13:46:07 -0600793
Derek Allard2067d1a2008-11-13 22:59:24 +0000794 // Does the file exist? No? Bummer...
795 if ( ! file_exists($filepath))
796 {
797 continue;
798 }
Barry Mienydd671972010-10-04 16:33:58 +0200799
Derek Allard2067d1a2008-11-13 22:59:24 +0000800 // Safety: Was the class already loaded by a previous call?
801 if (in_array($filepath, $this->_ci_loaded_files))
802 {
803 // Before we deem this to be a duplicate request, let's see
804 // if a custom object name is being supplied. If so, we'll
805 // return a new instance of the object
806 if ( ! is_null($object_name))
807 {
808 $CI =& get_instance();
809 if ( ! isset($CI->$object_name))
810 {
811 return $this->_ci_init_class($class, '', $params, $object_name);
812 }
813 }
Barry Mienydd671972010-10-04 16:33:58 +0200814
Derek Allard2067d1a2008-11-13 22:59:24 +0000815 $is_duplicate = TRUE;
816 log_message('debug', $class." class already loaded. Second attempt ignored.");
817 return;
818 }
Barry Mienydd671972010-10-04 16:33:58 +0200819
Derek Allard2067d1a2008-11-13 22:59:24 +0000820 include_once($filepath);
821 $this->_ci_loaded_files[] = $filepath;
Barry Mienydd671972010-10-04 16:33:58 +0200822 return $this->_ci_init_class($class, '', $params, $object_name);
Derek Allard2067d1a2008-11-13 22:59:24 +0000823 }
Derek Jones32bf1862010-03-02 13:46:07 -0600824
Derek Allard2067d1a2008-11-13 22:59:24 +0000825 } // END FOREACH
826
827 // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
828 if ($subdir == '')
829 {
830 $path = strtolower($class).'/'.$class;
831 return $this->_ci_load_class($path, $params);
832 }
Barry Mienydd671972010-10-04 16:33:58 +0200833
Derek Allard2067d1a2008-11-13 22:59:24 +0000834 // If we got this far we were unable to find the requested class.
835 // We do not issue errors if the load call failed due to a duplicate request
836 if ($is_duplicate == FALSE)
837 {
838 log_message('error', "Unable to load the requested class: ".$class);
839 show_error("Unable to load the requested class: ".$class);
840 }
841 }
Barry Mienydd671972010-10-04 16:33:58 +0200842
Derek Allard2067d1a2008-11-13 22:59:24 +0000843 // --------------------------------------------------------------------
844
845 /**
846 * Instantiates a class
847 *
848 * @access private
849 * @param string
850 * @param string
851 * @param string an optional object name
852 * @return null
853 */
854 function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
Barry Mienydd671972010-10-04 16:33:58 +0200855 {
Derek Jones32bf1862010-03-02 13:46:07 -0600856 // Is there an associated config file for this class? Note: these should always be lowercase
Derek Allard2067d1a2008-11-13 22:59:24 +0000857 if ($config === NULL)
858 {
859 // We test for both uppercase and lowercase, for servers that
860 // are case-sensitive with regard to file names
861 if (file_exists(APPPATH.'config/'.strtolower($class).EXT))
862 {
863 include_once(APPPATH.'config/'.strtolower($class).EXT);
Barry Mienydd671972010-10-04 16:33:58 +0200864 }
Derek Jonesc8dddd92009-07-10 18:58:03 +0000865 elseif (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT))
Derek Allard2067d1a2008-11-13 22:59:24 +0000866 {
Derek Jonesc8dddd92009-07-10 18:58:03 +0000867 include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT);
Derek Allard2067d1a2008-11-13 22:59:24 +0000868 }
869 }
Barry Mienydd671972010-10-04 16:33:58 +0200870
Derek Allard2067d1a2008-11-13 22:59:24 +0000871 if ($prefix == '')
Barry Mienydd671972010-10-04 16:33:58 +0200872 {
873 if (class_exists('CI_'.$class))
Derek Allard2067d1a2008-11-13 22:59:24 +0000874 {
875 $name = 'CI_'.$class;
876 }
Barry Mienydd671972010-10-04 16:33:58 +0200877 elseif (class_exists(config_item('subclass_prefix').$class))
Derek Allard2067d1a2008-11-13 22:59:24 +0000878 {
879 $name = config_item('subclass_prefix').$class;
880 }
881 else
882 {
883 $name = $class;
884 }
885 }
886 else
887 {
888 $name = $prefix.$class;
889 }
Barry Mienydd671972010-10-04 16:33:58 +0200890
Derek Allard2067d1a2008-11-13 22:59:24 +0000891 // Is the class name valid?
892 if ( ! class_exists($name))
893 {
894 log_message('error', "Non-existent class: ".$name);
895 show_error("Non-existent class: ".$class);
896 }
Barry Mienydd671972010-10-04 16:33:58 +0200897
Derek Allard2067d1a2008-11-13 22:59:24 +0000898 // Set the variable name we will assign the class to
899 // Was a custom class name supplied? If so we'll use it
900 $class = strtolower($class);
Barry Mienydd671972010-10-04 16:33:58 +0200901
Derek Allard2067d1a2008-11-13 22:59:24 +0000902 if (is_null($object_name))
903 {
904 $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
905 }
906 else
907 {
908 $classvar = $object_name;
909 }
910
Barry Mienydd671972010-10-04 16:33:58 +0200911 // Save the class name and object name
Derek Allard2067d1a2008-11-13 22:59:24 +0000912 $this->_ci_classes[$class] = $classvar;
913
Barry Mienydd671972010-10-04 16:33:58 +0200914 // Instantiate the class
Derek Allard2067d1a2008-11-13 22:59:24 +0000915 $CI =& get_instance();
916 if ($config !== NULL)
917 {
918 $CI->$classvar = new $name($config);
919 }
920 else
Barry Mienydd671972010-10-04 16:33:58 +0200921 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000922 $CI->$classvar = new $name;
Barry Mienydd671972010-10-04 16:33:58 +0200923 }
924 }
925
Derek Allard2067d1a2008-11-13 22:59:24 +0000926 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200927
Derek Allard2067d1a2008-11-13 22:59:24 +0000928 /**
929 * Autoloader
930 *
931 * The config/autoload.php file contains an array that permits sub-systems,
Derek Jonesc6da5032010-03-09 20:44:27 -0600932 * libraries, and helpers to be loaded automatically.
Derek Allard2067d1a2008-11-13 22:59:24 +0000933 *
934 * @access private
935 * @param array
936 * @return void
937 */
938 function _ci_autoloader()
Barry Mienydd671972010-10-04 16:33:58 +0200939 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000940 include_once(APPPATH.'config/autoload'.EXT);
Barry Mienydd671972010-10-04 16:33:58 +0200941
Derek Allard2067d1a2008-11-13 22:59:24 +0000942 if ( ! isset($autoload))
943 {
944 return FALSE;
945 }
Barry Mienydd671972010-10-04 16:33:58 +0200946
Derek Allard2067d1a2008-11-13 22:59:24 +0000947 // Load any custom config file
948 if (count($autoload['config']) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200949 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000950 $CI =& get_instance();
951 foreach ($autoload['config'] as $key => $val)
952 {
953 $CI->config->load($val);
954 }
Barry Mienydd671972010-10-04 16:33:58 +0200955 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000956
Derek Jonesc6da5032010-03-09 20:44:27 -0600957 // Autoload helpers and languages
958 foreach (array('helper', 'language') as $type)
Barry Mienydd671972010-10-04 16:33:58 +0200959 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000960 if (isset($autoload[$type]) AND count($autoload[$type]) > 0)
961 {
962 $this->$type($autoload[$type]);
Barry Mienydd671972010-10-04 16:33:58 +0200963 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000964 }
965
966 // A little tweak to remain backward compatible
967 // The $autoload['core'] item was deprecated
Derek Jones32bf1862010-03-02 13:46:07 -0600968 if ( ! isset($autoload['libraries']) AND isset($autoload['core']))
Derek Allard2067d1a2008-11-13 22:59:24 +0000969 {
970 $autoload['libraries'] = $autoload['core'];
971 }
Barry Mienydd671972010-10-04 16:33:58 +0200972
Derek Allard2067d1a2008-11-13 22:59:24 +0000973 // Load libraries
974 if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0)
975 {
976 // Load the database driver.
977 if (in_array('database', $autoload['libraries']))
978 {
979 $this->database();
980 $autoload['libraries'] = array_diff($autoload['libraries'], array('database'));
981 }
Barry Mienydd671972010-10-04 16:33:58 +0200982
Derek Allard2067d1a2008-11-13 22:59:24 +0000983 // Load all other libraries
984 foreach ($autoload['libraries'] as $item)
985 {
986 $this->library($item);
987 }
Barry Mienydd671972010-10-04 16:33:58 +0200988 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000989
990 // Autoload models
991 if (isset($autoload['model']))
992 {
993 $this->model($autoload['model']);
994 }
Barry Mienydd671972010-10-04 16:33:58 +0200995 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000996
997 // --------------------------------------------------------------------
998
999 /**
1000 * Object to Array
1001 *
1002 * Takes an object as input and converts the class variables to array key/vals
1003 *
1004 * @access private
1005 * @param object
1006 * @return array
1007 */
1008 function _ci_object_to_array($object)
1009 {
1010 return (is_object($object)) ? get_object_vars($object) : $object;
1011 }
1012
1013 // --------------------------------------------------------------------
1014
1015 /**
Derek Jones32bf1862010-03-02 13:46:07 -06001016 * Get a reference to a specific library or model
1017 *
1018 * @access private
1019 * @return bool
1020 */
1021 function &_ci_get_component($component)
1022 {
Pascal Kriete89ace432010-11-10 15:49:10 -05001023 $CI =& get_instance();
1024 return $CI->$component;
Derek Jones32bf1862010-03-02 13:46:07 -06001025 }
1026
1027 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +02001028
Derek Jones32bf1862010-03-02 13:46:07 -06001029 /**
1030 * Prep filename
1031 *
1032 * This function preps the name of various items to make loading them more reliable.
1033 *
1034 * @access private
1035 * @param mixed
1036 * @return array
1037 */
1038 function _ci_prep_filename($filename, $extension)
1039 {
1040 if ( ! is_array($filename))
Barry Mienydd671972010-10-04 16:33:58 +02001041 {
1042 return array(strtolower(str_replace(EXT, '', str_replace($extension, '', $filename)).$extension));
Derek Jones32bf1862010-03-02 13:46:07 -06001043 }
1044 else
1045 {
1046 foreach ($filename as $key => $val)
1047 {
Barry Mienydd671972010-10-04 16:33:58 +02001048 $filename[$key] = strtolower(str_replace(EXT, '', str_replace($extension, '', $val)).$extension);
Derek Jones32bf1862010-03-02 13:46:07 -06001049 }
Barry Mienydd671972010-10-04 16:33:58 +02001050
Derek Jones32bf1862010-03-02 13:46:07 -06001051 return $filename;
1052 }
1053 }
Barry Mienydd671972010-10-04 16:33:58 +02001054
Derek Allard2067d1a2008-11-13 22:59:24 +00001055
1056}
1057
1058/* End of file Loader.php */
Derek Jonesc68dfbf2010-03-02 12:59:23 -06001059/* Location: ./system/core/Loader.php */