示例#1
0
 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;
         }
     }
 }
示例#2
0
 public static function getCheckList($checkGroup = "")
 {
     $checkLists = ["Checking Directory Permission" => [["title" => 'Checking base directory permissions', "check" => function () {
         return Setting::checkPath(Setting::getBasePath(), true);
     }], ["title" => 'Checking app directory permissions', "check" => function () {
         return Setting::checkPath(Setting::getAppPath());
     }], ["title" => 'Checking assets directory permissions', "check" => function () {
         return Setting::checkPath(Setting::getAssetPath(), true);
     }], ["title" => 'Checking runtime directory permissions', "check" => function () {
         return Setting::checkPath(Setting::getRuntimePath(), true);
     }], ["title" => 'Checking config directory permissions', "check" => function () {
         return Setting::checkPath(Setting::getConfigPath(), true);
     }], ["title" => 'Checking repository directory permissions', "check" => function () {
         $repo = Setting::get('repo.path');
         if (!is_dir($repo)) {
             @mkdir($repo, 0777, true);
         }
         return Setting::checkPath(realpath($repo), true);
     }]], "Checking Framework Requirements" => [['title' => 'Checking PHP Version ( > 5.5.0 )', 'check' => function () {
         $result = version_compare(PHP_VERSION, "5.5.0", ">");
         $msg = "Current PHP version is:" . PHP_VERSION;
         return $result !== true ? $msg : true;
     }], ['title' => 'Reflection Extension', 'check' => function () {
         $result = class_exists('Reflection', false);
         $msg = "Reflection class does not exists!";
         return $result !== true ? $msg : true;
     }], ['title' => 'PCRE Extension', 'check' => function () {
         $result = extension_loaded("pcre");
         $msg = "Extension \"pcre\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'SPL extension', 'check' => function () {
         $result = extension_loaded("SPL");
         $msg = "Extension \"SPL\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'DOM extension', 'check' => function () {
         $result = class_exists("DOMDocument", false);
         $msg = "DomDocument class does not exists!";
         return $result !== true ? $msg : true;
     }], ['title' => 'PDO extension', 'check' => function () {
         $result = extension_loaded("pdo");
         $msg = "Extension \"pdo\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'PDO MySQL extension', 'check' => function () {
         $result = extension_loaded("pdo_mysql");
         $msg = "Extension \"pdo_mysql\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'Mcrypt extension', 'check' => function () {
         $result = extension_loaded("mcrypt");
         $msg = "Extension \"mcrypt\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'CURL extension', 'check' => function () {
         $result = extension_loaded("curl");
         $msg = "Extension \"curl\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'GD extension with FreeType support<br />or ImageMagick extension with <br/> PNG support', 'check' => function () {
         if (extension_loaded('imagick')) {
             $imagick = new Imagick();
             $imagickFormats = $imagick->queryFormats('PNG');
         }
         if (extension_loaded('gd')) {
             $gdInfo = gd_info();
         }
         if (isset($imagickFormats) && in_array('PNG', $imagickFormats)) {
             return true;
         } elseif (isset($gdInfo)) {
             if ($gdInfo['FreeType Support']) {
                 return true;
             }
             return "GD Extension is loaded but no Freetype support";
         }
         return "GD Extension / ImageMagick is not loaded";
     }], ['title' => 'Ctype extension', 'check' => function () {
         $result = extension_loaded("ctype");
         $msg = "Extension \"ctype\" is not loaded";
         return $result !== true ? $msg : true;
     }], ['title' => 'Checking Server variables', 'check' => function () {
         return Installer::checkServerVar();
     }]]];
     if ($checkGroup == "") {
         return $checkLists;
     } else {
         return [$checkGroup => $checkLists[$checkGroup]];
     }
 }
示例#3
0
 public static function getModules()
 {
     $modules = glob(Setting::getBasePath() . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "*");
     $appModules = glob(Setting::getAppPath() . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "*");
     $return = [];
     foreach ($modules as $key => $module) {
         $m = Setting::explodeLast(DIRECTORY_SEPARATOR, $module);
         $return[$m] = ['class' => 'application.modules.' . $m . '.' . ucfirst($m) . 'Module'];
     }
     foreach ($appModules as $key => $module) {
         $m = Setting::explodeLast(DIRECTORY_SEPARATOR, $module);
         if (!is_file($module . DIRECTORY_SEPARATOR . ucfirst($m) . 'Module.php')) {
             continue;
         }
         $return[$m] = ['class' => 'app.modules.' . $m . '.' . ucfirst($m) . 'Module'];
     }
     return $return;
 }
示例#4
0
 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 [];
 }