From 20208535248a248436465213dd05b9046a8ad237 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 29 Dec 2002 15:37:36 +0000 Subject: [PATCH] - Usability improvements: made the taxonomy administration pages use the new table rendering functions, made the overview table's HTML code a lot simpler, tidied up the status messages, and removed some redundant check_output()s. --- modules/taxonomy.module | 22 ++++++++-------------- modules/taxonomy/taxonomy.module | 22 ++++++++-------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 433a7ebf101..e7571858b20 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -173,7 +173,7 @@ function taxonomy_save_term($edit) { $data = array("name" => $edit["name"], "description" => $edit["description"], "weight" => $edit["weight"]); db_query("UPDATE term_data SET ". _prepare_update($data) ." WHERE tid = '%d'", $edit["tid"]); - $message = t("Term %a updated.", array("%a" => $edit["name"])); + $message = t("the term '%a' has been updated.", array("%a" => $edit["name"])); } else if ($edit["tid"]) { return taxonomy_del_term($edit["tid"]); @@ -182,7 +182,6 @@ function taxonomy_save_term($edit) { $edit["tid"] = db_next_id("term_data"); $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]); db_query("INSERT INTO term_data ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2)); - $message = t("created new term '%name'.", array("%name" => $edit["name"])); } @@ -210,7 +209,6 @@ function taxonomy_save_term($edit) { db_query("INSERT INTO term_hierarchy (tid, parent) VALUES ('%d', '%d')", $edit["tid"], $edit["parent"][0]); } - // synonyms (very cool idea indeed) db_query("DELETE FROM term_synonym WHERE tid = '%d'", $edit["tid"]); if ($edit["synonyms"]) { foreach (explode ("\n", str_replace("\r", "", $edit["synonyms"])) as $synonym) { @@ -255,30 +253,26 @@ function taxonomy_overview() { global $tree; $output .= "

" . t("Vocabularies overview") . "

"; - $output .= "\n"; - $output .= " \n"; + + $header = array(t("name"), t("node types"), array("data" => t("operations"), "colspan" => 3)); $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vocabulary) { $links = array(); - $links[] = la(t("edit vocabulary"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "edit", "id" => $vocabulary->vid)); - $links[] = la(t("add term"), array("mod" => "taxonomy", "op" => "add", "type" => "leaf", "vocabulary_id" => $vocabulary->vid)); - $links[] = la(t("preview form"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "preview", "id" => $vocabulary->vid)); - $output .= " \n"; + $rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), la(t("edit vocabulary"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "edit", "id" => $vocabulary->vid)), la(t("add term"), array("mod" => "taxonomy", "op" => "add", "type" => "leaf", "vocabulary_id" => $vocabulary->vid)), la(t("preview form"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "preview", "id" => $vocabulary->vid))); $tree = taxonomy_get_tree($vocabulary->vid); if ($tree) { - $output .= "\n"; + $rows[] = array(array("data" => $data, "colspan" => 5)); } } - $output .= "
" . t("name") . "" . t("node types") . "" . t("operations") . "
". check_output($vocabulary->name) ."". check_output($vocabulary->types) ."". implode(" | ", $links) ."
"; + $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". la(t("edit term"), array("mod" => "taxonomy", "op" => "edit", "type" => "term", "id" => check_output($term->tid))) .")
"; } - $output .= "
"; + unset($data); foreach ($tree as $term) { - $output .= "
". la(_taxonomy_depth($term->depth) . check_output($term->name), array("mod" => "taxonomy", "op" => "edit", "type" => "term", "id" => check_output($term->tid))) ."
\n"; - return $output; + return table($header, $rows); } function taxonomy_form($vocabulary_id, $value = 0) { diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 433a7ebf101..e7571858b20 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -173,7 +173,7 @@ function taxonomy_save_term($edit) { $data = array("name" => $edit["name"], "description" => $edit["description"], "weight" => $edit["weight"]); db_query("UPDATE term_data SET ". _prepare_update($data) ." WHERE tid = '%d'", $edit["tid"]); - $message = t("Term %a updated.", array("%a" => $edit["name"])); + $message = t("the term '%a' has been updated.", array("%a" => $edit["name"])); } else if ($edit["tid"]) { return taxonomy_del_term($edit["tid"]); @@ -182,7 +182,6 @@ function taxonomy_save_term($edit) { $edit["tid"] = db_next_id("term_data"); $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]); db_query("INSERT INTO term_data ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2)); - $message = t("created new term '%name'.", array("%name" => $edit["name"])); } @@ -210,7 +209,6 @@ function taxonomy_save_term($edit) { db_query("INSERT INTO term_hierarchy (tid, parent) VALUES ('%d', '%d')", $edit["tid"], $edit["parent"][0]); } - // synonyms (very cool idea indeed) db_query("DELETE FROM term_synonym WHERE tid = '%d'", $edit["tid"]); if ($edit["synonyms"]) { foreach (explode ("\n", str_replace("\r", "", $edit["synonyms"])) as $synonym) { @@ -255,30 +253,26 @@ function taxonomy_overview() { global $tree; $output .= "

" . t("Vocabularies overview") . "

"; - $output .= "\n"; - $output .= " \n"; + + $header = array(t("name"), t("node types"), array("data" => t("operations"), "colspan" => 3)); $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vocabulary) { $links = array(); - $links[] = la(t("edit vocabulary"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "edit", "id" => $vocabulary->vid)); - $links[] = la(t("add term"), array("mod" => "taxonomy", "op" => "add", "type" => "leaf", "vocabulary_id" => $vocabulary->vid)); - $links[] = la(t("preview form"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "preview", "id" => $vocabulary->vid)); - $output .= " \n"; + $rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), la(t("edit vocabulary"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "edit", "id" => $vocabulary->vid)), la(t("add term"), array("mod" => "taxonomy", "op" => "add", "type" => "leaf", "vocabulary_id" => $vocabulary->vid)), la(t("preview form"), array("mod" => "taxonomy", "type" => "vocabulary", "op" => "preview", "id" => $vocabulary->vid))); $tree = taxonomy_get_tree($vocabulary->vid); if ($tree) { - $output .= "\n"; + $rows[] = array(array("data" => $data, "colspan" => 5)); } } - $output .= "
" . t("name") . "" . t("node types") . "" . t("operations") . "
". check_output($vocabulary->name) ."". check_output($vocabulary->types) ."". implode(" | ", $links) ."
"; + $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". la(t("edit term"), array("mod" => "taxonomy", "op" => "edit", "type" => "term", "id" => check_output($term->tid))) .")
"; } - $output .= "
"; + unset($data); foreach ($tree as $term) { - $output .= "
". la(_taxonomy_depth($term->depth) . check_output($term->name), array("mod" => "taxonomy", "op" => "edit", "type" => "term", "id" => check_output($term->tid))) ."
\n"; - return $output; + return table($header, $rows); } function taxonomy_form($vocabulary_id, $value = 0) {