Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.49
diff -u -r1.49 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc 13 Jan 2010 23:19:54 -0000 1.49
+++ modules/taxonomy/taxonomy.pages.inc 15 Jan 2010 13:17:27 -0000
@@ -28,18 +28,13 @@
$breadcrumb = array_reverse($breadcrumb);
drupal_set_breadcrumb($breadcrumb);
drupal_add_feed(url('taxonomy/term/' . $term->tid . '/feed'), 'RSS - ' . $term->name);
- drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
- field_attach_prepare_view('taxonomy_term', array($term->tid => $term), 'full');
- entity_prepare_view('taxonomy_term', array($term->tid => $term));
- $build = array();
- $build += field_attach_view('taxonomy_term', $term);
- $build['term_description'] = array(
- '#markup' => check_markup($term->description, $term->format, '', TRUE),
- '#weight' => -1,
- '#prefix' => '
',
+ $build['term_heading'] = array(
+ '#prefix' => '
',
'#suffix' => '
',
+ 'term' => taxonomy_term_view($term, 'full'),
);
+
if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
$nodes = node_load_multiple($nids);
$build += node_view_multiple($nodes);
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.567
diff -u -r1.567 taxonomy.module
--- modules/taxonomy/taxonomy.module 15 Jan 2010 10:49:46 -0000 1.567
+++ modules/taxonomy/taxonomy.module 15 Jan 2010 13:17:27 -0000
@@ -137,6 +137,30 @@
}
/**
+ * Implements hook_field_extra_fields().
+ */
+function taxonomy_field_extra_fields() {
+ $return = array();
+
+ foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) {
+ $return['taxonomy_term'][$machine_name] = array(
+ 'name' => array(
+ 'label' => t('Name'),
+ 'description' => t('Term name textfield'),
+ 'weight' => -5,
+ ),
+ 'description' => array(
+ 'label' => t('Description'),
+ 'description' => t('Term description textarea'),
+ 'weight' => 0,
+ )
+ );
+ }
+
+ return $return;
+}
+
+/**
* Return nodes attached to a term across all field instances.
*
* This function requires taxonomy module to be maintaining its own tables,
@@ -201,6 +225,10 @@
'taxonomy_overview_terms' => array(
'render element' => 'form',
),
+ 'taxonomy_term' => array(
+ 'render element' => 'elements',
+ 'template' => 'taxonomy-term',
+ ),
);
}
@@ -561,6 +589,86 @@
return SAVED_DELETED;
}
+
+/**
+ * Generate an array for rendering the given term.
+ *
+ * @param $term
+ * A term object.
+ * @param $view_mode
+ * View mode, e.g. 'full', 'teaser'...
+ *
+ * @return
+ * An array as expected by drupal_render().
+ */
+function taxonomy_term_view($term, $view_mode = 'full') {
+ field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode);
+ entity_prepare_view('taxonomy_term', array($term->tid => $term));
+
+ $build = array(
+ '#theme' => 'taxonomy_term',
+ '#term' => $term,
+ '#view_mode' => $view_mode,
+ );
+
+ $build += field_attach_view('taxonomy_term', $term, $view_mode);
+
+ $build['description'] = array(
+ '#markup' => check_markup($term->description, $term->format, '', TRUE),
+ '#weight' => 0,
+ '#prefix' => '
',
+ '#suffix' => '
',
+ );
+
+ $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/taxonomy.css';
+
+ return $build;
+}
+
+function template_preprocess_taxonomy_term(&$variables) {
+ $variables['view_mode'] = $variables['elements']['#view_mode'];
+ $variables['term'] = $variables['elements']['#term'];
+ $term = $variables['term'];
+
+ $variables['term_url'] = url('taxonomy/term/' . $term->tid);
+ $variables['term_name'] = check_plain($term->name);
+ $variables['page'] = taxonomy_term_is_page($term);
+
+ // Flatten the term object's member fields.
+ $variables = array_merge((array)$term, $variables);
+
+ // Helpful $content variable for templates.
+ foreach (element_children($variables['elements']) as $key) {
+ $variables['content'][$key] = $variables['elements'][$key];
+ }
+
+ // field_attach_preprocess() overwrites the $[field_name] variables with the
+ // values of the field in the language that was selected for display, instead
+ // of the raw values in $term->[field_name], which contain all values in all
+ // languages.
+ field_attach_preprocess('taxonomy_term', $term, $variables['content'], $variables);
+
+ $vocabulary_name_css = str_replace('_', '-', $term->vocabulary_machine_name);
+
+ // Gather classes.
+ $variables['classes_array'][] = 'vocabulary-' . $vocabulary_name_css;
+
+ // Clean up name so there are no underscores.
+ $variables['theme_hook_suggestions'][] = 'taxonomy-term__' . $vocabulary_name_css;
+ $variables['theme_hook_suggestions'][] = 'taxonomy-term__' . $term->tid;
+}
+
+/**
+ * Returns whether the current page is the page of the passed in term.
+ *
+ * @param $term
+ * A term object.
+ */
+function taxonomy_term_is_page($term) {
+ $page_term = menu_get_object('taxonomy_term', 2);
+ return (!empty($page_term) ? $page_term->tid == $term->tid : FALSE);
+}
+
/**
* Clear all static cache variables for terms..
*/
Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.91
diff -u -r1.91 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc 9 Jan 2010 12:54:51 -0000 1.91
+++ modules/taxonomy/taxonomy.admin.inc 15 Jan 2010 13:17:25 -0000
@@ -643,12 +643,15 @@
'#title' => t('Name'),
'#default_value' => $edit['name'],
'#maxlength' => 255,
- '#required' => TRUE);
+ '#required' => TRUE,
+ '#weight' => -5,
+ );
$form['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $edit['description'],
'#text_format' => $edit['format'],
+ '#weight' => 0,
);
$form['vocabulary_machine_name'] = array(
Index: modules/taxonomy/taxonomy-term.tpl.php
===================================================================
RCS file: modules/taxonomy/taxonomy-term.tpl.php
diff -N modules/taxonomy/taxonomy-term.tpl.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/taxonomy/taxonomy-term.tpl.php 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,51 @@
+
+