summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-06-19 09:57:13 +0000
committerDries Buytaert <dries@buytaert.net>2004-06-19 09:57:13 +0000
commitc3a6f3dc545bf3befe8b1bad8ece4695d660128b (patch)
treedc88d4d472eaa11398f0398cb2ad552a5740ec4f
parenta42b84e5d690a82c897edf90b37045f0e3aa68a2 (diff)
downloadbrdo-c3a6f3dc545bf3befe8b1bad8ece4695d660128b.tar.gz
brdo-c3a6f3dc545bf3befe8b1bad8ece4695d660128b.tar.bz2
- Patch #8632 by Mohse: made the taxonomy select menus more flexible.
Specifically, it lets you edit more than one node's taxonomy within the same form. This patch also removes the behavior where taxonomy remembers your last choice for a given vocab and automatically selects it for you. That is poor behavior. If someone changes a date or author in a node, he is likely to inadvertently add taxo terms using with this 'feature'.
-rw-r--r--modules/taxonomy.module21
-rw-r--r--modules/taxonomy/taxonomy.module21
2 files changed, 8 insertions, 34 deletions
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index 9b27d6db5..f907edf64 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -311,7 +311,7 @@ function taxonomy_overview() {
/**
* Generate a form element for selecting terms from a vocabulary.
*/
-function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL) {
+function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL, $name = 'taxonomy') {
$vocabulary = taxonomy_get_vocabulary($vid);
$help = ($help) ? $help : $vocabulary->help;
if ($vocabulary->required) {
@@ -323,7 +323,7 @@ function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL) {
$help .= $error['taxonomy'];
- return _taxonomy_term_select($vocabulary->name, 'taxonomy', $value, $vid, $help, intval($vocabulary->multiple), $blank);
+ return _taxonomy_term_select($vocabulary->name, $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
}
/**
@@ -350,7 +350,7 @@ function taxonomy_get_vocabularies($type = '', $key = 'vid') {
/**
* Generate a form for selecting terms to associate with a node.
*/
-function taxonomy_node_form($type, $node = '', $error = array()) {
+function taxonomy_node_form($type, $node = '', $error = array(), $help = NULL, $name = 'taxonomy') {
if (!$node->taxonomy) {
if ($node->nid) {
$terms = array_keys(taxonomy_node_get_terms($node->nid));
@@ -365,7 +365,7 @@ function taxonomy_node_form($type, $node = '', $error = array()) {
$c = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type);
while ($vocabulary = db_fetch_object($c)) {
- $result[] .= taxonomy_form($vocabulary->vid, $terms, $error);
+ $result[] = taxonomy_form($vocabulary->vid, $terms, $error, $help, $name);
}
return $result ? $result : array();
}
@@ -673,19 +673,6 @@ function taxonomy_get_term($tid) {
function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
$tree = taxonomy_get_tree($vocabulary_id);
-
- // We store the last selected ID in a session variable:
- if (!$value) {
- $value = $_SESSION['vocabulary']["$vocabulary_id"];
- }
- else {
- $_SESSION['vocabulary']["$vocabulary_id"] = $value;
- }
-
- if ($blank) {
- $options[] = array('tid' => 0, 'name' => $blank);
- }
-
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 9b27d6db5..f907edf64 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -311,7 +311,7 @@ function taxonomy_overview() {
/**
* Generate a form element for selecting terms from a vocabulary.
*/
-function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL) {
+function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL, $name = 'taxonomy') {
$vocabulary = taxonomy_get_vocabulary($vid);
$help = ($help) ? $help : $vocabulary->help;
if ($vocabulary->required) {
@@ -323,7 +323,7 @@ function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL) {
$help .= $error['taxonomy'];
- return _taxonomy_term_select($vocabulary->name, 'taxonomy', $value, $vid, $help, intval($vocabulary->multiple), $blank);
+ return _taxonomy_term_select($vocabulary->name, $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
}
/**
@@ -350,7 +350,7 @@ function taxonomy_get_vocabularies($type = '', $key = 'vid') {
/**
* Generate a form for selecting terms to associate with a node.
*/
-function taxonomy_node_form($type, $node = '', $error = array()) {
+function taxonomy_node_form($type, $node = '', $error = array(), $help = NULL, $name = 'taxonomy') {
if (!$node->taxonomy) {
if ($node->nid) {
$terms = array_keys(taxonomy_node_get_terms($node->nid));
@@ -365,7 +365,7 @@ function taxonomy_node_form($type, $node = '', $error = array()) {
$c = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type);
while ($vocabulary = db_fetch_object($c)) {
- $result[] .= taxonomy_form($vocabulary->vid, $terms, $error);
+ $result[] = taxonomy_form($vocabulary->vid, $terms, $error, $help, $name);
}
return $result ? $result : array();
}
@@ -673,19 +673,6 @@ function taxonomy_get_term($tid) {
function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
$tree = taxonomy_get_tree($vocabulary_id);
-
- // We store the last selected ID in a session variable:
- if (!$value) {
- $value = $_SESSION['vocabulary']["$vocabulary_id"];
- }
- else {
- $_SESSION['vocabulary']["$vocabulary_id"] = $value;
- }
-
- if ($blank) {
- $options[] = array('tid' => 0, 'name' => $blank);
- }
-
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {