blob: 4b6b19eeadb3b68eafb8e167a97f439601ee2f2b [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 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
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 */
Greg Akera9263282010-11-10 15:26:43 -060053 function __construct()
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
Pascal Kriete58560022010-11-10 16:01:20 -0500270 $CI->dbutil = 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 {
Greg Aker22f1a632010-11-10 15:34:35 -0600706 $_ci_CI->output->append_output(ob_get_contents());
Derek Allard2067d1a2008-11-13 22:59:24 +0000707 @ob_end_clean();
708 }
709 }
710
711 // --------------------------------------------------------------------
712
713 /**
714 * Load class
715 *
716 * This function loads the requested class.
717 *
718 * @access private
Barry Mienydd671972010-10-04 16:33:58 +0200719 * @param string the item that is being loaded
Derek Allard2067d1a2008-11-13 22:59:24 +0000720 * @param mixed any additional parameters
721 * @param string an optional object name
Barry Mienydd671972010-10-04 16:33:58 +0200722 * @return void
Derek Allard2067d1a2008-11-13 22:59:24 +0000723 */
724 function _ci_load_class($class, $params = NULL, $object_name = NULL)
Barry Mienydd671972010-10-04 16:33:58 +0200725 {
726 // Get the class name, and while we're at it trim any slashes.
727 // The directory path can be included as part of the class name,
Derek Allard2067d1a2008-11-13 22:59:24 +0000728 // but we don't want a leading slash
729 $class = str_replace(EXT, '', trim($class, '/'));
Barry Mienydd671972010-10-04 16:33:58 +0200730
Derek Allard2067d1a2008-11-13 22:59:24 +0000731 // Was the path included with the class name?
732 // We look for a slash to determine this
733 $subdir = '';
Derek Jones32bf1862010-03-02 13:46:07 -0600734 if (($last_slash = strrpos($class, '/')) !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000735 {
Derek Jones32bf1862010-03-02 13:46:07 -0600736 // Extract the path
737 $subdir = substr($class, 0, $last_slash + 1);
Barry Mienydd671972010-10-04 16:33:58 +0200738
Derek Jones32bf1862010-03-02 13:46:07 -0600739 // Get the filename from the path
740 $class = substr($class, $last_slash + 1);
Derek Allard2067d1a2008-11-13 22:59:24 +0000741 }
742
743 // We'll test for both lowercase and capitalized versions of the file name
744 foreach (array(ucfirst($class), strtolower($class)) as $class)
745 {
746 $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT;
747
Barry Mienydd671972010-10-04 16:33:58 +0200748 // Is this a class extension request?
Derek Allard2067d1a2008-11-13 22:59:24 +0000749 if (file_exists($subclass))
750 {
751 $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT;
Barry Mienydd671972010-10-04 16:33:58 +0200752
Derek Allard2067d1a2008-11-13 22:59:24 +0000753 if ( ! file_exists($baseclass))
754 {
755 log_message('error', "Unable to load the requested class: ".$class);
756 show_error("Unable to load the requested class: ".$class);
757 }
758
759 // Safety: Was the class already loaded by a previous call?
760 if (in_array($subclass, $this->_ci_loaded_files))
761 {
762 // Before we deem this to be a duplicate request, let's see
763 // if a custom object name is being supplied. If so, we'll
764 // return a new instance of the object
765 if ( ! is_null($object_name))
766 {
767 $CI =& get_instance();
768 if ( ! isset($CI->$object_name))
769 {
Barry Mienydd671972010-10-04 16:33:58 +0200770 return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
Derek Allard2067d1a2008-11-13 22:59:24 +0000771 }
772 }
Barry Mienydd671972010-10-04 16:33:58 +0200773
Derek Allard2067d1a2008-11-13 22:59:24 +0000774 $is_duplicate = TRUE;
775 log_message('debug', $class." class already loaded. Second attempt ignored.");
776 return;
777 }
Barry Mienydd671972010-10-04 16:33:58 +0200778
779 include_once($baseclass);
Derek Allard2067d1a2008-11-13 22:59:24 +0000780 include_once($subclass);
781 $this->_ci_loaded_files[] = $subclass;
Barry Mienydd671972010-10-04 16:33:58 +0200782
783 return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
Derek Allard2067d1a2008-11-13 22:59:24 +0000784 }
Barry Mienydd671972010-10-04 16:33:58 +0200785
Derek Allard2067d1a2008-11-13 22:59:24 +0000786 // Lets search for the requested library file and load it.
Derek Jones32bf1862010-03-02 13:46:07 -0600787 $is_duplicate = FALSE;
788 foreach ($this->_ci_library_paths as $path)
Derek Allard2067d1a2008-11-13 22:59:24 +0000789 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000790 $filepath = $path.'libraries/'.$subdir.$class.EXT;
Derek Jones32bf1862010-03-02 13:46:07 -0600791
Derek Allard2067d1a2008-11-13 22:59:24 +0000792 // Does the file exist? No? Bummer...
793 if ( ! file_exists($filepath))
794 {
795 continue;
796 }
Barry Mienydd671972010-10-04 16:33:58 +0200797
Derek Allard2067d1a2008-11-13 22:59:24 +0000798 // Safety: Was the class already loaded by a previous call?
799 if (in_array($filepath, $this->_ci_loaded_files))
800 {
801 // Before we deem this to be a duplicate request, let's see
802 // if a custom object name is being supplied. If so, we'll
803 // return a new instance of the object
804 if ( ! is_null($object_name))
805 {
806 $CI =& get_instance();
807 if ( ! isset($CI->$object_name))
808 {
809 return $this->_ci_init_class($class, '', $params, $object_name);
810 }
811 }
Barry Mienydd671972010-10-04 16:33:58 +0200812
Derek Allard2067d1a2008-11-13 22:59:24 +0000813 $is_duplicate = TRUE;
814 log_message('debug', $class." class already loaded. Second attempt ignored.");
815 return;
816 }
Barry Mienydd671972010-10-04 16:33:58 +0200817
Derek Allard2067d1a2008-11-13 22:59:24 +0000818 include_once($filepath);
819 $this->_ci_loaded_files[] = $filepath;
Barry Mienydd671972010-10-04 16:33:58 +0200820 return $this->_ci_init_class($class, '', $params, $object_name);
Derek Allard2067d1a2008-11-13 22:59:24 +0000821 }
Derek Jones32bf1862010-03-02 13:46:07 -0600822
Derek Allard2067d1a2008-11-13 22:59:24 +0000823 } // END FOREACH
824
825 // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
826 if ($subdir == '')
827 {
828 $path = strtolower($class).'/'.$class;
829 return $this->_ci_load_class($path, $params);
830 }
Barry Mienydd671972010-10-04 16:33:58 +0200831
Derek Allard2067d1a2008-11-13 22:59:24 +0000832 // If we got this far we were unable to find the requested class.
833 // We do not issue errors if the load call failed due to a duplicate request
834 if ($is_duplicate == FALSE)
835 {
836 log_message('error', "Unable to load the requested class: ".$class);
837 show_error("Unable to load the requested class: ".$class);
838 }
839 }
Barry Mienydd671972010-10-04 16:33:58 +0200840
Derek Allard2067d1a2008-11-13 22:59:24 +0000841 // --------------------------------------------------------------------
842
843 /**
844 * Instantiates a class
845 *
846 * @access private
847 * @param string
848 * @param string
849 * @param string an optional object name
850 * @return null
851 */
852 function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
Barry Mienydd671972010-10-04 16:33:58 +0200853 {
Derek Jones32bf1862010-03-02 13:46:07 -0600854 // Is there an associated config file for this class? Note: these should always be lowercase
Derek Allard2067d1a2008-11-13 22:59:24 +0000855 if ($config === NULL)
856 {
857 // We test for both uppercase and lowercase, for servers that
858 // are case-sensitive with regard to file names
859 if (file_exists(APPPATH.'config/'.strtolower($class).EXT))
860 {
861 include_once(APPPATH.'config/'.strtolower($class).EXT);
Barry Mienydd671972010-10-04 16:33:58 +0200862 }
Derek Jonesc8dddd92009-07-10 18:58:03 +0000863 elseif (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT))
Derek Allard2067d1a2008-11-13 22:59:24 +0000864 {
Derek Jonesc8dddd92009-07-10 18:58:03 +0000865 include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT);
Derek Allard2067d1a2008-11-13 22:59:24 +0000866 }
867 }
Barry Mienydd671972010-10-04 16:33:58 +0200868
Derek Allard2067d1a2008-11-13 22:59:24 +0000869 if ($prefix == '')
Barry Mienydd671972010-10-04 16:33:58 +0200870 {
871 if (class_exists('CI_'.$class))
Derek Allard2067d1a2008-11-13 22:59:24 +0000872 {
873 $name = 'CI_'.$class;
874 }
Barry Mienydd671972010-10-04 16:33:58 +0200875 elseif (class_exists(config_item('subclass_prefix').$class))
Derek Allard2067d1a2008-11-13 22:59:24 +0000876 {
877 $name = config_item('subclass_prefix').$class;
878 }
879 else
880 {
881 $name = $class;
882 }
883 }
884 else
885 {
886 $name = $prefix.$class;
887 }
Barry Mienydd671972010-10-04 16:33:58 +0200888
Derek Allard2067d1a2008-11-13 22:59:24 +0000889 // Is the class name valid?
890 if ( ! class_exists($name))
891 {
892 log_message('error', "Non-existent class: ".$name);
893 show_error("Non-existent class: ".$class);
894 }
Barry Mienydd671972010-10-04 16:33:58 +0200895
Derek Allard2067d1a2008-11-13 22:59:24 +0000896 // Set the variable name we will assign the class to
897 // Was a custom class name supplied? If so we'll use it
898 $class = strtolower($class);
Barry Mienydd671972010-10-04 16:33:58 +0200899
Derek Allard2067d1a2008-11-13 22:59:24 +0000900 if (is_null($object_name))
901 {
902 $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
903 }
904 else
905 {
906 $classvar = $object_name;
907 }
908
Barry Mienydd671972010-10-04 16:33:58 +0200909 // Save the class name and object name
Derek Allard2067d1a2008-11-13 22:59:24 +0000910 $this->_ci_classes[$class] = $classvar;
911
Barry Mienydd671972010-10-04 16:33:58 +0200912 // Instantiate the class
Derek Allard2067d1a2008-11-13 22:59:24 +0000913 $CI =& get_instance();
914 if ($config !== NULL)
915 {
916 $CI->$classvar = new $name($config);
917 }
918 else
Barry Mienydd671972010-10-04 16:33:58 +0200919 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000920 $CI->$classvar = new $name;
Barry Mienydd671972010-10-04 16:33:58 +0200921 }
922 }
923
Derek Allard2067d1a2008-11-13 22:59:24 +0000924 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200925
Derek Allard2067d1a2008-11-13 22:59:24 +0000926 /**
927 * Autoloader
928 *
929 * The config/autoload.php file contains an array that permits sub-systems,
Derek Jonesc6da5032010-03-09 20:44:27 -0600930 * libraries, and helpers to be loaded automatically.
Derek Allard2067d1a2008-11-13 22:59:24 +0000931 *
932 * @access private
933 * @param array
934 * @return void
935 */
936 function _ci_autoloader()
Barry Mienydd671972010-10-04 16:33:58 +0200937 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000938 include_once(APPPATH.'config/autoload'.EXT);
Barry Mienydd671972010-10-04 16:33:58 +0200939
Derek Allard2067d1a2008-11-13 22:59:24 +0000940 if ( ! isset($autoload))
941 {
942 return FALSE;
943 }
Barry Mienydd671972010-10-04 16:33:58 +0200944
Derek Allard2067d1a2008-11-13 22:59:24 +0000945 // Load any custom config file
946 if (count($autoload['config']) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200947 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000948 $CI =& get_instance();
949 foreach ($autoload['config'] as $key => $val)
950 {
951 $CI->config->load($val);
952 }
Barry Mienydd671972010-10-04 16:33:58 +0200953 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000954
Derek Jonesc6da5032010-03-09 20:44:27 -0600955 // Autoload helpers and languages
956 foreach (array('helper', 'language') as $type)
Barry Mienydd671972010-10-04 16:33:58 +0200957 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000958 if (isset($autoload[$type]) AND count($autoload[$type]) > 0)
959 {
960 $this->$type($autoload[$type]);
Barry Mienydd671972010-10-04 16:33:58 +0200961 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000962 }
963
964 // A little tweak to remain backward compatible
965 // The $autoload['core'] item was deprecated
Derek Jones32bf1862010-03-02 13:46:07 -0600966 if ( ! isset($autoload['libraries']) AND isset($autoload['core']))
Derek Allard2067d1a2008-11-13 22:59:24 +0000967 {
968 $autoload['libraries'] = $autoload['core'];
969 }
Barry Mienydd671972010-10-04 16:33:58 +0200970
Derek Allard2067d1a2008-11-13 22:59:24 +0000971 // Load libraries
972 if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0)
973 {
974 // Load the database driver.
975 if (in_array('database', $autoload['libraries']))
976 {
977 $this->database();
978 $autoload['libraries'] = array_diff($autoload['libraries'], array('database'));
979 }
Barry Mienydd671972010-10-04 16:33:58 +0200980
Derek Allard2067d1a2008-11-13 22:59:24 +0000981 // Load all other libraries
982 foreach ($autoload['libraries'] as $item)
983 {
984 $this->library($item);
985 }
Barry Mienydd671972010-10-04 16:33:58 +0200986 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000987
988 // Autoload models
989 if (isset($autoload['model']))
990 {
991 $this->model($autoload['model']);
992 }
Barry Mienydd671972010-10-04 16:33:58 +0200993 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000994
995 // --------------------------------------------------------------------
996
997 /**
998 * Object to Array
999 *
1000 * Takes an object as input and converts the class variables to array key/vals
1001 *
1002 * @access private
1003 * @param object
1004 * @return array
1005 */
1006 function _ci_object_to_array($object)
1007 {
1008 return (is_object($object)) ? get_object_vars($object) : $object;
1009 }
1010
1011 // --------------------------------------------------------------------
1012
1013 /**
Derek Jones32bf1862010-03-02 13:46:07 -06001014 * Get a reference to a specific library or model
1015 *
1016 * @access private
1017 * @return bool
1018 */
1019 function &_ci_get_component($component)
1020 {
Pascal Kriete89ace432010-11-10 15:49:10 -05001021 $CI =& get_instance();
1022 return $CI->$component;
Derek Jones32bf1862010-03-02 13:46:07 -06001023 }
1024
1025 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +02001026
Derek Jones32bf1862010-03-02 13:46:07 -06001027 /**
1028 * Prep filename
1029 *
1030 * This function preps the name of various items to make loading them more reliable.
1031 *
1032 * @access private
1033 * @param mixed
1034 * @return array
1035 */
1036 function _ci_prep_filename($filename, $extension)
1037 {
1038 if ( ! is_array($filename))
Barry Mienydd671972010-10-04 16:33:58 +02001039 {
1040 return array(strtolower(str_replace(EXT, '', str_replace($extension, '', $filename)).$extension));
Derek Jones32bf1862010-03-02 13:46:07 -06001041 }
1042 else
1043 {
1044 foreach ($filename as $key => $val)
1045 {
Barry Mienydd671972010-10-04 16:33:58 +02001046 $filename[$key] = strtolower(str_replace(EXT, '', str_replace($extension, '', $val)).$extension);
Derek Jones32bf1862010-03-02 13:46:07 -06001047 }
Barry Mienydd671972010-10-04 16:33:58 +02001048
Derek Jones32bf1862010-03-02 13:46:07 -06001049 return $filename;
1050 }
1051 }
Barry Mienydd671972010-10-04 16:33:58 +02001052
Derek Allard2067d1a2008-11-13 22:59:24 +00001053
1054}
1055
1056/* End of file Loader.php */
Derek Jonesc68dfbf2010-03-02 12:59:23 -06001057/* Location: ./system/core/Loader.php */