summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-11-04 06:07:03 +0100
committeradmin <devnull@localhost>2006-11-04 06:07:03 +0100
commitbe013b3270f751e248efcbe82d5ea28e9386ce05 (patch)
tree4d9c9ab467c835be13bd22d46d908217fd71a34e
parentc50747cfe50a4c6b7e8bde81d0f56c3bd26bd29a (diff)
-rw-r--r--system/libraries/Loader.php106
1 files changed, 61 insertions, 45 deletions
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 5db9886b4..41c0a9b94 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -71,12 +71,25 @@ class CI_Loader {
* @param mixed the optional parameters
* @return void
*/
- function library($class, $params = NULL)
+ function library($library = '', $params = NULL)
{
- if ($class == '')
- return;
-
- $this->_ci_load_class($class, $params);
+ if ($library == '')
+ {
+ return FALSE;
+ }
+
+ if (is_array($library))
+ {
+ foreach ($library as $class)
+ {
+ $this->_ci_load_class($class, $params);
+ }
+ }
+ else
+ {
+ $this->_ci_load_class($library, $params);
+ }
+
$this->_ci_assign_to_models();
}
@@ -621,8 +634,7 @@ class CI_Loader {
if ($return === TRUE)
{
$buffer = ob_get_contents();
- ob_end_clean();
-
+ @ob_end_clean();
return $buffer;
}
@@ -645,7 +657,7 @@ class CI_Loader {
// PHP 4 requires that we use a global
global $OUT;
$OUT->set_output(ob_get_contents());
- ob_end_clean();
+ @ob_end_clean();
}
}
@@ -663,49 +675,53 @@ class CI_Loader {
*/
function _ci_load_class($class, $params = NULL)
{
- // Prep the class name
- $class = ucfirst(strtolower(str_replace(EXT, '', $class)));
-
- // Is this a class extension request?
- if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
- {
- if ( ! file_exists(BASEPATH.'libraries/'.$class.EXT))
- {
- log_message('error', "Unable to load the requested class: ".$class);
- show_error("Unable to load the requested class: ".$class);
- }
-
- include(BASEPATH.'libraries/'.ucfirst($class).EXT);
- include(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);
-
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params);
- }
+ // Get the class name
+ $class = str_replace(EXT, '', $class);
- // Lets search for the requested library file and load it.
- $is_duplicate = FALSE;
- for ($i = 1; $i < 3; $i++)
+ // We'll test for both lowercase and capitalized versions of the file name
+ foreach (array(ucfirst($class), strtolower($class)) as $class)
{
- $path = ($i % 2) ? APPPATH : BASEPATH;
- $fp = $path.'libraries/'.$class.EXT;
-
- // Does the file exist? No? Bummer...
- if ( ! file_exists($fp))
+ // Is this a class extension request?
+ if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
{
- continue;
+ if ( ! file_exists(BASEPATH.'libraries/'.ucfirst($class).EXT))
+ {
+ log_message('error', "Unable to load the requested class: ".$class);
+ show_error("Unable to load the requested class: ".$class);
+ }
+
+ include(BASEPATH.'libraries/'.ucfirst($class).EXT);
+ include(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);
+
+ return $this->_ci_init_class($class, config_item('subclass_prefix'), $params);
}
-
- // Safety: Was the class already loaded by a previous call?
- if (in_array($fp, $this->_ci_classes))
+
+ // Lets search for the requested library file and load it.
+ $is_duplicate = FALSE;
+ for ($i = 1; $i < 3; $i++)
{
- $is_duplicate = TRUE;
- continue;
+ $path = ($i % 2) ? APPPATH : BASEPATH;
+ $fp = $path.'libraries/'.$class.EXT;
+
+ // Does the file exist? No? Bummer...
+ if ( ! file_exists($fp))
+ {
+ continue;
+ }
+
+ // Safety: Was the class already loaded by a previous call?
+ if (in_array($fp, $this->_ci_classes))
+ {
+ $is_duplicate = TRUE;
+ continue;
+ }
+
+ include($fp);
+ $this->_ci_classes[] = $fp;
+ return $this->_ci_init_class($class, '', $params);
}
-
- include($fp);
- $this->_ci_classes[] = $fp;
- return $this->_ci_init_class($class, '', $params);
- }
-
+ } // END FOREACH
+
// If we got this far we were unable to find the requested class.
// We do not issue errors if the load call failed due to a duplicate request
if ($is_duplicate == FALSE)