Пример #1
0
function yze_autoload($class)
{
    $_ = preg_split("{\\\\}", strtolower($class));
    if ($_[0] == "app") {
        $module_name = $_[1];
        $class_name = $_[2];
        $loaded_module_info = \yangzie\YZE_Object::loaded_module($module_name);
        $file = "";
        if ($loaded_module_info['is_phar']) {
            $module_name .= ".phar";
            $file = "phar://";
        }
        $file .= YZE_INSTALL_PATH . "app" . DS . "modules" . DS . $module_name . DS;
        if (preg_match("{_controller\$}i", $class)) {
            $file .= "controllers" . DS . $class_name . ".class.php";
        } else {
            if (preg_match("{_model\$}i", $class)) {
                $file .= "models" . DS . $class_name . ".class.php";
            } else {
                if (preg_match("{_define\$}i", $class)) {
                    $file .= "models" . DS . $class_name . ".trait.php";
                } else {
                    if (preg_match("{_module\$}i", $class)) {
                        $file .= "__module__.php";
                    } else {
                        $file = YZE_INSTALL_PATH . strtr(strtolower($class), array("\\" => "/")) . ".class.php";
                    }
                }
            }
        }
        if (@$file && file_exists($file)) {
            include $file;
        }
    }
}
Пример #2
0
 /**
  * 返回当前请求的模块views目录,注意结尾无/
  */
 public function view_path()
 {
     $info = \yangzie\YZE_Object::loaded_module($this->module());
     if ($info['is_phar']) {
         return "phar://" . YZE_APP_PATH . "modules/" . $this->module() . ".phar/views";
     } else {
         return YZE_APP_PATH . "modules/" . $this->module() . "/views";
     }
 }