public function load($module) { $m = explode(".", $module); if (count($m) == 2 && $m[1] != '') { $name = lcfirst($m[1]); $class = ucfirst($name) . "Module"; $basePath = $m[0] == "app" ? Setting::getAppPath() : Setting::getApplicationPath(); $alias = ($m[0] == "app" ? 'app' : 'application') . ".modules.{$name}.{$class}"; $path = $basePath . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $name; $classPath = $path . DIRECTORY_SEPARATOR . $class . ".php"; $this->name = $name; $this->alias = $alias; $this->path = $path; $this->classPath = $classPath; if (is_file($this->classPath)) { $this->module = ModuleGenerator::init($alias, 'load'); $this->accessType = $this->module->checkAccessType(); $this->defaultRule = $this->module->defaultRule; $this->rolesRule = $this->module->rolesRule; $this->usersRule = $this->module->usersRule; $this->acSource = $this->module->acSource; $this->imports = $this->module->loadImport(); } else { $this->module = null; } } }
public static function getConfigPath() { return Setting::getApplicationPath() . DIRECTORY_SEPARATOR . "config"; }
public static function parseModule($module) { $m = explode(".", $module); if (count($m) == 2 && $m[1] != '') { $name = lcfirst($m[1]); $class = ucfirst($name) . "Module"; $basePath = $m[0] == "app" ? Setting::getAppPath() : Setting::getApplicationPath(); $alias = ($m[0] == "app" ? 'app' : 'application') . ".modules.{$name}.{$class}"; $path = $basePath . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $name; $classPath = $path . DIRECTORY_SEPARATOR . $class . ".php"; if (!Helper::isValidVar($class)) { return []; } return ['name' => $name, 'class' => $class, 'alias' => $alias, 'path' => $path, 'classPath' => $classPath]; } return []; }
public static function createIndexFile($mode = "install") { $path = Setting::getApplicationPath() . DIRECTORY_SEPARATOR . "index.php"; $file = file_get_contents($path); $file = str_replace(['$mode = "init"', '$mode = "install"', '$mode = "running"'], '$mode = "' . $mode . '"', $file); Setting::$mode = $mode; if (!is_file($path)) { return @file_put_contents(Setting::getRootPath() . DIRECTORY_SEPARATOR . "index.php", $file); } else { $oldpath = Setting::getRootPath() . DIRECTORY_SEPARATOR . "index.php"; $oldfile = @file_get_contents($oldpath); if ($oldfile != $file) { return @file_put_contents($oldpath, $file); } else { return true; } } }
<?php if (Setting::$mode == "init" || Setting::$mode == "install") { Yii::import("application.modules.install.*"); Yii::import("application.modules.install.controllers.*"); $module = new InstallModule("install", null); $controller = new DefaultController("default", $module); $controller->action = $controller->createAction("index"); $msg = @$data['message']; if (strpos(@$data['message'], 'Application Runtime Path') === 0) { $msg = null; } $controller->action->runWithParams(['msg' => $msg]); } else { Yii::import("application.controllers.*"); $controller = new SiteController("site"); $controller->action = $controller->createAction("error"); $controller->action->run(); if (!@$_GET['rendered']) { include Setting::getApplicationPath() . DIRECTORY_SEPARATOR . "framework" . DIRECTORY_SEPARATOR . "views" . DIRECTORY_SEPARATOR . "exception.php"; } }