یه کلاس هست که یه مدت هست که دارم روش کار می کنم ولی هنوز نتونستم تجذیه تحلیلش کنم اگه یکی پیدا بشه و توابع این کلاس رو برام تجذیه و تحلیل کنه و بگه که این توابع چه کار می کنند ممنون میشم.
class jloader
{
/**
* loads a class from specified directories.
*
* @param string $name the class name to look for ( dot notation ).
* @param string $base search this directory for the class.
* @param string $key string used as a prefix to denote the full path of the file ( dot notation ).
* @return void
* @since 1.5
*/
function import( $filepath, $base = null, $key = 'libraries.' )
{
static $paths;
if (!isset($paths)) {
$paths = array();
}
$keypath = $key ? $key . $filepath : $filepath;
if (!isset($paths[$keypath]))
{
if ( ! $base ) {
$base = dirname( __file__ );
}
$parts = explode( '.', $filepath );
$classname = array_pop( $parts );
switch($classname)
{
case 'helper' :
$classname = ucfirst(array_pop( $parts )).ucfirst($classname);
break;
default :
$classname = ucfirst($classname);
break;
}
$path = str_replace( '.', ds, $filepath );
if (strpos($filepath, 'joomla') === 0)
{
/*
* if we are loading a joomla class prepend the classname with a
* capital j.
*/
$classname = 'j'.$classname;
$classes = jloader::register($classname, $base.ds.$path.'.php');
$rs = isset($classes[strtolower($classname)]);
}
else
{
/*
* if it is not in the joomla namespace then we have no idea if
* it uses our pattern for class names/files so just include.
*/
$rs = include($base.ds.$path.'.php');
}
$paths[$keypath] = $rs;
}
return $paths[$keypath];
}
/**
* add a class to autoload
*
* @param string $classname the class name
* @param string $file full path to the file that holds the class
* @return array|boolean array of classes
* @since 1.5
*/
function & register ($class = null, $file = null)
{
static $classes;
if(!isset($classes)) {
$classes = array();
}
if($class && is_file($file))
{
// force to lower case.
$class = strtolower($class);
$classes[$class] = $file;
// in php4 we load the class immediately.
If((version_compare( phpversion(), '5.0' ) < 0)) {
jloader::load($class);
}
}
return $classes;
}
/**
* load the file for a class
*
* @access public
* @param string $class the class that will be loaded
* @return boolean true on success
* @since 1.5
*/
function load( $class )
{
$class = strtolower($class); //force to lower case
if (class_exists($class)) {
return;
}
$classes = jloader::register();
if(array_key_exists( strtolower($class), $classes)) {
include($classes[$class]);
return true;
}
return false;
}
}
آخرین ویرایش: