--- /home/axel/src/drupal-4.5.2/modules/taxonomy.module 2004-12-24 09:49:46.000000000 +0300
+++ modules/taxonomy.module 2005-03-09 22:07:14.000000000 +0300
@@ -212,7 +212,7 @@
$exclude[] = $edit['tid'];
if ($vocabulary->hierarchy == 1) {
- $form .= _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
+ $form .= _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude, $containers = false);
}
elseif ($vocabulary->hierarchy == 2) {
$form .= _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
@@ -222,8 +222,8 @@
if ($vocabulary->relations) {
$form .= _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, NULL, 1, '<'. t('none') .'>', array($edit['tid']));
}
-
$form .= form_textarea(t('Synonyms'), 'synonyms', implode("\n", taxonomy_get_synonyms($edit['tid'])), 30, 5, t('Synonyms of this term, one synonym per line.', array('%help-url' => url('admin/help/taxonomy', NULL, NULL, 'synonyms'))));
+ $form .= form_checkbox(t('Containter'), 'container', 1, $edit['container'], t('If enabled, term became as container for subterms, not real term.'));
$form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top.'));
$form .= form_hidden('vid', $vocabulary->vid);
$form .= form_submit(t('Submit'));
@@ -238,7 +238,7 @@
function taxonomy_save_term($edit) {
if ($edit['tid'] && $edit['name']) {
- $data = array('name' => $edit['name'], 'description' => $edit['description'], 'weight' => $edit['weight']);
+ $data = array('name' => $edit['name'], 'description' => $edit['description'], 'container' => $edit['container'], 'weight' => $edit['weight']);
db_query('UPDATE {term_data} SET '. _taxonomy_prepare_update($data) .' WHERE tid = %d', $edit['tid']);
module_invoke_all('taxonomy', 'update', 'term', $edit);
@@ -359,7 +359,7 @@
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 .= ($term->container ? '+' : ' '). _taxonomy_depth($term->depth) .' '. $term->name .' ('. l(t('edit term'), "admin/taxonomy/edit/term/$term->tid") .')
';
}
$rows[] = array(array('data' => $data, 'colspan' => 5));
}
@@ -732,7 +732,7 @@
return db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
}
-function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
+function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array(), $containers = true) {
$tree = taxonomy_get_tree($vocabulary_id);
if ($blank) {
$options[] = array('tid' => 0, 'name' => $blank);
@@ -740,7 +740,7 @@
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
- $options[] = array('tid' => $term->tid, 'name' => _taxonomy_depth($term->depth, '-').$term->name);
+ $options[] = array('tid' => $term->tid, 'name' => _taxonomy_depth($term->depth, '-').$term->name, 'container' => $term->container ? 1 : 0);
}
}
if (!$blank && !$value) {
@@ -751,7 +751,13 @@
if (count($options) > 0) {
foreach ($options as $option) {
- $select .= '';
+ if ($containers && $option['container']) {
+ $item = '';
+ }
+ else {
+ $item = '';
+ }
+ $select .= $item;
}
$size = min(12, count($options));