function activerecord_autoload($class_name)
{
    $path = ActiveRecord\Config::instance()->get_model_directory();
    $root = realpath(isset($path) ? $path : '.');
    if ($namespaces = ActiveRecord\get_namespaces($class_name)) {
        $class_name = array_pop($namespaces);
        $directories = array();
        foreach ($namespaces as $directory) {
            $directories[] = $directory;
        }
        $root .= DS . implode($directories, DS);
    }
    $file_name = "{$class_name}.php";
    $file = $root . DS . $file_name;
    if (file_exists($file)) {
        require $file;
    } else {
        $modules_path = APPPATH . 'modules';
        if (is_dir($modules_path)) {
            $modules = scandir(realpath($modules_path));
            foreach ($modules as $module) {
                $full_path = $modules_path . DS . $module . DS . 'models' . DS . $file_name;
                if ($module != '.' && $module != '..' && file_exists($full_path)) {
                    require $full_path;
                }
            }
        }
    }
}
Example #2
0
/**
 * Load classes of php-activerecord framework
 * 
 * @param string
 * @return void
 */

function activerecord_autoload($class_name)
{
	$path = ActiveRecord\Config::instance()->get_model_directory();
	$root = realpath(isset($path) ? $path : '.');

	if (($namespaces = ActiveRecord\get_namespaces($class_name)))
	{
		$class_name = array_pop($namespaces);
		$directories = array();

		foreach ($namespaces as $directory)
		{
		    $directories[] = $directory;
		}

		$root .= DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
	}

	$file = "$root/$class_name.php";

	if (file_exists($file))
	{
	    require $file;
	}
}
Example #3
0
function routing_autoload($class_name)
{
    $path = Routing\Config::instance()->get_controller_directory();
    $root = realpath(isset($path) ? $path : '.');
    if ($namespaces = ActiveRecord\get_namespaces($class_name)) {
        //print_r($namespaces);
        $class_name = array_pop($namespaces);
        $directories = array();
        foreach ($namespaces as $directory) {
            $directories[] = $directory;
        }
        $root .= DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
    }
    $file = "{$root}/{$class_name}.php";
    if (file_exists($file)) {
        require_once $file;
    }
}
Example #4
0
function activerecord_autoload($class_name)
{
    $paths = ActiveRecord\Config::instance()->get_model_directories();
    $namespace_directory = '';
    if ($namespaces = ActiveRecord\get_namespaces($class_name)) {
        $class_name = array_pop($namespaces);
        $directories = array();
        foreach ($namespaces as $directory) {
            $directories[] = $directory;
        }
        $namespace_directory = DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
    }
    $paths = count($paths) ? $paths : array('.');
    foreach ($paths as $path) {
        $root = realpath($path);
        $file = "{$root}{$namespace_directory}/{$class_name}.php";
        if (file_exists($file)) {
            require $file;
            return;
        }
    }
}
function activerecord_autoload($class_name)
{
    // iterate over all directories and search within each of them
    $paths = ActiveRecord\JoomlaConfig::instance()->get_model_directories();
    foreach ($paths as $path) {
        $root = realpath(isset($path) ? $path : '.');
        if ($namespaces = ActiveRecord\get_namespaces($class_name)) {
            $class_name = array_pop($namespaces);
            $directories = array();
            foreach ($namespaces as $directory) {
                $directories[] = $directory;
            }
            $root .= DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
        }
        $file = "{$root}/{$class_name}.php";
        if (file_exists($file)) {
            require $file;
            // cancel function as file has been found
            return;
        }
    }
}
Example #6
0
function activerecord_autoload($class_name)
{
    // $path = ActiveRecord\Config::instance()->get_model_directory();
    $paths = ActiveRecord\Config::instance()->get_model_directorise();
    if ($paths) {
        foreach ($paths as $path) {
            $root = realpath(isset($path) ? $path : '.');
            if ($namespaces = ActiveRecord\get_namespaces($class_name)) {
                $class_name = array_pop($namespaces);
                $directories = array();
                foreach ($namespaces as $directory) {
                    $directories[] = $directory;
                }
                $root .= DS . implode($directories, DS);
            }
            $file_name = "{$class_name}.php";
            $file = $root . DS . $file_name;
            if (file_exists($file)) {
                require $file;
            } else {
                $modules_path = APPPATH . 'modules';
                if (is_dir($modules_path)) {
                    $modules = scandir(realpath($modules_path));
                    foreach ($modules as $module) {
                        $full_path = $modules_path . DS . $module . DS . 'models' . DS . $file_name;
                        if ($module != '.' && $module != '..' && file_exists($full_path)) {
                            require $full_path;
                        }
                    }
                }
            }
        }
    }
    if (ENVIRONMENT === 'production') {
        $cfg_ar = ActiveRecord\Config::instance();
        $cfg_ar->set_cache("OrmCache://localhost");
    }
}