public static function refresh_module_action() { $register = Module_ModuleManager_Register::get_instance()->register_modules(); if ($register === false) { Module_View_Main::view()->output(0); } else { Module_OperationRecord_Main::add_record(Module_OperationRecord_Main::OPCODE_MODULE_UPDATE); Module_View_Main::view()->output($register); } }
/** * @return array */ function gen_nav_from_module() { $modules = Module_ModuleManager_Register::get_instance()->get_modules_with_register('web'); $nav_info = []; foreach ($modules as $_m) { if (!isset($_m['entry_class']) || !isset($_m['indentify'])) { continue; } $pre_path = $_m['indentify']; $entry_class = $_m['entry_class']; if (!method_exists($entry_class, 'register_router')) { continue; } $_router = call_user_func([$entry_class, 'register_router']); foreach ($_router as $__p => $__i) { if (!isset($__i[3][Const_DataAccess::URL_NAME])) { continue; } $__info = $__i[3]; $nav_info['/' . $pre_path . '/' . $__p] = $__info; } } $convert_nav = function ($url, $info) { $nav = ['name' => $info[Const_DataAccess::URL_NAME], 'path' => $url, 'weight' => isset($info[Const_DataAccess::URL_WEIGHT]) ? $info[Const_DataAccess::URL_WEIGHT] : 0]; isset($info[Const_DataAccess::URL_PERM]) && ($nav['perm'] = $info[Const_DataAccess::URL_PERM]); $nav['show'] = isset($info[Const_DataAccess::URL_NAV]) && $info[Const_DataAccess::URL_NAV] ? true : false; return $nav; }; $nav = []; foreach ($nav_info as $_url => $_info) { if (isset($_info[Const_DataAccess::URL_CATALOG])) { $_catalog = $_info[Const_DataAccess::URL_CATALOG]; isset($nav[$_catalog]) || ($nav[$_catalog] = ['name' => $_info[Const_DataAccess::URL_CATALOG], 'children' => [], 'weight' => 0]); isset($_info[Const_DataAccess::URL_WEIGHT]) && $nav[$_catalog]['weight'] < $_info[Const_DataAccess::URL_WEIGHT] && ($nav[$_catalog]['weight'] = $_info[Const_DataAccess::URL_WEIGHT]); $nav[$_info[Const_DataAccess::URL_CATALOG]]['children'][$_url] = $convert_nav($_url, $_info); } else { isset($_info[Const_DataAccess::URL_WEIGHT]) && ($_info['weight'] = $_info[Const_DataAccess::URL_WEIGHT]); $nav[$_info[Const_DataAccess::URL_NAME]] = $convert_nav($_url, $_info); } } $nav[] = ['name' => '首页', 'path' => '/', 'weight' => 3000]; foreach ($nav as &$_v) { if (isset($_v['children'])) { Lib_Array::sort_two_dimension_array($_v['children'], 'weight', false, true); $_f = reset($_v['children']); $_v['path'] = $_f['path']; } } Lib_Array::sort_two_dimension_array($nav, 'weight', false, false); $this->_nav = $nav; return $nav; }
/** * @return array */ function get_registered_fields() { if (empty($this->_fields)) { $modules = Module_ModuleManager_Register::get_instance()->get_registered_modules(); foreach ($modules as $_k => $_m) { $type = $_m[Const_Module::META_TYPE]; if (strcmp($type, Const_Module::TYPE_ABSTRACT) === 0) { continue; } $register = isset($_m[Const_Module::META_REGISTER]) ? $_m[Const_Module::META_REGISTER] : []; in_array(Const_Module::REGISTER_FIELDS, $register) && $this->_register_module_fields($_m); } } return $this->_fields; }
#!/usr/bin/env php <?php require_once dirname(dirname(dirname(__FILE__))) . '/app/init.php'; $o = getopt('r::s::l::', ['show', 'register', 'list']); if (isset($o['register']) || isset($o['r'])) { $register = Module_ModuleManager_Register::get_instance()->register_modules(); p($register); } else { $modules = Module_ModuleManager_Register::get_instance()->get_registered_modules(); if (empty($modules)) { p('No modules...'); exit; } if (isset($o['list']) || isset($o['l'])) { foreach ($modules as $_k => $_v) { echo $_k . "\t" . $_v[Const_Interface::FIELD_ATTR_NAME] . "\t" . $_v[Const_Interface::FIELD_ATTR_TYPE] . "\t" . $_v['indentify'] . "\t" . PHP_EOL; //.$_v['author'] . "\t" } exit; } else { p($modules); exit; } }
static function task_module_list_action() { $task_id = Lib_Request::get_int('task_id'); $page = Lib_Request::get_int('page'); $page = $page < 1 ? 1 : $page; $page_size = 20; $offset = intval(($page - 1) * $page_size); if (empty($task_id) && $task_id != 0) { Module_View_Main::view()->output(['errno' => Const_Err_DataAccess::ERR_GET_PARAM, 'data' => '无此任务']); } $task_module_record = new Model_TaskRunModuleRecord(); $records = $task_module_record->get_records_by_task_id($task_id, $page_size, $offset); if (!isset($records['errno']) && $records['errno'] !== Const_Err_Base::ERR_OK) { Module_View_Main::view()->output(['errno' => Const_Err_DataAccess::ERR_TASK_NOT_EXISTS, 'data' => '获取任务失败']); } $task_infos = $records['data']; $modules = Module_ModuleManager_Register::get_instance()->get_registered_modules(); $status = Module_ModuleManager_Main::$run_module_status_list; $task_info = []; foreach ($task_infos as $_k => $_v) { $_v['start_time'] = isset($_v['start_time']) ? date('Y-m-d H:i:s', $_v['start_time']) : ''; $_v['end_time'] = isset($_v['end_time']) ? date('Y-m-d H:i:s', $_v['end_time']) : ''; $_v['module'] = isset($modules[$_v['module_id']]) ? $modules[$_v['module_id']]['name'] : 'UNKNOW'; $_v['module_brief'] = isset($modules[$_v['module_id']]) ? $modules[$_v['module_id']]['brief'] : '暂无信息'; $_v['digit_status'] = $_v['status']; $_v['status'] = $status[$_v['status']]; $task_info[] = $_v; } Module_View_Main::view()->output($task_info); }
/** * @return array */ private static function _get_form_data() { $data = []; $functional_modules = []; $configure_modules = []; $modules = Module_ModuleManager_Register::get_instance()->get_registered_modules(); if (is_array($modules)) { foreach ($modules as $k => $v) { if ($v['type'] == 'functional') { $functional_modules[$k]['module_id'] = $v['module_id']; $functional_modules[$k]['name'] = $v['name']; } if ($v['type'] == 'configure' && isset($v['register']) && in_array('dataflow', $v['register'])) { $configure_modules[$k]['module_id'] = $v['module_id']; $configure_modules[$k]['name'] = $v['name']; } } } $data['functional_modules'] = $functional_modules; $data['configure_modules'] = $configure_modules; return $data; }