From 0b7cecd5b694b1937c29c7ea2ca996f1137c3efc Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 27 Feb 2003 23:43:50 +0000 Subject: [PATCH] - Some fixes and improvements to the taxonomy module. Patch by Al. --- modules/taxonomy.module | 35 +++++++++++++++----------------- modules/taxonomy/taxonomy.module | 35 +++++++++++++++----------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 9917281fa84..4a0399165c7 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -28,11 +28,11 @@ function taxonomy_perm() { function taxonomy_link($type, $node = NULL) { if ($type == "admin" && user_access("administer taxonomy")) { - $help["taxonomy"] = "The taxonomy module allows you to classify post into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically)."; + $help["taxonomy"] = "The taxonomy module allows you to classify posts into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically)."; $help["vocabulary"] = "When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node of content (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories."; menu("admin/taxonomy", "taxonomy", "taxonomy_admin", $help["taxonomy"], 3); - menu("admin/taxonomy/create vocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]); + menu("admin/taxonomy/addvocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]); menu("admin/taxonomy/help", "help", "taxonomy_admin", NULL, 9); } else if ($type == "taxonomy terms" && $node != NULL) { @@ -85,7 +85,6 @@ function taxonomy_form_vocabulary($edit = array()) { function taxonomy_save_vocabulary($edit) { $data = array("name" => $edit["name"], "types" => @implode(",", $edit["types"]), "description" => $edit["description"], "multiple" => $edit["multiple"], "required" => $edit["required"], "hierarchy" => $edit["hierarchy"], "relations" => $edit["relations"], "weight" => $edit["weight"]); - if ($edit["vid"] && $edit["name"]) { db_query("UPDATE vocabulary SET ". _prepare_update($data) ." WHERE vid = '%d'", $edit["vid"]); module_invoke_all("taxonomy", "update", "vocabulary", $edit); @@ -135,7 +134,7 @@ function _taxonomy_confirm_del_vocabulary($vid) { } function taxonomy_form_term($edit = array()) { - $vocabulary_id = arg(4); + $vocabulary_id = arg(3); if (!$vocabulary_id) { $vocabulary_id = $edit["vid"]; @@ -181,7 +180,7 @@ function taxonomy_form_term($edit = array()) { } function taxonomy_save_term($edit) { - if ($edit["tid"] && $edit["name"]) { + if ($edit["tid"] && $edit["name"]) { $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"]); @@ -274,13 +273,13 @@ function taxonomy_overview() { foreach ($vocabularies as $vocabulary) { $links = array(); - $rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/add term/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid")); + $rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/editvocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/addterm/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid")); $tree = taxonomy_get_tree($vocabulary->vid); if ($tree) { unset($data); foreach ($tree as $term) { - $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/edit/term/$term->tid") .")
"; + $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/editterm/$term->tid") .")
"; } $rows[] = array(array("data" => $data, "colspan" => 5)); } @@ -716,19 +715,17 @@ function taxonomy_admin() { } switch ($op) { - case "create vocabulary": + case "addvocabulary": print taxonomy_form_vocabulary(); break; - case "add term": + case "addterm": print taxonomy_form_term(); break; - case "edit": - if (arg(3) == "vocabulary") { - print taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4)))); - } - else { - print taxonomy_form_term(object2array(taxonomy_get_term(arg(4)))); - } + case "editvocabulary": + print taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(3)))); + break; + case "editterm": + print taxonomy_form_term(object2array(taxonomy_get_term(arg(3)))); break; case "preview": print taxonomy_form(arg(4)); @@ -751,7 +748,7 @@ function taxonomy_admin() { // fall through: } case t("Submit"): - if (arg(3) == "vocabulary") { + if (arg(2) == "addvocabulary" || arg(2) == "editvocabulary") { print status(taxonomy_save_vocabulary($edit)); } else { @@ -828,10 +825,10 @@ function taxonomy_help() { Synonyms
Optional. Enter synonyms for this term, one synonym per line. Synonyms can be used for variant spellings, acronyms, and other terms that have the same meaning as the added term, but which are not explicitly listed in this thesaurus (i.e. unauthorized terms).

Displaying nodes organized by term(s)

-

In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed URL. For example, see ">. Taxonomy URLs always contain a term ID or list of term IDs at the end of the URL (aka querystring). You may learn the term ID for a given term by hovering over that term in the page in the Admin and noting the number after the querystring parameter called tid. If you wish to see nodes from a collection of term IDs, separate each term ID with a comma. Also, the name of the querystring parameter may be or or and: or shows nodes which appear in any of the term IDs while and shows nodes in all the specified term IDs. Thus, or is less specific than and.

+

In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed URL. For example, see ">. Taxonomy URLs always contain a term ID or list of term IDs at the end of the URL (aka querystring). You may learn the term ID for a given term by hovering over that term in the page in the Admin and noting the number after the querystring parameter called tid. If you wish to see nodes from a collection of term IDs, separate each term ID with a comma. Also, the name of the querystring parameter may be or or and: or shows nodes which appear in any of the term IDs while and shows nodes in all the specified term IDs. Thus, or is less specific than and.

RSS feeds

-

Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for an sample RSS feed is ">.

+

Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for an sample RSS feed is ">.

diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 9917281fa84..4a0399165c7 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -28,11 +28,11 @@ function taxonomy_perm() { function taxonomy_link($type, $node = NULL) { if ($type == "admin" && user_access("administer taxonomy")) { - $help["taxonomy"] = "The taxonomy module allows you to classify post into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically)."; + $help["taxonomy"] = "The taxonomy module allows you to classify posts into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically)."; $help["vocabulary"] = "When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node of content (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories."; menu("admin/taxonomy", "taxonomy", "taxonomy_admin", $help["taxonomy"], 3); - menu("admin/taxonomy/create vocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]); + menu("admin/taxonomy/addvocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]); menu("admin/taxonomy/help", "help", "taxonomy_admin", NULL, 9); } else if ($type == "taxonomy terms" && $node != NULL) { @@ -85,7 +85,6 @@ function taxonomy_form_vocabulary($edit = array()) { function taxonomy_save_vocabulary($edit) { $data = array("name" => $edit["name"], "types" => @implode(",", $edit["types"]), "description" => $edit["description"], "multiple" => $edit["multiple"], "required" => $edit["required"], "hierarchy" => $edit["hierarchy"], "relations" => $edit["relations"], "weight" => $edit["weight"]); - if ($edit["vid"] && $edit["name"]) { db_query("UPDATE vocabulary SET ". _prepare_update($data) ." WHERE vid = '%d'", $edit["vid"]); module_invoke_all("taxonomy", "update", "vocabulary", $edit); @@ -135,7 +134,7 @@ function _taxonomy_confirm_del_vocabulary($vid) { } function taxonomy_form_term($edit = array()) { - $vocabulary_id = arg(4); + $vocabulary_id = arg(3); if (!$vocabulary_id) { $vocabulary_id = $edit["vid"]; @@ -181,7 +180,7 @@ function taxonomy_form_term($edit = array()) { } function taxonomy_save_term($edit) { - if ($edit["tid"] && $edit["name"]) { + if ($edit["tid"] && $edit["name"]) { $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"]); @@ -274,13 +273,13 @@ function taxonomy_overview() { foreach ($vocabularies as $vocabulary) { $links = array(); - $rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/add term/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid")); + $rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/editvocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/addterm/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid")); $tree = taxonomy_get_tree($vocabulary->vid); if ($tree) { unset($data); foreach ($tree as $term) { - $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/edit/term/$term->tid") .")
"; + $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/editterm/$term->tid") .")
"; } $rows[] = array(array("data" => $data, "colspan" => 5)); } @@ -716,19 +715,17 @@ function taxonomy_admin() { } switch ($op) { - case "create vocabulary": + case "addvocabulary": print taxonomy_form_vocabulary(); break; - case "add term": + case "addterm": print taxonomy_form_term(); break; - case "edit": - if (arg(3) == "vocabulary") { - print taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4)))); - } - else { - print taxonomy_form_term(object2array(taxonomy_get_term(arg(4)))); - } + case "editvocabulary": + print taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(3)))); + break; + case "editterm": + print taxonomy_form_term(object2array(taxonomy_get_term(arg(3)))); break; case "preview": print taxonomy_form(arg(4)); @@ -751,7 +748,7 @@ function taxonomy_admin() { // fall through: } case t("Submit"): - if (arg(3) == "vocabulary") { + if (arg(2) == "addvocabulary" || arg(2) == "editvocabulary") { print status(taxonomy_save_vocabulary($edit)); } else { @@ -828,10 +825,10 @@ function taxonomy_help() { Synonyms
Optional. Enter synonyms for this term, one synonym per line. Synonyms can be used for variant spellings, acronyms, and other terms that have the same meaning as the added term, but which are not explicitly listed in this thesaurus (i.e. unauthorized terms).

Displaying nodes organized by term(s)

-

In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed URL. For example, see ">. Taxonomy URLs always contain a term ID or list of term IDs at the end of the URL (aka querystring). You may learn the term ID for a given term by hovering over that term in the page in the Admin and noting the number after the querystring parameter called tid. If you wish to see nodes from a collection of term IDs, separate each term ID with a comma. Also, the name of the querystring parameter may be or or and: or shows nodes which appear in any of the term IDs while and shows nodes in all the specified term IDs. Thus, or is less specific than and.

+

In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed URL. For example, see ">. Taxonomy URLs always contain a term ID or list of term IDs at the end of the URL (aka querystring). You may learn the term ID for a given term by hovering over that term in the page in the Admin and noting the number after the querystring parameter called tid. If you wish to see nodes from a collection of term IDs, separate each term ID with a comma. Also, the name of the querystring parameter may be or or and: or shows nodes which appear in any of the term IDs while and shows nodes in all the specified term IDs. Thus, or is less specific than and.

RSS feeds

-

Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for an sample RSS feed is ">.

+

Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for an sample RSS feed is ">.