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/citymanagement/config.json | 4 ++ .../citymanagement/lang/en/module.json | 14 ++++ .../lang/en/templates/citymanagement.json | 13 ++++ .../citymanagement/lang/pt/module.json | 14 ++++ modules-available/citymanagement/page.inc.php | 81 ++++++++++++++++++++++ .../templates/page-citymanagement.html | 77 ++++++++++++++++++++ 6 files changed, 203 insertions(+) create mode 100644 modules-available/citymanagement/config.json create mode 100644 modules-available/citymanagement/lang/en/module.json create mode 100644 modules-available/citymanagement/lang/en/templates/citymanagement.json create mode 100644 modules-available/citymanagement/lang/pt/module.json create mode 100644 modules-available/citymanagement/page.inc.php create mode 100644 modules-available/citymanagement/templates/page-citymanagement.html (limited to 'modules-available/citymanagement') diff --git a/modules-available/citymanagement/config.json b/modules-available/citymanagement/config.json new file mode 100644 index 00000000..aff54b3a --- /dev/null +++ b/modules-available/citymanagement/config.json @@ -0,0 +1,4 @@ +{ + "enabled":"false", + "permission":"0" +} diff --git a/modules-available/citymanagement/lang/en/module.json b/modules-available/citymanagement/lang/en/module.json new file mode 100644 index 00000000..ba6c5c44 --- /dev/null +++ b/modules-available/citymanagement/lang/en/module.json @@ -0,0 +1,14 @@ +{ + "lang_cancelConfirm": "Do you really want to remove this city?", + "lang_cityInfo": "Here you can create new cities for the website, besides editing or removing the existing ones", + "lang_cityPage": "Manage cities", + "lang_cityname": "City name", + "lang_close": "Close", + "lang_create": "Create", + "lang_edit": "Edit", + "lang_editcity": "Edit City", + "lang_operations": "Operations", + "lang_remove": "Remove", + "lang_save": "Save", + "module_name": "Management" +} \ No newline at end of file diff --git a/modules-available/citymanagement/lang/en/templates/citymanagement.json b/modules-available/citymanagement/lang/en/templates/citymanagement.json new file mode 100644 index 00000000..27bb60c0 --- /dev/null +++ b/modules-available/citymanagement/lang/en/templates/citymanagement.json @@ -0,0 +1,13 @@ +{ + "lang_cancelConfirm": "Do you really want to remove this city?", + "lang_cityInfo":"Here you can create new cities for the website, besides editing or removing the existing ones", + "lang_cityPage":"Manage cities", + "lang_cityname":"City name", + "lang_close": "Close", + "lang_create": "Create", + "lang_edit":"Edit", + "lang_editcity":"Edit City", + "lang_operations": "Operations", + "lang_remove": "Remove", + "lang_save": "Save" +} diff --git a/modules-available/citymanagement/lang/pt/module.json b/modules-available/citymanagement/lang/pt/module.json new file mode 100644 index 00000000..c514f437 --- /dev/null +++ b/modules-available/citymanagement/lang/pt/module.json @@ -0,0 +1,14 @@ +{ + "lang_cancelConfirm": "Deseja realmente remover a cidade?", + "lang_cityInfo": "Nesta se\u00e7\u00e3o voc\u00ea poder\u00e1 criar cidades para o site, al\u00e9m de editar ou remover cidades existentes", + "lang_cityPage": "Gerenciar cidades", + "lang_cityname": "Nome da cidade", + "lang_close": "Fechar", + "lang_create": "Criar", + "lang_edit": "Editar", + "lang_editcity": "Editar Cidade", + "lang_operations": "Opera\u00e7\u00f5es", + "lang_remove": "Remover", + "lang_save": "Salvar", + "module_name": "Gerenciamento" +} \ No newline at end of file diff --git a/modules-available/citymanagement/page.inc.php b/modules-available/citymanagement/page.inc.php new file mode 100644 index 00000000..acc30bf9 --- /dev/null +++ b/modules-available/citymanagement/page.inc.php @@ -0,0 +1,81 @@ +page = $p; + else + $this->page = 1; + switch(Request::post('action')){ + case "edit": + $this->edit(Request::post('cityid'),Request::post('name')); + break; + case "create": + $this->create(Request::post('name')); + break; + case "delete": + $this->delete(Request::post('cityid')); + break; + } + + + if (!User::hasPermission('superadmin')) { + Message::addError('no-permission'); + Util::redirect('?do=Main'); + } + + } + + protected function doRender() + { + // load every city + $cities = array(); + $res = Database::simpleQuery("SELECT cityid, name FROM cities ORDER BY cityid DESC"); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $cities[] = array( + 'id' => $row['cityid'], + 'name' => $row['name'], + ); + } + + $pag = new Pagination($cities,$this->page); + + Render::addTemplate('page-citymanagement', array( + 'cities' => $pag->getItems(), + 'pages' => $pag->getPagination() + )); + } + + private function edit($cityid, $newname){ + $data = array ( + 'cityid' => $cityid, + 'name' => $newname, + ); + Database::exec ( 'UPDATE cities SET name = :name WHERE cityid = :cityid', $data ); + Message::addSuccess('update-city'); + } + + private function create($name){ + $data = array ( + 'name' => $name, + ); + Database::exec('INSERT INTO cities(name) VALUES( :name )',$data); + Message::addSuccess('add-city'); + } + + private function delete($cityid){ + $data = array ( + 'cityid' => $cityid + ); + Database::exec ( 'DELETE FROM cities WHERE cityid = :cityid', $data ); + Message::addSuccess('delete-city'); + } +} diff --git a/modules-available/citymanagement/templates/page-citymanagement.html b/modules-available/citymanagement/templates/page-citymanagement.html new file mode 100644 index 00000000..6d7750cf --- /dev/null +++ b/modules-available/citymanagement/templates/page-citymanagement.html @@ -0,0 +1,77 @@ +
+
+
{{lang_cityPage}}
+
+
+

+ {{lang_cityInfo}} +

+ +
+ + + + + + + + + + + + + + + {{#cities}} + + + + + + {{/cities}} + + + +
ID{{lang_cityname}}{{lang_operations}}
+ +
+ + + +
+
    + {{#pages}} +
  • {{page}}
  • + {{/pages}} +
+
+
+{{#cities}} + +{{/cities}} -- cgit v1.2.3-55-g7522