views_handler_relationship_node_term_data.inc

  1. cis7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  2. cle7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  3. ecd7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  4. elmsmedia7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  5. harmony7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  6. icor7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  7. meedjum_blog7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
  8. mooc7 sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc

Definition of views_handler_relationship_node_term_data.

Classes

Namesort descending Description
views_handler_relationship_node_term_data Relationship handler to return the taxonomy terms of nodes.

File

sites/all/modules/ulmus/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_relationship_node_term_data.
  5. */
  6. /**
  7. * Relationship handler to return the taxonomy terms of nodes.
  8. *
  9. * @ingroup views_relationship_handlers
  10. */
  11. class views_handler_relationship_node_term_data extends views_handler_relationship {
  12. function init(&$view, &$options) {
  13. parent::init($view, $options);
  14. // Convert legacy vids option to machine name vocabularies.
  15. if (!empty($this->options['vids'])) {
  16. $vocabularies = taxonomy_get_vocabularies();
  17. foreach ($this->options['vids'] as $vid) {
  18. if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
  19. $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
  20. }
  21. }
  22. }
  23. }
  24. function option_definition() {
  25. $options = parent::option_definition();
  26. $options['vocabularies'] = array('default' => array());
  27. return $options;
  28. }
  29. function options_form(&$form, &$form_state) {
  30. $vocabularies = taxonomy_get_vocabularies();
  31. $options = array();
  32. foreach ($vocabularies as $voc) {
  33. $options[$voc->machine_name] = check_plain($voc->name);
  34. }
  35. $form['vocabularies'] = array(
  36. '#type' => 'checkboxes',
  37. '#title' => t('Vocabularies'),
  38. '#options' => $options,
  39. '#default_value' => $this->options['vocabularies'],
  40. '#description' => t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'),
  41. );
  42. parent::options_form($form, $form_state);
  43. }
  44. /**
  45. * Called to implement a relationship in a query.
  46. */
  47. function query() {
  48. $this->ensure_my_table();
  49. $def = $this->definition;
  50. $def['table'] = 'taxonomy_term_data';
  51. if (!array_filter($this->options['vocabularies'])) {
  52. $taxonomy_index = $this->query->add_table('taxonomy_index', $this->relationship);
  53. $def['left_table'] = $taxonomy_index;
  54. $def['left_field'] = 'tid';
  55. $def['field'] = 'tid';
  56. $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
  57. }
  58. else {
  59. // If vocabularies are supplied join a subselect instead
  60. $def['left_table'] = $this->table_alias;
  61. $def['left_field'] = 'nid';
  62. $def['field'] = 'nid';
  63. $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
  64. $query = db_select('taxonomy_term_data', 'td');
  65. $query->addJoin($def['type'], 'taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
  66. $query->addJoin($def['type'], 'taxonomy_index', 'tn', 'tn.tid = td.tid');
  67. $query->condition('tv.machine_name', array_filter($this->options['vocabularies']));
  68. $query->addTag('term_access');
  69. $query->fields('td');
  70. $query->fields('tn', array('nid'));
  71. $def['table formula'] = $query;
  72. }
  73. $join = new views_join();
  74. $join->definition = $def;
  75. $join->construct();
  76. $join->adjusted = TRUE;
  77. // use a short alias for this:
  78. $alias = $def['table'] . '_' . $this->table;
  79. $this->alias = $this->query->add_relationship($alias, $join, 'taxonomy_term_data', $this->relationship);
  80. }
  81. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.