core.inc 2.35 KB
Newer Older
Cody Craven's avatar
Cody Craven committed
1
2
3
4
5
6
7
8
<?php
// $Id$

/**
 * Add a display handler that will use the Drupal core method of display.
 */
class TaxonomyDisplayTermDisplayHandlerCore extends TaxonomyDisplayTermDisplayHandler {
  /**
9
   * Build our output to be rendered to the user.
Cody Craven's avatar
Cody Craven committed
10
11
12
   *
   * @see TaxonomyDisplayTermDisplayHandler::displayTerm()
   */
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  public function displayTerm($term, $options = NULL) {
    $build = array();

    // Allow display of term's additional content even if the description field
    // is blank, if the option is enabled.
    // @see http://drupal.org/node/796692
    if ($options && $options['display_fields_description_empty']) {
      $build = array(
        '#prefix' => '<div class="term-listing-heading">',
        '#suffix' => '</div>',
        'term' => taxonomy_term_view($term, 'full'),
      );
      if (empty($term->description)) {
        unset($build['description']);
      }
    }
    elseif (!empty($term->description)) {
      $build = array(
        '#prefix' => '<div class="term-listing-heading">',
        '#suffix' => '</div>',
        'term' => taxonomy_term_view($term, 'full'),
      );
    }

    return $build;
Cody Craven's avatar
Cody Craven committed
38
39
40
  }

  /**
41
   * Build our form for the fieldset.
Cody Craven's avatar
Cody Craven committed
42
43
44
   *
   * @see TaxonomyDisplayHandlerForm::formFieldset()
   */
45
46
47
48
49
50
51
52
53
54
  public function formFieldset(&$form, &$values, $options = NULL) {
    $form['#description'] = t('The core Drupal functionality will be used to display the term.');

    $form['display_fields_description_empty'] = array(
      '#default_value' => isset($options['display_fields_description_empty']) ? $options['display_fields_description_empty'] : 0,
      '#description' => t('If a taxonomy term does not have a description entered Drupal core will not display any of its fields. Selecting <em>yes</em> will overcome <a href="!link">this problem</a>.', array('!link' => url('http://drupal.org/node/796692'))),
      '#options' => array(t('No'), t('Yes')),
      '#title' => t('Render term when the description field is empty?'),
      '#type' => 'radios',
    );
Cody Craven's avatar
Cody Craven committed
55
56
57
  }

  /**
58
   * We store values to access later for rendering and editing.
Cody Craven's avatar
Cody Craven committed
59
60
61
   *
   * @see TaxonomyDisplayHandlerForm::formSubmit()
   */
62
63
64
65
66
  public function formSubmit($form, &$values) {
    // We are using the exact keys that our formFieldset() implementation
    // defines and we want all of the values stored, so we have no need to alter
    // them before returning.
    return $values;
Cody Craven's avatar
Cody Craven committed
67
68
  }
}