Exemple #1
0
 static function _shift($name, $target)
 {
     $name = str_replace(array('F3CMS\\', '\\'), array('', ''), $name);
     list($type, $className) = preg_split("/(?<=[rfo])(?=[A-Z])/", $name);
     return '\\F3CMS\\' . \F3CMS_Autoloader::getPrefix()[$target] . $className;
 }
Exemple #2
0
     * @param    string    $pClassName        Name of the object to load
     */
    public static function Load($pClassName)
    {
        if (class_exists($pClassName, FALSE) || strpos($pClassName, 'F3CMS') !== 0) {
            return FALSE;
        }
        $className = ltrim($pClassName, '\\');
        $fileName = '';
        $namespace = '';
        if ($lastNsPos = strrpos($className, '\\')) {
            $namespace = substr($className, 0, $lastNsPos);
            $className = substr($className, $lastNsPos + 1);
            $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
        }
        list($type, $className) = preg_split("/(?<=[rfo])(?=[A-Z])/", $className);
        if ($className !== null) {
            $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . DIRECTORY_SEPARATOR . self::getType()[$type] . '.php';
            $fileName = str_replace('libs', 'modules', __DIR__) . str_replace('F3CMS', '', $fileName);
        } else {
            $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $type) . '.php';
            $fileName = __DIR__ . str_replace('F3CMS', '', $fileName);
        }
        if (file_exists($fileName) === FALSE || is_readable($fileName) === FALSE) {
            return FALSE;
        }
        require $fileName;
    }
}
F3CMS_Autoloader::Register();