diff options
-rw-r--r-- | ratatoeskr/backend.php | 79 | ||||
-rw-r--r-- | ratatoeskr/templates/src/systemtemplates/instant_select.tpl | 5 | ||||
-rw-r--r-- | ratatoeskr/templates/src/systemtemplates/sections.html | 6 | ||||
-rw-r--r-- | ratatoeskr/templates/src/systemtemplates/settings.html | 52 | ||||
-rw-r--r-- | ratatoeskr/translations/en.php | 14 |
5 files changed, 150 insertions, 6 deletions
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 @@ +<ste:mktag name="instant_select" mandatory="name|array"><select name="$_tag_parameters[name]"> + <ste:foreach array="$_tag_parameters[array]" value="instant_select_v"> + <option value="$instant_select_v"?{~{$_tag_parameters[selected]|eq|$instant_select_v}| selected="selected"|}>$instant_select_v</option> + </ste:foreach> +</select></ste:mktag> 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 @@ <ste:load name="master.html" /> -<ste:mktag name="instant_select" mandatory="name|array"><select name="$_tag_parameters[name]"> - <ste:foreach array="$_tag_parameters[array]" value="instant_select_v"> - <option value="$instant_select_v"?{~{$_tag_parameters[selected]|eq|$instant_select_v}| selected="selected"|}>$instant_select_v</option> - </ste:foreach> -</select></ste:mktag> +<ste:load name="instant_select.tpl" /> <ste:block name="content"> <ste:if>$success <ste:then> 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 @@ +<ste:load name="master.html" /> +<ste:load name="instant_select.tpl" /> +<ste:block name="content"> + <ste:if>$error + <ste:then> + <div class="error"><ste:escape>$error</ste:escape></div> + </ste:then> + </ste:if> + <ste:if>$success + <ste:then> + <div class="success"><ste:escape>$success</ste:escape></div> + </ste:then> + </ste:if> + + <form action="$rel_path_to_root/backend/admin/settings" method="POST" accept-charset="UTF-8"> + <h2><ste:get_translation for="comment_settings" /></h2> + <strong><ste:get_translation for="comment_textprocessor" />:</strong> <ste:instant_select name="comment_textprocessor" array="textprocessors" selected="$comment_textprocessor" /><br /> + <strong><ste:get_translation for="comment_auto_visible" />:</strong> <input type="checkbox" name="comment_auto_visible" value="yes"?{$comment_auto_visible| checked="checked"|} /><br /> + <input type="submit" name="save_comment_settings" /> + </form> + + <form action="$rel_path_to_root/backend/admin/settings" method="POST" accept-charset="UTF-8"> + <h2><ste:get_translation for="language_settings" /></h2> + <table class="listtab"> + <thead> + <tr> + <th> </th> + <th><ste:get_translation for="language_code" /></th> + <th><ste:get_translation for="language" /></th> + <th><ste:get_translation for="default_language" /></th> + </tr> + </thead> + <tbody> + <ste:foreach array="used_langs" value="lang"> + <tr> + <td><input type="radio" name="language_select" value="$lang[code]" /></td> + <td>$lang[code]</td> + <td><ste:escape>$lang[name]</ste:escape></td> + <td>?{$lang[default]|<strong><ste:get_translation for="yes" /></strong>|<ste:get_translation for="no" />}</td> + </tr> + </ste:foreach> + </tbody> + </table> + <div> + <input type="submit" name="delete" value="<ste:get_translation for='delete' />" /> <select name="really_delete"><option value="no" selected="selected"><ste:get_translation for="no" /></option><option value="yes"><ste:get_translation for="yes" /></option></select> + | + <input type="submit" name="make_default" value="<ste:get_translation for='make_default' />" /> + | + <input type="submit" name="add_language" value="<ste:get_translation for='add_language' />" /> <ste:instant_select name="language_to_add" array="all_langcodes" /> + </div> + </form> +</ste:block> 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." ); ?> |