Exemple #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;
         }
     }
 }
 public function actionRename($f, $t)
 {
     try {
         $result = ModuleGenerator::rename($f, $t);
     } catch (CException $ex) {
         echo "ERROR: " . strtoupper($ex->getMessage());
         die;
     }
     echo "SUCCESS";
 }
Exemple #3
0
 public static function getModuleList()
 {
     $rawList = ModuleGenerator::listModuleForMenuTree();
     $modules = ['' => '-- Choose Module --', '---' => '---'];
     foreach ($rawList as $k => $list) {
         $m = $list['module'] == 'plansys' ? 'application' : $list['module'];
         $modules[$m . ".commands"] = ucfirst($list['label']);
     }
     foreach ($rawList as $k => $list) {
         $modules[$list['label'] . " Module"] = [];
         foreach ($list['items'] as $j => $l) {
             $l['module'] = $l['module'] == 'plansys' ? 'application' : $l['module'];
             $modules[$list['label'] . " Module"][$l['module'] . ".modules." . $j . ".commands"] = ucfirst($j);
         }
     }
     return $modules;
 }
Exemple #4
0
<?php

## AUTOGENERATED OPTIONS - DO NOT EDIT
$options = array('mode' => 'custom', 'layout' => array('size' => '200', 'sizetype' => 'px', 'type' => 'menu', 'name' => 'col1', 'file' => 'application.modules.dev.menus.GenModule', 'title' => 'Module', 'icon' => 'fa-empire', 'inlineJS' => 'GenModule.js', 'menuOptions' => array()));
## END OF AUTOGENERATED OPTIONS
return ModuleGenerator::listModuleForMenuTree();
Exemple #5
0
 public static function rename($from, $to)
 {
     $from = ModuleGenerator::parseModule($from);
     $to = ModuleGenerator::parseModule($to);
     if (empty($from)) {
         throw new CException("Invalid source name.");
         return false;
     }
     if (empty($to)) {
         throw new CException("Invalid destination name.");
         return false;
     }
     if (is_dir($from['path']) && is_file($from['classPath'])) {
         if (!is_file($to['classPath'])) {
             ## rename module class
             $file = file_get_contents($from['classPath']);
             $file = preg_replace('/class\\s+' . $from['class'] . '/', 'class ' . $to['class'], $file, 1);
             file_put_contents($from['classPath'], $file);
             ## rename directory
             rename($from['classPath'], $from['path'] . DIRECTORY_SEPARATOR . $to['class'] . ".php");
             rename($from['path'], $to['path']);
             ## rename forms
             $formsDir = $to['path'] . DIRECTORY_SEPARATOR . 'forms';
             $forms = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($formsDir));
             foreach ($forms as $d) {
                 if ($d->isFile() && $d->getExtension() == "php") {
                     ## determine old and new file
                     $oldClass = substr($d->getFilename(), 0, -4);
                     $newClass = ucfirst($to['name']) . substr($oldClass, strlen($from['name']));
                     $oldFilePath = $d->getRealPath();
                     $newFilePath = $d->getPath() . DIRECTORY_SEPARATOR . $newClass . ".php";
                     ## change class name inside file
                     $file = file_get_contents($d->getRealPath());
                     $file = preg_replace('/class\\s*' . $oldClass . '/', 'class ' . $newClass, $file, 1);
                     file_put_contents($oldFilePath, $file);
                     ## rename file
                     rename($oldFilePath, $newFilePath);
                 }
             }
             return $to;
         } else {
             throw new CException("Destination module already exist.");
             return false;
         }
     } else {
         throw new CException("Invalid source name.");
         return false;
     }
 }