diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-01-31 15:49:26 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-01-31 15:49:26 +0000 |
commit | 05a708fb06137758cf7a15a623b4813af2fc005f (patch) | |
tree | 6ae6f50edbcb601329805cbbd7c22d11340327e3 /modules/taxonomy | |
parent | 4c9fc80fc48608982a731b03655b02e5ccdb6b17 (diff) | |
download | brdo-05a708fb06137758cf7a15a623b4813af2fc005f.tar.gz brdo-05a708fb06137758cf7a15a623b4813af2fc005f.tar.bz2 |
- Patch #112715 by chx, webchick, asimmonds, et al: fixing E_ALL notices. Thanks.
Diffstat (limited to 'modules/taxonomy')
-rw-r--r-- | modules/taxonomy/taxonomy.module | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 6df04ac84..ed05eb8bb 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -296,7 +296,7 @@ function taxonomy_form_vocabulary_submit($form_id, $form_values) { function taxonomy_save_vocabulary(&$edit) { $edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes']; - if ($edit['vid'] && $edit['name']) { + if (!empty($edit['vid']) && !empty($edit['name'])) { db_query("UPDATE {vocabulary} SET name = '%s', description = '%s', help = '%s', multiple = %d, required = %d, hierarchy = %d, relations = %d, tags = %d, weight = %d, module = '%s' WHERE vid = %d", $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy', $edit['vid']); db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']); foreach ($edit['nodes'] as $type => $selected) { @@ -305,12 +305,12 @@ function taxonomy_save_vocabulary(&$edit) { module_invoke_all('taxonomy', 'update', 'vocabulary', $edit); $status = SAVED_UPDATED; } - else if ($edit['vid']) { + else if (!empty($edit['vid'])) { $status = taxonomy_del_vocabulary($edit['vid']); } else { $edit['vid'] = db_next_id('{vocabulary}_vid'); - db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy'); + db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], isset($edit['description']) ? $edit['description'] : NULL, isset($edit['help']) ? $edit['help'] : NULL, $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], isset($edit['tags']) ? $edit['tags'] : NULL, $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy'); foreach ($edit['nodes'] as $type => $selected) { db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type); } @@ -657,12 +657,7 @@ function taxonomy_form_alter($form_id, &$form) { $node = $form['#node']; if (!isset($node->taxonomy)) { - if ($node->nid) { - $terms = taxonomy_node_get_terms($node->nid); - } - else { - $terms = array(); - } + $terms = empty($node->nid) ? array() : taxonomy_node_get_terms($node->nid); } else { $terms = $node->taxonomy; @@ -716,7 +711,7 @@ function taxonomy_form_alter($form_id, &$form) { $form['taxonomy'][$vocabulary->vid]['#required'] = $vocabulary->required; } } - if (is_array($form['taxonomy']) && !empty($form['taxonomy'])) { + if (!empty($form['taxonomy']) && is_array($form['taxonomy'])) { if (count($form['taxonomy']) > 1) { // Add fieldset only if form has more than 1 element. $form['taxonomy'] += array( '#type' => 'fieldset', @@ -768,7 +763,7 @@ function taxonomy_node_validate(&$node) { if ($terms['tags']) { foreach ($terms['tags'] as $vid => $vid_value) { $vocabulary = taxonomy_get_vocabulary($vid); - if (!$vocabulary->tags) { + if (empty($vocabulary->tags)) { // see form_get_error $key = implode('][', $element['#parents']); // on why this is the key form_set_error("taxonomy][tags][$vid", t('The %name vocabulary can not be modified in this way.', array('%name' => $vocabulary->name))); @@ -976,7 +971,8 @@ function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) { } $max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth; - if ($children[$vid][$parent]) { + $tree = array(); + if (!empty($children[$vid][$parent])) { foreach ($children[$vid][$parent] as $child) { if ($max_depth > $depth) { $term = drupal_clone($terms[$vid][$child]); @@ -986,14 +982,14 @@ function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) { $term->parents = $parents[$vid][$child]; $tree[] = $term; - if ($children[$vid][$child]) { + if (!empty($children[$vid][$child])) { $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth)); } } } } - return $tree ? $tree : array(); + return $tree; } /** |