Beispiel #1
0
 public static function get_children_of($parent)
 {
     \System\Loader::load_all();
     $list = array();
     $all = get_declared_classes();
     foreach ($all as $cname) {
         if (in_array($parent, class_parents($cname))) {
             $list[] = $cname;
         }
     }
     return $list;
 }
Beispiel #2
0
 public static function show_usage($script)
 {
     self::out('Fudjan system manager');
     self::out();
     self::out('Usage: ' . $script . ' module [command] [params]');
     self::out('Use --help with command to see help for modules');
     self::out();
     \System\Loader::load_all();
     \System\Loader::load_all_helpers();
     $all_classes = get_declared_classes();
     $child_classes = array();
     foreach ($all_classes as $class) {
         if (is_subclass_of('\\' . $class, '\\Helper\\Cli\\Module')) {
             $ref = new \ReflectionClass($class);
             if (!$ref->isAbstract()) {
                 $name = explode('\\', $class);
                 $child_classes[] = strtolower($name[count($name) - 1]);
             }
         }
     }
     sort($child_classes);
     self::out('Modules:');
     self::out_flist(array("list" => $child_classes, "show_keys" => false, "margin" => 4));
 }
Beispiel #3
0
 public function cmd_dump(array $params = array())
 {
     \System\Init::full();
     $file = array_shift($params);
     if ($this->json) {
         \System\Loader::load_all();
         $models = \System\Model\Database::get_all_children();
         $data = array();
         \Helper\Cli::do_over($models, function ($key, $model, &$data) {
             $objects = $model::get_all()->fetch();
             if (any($objects)) {
                 $data[$model] = \System\Template::to_json($objects, false);
             }
         }, null, $data, !is_null($file));
         if ($file) {
             \System\Json::put($file, $data);
         } else {
             echo json_encode($data);
         }
     } else {
         $cmd = self::assemble_mysql_command("mysqldump", true);
         if ($file) {
             shell_exec("mkdir -m775 -p " . dirname($file));
             $cmd .= " > " . $file;
         }
         passthru($cmd);
     }
 }