示例#1
0
/**
 * Called whenever a class shall be instanciated but there's no definition found
 * 
 * See http://www.php.net/manual/de/function.spl-autoload-register.php
 * @param string $class_name Name of the class to load
 * @return void
 */
function system_spl_autoload($class_name)
{
    if ($class_name == "" || $class_name[0] == "<") {
        return;
    }
    // it's html
    try {
        if (strpos($class_name, '\\') !== false) {
            $orig = $class_name;
            $class_name = array_pop(explode('\\', $class_name));
        }
        $file = __search_file_for_class($class_name);
        if ($file && is_readable($file)) {
            $pre = get_declared_classes();
            require_once $file;
            $post = array_unique(array_diff(get_declared_classes(), $pre));
            foreach ($post as $cd) {
                $d = explode("\\", $cd);
                if (count($d) > 1) {
                    create_class_alias($cd, array_pop($d));
                }
            }
            $def = array_pop($post);
            if (!isset($orig) && !$def) {
                foreach (array_reverse($pre) as $c) {
                    if (!ends_with($c, $class_name)) {
                        continue;
                    }
                    log_info("Aliasing previously included class '{$c}' to '{$class_name}'. To avoid this check the use statements or use a qualified classname.");
                    create_class_alias($c, $class_name, true);
                    break;
                }
            } else {
                $class_name = isset($orig) ? $orig : $class_name;
                if (strtolower($def) != strtolower($class_name) && ends_iwith($def, $class_name)) {
                    log_info("Aliasing class '{$def}' to '{$class_name}'. To avoid this check the use statements or use a qualified classname.");
                    create_class_alias($def, $class_name, true);
                }
            }
        }
    } catch (Exception $ex) {
        WdfException::Log("system_spl_autoload", $ex);
    }
}
 /**
  * @internal Returns a CSS resource
  * @attribute[RequestParam('res','string')]
  */
 function skin($res)
 {
     $res = explode("?", $res);
     $res = realpath(__DIR__ . "/../../skin/" . $res[0]);
     if (ends_iwith($res, '.css')) {
         header('Content-Type: text/css');
     } elseif (ends_iwith($res, '.png')) {
         header('Content-Type: image/png');
     } elseif (ends_iwith($res, '.jpg')) {
         header('Content-Type: image/jpeg');
     } elseif (ends_iwith($res, '.gif')) {
         header('Content-Type: image/gif');
     }
     WdfResource::ValidatedCacheResponse($res);
     readfile($res);
     die;
 }