From d626a6cfda1429eb7c23af068f2e6755e7df7641 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 29 Dec 2002 16:03:01 +0000 Subject: CHANGES: - Usability improvement: made the block administration pages use the new table rendering functions. By the way, the old code rendered invalid HTML code. - Usability improvement: saving block changes will now show a status message. - Usability improvement: quite a few strings could not be translated. TODO: - I think the "enabled" and "custom" field are somewhat confusing. Suggestions? --- modules/block.module | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'modules/block.module') diff --git a/modules/block.module b/modules/block.module index be7ac7644..2fcd5d1ea 100644 --- a/modules/block.module +++ b/modules/block.module @@ -81,11 +81,7 @@ function block_admin_save($edit) { } } - /* - ** Clear the cache so the changes take effect for anonymous users. - */ - - cache_clear_all(); + return t("the block settings have been updated."); } /** @@ -139,29 +135,21 @@ function _block_rehash($order_by = array("weight")) { } function block_admin_display() { - // Generate output: - $output = "\n"; - $output .= "\n"; $blocks = _block_rehash(); + $header = array(t("block"), t("enabled"), t("custom"), t("weight"), t("region"), t("path"), array("data" => "operations", "colspan" => 2)); + foreach ($blocks as $block) { - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - if ($block["module"] == 'block') { - $output .= ""; - $output .= ""; + if ($block["module"] == "block") { + $edit = la(t("edit"), array("mod" => "block", "op" => "edit", "id" => $block["delta"])); + $delete = la(t("delete"), array("mod" => "block", "op" => "delete", "id" => $block["delta"])); } - $output .= "\n"; + + $rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array("left", "right")), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete); } - $output .= "
blockmoduleenabledcustomweightregionpathoperations
".$block["info"]."". (module_hook($block["module"], "admin") ? la($block["module"], array("mod" => $block["module"]), "", array("title" => t("Administer module"))) : $block["module"]) ."". form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]) ."". form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]) ."". form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]) ."". form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array("left", "right")) ."". form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255) ."". la(t("edit"), array("mod" => "block", "op" => "edit", "id" => $block["delta"])) ."". la(t("delete"), array("mod" => "block", "op" => "delete", "id" => $block["delta"])) ."
\n"; + $output = table($header, $rows); $output .= form_submit("Save blocks"); print form($output); @@ -250,18 +238,18 @@ function block_box_save($edit) { if ($edit["bid"]) { db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = '%s' WHERE bid = '%s'", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]); - return "block updated."; + return t("the block has been updated."); } else { db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', '%s')", $edit["title"], $edit["body"], $edit["info"], $edit["type"]); - return "block added."; + return t("the new block has been added."); } } function block_box_delete($bid) { if ($bid) { db_query("DELETE FROM boxes WHERE bid = '%s'", $bid); - return "block deleted."; + return t("the block has been deleted."); } } @@ -287,14 +275,17 @@ function block_admin() { case "delete": global $id; print status(block_box_delete($id)); + cache_clear_all(); block_admin_display(); break; case "Save block": print status(block_box_save($edit)); + cache_clear_all(); block_admin_display(); break; case "Save blocks": - block_admin_save($edit); + print status(block_admin_save($edit)); + cache_clear_all(); // fall through default: block_admin_display(); -- cgit v1.2.3