Projet

Général

Profil

Paste
Télécharger (1,44 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / taxonomy / views_handler_argument_term_node_tid.inc @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_argument_term_node_tid.
6
 */
7

    
8
/**
9
 * Allow taxonomy term ID(s) as argument.
10
 *
11
 * @ingroup views_argument_handlers
12
 */
13
class views_handler_argument_term_node_tid extends views_handler_argument_many_to_one {
14
  function option_definition() {
15
    $options = parent::option_definition();
16
    $options['set_breadcrumb'] = array('default' => FALSE, 'bool' => TRUE);
17
    return $options;
18
  }
19

    
20
  function options_form(&$form, &$form_state) {
21
    parent::options_form($form, $form_state);
22
    $form['set_breadcrumb'] = array(
23
      '#type' => 'checkbox',
24
      '#title' => t("Set the breadcrumb for the term parents"),
25
      '#description' => t('If selected, the breadcrumb trail will include all parent terms, each one linking to this view. Note that this only works if just one term was received.'),
26
      '#default_value' => !empty($this->options['set_breadcrumb']),
27
    );
28
  }
29

    
30
  function set_breadcrumb(&$breadcrumb) {
31
    if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
32
      return;
33
    }
34

    
35
    return views_taxonomy_set_breadcrumb($breadcrumb, $this);
36
  }
37

    
38
  function title_query() {
39
    $titles = array();
40
    $result = db_select('taxonomy_term_data', 'td')
41
      ->addTag('term_access')
42
      ->fields('td', array('name'))
43
      ->condition('td.tid', $this->value)
44
      ->execute();
45
    foreach ($result as $term) {
46
      $titles[] = check_plain($term->name);
47
    }
48
    return $titles;
49
  }
50
}