diff --git a/module/common/lang/en.php b/module/common/lang/en.php index af34bdb0fe..e0c9eb401a 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -73,6 +73,8 @@ $lang->openedByAB = 'Open'; $lang->assignedToAB = 'To'; $lang->typeAB = 'Type'; +$lang->common->common = 'Common module'; + /* The main menu. */ $lang->menu->my = 'Dashboard|my|index'; $lang->menu->product = 'Product|product|index'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 82d34eccf4..c32740fe19 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -73,6 +73,8 @@ $lang->openedByAB = '创建'; $lang->assignedToAB = '指派'; $lang->typeAB = '类型'; +$lang->common->common = '公有模块'; + /* 主导航菜单。*/ $lang->menu->my = '我的地盘|my|index'; $lang->menu->product = '产品视图|product|index'; diff --git a/module/editor/config.php b/module/editor/config.php new file mode 100644 index 0000000000..59e9e26969 --- /dev/null +++ b/module/editor/config.php @@ -0,0 +1,18 @@ +editor->sort[] = 'model.php'; +$config->editor->sort[] = 'control.php'; +$config->editor->sort[] = 'view'; +$config->editor->sort[] = 'lang'; +$config->editor->sort[] = 'config.php'; +$config->editor->sort[] = 'js'; +$config->editor->sort[] = 'css'; +$config->editor->sort[] = 'ext'; + +$config->editor->extSort[] = 'model'; +$config->editor->extSort[] = 'control'; +$config->editor->extSort[] = 'view'; +$config->editor->extSort[] = 'lang'; +$config->editor->extSort[] = 'js'; +$config->editor->extSort[] = 'css'; +$config->editor->extSort[] = 'config'; + diff --git a/module/editor/control.php b/module/editor/control.php index a01f8d455a..d9a2ff0b0d 100644 --- a/module/editor/control.php +++ b/module/editor/control.php @@ -17,15 +17,43 @@ class editor extends control * @access public * @return void */ - public function index($filePath = '', $action = '', $isExtends = '') + public function index() + { + $this->view->moduleList = $this->editor->getModules(); + $this->display(); + } + + /** + * Show this module of files. + * + * @param string $moduleDir + * @access public + * @return void + */ + public function extend($moduleDir = '') + { + $moduleFiles = $this->editor->getModuleFiles($moduleDir); + $this->view->module = $moduleDir; + $this->view->tree = $this->editor->printTree($moduleFiles); + $this->display(); + } + + /** + * Edit extend. + * + * @param string $filePath + * @param string $action + * @param string $isExtends + * @access public + * @return void + */ + public function edit($filePath = '', $action = '', $isExtends = '') { - $allModules = $this->editor->getModuleFiles(); - $this->view->tree = $this->editor->printTree($allModules); $this->view->safeFilePath = $filePath; - $filePath = helper::safe64Decode($filePath); $fileContent = ''; if($filePath) { + $filePath = helper::safe64Decode($filePath); if($action == 'extendOther' and file_exists($filePath)) { $this->view->showContent = htmlspecialchars(file_get_contents($filePath)); @@ -35,6 +63,11 @@ class editor extends control if(file_exists($filePath)) { $fileContent = file_get_contents($filePath); + if($action == 'override') + { + $fileContent = str_replace('../../', '../../../', $fileContent); + $fileContent = str_replace(array('\'./', '"./'), array('\'../../view/', '"../../view'), $fileContent); + } } else { @@ -80,8 +113,6 @@ class editor extends control if(file_exists($saveFilePath) and !$this->post->override) die(js::confirm($this->lang->editor->repeatPage, $extendLink, '', 'parent')); die(js::locate($extendLink, 'parent')); } - $allModules = $this->editor->getModuleFiles(); - $this->view->tree = $this->editor->printTree($allModules); $this->view->filePath = $filePath; $this->display(); } @@ -101,7 +132,7 @@ class editor extends control if($action != 'edit' and $action != 'newPage') $filePath = $this->editor->getSavePath($filePath, $action); if($action != 'edit' and $action != 'newPage' and file_exists($filePath) and !$this->post->override) die(js::error($this->lang->editor->repeatFile)); $this->editor->save($filePath); - die(js::locate(inlink('index', "filePath=" . helper::safe64Encode($filePath) . "&action=edit"), 'parent')); + die(js::locate(inlink('edit', "filePath=" . helper::safe64Encode($filePath) . "&action=edit"), 'parent')); } } diff --git a/module/editor/css/extend.css b/module/editor/css/extend.css new file mode 100644 index 0000000000..592bf5002d --- /dev/null +++ b/module/editor/css/extend.css @@ -0,0 +1,3 @@ +#extendTree li {list-style-type:none;} +#extendTree .active {color:blue; font-weight:bold} + diff --git a/module/editor/js/extend.js b/module/editor/js/extend.js new file mode 100644 index 0000000000..300df47381 --- /dev/null +++ b/module/editor/js/extend.js @@ -0,0 +1,4 @@ +$(function() +{ + $("#extendTree").treeview(); +}); diff --git a/module/editor/js/index.js b/module/editor/js/index.js new file mode 100644 index 0000000000..f742a08e7d --- /dev/null +++ b/module/editor/js/index.js @@ -0,0 +1,6 @@ +$(function() +{ + var showHeight = $(window).height() - 125; + $('#editWin').height(showHeight); + $('#extendWin').height(showHeight); +}); diff --git a/module/editor/lang/en.php b/module/editor/lang/en.php index 405ba974a7..690b07b227 100644 --- a/module/editor/lang/en.php +++ b/module/editor/lang/en.php @@ -9,6 +9,7 @@ $lang->editor->newPage = 'New page'; $lang->editor->override = 'override'; $lang->editor->edit = 'Edit extend'; +$lang->editor->moduleList = 'Module list'; $lang->editor->filePath = "File Path:"; $lang->editor->sourceFile = 'Source file:'; $lang->editor->fileName = "File name:"; @@ -29,3 +30,52 @@ $lang->editor->repeatPage = 'This page has extisted. Is override?'; $lang->editor->notWritable = "Can't writable, maybe no power. please try chmod 777 -R "; $lang->editor->notDelete = "Can't delete, please check power!"; $lang->editor->emptyFileName = 'Please write file name'; + +$lang->editor->translate['config.php'] = 'Config file'; +$lang->editor->translate['config'] = 'Config extend'; +$lang->editor->translate['control.php'] = 'Control file'; +$lang->editor->translate['control'] = 'Control extend'; +$lang->editor->translate['model.php'] = 'Model file'; +$lang->editor->translate['model'] = 'Model extend'; +$lang->editor->translate['view'] = 'View file'; +$lang->editor->translate['lang'] = 'Language file'; +$lang->editor->translate['en'] = 'English'; +$lang->editor->translate['zh-cn'] = 'Chinese Simple'; +$lang->editor->translate['zh-tw'] = 'Chinese Traditional'; +$lang->editor->translate['js'] = 'Javascript'; +$lang->editor->translate['css'] = 'Css'; +$lang->editor->translate['ext'] = 'Extend file'; + +$lang->editor->modules['action'] = 'Logs'; +$lang->editor->modules['admin'] = 'Admin'; +$lang->editor->modules['api'] = 'API'; +$lang->editor->modules['bug'] = 'Bug'; +$lang->editor->modules['build'] = 'Build'; +$lang->editor->modules['common'] = 'Common module'; +$lang->editor->modules['company'] = 'Company'; +$lang->editor->modules['convert'] = 'Import'; +$lang->editor->modules['dept'] = 'Department'; +$lang->editor->modules['doc'] = 'Doc'; +$lang->editor->modules['extension'] = 'Extension'; +$lang->editor->modules['file'] = 'File'; +$lang->editor->modules['group'] = 'Group'; +$lang->editor->modules['index'] = 'Index'; +$lang->editor->modules['install'] = 'Install'; +$lang->editor->modules['misc'] = 'Misc'; +$lang->editor->modules['my'] = 'Dashboard'; +$lang->editor->modules['product'] = 'Product'; +$lang->editor->modules['productplan'] = 'Plan'; +$lang->editor->modules['project'] = 'Project'; +$lang->editor->modules['qa'] = 'QA'; +$lang->editor->modules['release'] = 'Release'; +$lang->editor->modules['report'] = 'Report'; +$lang->editor->modules['search'] = 'Search'; +$lang->editor->modules['story'] = 'Story'; +$lang->editor->modules['task'] = 'Task'; +$lang->editor->modules['testcase'] = 'Case'; +$lang->editor->modules['testtask'] = 'Test task'; +$lang->editor->modules['todo'] = 'TODO'; +$lang->editor->modules['tree'] = 'Module manage'; +$lang->editor->modules['upgrade'] = 'Upgrade'; +$lang->editor->modules['user'] = 'User'; + diff --git a/module/editor/lang/zh-cn.php b/module/editor/lang/zh-cn.php index 2363621779..42cd284514 100644 --- a/module/editor/lang/zh-cn.php +++ b/module/editor/lang/zh-cn.php @@ -9,6 +9,7 @@ $lang->editor->newPage = '新增页面'; $lang->editor->override = '覆盖'; $lang->editor->edit = '编辑扩展'; +$lang->editor->moduleList = '模块列表'; $lang->editor->filePath = "文件路径:"; $lang->editor->sourceFile = '源文件:'; $lang->editor->fileName = "文件名:"; @@ -29,3 +30,51 @@ $lang->editor->repeatPage = '已经有此页面。是否覆盖?'; $lang->editor->notWritable = "无法写入,可能没有权限。请尝试执行 chmod 777 -R "; $lang->editor->notDelete = '无法删除,请检查权限!'; $lang->editor->emptyFileName = '请写入一个文件名!'; + +$lang->editor->translate['config.php'] = '配置文件'; +$lang->editor->translate['config'] = '配置扩展'; +$lang->editor->translate['control.php'] = '控制文件'; +$lang->editor->translate['control'] = '控制扩展'; +$lang->editor->translate['model.php'] = '模型文件'; +$lang->editor->translate['model'] = '模型扩展'; +$lang->editor->translate['view'] = '模板文件'; +$lang->editor->translate['lang'] = '语言文件'; +$lang->editor->translate['en'] = '英文'; +$lang->editor->translate['zh-cn'] = '中文简体'; +$lang->editor->translate['zh-tw'] = '中文繁体'; +$lang->editor->translate['js'] = 'JS脚本'; +$lang->editor->translate['css'] = 'CSS样式'; +$lang->editor->translate['ext'] = '扩展文件'; + +$lang->editor->modules['action'] = '系统日志'; +$lang->editor->modules['admin'] = '后台管理'; +$lang->editor->modules['api'] = 'API接口'; +$lang->editor->modules['bug'] = '缺陷管理'; +$lang->editor->modules['build'] = 'Build'; +$lang->editor->modules['common'] = '公有模块'; +$lang->editor->modules['company'] = '组织视图'; +$lang->editor->modules['convert'] = '从其他系统导入'; +$lang->editor->modules['dept'] = '部门结构'; +$lang->editor->modules['doc'] = '文档视图'; +$lang->editor->modules['extension'] = '插件管理'; +$lang->editor->modules['file'] = '附件'; +$lang->editor->modules['group'] = '权限分组'; +$lang->editor->modules['index'] = '首页'; +$lang->editor->modules['install'] = '安装'; +$lang->editor->modules['misc'] = '杂项'; +$lang->editor->modules['my'] = '我的地盘'; +$lang->editor->modules['product'] = '产品视图'; +$lang->editor->modules['productplan'] = '产品计划'; +$lang->editor->modules['project'] = '项目视图'; +$lang->editor->modules['qa'] = 'QA视图'; +$lang->editor->modules['release'] = '发布'; +$lang->editor->modules['report'] = '报表'; +$lang->editor->modules['search'] = '搜索'; +$lang->editor->modules['story'] = '需求'; +$lang->editor->modules['task'] = '任务'; +$lang->editor->modules['testcase'] = '用例管理'; +$lang->editor->modules['testtask'] = '测试任务'; +$lang->editor->modules['todo'] = 'TODO'; +$lang->editor->modules['tree'] = '模块维护'; +$lang->editor->modules['upgrade'] = '升级'; +$lang->editor->modules['user'] = '用户'; diff --git a/module/editor/model.php b/module/editor/model.php index 16c2c3de7b..b1ce4a8de0 100644 --- a/module/editor/model.php +++ b/module/editor/model.php @@ -11,45 +11,61 @@ */ class editorModel extends model { + /** + * Get all modules + * + * @access public + * @return string + */ + public function getModules() + { + $modules = glob($this->app->getModuleRoot() . '*'); + $moduleList = ''; + return $moduleList; + } + /** * Get module files, contain control's methods and model's method but except ext. * * @access public * @return array */ - public function getModuleFiles() + public function getModuleFiles($moduleDir) { $moduleRoot = $this->app->getModuleRoot(); - $allModules = array(); - $moduleDirs = scandir($moduleRoot); - foreach($moduleDirs as $moduleDir) + $moduleFullDir = $moduleRoot . $moduleDir; + $moduleFiles = scandir($moduleFullDir); + foreach($moduleFiles as $moduleFile) { - if($moduleDir == '.' or $moduleDir == '..' or $moduleDir == '.svn') continue; - $moduleFullDir = $moduleRoot . $moduleDir; - $moduleFiles = scandir($moduleFullDir); - foreach($moduleFiles as $moduleFile) + if($moduleFile == '.' or $moduleFile == '..' or $moduleFile == '.svn') continue; + $moduleFullFile = $moduleFullDir . '/' . $moduleFile; + if($moduleFile == 'control.php' or $moduleFile == 'model.php') { - if($moduleFile == '.' or $moduleFile == '..' or $moduleFile == '.svn') continue; - $moduleFullFile = $moduleFullDir . '/' . $moduleFile; - if($moduleFile == 'control.php' or $moduleFile == 'model.php') - { - $allModules[$moduleFullDir][$moduleFullFile] = $this->analysis($moduleFullFile); - } - elseif($moduleFile == 'ext') - { - $allModules[$moduleFullDir][$moduleFullFile] = $this->getExtensionFiles($moduleFullFile); - } - elseif(is_dir($moduleFullFile)) - { - $ext = ($moduleFile == 'js' or $moduleFile == 'css') ? $moduleFile : 'php'; - foreach(glob($moduleFullFile . '/' . "*.$ext") as $fileName) $allModules[$moduleFullDir][$moduleFullFile][$fileName] = basename($fileName); - } - else - { - $allModules[$moduleFullDir][$moduleFullFile] = $moduleFile; - } + $allModules[$moduleFullDir][$moduleFullFile] = $this->analysis($moduleFullFile); + } + elseif($moduleFile == 'ext') + { + $allModules[$moduleFullDir][$moduleFullFile] = $this->getExtensionFiles($moduleFullFile); + } + elseif(is_dir($moduleFullFile)) + { + $ext = ($moduleFile == 'js' or $moduleFile == 'css') ? $moduleFile : 'php'; + foreach(glob($moduleFullFile . '/' . "*.$ext") as $fileName) $allModules[$moduleFullDir][$moduleFullFile][$fileName] = basename($fileName); + } + else + { + $allModules[$moduleFullDir][$moduleFullFile] = $moduleFile; } } + $allModules = $this->sortModule($moduleFullDir, $allModules); return $allModules; } @@ -87,9 +103,32 @@ class editorModel extends model } } } + $extensionList = $this->sortModule($extPath, $extensionList, true); return $extensionList; } + /** + * Sort module + * + * @param string $filePath + * @param string $moduleFiles + * @param bool $isExtension + * @access public + * @return array + */ + public function sortModule($filePath, $moduleFiles, $isExtension = false) + { + $sort = $isExtension ? 'extSort' : 'sort'; + $sortModules = array(); + if(!$isExtension) $moduleFiles = $moduleFiles[$filePath]; + foreach($this->config->editor->$sort as $sort) + { + $sortKey = empty($sort) ? $filePath : $filePath . '/' . $sort; + if(array_key_exists($sortKey, $moduleFiles)) $sortModules[$sortKey] = $moduleFiles[$sortKey]; + } + return $sortModules; + } + /** * if a directory has two grage, this method will get files * @@ -140,6 +179,7 @@ class editorModel extends model { $methodName = $method->name; if($method->getFileName() != $fileName) continue; + if($methodName == '__construct') continue; $classMethod[$fileName . '/' . $methodName] = $methodName; } return $classMethod; @@ -155,7 +195,14 @@ class editorModel extends model public function printTree($files, $isRoot = true) { if(empty($files) or !is_array($files)) return false; - $tree = $isRoot ? "