summaryrefslogtreecommitdiffstats
path: root/system/core/Loader.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-03-09 11:08:36 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-03-09 11:08:36 +0100
commit93ca71552d9a3e28eeaa00dd10755d20b2cbf32e (patch)
tree660233f2ec631e5730731491d2fd244fe15f7df8 /system/core/Loader.php
parenta9924b8352aa18869677bea0182c45e2a7e2ce37 (diff)
parent2f8b27efeb0a39c24eddf89cf31ea0fd113a6b71 (diff)
Merged recent Core changes and fixed conflict.
Diffstat (limited to 'system/core/Loader.php')
-rw-r--r--system/core/Loader.php70
1 files changed, 55 insertions, 15 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 8b1986b9d..7003318ee 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -79,14 +79,14 @@ class CI_Loader {
{
if (is_array($library))
{
- foreach($library as $read)
+ foreach ($library as $read)
{
- $this->library($read);
+ $this->library($read);
}
-
+
return;
}
-
+
if ($library == '' OR isset($this->_base_classes[$library]))
{
return FALSE;
@@ -127,7 +127,7 @@ class CI_Loader {
{
if (is_array($model))
{
- foreach($model as $babe)
+ foreach ($model as $babe)
{
$this->model($babe);
}
@@ -527,7 +527,7 @@ class CI_Loader {
function add_package_path($path)
{
$path = rtrim($path, '/').'/';
-
+
array_unshift($this->_ci_library_paths, $path);
array_unshift($this->_ci_model_paths, $path);
array_unshift($this->_ci_helper_paths, $path);
@@ -540,6 +540,22 @@ class CI_Loader {
// --------------------------------------------------------------------
/**
+ * Get Package Paths
+ *
+ * Return a list of all package paths, by default it will ignore BASEPATH.
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function get_package_paths($include_base = FALSE)
+ {
+ return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Remove Package Path
*
* Remove a path from the library, model, and helper path arrays if it exists
@@ -563,7 +579,7 @@ class CI_Loader {
else
{
$path = rtrim($path, '/').'/';
-
+
foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var)
{
if (($key = array_search($path, $this->{$var})) !== FALSE)
@@ -854,15 +870,39 @@ class CI_Loader {
// Is there an associated config file for this class? Note: these should always be lowercase
if ($config === NULL)
{
- // We test for both uppercase and lowercase, for servers that
- // are case-sensitive with regard to file names
- if (file_exists(APPPATH.'config/'.strtolower($class).EXT))
- {
- include_once(APPPATH.'config/'.strtolower($class).EXT);
- }
- elseif (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT))
+ // Fetch the config paths containing any package paths
+ $config_component = $this->_ci_get_component('config');
+
+ if (is_array($config_component->_config_paths))
{
- include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT);
+ // Break on the first found file, thus package files
+ // are not overridden by default paths
+ foreach ($config_component->_config_paths as $path)
+ {
+ // We test for both uppercase and lowercase, for servers that
+ // are case-sensitive with regard to file names. Check for environment
+ // first, global next
+ if (file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
+ {
+ include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT);
+ break;
+ }
+ elseif (file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
+ {
+ include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT);
+ break;
+ }
+ elseif (file_exists($path .'config/'.strtolower($class).EXT))
+ {
+ include_once($path .'config/'.strtolower($class).EXT);
+ break;
+ }
+ elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT))
+ {
+ include_once($path .'config/'.ucfirst(strtolower($class)).EXT);
+ break;
+ }
+ }
}
}