Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Checking existence of backslash and recursivity function #23

Open
wants to merge 1 commit into from

1 participant

@willmendesneto

Checking existence of backslash and recursivity function. Previously the file called functions 'ltrim ()' and 'rtrim ()' PHP, but if there were no backslash an error like 'Warning';

@willmendesneto willmendesneto Checking existence of backslash and recursivity function
Checking existence of backslash and recursivity function. Previously the file called functions 'ltrim ()' and 'rtrim ()' PHP, but if there were no backslash an error like 'Warning';
dea1f10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 7, 2012
  1. @willmendesneto

    Checking existence of backslash and recursivity function

    willmendesneto authored
    Checking existence of backslash and recursivity function. Previously the file called functions 'ltrim ()' and 'rtrim ()' PHP, but if there were no backslash an error like 'Warning';
This page is out of date. Refresh to see the latest.
Showing with 48 additions and 46 deletions.
  1. +48 −46 application/core/MY_Loader.php
View
94 application/core/MY_Loader.php
@@ -93,53 +93,55 @@ function spark($spark, $autoload = array())
{
$this->spark($s);
}
+ }else{
+ //
+ $length = strlen($spark);
+ if( ($length > 0) && (($spark[0] == '/') || ($spark[$length-1] == '/')) )
+ $spark = trim($spark, '/');
+
+ $spark_path = SPARKPATH . $spark . '/';
+ $parts = explode('/', $spark);
+ $spark_slug = strtolower($parts[0]);
+
+ # If we've already loaded this spark, bail
+ if(array_key_exists($spark_slug, $this->_ci_loaded_sparks))
+ {
+ return true;
+ }
+
+ # Check that it exists. CI Doesn't check package existence by itself
+ if(!file_exists($spark_path))
+ {
+ show_error("Cannot find spark path at $spark_path");
+ }
+
+ if(count($parts) == 2)
+ {
+ $this->_ci_loaded_sparks[$spark_slug] = $spark;
+ }
+
+ $this->add_package_path($spark_path);
+
+ foreach($autoload as $type => $read)
+ {
+ if($type == 'library')
+ $this->library($read);
+ elseif($type == 'model')
+ $this->model($read);
+ elseif($type == 'config')
+ $this->config($read);
+ elseif($type == 'helper')
+ $this->helper($read);
+ elseif($type == 'view')
+ $this->view($read);
+ else
+ show_error ("Could not autoload object of type '$type' ($read) for spark $spark");
+ }
+
+ // Looks for a spark's specific autoloader
+ $this->ci_autoloader($spark_path);
}
-
- $spark = ltrim($spark, '/');
- $spark = rtrim($spark, '/');
-
- $spark_path = SPARKPATH . $spark . '/';
- $parts = explode('/', $spark);
- $spark_slug = strtolower($parts[0]);
-
- # If we've already loaded this spark, bail
- if(array_key_exists($spark_slug, $this->_ci_loaded_sparks))
- {
- return true;
- }
-
- # Check that it exists. CI Doesn't check package existence by itself
- if(!file_exists($spark_path))
- {
- show_error("Cannot find spark path at $spark_path");
- }
-
- if(count($parts) == 2)
- {
- $this->_ci_loaded_sparks[$spark_slug] = $spark;
- }
-
- $this->add_package_path($spark_path);
-
- foreach($autoload as $type => $read)
- {
- if($type == 'library')
- $this->library($read);
- elseif($type == 'model')
- $this->model($read);
- elseif($type == 'config')
- $this->config($read);
- elseif($type == 'helper')
- $this->helper($read);
- elseif($type == 'view')
- $this->view($read);
- else
- show_error ("Could not autoload object of type '$type' ($read) for spark $spark");
- }
-
- // Looks for a spark's specific autoloader
- $this->ci_autoloader($spark_path);
-
+
return true;
}
Something went wrong with that request. Please try again.