views_handler_argument_term_node_tid.inc

  1. 3.x modules/taxonomy/views_handler_argument_term_node_tid.inc
  2. 2.x modules/taxonomy/views_handler_argument_term_node_tid.inc

Definition of views_handler_argument_term_node_tid.

File

modules/taxonomy/views_handler_argument_term_node_tid.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_argument_term_node_tid.
  5. */
  6. /**
  7. * Allow taxonomy term ID(s) as argument.
  8. *
  9. * @ingroup views_argument_handlers
  10. */
  11. class views_handler_argument_term_node_tid extends views_handler_argument_many_to_one {
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['set_breadcrumb'] = array('default' => FALSE, 'bool' => TRUE);
  15. return $options;
  16. }
  17. function options_form(&$form, &$form_state) {
  18. parent::options_form($form, $form_state);
  19. $form['set_breadcrumb'] = array(
  20. '#type' => 'checkbox',
  21. '#title' => t("Set the breadcrumb for the term parents"),
  22. '#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.'),
  23. '#default_value' => !empty($this->options['set_breadcrumb']),
  24. );
  25. }
  26. function set_breadcrumb(&$breadcrumb) {
  27. if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
  28. return;
  29. }
  30. return views_taxonomy_set_breadcrumb($breadcrumb, $this);
  31. }
  32. function title_query() {
  33. $titles = array();
  34. $result = db_select('taxonomy_term_data', 'td')
  35. ->fields('td', array('name'))
  36. ->condition('td.tid', $this->value)
  37. ->execute();
  38. foreach ($result as $term) {
  39. $titles[] = check_plain($term->name);
  40. }
  41. return $titles;
  42. }
  43. }