From 50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 3 May 2016 19:03:09 +0200 Subject: WIP --- modules-available/sysconfignew/config.json | 3 + modules-available/sysconfignew/lang/en/module.json | 23 ++ modules-available/sysconfignew/lang/pt/module.json | 23 ++ modules-available/sysconfignew/page.inc.php | 113 +++++++++ .../sysconfignew/templates/_pagenew.html | 190 +++++++++++++++ .../sysconfignew/templates/module-editor.html | 269 +++++++++++++++++++++ 6 files changed, 621 insertions(+) create mode 100644 modules-available/sysconfignew/config.json create mode 100644 modules-available/sysconfignew/lang/en/module.json create mode 100644 modules-available/sysconfignew/lang/pt/module.json create mode 100644 modules-available/sysconfignew/page.inc.php create mode 100644 modules-available/sysconfignew/templates/_pagenew.html create mode 100644 modules-available/sysconfignew/templates/module-editor.html (limited to 'modules-available/sysconfignew') diff --git a/modules-available/sysconfignew/config.json b/modules-available/sysconfignew/config.json new file mode 100644 index 00000000..4da67ef8 --- /dev/null +++ b/modules-available/sysconfignew/config.json @@ -0,0 +1,3 @@ +{ + "enabled":"true" +} diff --git a/modules-available/sysconfignew/lang/en/module.json b/modules-available/sysconfignew/lang/en/module.json new file mode 100644 index 00000000..3ec89616 --- /dev/null +++ b/modules-available/sysconfignew/lang/en/module.json @@ -0,0 +1,23 @@ +{ + "lang_back": "Back", + "lang_cancel": "Cancel", + "lang_cannotOpen": "could no be opened", + "lang_changeLink": "Change link", + "lang_compilingIpxe": "Compiling iPXE", + "lang_configName": "Name", + "lang_configsDescription": "Here it is possible to create a system configuration by choosing the desired modules.", + "lang_configurations": "Configurations", + "lang_create": "Create", + "lang_edit": "Edit", + "lang_file": "File", + "lang_leavingMessage": "You have unsaved changes on your module.", + "lang_loading": "Loading", + "lang_modules": "Modules", + "lang_modulesDescription": "Here it is possible to create a system module through an editor.", + "lang_name": "Name", + "lang_new": "New", + "lang_newConfig": "New Config", + "lang_newModule": "New Module", + "lang_remove": "Remove", + "lang_save": "Save" +} \ No newline at end of file diff --git a/modules-available/sysconfignew/lang/pt/module.json b/modules-available/sysconfignew/lang/pt/module.json new file mode 100644 index 00000000..af0d7ad7 --- /dev/null +++ b/modules-available/sysconfignew/lang/pt/module.json @@ -0,0 +1,23 @@ +{ + "lang_back": "Voltar", + "lang_cancel": "Cancelar", + "lang_cannotOpen": "n\u00e3o p\u00f4de ser aberto", + "lang_changeLink": "Mudar link", + "lang_compilingIpxe": "Compilando iPXE", + "lang_configName": "Nome", + "lang_configsDescription": "Aqui \u00e9 poss\u00edvel criar uma configura\u00e7\u00e3o do sistema escolhendo os m\u00f3dulos desejados.", + "lang_configurations": "Configura\u00e7\u00f5es", + "lang_create": "Criar", + "lang_edit": "Editar", + "lang_file": "Arquivo", + "lang_leavingMessage": "Voc\u00ea possui mudan\u00e7as n\u00e3o salvas no seu m\u00f3dulo.", + "lang_loading": "Carregando", + "lang_modules": "M\u00f3dulos", + "lang_modulesDescription": "Aqui \u00e9 poss\u00edvel criar um m\u00f3dulo do sistema atrav\u00e9s de um editor.", + "lang_name": "Nome", + "lang_new": "Novo", + "lang_newConfig": "Nova Configura\u00e7\u00e3o", + "lang_newModule": "Novo M\u00f3dulo", + "lang_remove": "Remover", + "lang_save": "Salvar" +} \ No newline at end of file diff --git a/modules-available/sysconfignew/page.inc.php b/modules-available/sysconfignew/page.inc.php new file mode 100644 index 00000000..105ad6c7 --- /dev/null +++ b/modules-available/sysconfignew/page.inc.php @@ -0,0 +1,113 @@ +tmconfigs = $this->tmpath . '/configs'; + $this->tmmodules = $this->tmpath . '/modules'; + } + + + protected function doRender(){ + $module = $_GET['module']; + if(isset($module)){ + Render::addTemplate('module-editor',array( + "module" => $module + )); + }else{ + if(is_dir($this->tmpath)){ + $configs = array(); + $modules = array(); + + foreach($this->listDirectory($this->tmconfigs) as $key => $value) + $configs[] = array( + "name" => $value + ); + + foreach($this->listDirectory($this->tmmodules) as $key => $value) + $modules[] = array( + "name" => $value + ); + + $data = array( + "configs" => $configs, + "modules" => $modules + ); + Render::addTemplate('_pagenew',$data); + }else{ + Message::addError('no-tm-scripts'); + } + } + } + + protected function doAjax(){ + $request = $_GET['request']; + switch($request){ + case "module-contents": + $path = $this->tmpath . '/modules/' . Request::get('module'); + $data = $this->getDirContents($path); + $json = json_encode($data); + print_r($json); + break; + case "configs": + $this->tmconfigs = $this->tmpath . '/configs'; + $this->tmmodules = $this->tmpath . '/modules'; + $userModules = $this->listDirectory($this->tmconfigs . '/' . Request::get('config')); + $modules = array(); + foreach($this->listDirectory($this->tmmodules) as $key => $value){ + $chosen = (in_array($value, $userModules)) ? true : false; + $modules[] = array( + "name" => $value, + "chosen" => $chosen + ); + } + + foreach ($modules as $module) { + $class = ($module['chosen']) ? "select-item select-item-selected" : "select-item"; + $ret .= ""; + } + + echo $ret; + break; + } + + } + + private function getDirContents($path){ + $ret = array(); + foreach ($this->listDirectory($path) as $key => $value) { + if(is_dir($path . "/" . $value)){ + $ret["dir_" . $value] = $this->getDirContents($path . "/" . $value); + }else{ + if(is_link($path . "/" . $value)){ + $ret["link_" . $value] = readlink($path . "/" . $value); + }else{ + if(mime_content_type($path . "/" . $value) == "text/plain"){ + $ret["file_" . $value] = file_get_contents($path . "/" . $value); + }else{ + $ret["lock_" . $value] = " oops"; + } + } + } + } + return $ret; + } + + private function listDirectory($path){ + return array_diff(scandir($path), array('..', '.')); + } + +} diff --git a/modules-available/sysconfignew/templates/_pagenew.html b/modules-available/sysconfignew/templates/_pagenew.html new file mode 100644 index 00000000..98881ae3 --- /dev/null +++ b/modules-available/sysconfignew/templates/_pagenew.html @@ -0,0 +1,190 @@ +
+
+
+
+
{{lang_configurations}}
+
+
+ {{lang_configsDescription}} +
+ + + + + + + + {{#configs}} + + + + + + {{/configs}} + +
{{lang_configName}}
{{name}} + + + +
+ +
+
+
+
+
+
{{lang_modules}}
+
+
+ {{lang_modulesDescription}} +
+ + + + + + + + {{#modules}} + + + + + + {{/modules}} + +
{{lang_configName}}
{{name}} + + + +
+ +
+
+
+ + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/modules-available/sysconfignew/templates/module-editor.html b/modules-available/sysconfignew/templates/module-editor.html new file mode 100644 index 00000000..3ea28bf8 --- /dev/null +++ b/modules-available/sysconfignew/templates/module-editor.html @@ -0,0 +1,269 @@ + +
+
+ {{lang_back}} +
+
+ {{module}} +
+
+
+ +
+ + +
+ +
+
+
+ + + + + \ No newline at end of file -- cgit v1.2.3-55-g7522