From e11f256bf045da15620dae50806929f758c77e6d Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 26 Nov 2011 21:51:01 +0100 Subject: Added a settings page to the backend. --- ratatoeskr/backend.php | 79 ++++++++++++++++++++++ .../src/systemtemplates/instant_select.tpl | 5 ++ .../templates/src/systemtemplates/sections.html | 6 +- .../templates/src/systemtemplates/settings.html | 52 ++++++++++++++ ratatoeskr/translations/en.php | 14 +++- 5 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 ratatoeskr/templates/src/systemtemplates/instant_select.tpl create mode 100644 ratatoeskr/templates/src/systemtemplates/settings.html diff --git a/ratatoeskr/backend.php b/ratatoeskr/backend.php index 7db6a22..ecdb259 100644 --- a/ratatoeskr/backend.php +++ b/ratatoeskr/backend.php @@ -1243,6 +1243,85 @@ $backend_subactions = url_action_subactions(array( echo $ste->exectemplate("systemtemplates/sections.html"); } + )), + "admin" => url_action_subactions(array( + "settings" => function(&$data, $url_now, &$url_next) + { + global $ste, $translation, $languages, $rel_path_to_root, $ratatoeskr_settings, $textprocessors; + + $url_next = array(); + + $ste->vars["section"] = "admin"; + $ste->vars["submenu"] = "settings"; + $ste->vars["pagetitle"] = $translation["menu_settings"]; + + $ste->vars["textprocessors"] = array(); + foreach($textprocessors as $txtproc => $properties) + if($properties[1]) + $ste->vars["textprocessors"][] = $txtproc; + + /* Save comment settings? */ + if(isset($_POST["save_comment_settings"])) + { + if(!in_array(@$_POST["comment_textprocessor"], $ste->vars["textprocessors"])) + $ste->vars["error"] = $translation["unknown_txtproc"]; + else + { + $ratatoeskr_settings["comment_textprocessor"] = $_POST["comment_textprocessor"]; + $ratatoeskr_settings["comment_visible_default"] = (isset($_POST["comment_auto_visible"]) and ($_POST["comment_auto_visible"] == "yes")); + $ste->vars["success"] = $translation["comment_settings_successfully_saved"]; + } + } + + /* Delete language? */ + if(isset($_POST["delete"]) and ($_POST["really_delete"] == "yes") and isset($_POST["language_select"])) + { + if($ratatoeskr_settings["default_language"] == $_POST["language_select"]) + $ste->vars["error"] = $translation["cannot_delete_default_language"]; + else + { + $ratatoeskr_settings["languages"] = array_filter($ratatoeskr_settings["languages"], function($l) { return $l != $_POST["language_select"]; }); + $ste->vars["success"] = $translation["language_successfully_deleted"]; + } + } + + /* Set default language */ + if(isset($_POST["make_default"]) and isset($_POST["language_select"])) + { + if(in_array($_POST["language_select"], $ratatoeskr_settings["languages"])) + { + $ratatoeskr_settings["default_language"] = $_POST["language_select"]; + $ste->vars["success"] = $translation["successfully_set_default_language"]; + } + } + + /* Add a language */ + if(isset($_POST["add_language"])) + { + if(!isset($languages[$_POST["language_to_add"]])) + $ste->vars["error"] = $translation["language_unknown"]; + else + { + if(!in_array($_POST["language_to_add"], $ratatoeskr_settings["languages"])) + { + $ls = $ratatoeskr_settings["languages"]; + $ls[] = $_POST["language_to_add"]; + $ratatoeskr_settings["languages"] = $ls; + } + $ste->vars["success"] = $translation["language_successfully_added"]; + } + } + + $ste->vars["comment_auto_visible"] = $ratatoeskr_settings["comment_visible_default"]; + $ste->vars["comment_textprocessor"] = $ratatoeskr_settings["comment_textprocessor"]; + $ste->vars["used_langs"] = array_map(function ($l) use ($ratatoeskr_settings, $languages) { return array( + "code" => $l, + "name" => $languages[$l]["language"], + "default" => ($l == $ratatoeskr_settings["default_language"]) + );}, $ratatoeskr_settings["languages"]); + + echo $ste->exectemplate("systemtemplates/settings.html"); + } )) )); diff --git a/ratatoeskr/templates/src/systemtemplates/instant_select.tpl b/ratatoeskr/templates/src/systemtemplates/instant_select.tpl new file mode 100644 index 0000000..01c5017 --- /dev/null +++ b/ratatoeskr/templates/src/systemtemplates/instant_select.tpl @@ -0,0 +1,5 @@ + diff --git a/ratatoeskr/templates/src/systemtemplates/sections.html b/ratatoeskr/templates/src/systemtemplates/sections.html index 1228933..8fd75bc 100644 --- a/ratatoeskr/templates/src/systemtemplates/sections.html +++ b/ratatoeskr/templates/src/systemtemplates/sections.html @@ -1,9 +1,5 @@ - + $success diff --git a/ratatoeskr/templates/src/systemtemplates/settings.html b/ratatoeskr/templates/src/systemtemplates/settings.html new file mode 100644 index 0000000..5b0d0c5 --- /dev/null +++ b/ratatoeskr/templates/src/systemtemplates/settings.html @@ -0,0 +1,52 @@ + + + + $error + +
$error
+
+
+ $success + +
$success
+
+
+ +
+

+ :
+ :
+ + + +
+

+ + + + + + + + + + + + + + + + + + + +
 
$lang[code]$lang[name]?{$lang[default]||}
+
+   + | + + | +   +
+
+
diff --git a/ratatoeskr/translations/en.php b/ratatoeskr/translations/en.php index 5a4d1c4..5c6bd5c 100644 --- a/ratatoeskr/translations/en.php +++ b/ratatoeskr/translations/en.php @@ -166,7 +166,19 @@ $translation = array( "default_section_changed_successfully" => "Default section changed successfully.", "successfully_added_style" => "Successfully added style.", "successfully_set_section_title" => "Successfully set title.", - "successfully_set_template" => "Successfully set template." + "successfully_set_template" => "Successfully set template.", + "comment_textprocessor" => "Textprocessor for comments", + "language_settings" => "Language settings", + "language_code" => "Language code", + "default_language" => "Default language", + "add_language" => "Add language", + "comment_auto_visible" => "Make comments visible automatically", + "comment_settings" => "Comment settings", + "comment_settings_successfully_saved" => "Comment settings successfully saved", + "cannot_delete_default_language" => "Can not delete default language.", + "language_successfully_deleted" => "Language successfully deleted.", + "successfully_set_default_language" => "Successfully set default language.", + "language_successfully_added" => "Language successfully added." ); ?> -- cgit v1.2.3-70-g09d2