Setup items support labels nicely, as pioneered by Artanis

git-svn-id: file:///home/shish/svn/shimmie2/trunk@78 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-05-08 20:36:02 +00:00
parent 3d4e4f1b8e
commit ea9da95c7b
11 changed files with 69 additions and 76 deletions

View file

@ -27,8 +27,7 @@ class ImageIO extends Extension {
$thumbers['ImageMagick'] = "convert"; $thumbers['ImageMagick'] = "convert";
$sb = new SetupBlock("Thumbnailing"); $sb = new SetupBlock("Thumbnailing");
$sb->add_label("Engine: "); $sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
$sb->add_choice_option("thumb_engine", $thumbers);
$sb->add_label("<br>Size "); $sb->add_label("<br>Size ");
$sb->add_int_option("thumb_width"); $sb->add_int_option("thumb_width");
@ -38,9 +37,8 @@ class ImageIO extends Extension {
$sb->add_int_option("thumb_quality"); $sb->add_int_option("thumb_quality");
$sb->add_label(" % quality "); $sb->add_label(" % quality ");
$sb->add_label("<br>Max GD memory use: "); $sb->add_shorthand_int_option("thumb_gd_mem_limit", "<br>Max GD memory use: ");
$sb->add_shorthand_int_option("thumb_gd_mem_limit");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -62,8 +62,7 @@ class Index extends Extension {
$sb->add_int_option("index_height"); $sb->add_int_option("index_height");
$sb->add_label(" images"); $sb->add_label(" images");
$sb->add_label("<br>Image tooltip "); $sb->add_text_option("image_tip", "<br>Image tooltip ");
$sb->add_text_option("image_tip");
$event->panel->add_main_block($sb, 20); $event->panel->add_main_block($sb, 20);
} }

View file

@ -36,42 +36,67 @@ class SetupBlock extends Block {
public function add_label($text) { public function add_label($text) {
$this->body .= $text; $this->body .= $text;
} }
public function add_text_option($name) {
public function add_text_option($name, $label=null) {
global $config; global $config;
$val = $config->get_string($name); $val = $config->get_string($name);
$this->body .= "<input type='text' name='$name' value='$val'>\n"; if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
$this->body .= "<input type='text' id='$name' name='$name' value='$val'>\n";
} }
public function add_longtext_option($name) {
public function add_longtext_option($name, $label=null) {
global $config; global $config;
$val = $config->get_string($name); $val = $config->get_string($name);
$this->body .= "<textarea rows='5' cols='40' name='$name'>$val</textarea>\n"; if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
$this->body .= "<textarea rows='5' cols='40' id='$name' name='$name'>$val</textarea>\n";
$this->body .= "<!--<br><br><br><br>-->\n"; // setup page auto-layout counts <br> tags $this->body .= "<!--<br><br><br><br>-->\n"; // setup page auto-layout counts <br> tags
} }
public function add_bool_option($name) {
public function add_bool_option($name, $label=null) {
global $config; global $config;
$checked = $config->get_bool($name) ? " checked" : ""; $checked = $config->get_bool($name) ? " checked" : "";
$this->body .= "<input type='checkbox' name='$name'$checked>\n"; if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
$this->body .= "<input type='checkbox' id='$name' name='$name'$checked>\n";
} }
public function add_hidden_option($name) {
public function add_hidden_option($name, $label=null) {
global $config; global $config;
$val = $config->get_string($name); $val = $config->get_string($name);
$this->body .= "<input type='hidden' name='$name' value='$val'>"; $this->body .= "<input type='hidden' id='$name' name='$name' value='$val'>";
} }
public function add_int_option($name) {
public function add_int_option($name, $label=null) {
global $config; global $config;
$val = $config->get_string($name); $val = $config->get_string($name);
$this->body .= "<input type='text' name='$name' value='$val' size='4' style='text-align: center;'>\n"; if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
$this->body .= "<input type='text' id='$name' name='$name' value='$val' size='4' style='text-align: center;'>\n";
} }
public function add_shorthand_int_option($name) {
public function add_shorthand_int_option($name, $label=null) {
global $config; global $config;
$val = to_shorthand_int($config->get_string($name)); $val = to_shorthand_int($config->get_string($name));
$this->body .= "<input type='text' name='$name' value='$val' size='6' style='text-align: center;'>\n"; if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
$this->body .= "<input type='text' id='$name' name='$name' value='$val' size='6' style='text-align: center;'>\n";
} }
public function add_choice_option($name, $options) {
public function add_choice_option($name, $options, $label=null) {
global $config; global $config;
$current = $config->get_string($name); $current = $config->get_string($name);
$html = "<select name='$name'>"; if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
$html = "<select id='$name' name='$name'>";
foreach($options as $optname => $optval) { foreach($options as $optname => $optval) {
if($optval == $current) $selected=" selected"; if($optval == $current) $selected=" selected";
else $selected=""; else $selected="";
@ -122,20 +147,13 @@ class Setup extends Extension {
} }
$sb = new SetupBlock("General"); $sb = new SetupBlock("General");
$sb->add_label("Site title: "); $sb->add_text_option("title", "Site title: ");
$sb->add_text_option("title"); $sb->add_text_option("front_page", "<br>Front page: ");
$sb->add_label("<br>Front page: "); $sb->add_text_option("base_href", "<br>Base URL: ");
$sb->add_text_option("front_page"); $sb->add_text_option("data_href", "<br>Data URL: ");
$sb->add_label("<br>Base URL: "); $sb->add_text_option("contact_link", "<br>Contact URL:");
$sb->add_text_option("base_href"); $sb->add_choice_option("theme", $themes, "<br>Theme: ");
$sb->add_label("<br>Data URL: "); // $sb->add_int_option("anon_id", "<br>Anonymous ID: "); // FIXME: create advanced options page
$sb->add_text_option("data_href");
$sb->add_label("<br>Contact URL: ");
$sb->add_text_option("contact_link");
$sb->add_label("<br>Theme: ");
$sb->add_choice_option("theme", $themes);
// $sb->add_label("<br>Anonymous ID: ");
// $sb->add_int_option("anon_id", 0, 100000);
$sb->add_hidden_option("anon_id"); $sb->add_hidden_option("anon_id");
$event->panel->add_main_block($sb, 0); $event->panel->add_main_block($sb, 0);
} }

View file

@ -59,8 +59,7 @@ class TagEdit extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Tag Editing"); $sb = new SetupBlock("Tag Editing");
$sb->add_label("Allow anonymous editing: "); $sb->add_bool_option("tag_edit_anon", "Allow anonymous editing: ");
$sb->add_bool_option("tag_edit_anon");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -31,12 +31,9 @@ class Upload extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Upload"); $sb = new SetupBlock("Upload");
$sb->add_label("Max Uploads: "); $sb->add_int_option("upload_count", "Max uploads: ");
$sb->add_int_option("upload_count"); $sb->add_shorthand_int_option("upload_size", "<br>Max size per file: ");
$sb->add_label("<br>Max size per file: "); $sb->add_bool_option("upload_anon", "<br>Allow anonymous upoads: ");
$sb->add_shorthand_int_option("upload_size");
$sb->add_label("<br>Allow anonymous upoads: ");
$sb->add_bool_option("upload_anon");
$event->panel->add_main_block($sb, 10); $event->panel->add_main_block($sb, 10);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -56,13 +56,9 @@ class UserPage extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("User Options"); $sb = new SetupBlock("User Options");
$sb->add_label("Login memory: "); $sb->add_int_option("login_memory", "Login memory: "); $sb->add_label(" days");
$sb->add_int_option("login_memory"); $sb->add_bool_option("login_signup_enabled", "<br>Allow new signups: ");
$sb->add_label(" days"); $sb->add_longtext_option("login_tac", "<br>Terms &amp; Conditions:<br>");
$sb->add_label("<br>Allow new signups: ");
$sb->add_bool_option("login_signup_enabled");
$sb->add_label("<br>Terms &amp; Conditions:<br>");
$sb->add_longtext_option("login_tac");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -35,12 +35,9 @@ class ViewImage extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("View Options"); $sb = new SetupBlock("View Options");
$sb->add_label("Long link "); $sb->add_text_option("image_ilink", "Long link ");
$sb->add_text_option("image_ilink"); $sb->add_text_option("image_slink", "<br>Short link ");
$sb->add_label("<br>Short link "); $sb->add_text_option("image_tlink", "<br>Thumbnail link ");
$sb->add_text_option("image_slink");
$sb->add_label("<br>Thumbnail link ");
$sb->add_text_option("image_tlink");
$event->panel->add_main_block($sb, 30); $event->panel->add_main_block($sb, 30);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -103,8 +103,7 @@ class CommentList extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Comment Options"); $sb = new SetupBlock("Comment Options");
$sb->add_label("Allow anonymous comments "); $sb->add_bool_option("comment_anon", "Allow anonymous comments: ");
$sb->add_bool_option("comment_anon");
$sb->add_label("<br>Limit to "); $sb->add_label("<br>Limit to ");
$sb->add_int_option("comment_limit"); $sb->add_int_option("comment_limit");
$sb->add_label(" comments per "); $sb->add_label(" comments per ");
@ -113,8 +112,7 @@ class CommentList extends Extension {
$sb->add_label("<br>Show "); $sb->add_label("<br>Show ");
$sb->add_int_option("comment_count"); $sb->add_int_option("comment_count");
$sb->add_label(" recent comments on the index"); $sb->add_label(" recent comments on the index");
$sb->add_label("<br>Akismet Key "); $sb->add_text_option("comment_wordpress_key", "<br>Akismet Key ");
$sb->add_text_option("comment_wordpress_key");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -7,10 +7,8 @@ class Downtime extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Downtime"); $sb = new SetupBlock("Downtime");
$sb->add_label("Disable non-admin access: "); $sb->add_bool_option("downtime", "Disable non-admin access: ");
$sb->add_bool_option("downtime"); $sb->add_longtext_option("downtime_message", "<br>");
$sb->add_label("<br>");
$sb->add_longtext_option("downtime_message");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -44,19 +44,13 @@ class TagList extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Tag Map Options"); $sb = new SetupBlock("Tag Map Options");
$sb->add_label("Ignore tags used fewer than "); $sb->add_int_option("tags_min", "Ignore tags used fewer than "); $sb->add_label(" times");
$sb->add_int_option("tags_min", 0, 99);
$sb->add_label(" times");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
$sb = new SetupBlock("Popular / Related Tag List"); $sb = new SetupBlock("Popular / Related Tag List");
$sb->add_label("Show top "); $sb->add_int_option("tag_list_length", "Show top "); $sb->add_label(" tags");
$sb->add_int_option("tag_list_length"); $sb->add_text_option("info_link", "<br>Tag info link: ");
$sb->add_label(" tags"); $sb->add_bool_option("tag_list_numbers", "<br>Show tag counts: ");
$sb->add_label("<br>Tag info link: ");
$sb->add_text_option("info_link");
$sb->add_label("<br>Show tag counts: ");
$sb->add_bool_option("tag_list_numbers");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {

View file

@ -9,8 +9,7 @@ class Zoom extends Extension {
if(is_a($event, 'SetupBuildingEvent')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Image Zoom"); $sb = new SetupBlock("Image Zoom");
$sb->add_label("Zoom by default: "); $sb->add_bool_option("image_zoom", "Zoom by default: ");
$sb->add_bool_option("image_zoom");
$event->panel->add_main_block($sb); $event->panel->add_main_block($sb);
} }
if(is_a($event, 'ConfigSaveEvent')) { if(is_a($event, 'ConfigSaveEvent')) {