Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking existence of backslash and recursivity function #23

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 48 additions & 46 deletions application/core/MY_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down