summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy
diff options
context:
space:
mode:
authorTorsten Grote <grote@kolabsys.com>2012-08-14 13:29:52 (GMT)
committerTorsten Grote <grote@kolabsys.com>2012-08-14 13:29:52 (GMT)
commit8a7a4f8e58df35a10fda833a9904eb8fd961a1ca (patch)
tree35e2f907372d637f76c0e3c3ac1c0f27f2dc1391 /kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy
parent146e20fc2d0941a6783641f26b3ea074dc03fc84 (diff)
downloadkolab.org-www-8a7a4f8e58df35a10fda833a9904eb8fd961a1ca.tar.gz
upgrade to drupal 7.15
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc24
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc43
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc139
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc59
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc21
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc21
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc80
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc54
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc142
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc349
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc94
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc20
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc20
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc95
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc150
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc221
16 files changed, 1532 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc
new file mode 100644
index 0000000..5c32ea4
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Argument handler for basic taxonomy tid.
+ *
+ * @ingroup views_argument_handlers
+ */
+class views_handler_argument_taxonomy extends views_handler_argument_numeric {
+
+ /**
+ * Override the behavior of title(). Get the title of the node.
+ */
+ function title() {
+ // There might be no valid argument.
+ if ($this->argument) {
+ $term = taxonomy_term_load($this->argument);
+ if (!empty($term)) {
+ return check_plain($term->name);
+ }
+ }
+ // TODO review text
+ return t('No name');
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc
new file mode 100644
index 0000000..e36c778
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Allow taxonomy term ID(s) as argument.
+ *
+ * @ingroup views_argument_handlers
+ */
+class views_handler_argument_term_node_tid extends views_handler_argument_many_to_one {
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['set_breadcrumb'] = array('default' => FALSE);
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $form['set_breadcrumb'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("Set the breadcrumb for the term parents"),
+ '#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.'),
+ '#default_value' => !empty($this->options['set_breadcrumb']),
+ );
+ }
+
+ function set_breadcrumb(&$breadcrumb) {
+ if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
+ return;
+ }
+
+ return views_taxonomy_set_breadcrumb($breadcrumb, $this);
+ }
+
+ function title_query() {
+ $titles = array();
+ $result = db_select('taxonomy_term_data', 'td')
+ ->fields('td', array('name'))
+ ->condition('td.tid', $this->value)
+ ->execute();
+ foreach ($result as $term) {
+ $titles[] = check_plain($term->name);
+ }
+ return $titles;
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
new file mode 100644
index 0000000..03b1409
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Argument handler for taxonomy terms with depth.
+ *
+ * This handler is actually part of the node table and has some restrictions,
+ * because it uses a subquery to find nodes with.
+ *
+ * @ingroup views_argument_handlers
+ */
+class views_handler_argument_term_node_tid_depth extends views_handler_argument {
+ function option_definition() {
+ $options = parent::option_definition();
+
+ $options['depth'] = array('default' => 0);
+ $options['break_phrase'] = array('default' => FALSE);
+ $options['set_breadcrumb'] = array('default' => FALSE);
+ $options['use_taxonomy_term_path'] = array('default' => FALSE);
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ $form['depth'] = array(
+ '#type' => 'weight',
+ '#title' => t('Depth'),
+ '#default_value' => $this->options['depth'],
+ '#description' => t('The depth will match nodes tagged with terms in the hierarchy. For example, if you have the term "fruit" and a child term "apple", with a depth of 1 (or higher) then filtering for the term "fruit" will get nodes that are tagged with "apple" as well as "fruit". If negative, the reverse is true; searching for "apple" will also pick up nodes tagged with "fruit" if depth is -1 (or lower).'),
+ );
+
+ $form['break_phrase'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Allow multiple values'),
+ '#description' => t('If selected, users can enter multiple values in the form of 1+2+3. Due to the number of JOINs it would require, AND will be treated as OR with this filter.'),
+ '#default_value' => !empty($this->options['break_phrase']),
+ );
+
+ $form['set_breadcrumb'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("Set the breadcrumb for the term parents"),
+ '#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.'),
+ '#default_value' => !empty($this->options['set_breadcrumb']),
+ );
+
+ $form['use_taxonomy_term_path'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("Use Drupal's taxonomy term path to create breadcrumb links"),
+ '#description' => t('If selected, the links in the breadcrumb trail will be created using the standard drupal method instead of the custom views method. This is useful if you are using modules like taxonomy redirect to modify your taxonomy term links.'),
+ '#default_value' => !empty($this->options['use_taxonomy_term_path']),
+ '#dependency' => array('edit-options-set-breadcrumb' => array(TRUE)),
+ );
+ parent::options_form($form, $form_state);
+ }
+
+ function set_breadcrumb(&$breadcrumb) {
+ if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
+ return;
+ }
+
+ return views_taxonomy_set_breadcrumb($breadcrumb, $this);
+ }
+
+ /**
+ * Override default_actions() to remove summary actions.
+ */
+ function default_actions($which = NULL) {
+ if ($which) {
+ if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
+ return parent::default_actions($which);
+ }
+ return;
+ }
+ $actions = parent::default_actions();
+ unset($actions['summary asc']);
+ unset($actions['summary desc']);
+ unset($actions['summary asc by count']);
+ unset($actions['summary desc by count']);
+ return $actions;
+ }
+
+ function query($group_by = FALSE) {
+ $this->ensure_my_table();
+
+ if (!empty($this->options['break_phrase'])) {
+ $tids = new stdClass();
+ $tids->value = $this->argument;
+ $tids = views_break_phrase($this->argument, $tids);
+ if ($tids->value == array(-1)) {
+ return FALSE;
+ }
+
+ if (count($tids->value) > 1) {
+ $operator = 'IN';
+ }
+ else {
+ $operator = '=';
+ }
+
+ $tids = $tids->value;
+ }
+ else {
+ $operator = "=";
+ $tids = $this->argument;
+ }
+ // Now build the subqueries.
+ $subquery = db_select('taxonomy_index', 'tn');
+ $subquery->addField('tn', 'nid');
+ $where = db_or()->condition('tn.tid', $tids, $operator);
+ $last = "tn";
+
+ if ($this->options['depth'] > 0) {
+ $subquery->leftJoin('taxonomy_term_hierarchy', 'th', "th.tid = tn.tid");
+ $last = "th";
+ foreach (range(1, abs($this->options['depth'])) as $count) {
+ $subquery->leftJoin('taxonomy_term_hierarchy', "th$count", "$last.parent = th$count.tid");
+ $where->condition("th$count.tid", $tids, $operator);
+ $last = "th$count";
+ }
+ }
+ elseif ($this->options['depth'] < 0) {
+ foreach (range(1, abs($this->options['depth'])) as $count) {
+ $subquery->leftJoin('taxonomy_term_hierarchy', "th$count", "$last.tid = th$count.parent");
+ $where->condition("th$count.tid", $tids, $operator);
+ $last = "th$count";
+ }
+ }
+
+ $subquery->condition($where);
+ $this->query->add_where(0, "$this->table_alias.$this->real_field", $subquery, 'IN');
+ }
+
+ function title() {
+ $term = taxonomy_term_load($this->argument);
+ if (!empty($term)) {
+ return check_plain($term->name);
+ }
+ // TODO review text
+ return t('No name');
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc
new file mode 100644
index 0000000..da71796
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * Argument handler for to modify depth for a previous term.
+ *
+ * This handler is actually part of the node table and has some restrictions,
+ * because it uses a subquery to find nodes with.
+ *
+ * @ingroup views_argument_handlers
+ */
+class views_handler_argument_term_node_tid_depth_modifier extends views_handler_argument {
+ function options_form(&$form, &$form_state) { }
+ function query($group_by = FALSE) { }
+ function pre_query() {
+ // We don't know our argument yet, but it's based upon our position:
+ $argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL;
+ if (!is_numeric($argument)) {
+ return;
+ }
+
+ if ($argument > 10) {
+ $argument = 10;
+ }
+
+ if ($argument < -10) {
+ $argument = -10;
+ }
+
+ // figure out which argument preceded us.
+ $keys = array_reverse(array_keys($this->view->argument));
+ $skip = TRUE;
+ foreach ($keys as $key) {
+ if ($key == $this->options['id']) {
+ $skip = FALSE;
+ continue;
+ }
+
+ if ($skip) {
+ continue;
+ }
+
+ if (empty($this->view->argument[$key])) {
+ continue;
+ }
+
+ if (isset($handler)) {
+ unset($handler);
+ }
+
+ $handler = &$this->view->argument[$key];
+ if (empty($handler->definition['accept depth modifier'])) {
+ continue;
+ }
+
+ // Finally!
+ $handler->options['depth'] = $argument;
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc
new file mode 100644
index 0000000..b91b08f
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Argument handler to accept a vocabulary machine name.
+ *
+ * @ingroup views_argument_handlers
+ */
+class views_handler_argument_vocabulary_machine_name extends views_handler_argument_string {
+ /**
+ * Override the behavior of title(). Get the name of the vocabulary..
+ */
+ function title() {
+ $title = db_query("SELECT v.name FROM {taxonomy_vocabulary} v WHERE v.machine_name = :machine_name", array(':machine_name' => $this->argument))->fetchField();
+
+ if (empty($title)) {
+ return t('No vocabulary');
+ }
+
+ return check_plain($title);
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc
new file mode 100644
index 0000000..d79859b
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Argument handler to accept a vocabulary id.
+ *
+ * @ingroup views_argument_handlers
+ */
+class views_handler_argument_vocabulary_vid extends views_handler_argument_numeric {
+ /**
+ * Override the behavior of title(). Get the name of the vocabulary.
+ */
+ function title() {
+ $title = db_query("SELECT v.name FROM {taxonomy_vocabulary} v WHERE v.vid = :vid", array(':vid' => $this->argument))->fetchField();
+
+ if (empty($title)) {
+ return t('No vocabulary');
+ }
+
+ return check_plain($title);
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc
new file mode 100644
index 0000000..c1ccb6d
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc
@@ -0,0 +1,80 @@
+<?php
+
+/**
+ * Field handler to provide simple renderer that allows linking to a taxonomy
+ * term.
+ *
+ * @ingroup views_field_handlers
+ */
+class views_handler_field_taxonomy extends views_handler_field {
+ /**
+ * Constructor to provide additional field to add.
+ *
+ * This constructer assumes the taxonomy_term_data table. If using another
+ * table, we'll need to be more specific.
+ */
+ function construct() {
+ parent::construct();
+ $this->additional_fields['vid'] = 'vid';
+ $this->additional_fields['tid'] = 'tid';
+ $this->additional_fields['vocabulary_machine_name'] = array(
+ 'table' => 'taxonomy_vocabulary',
+ 'field' => 'machine_name',
+ );
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['link_to_taxonomy'] = array('default' => FALSE);
+ $options['convert_spaces'] = array('default' => FALSE);
+ return $options;
+ }
+
+ /**
+ * Provide link to taxonomy option
+ */
+ function options_form(&$form, &$form_state) {
+ $form['link_to_taxonomy'] = array(
+ '#title' => t('Link this field to its taxonomy term page'),
+ '#description' => t("Enable to override this field's links."),
+ '#type' => 'checkbox',
+ '#default_value' => !empty($this->options['link_to_taxonomy']),
+ );
+ $form['convert_spaces'] = array(
+ '#title' => t('Convert spaces in term names to hyphens'),
+ '#description' => t('This allows links to work with Views taxonomy term arguments.'),
+ '#type' => 'checkbox',
+ '#default_value' => !empty($this->options['convert_spaces']),
+ );
+ parent::options_form($form, $form_state);
+ }
+
+ /**
+ * Render whatever the data is as a link to the taxonomy.
+ *
+ * Data should be made XSS safe prior to calling this function.
+ */
+ function render_link($data, $values) {
+ $tid = $this->get_value($values, 'tid');
+ if (!empty($this->options['link_to_taxonomy']) && !empty($tid) && $data !== NULL && $data !== '') {
+ $term = new stdClass();
+ $term->tid = $tid;
+ $term->vid = $this->get_value($values, 'vid');
+ $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']};
+ $this->options['alter']['make_link'] = TRUE;
+ $uri = entity_uri('taxonomy_term', $term);
+ $this->options['alter']['path'] = $uri['path'];
+ }
+
+ if (!empty($this->options['convert_spaces'])) {
+ $data = str_replace(' ', '-', $data);
+ }
+
+ return $data;
+ }
+
+ function render($values) {
+ $value = $this->get_value($values);
+ return $this->render_link($this->sanitize_value($value), $values);
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc
new file mode 100644
index 0000000..ae1f0a5
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * Field handler to present a term edit link.
+ *
+ * @ingroup views_field_handlers
+ */
+class views_handler_field_term_link_edit extends views_handler_field {
+ function construct() {
+ parent::construct();
+ $this->additional_fields['tid'] = 'tid';
+ $this->additional_fields['vid'] = 'vid';
+ $this->additional_fields['vocabulary_machine_name'] = array(
+ 'table' => 'taxonomy_vocabulary',
+ 'field' => 'machine_name',
+ );
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+
+ $options['text'] = array('default' => '', 'translatable' => TRUE);
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ $form['text'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Text to display'),
+ '#default_value' => $this->options['text'],
+ );
+ parent::options_form($form, $form_state);
+ }
+
+ function query() {
+ $this->ensure_my_table();
+ $this->add_additional_fields();
+ }
+
+ function render($values) {
+ // Mock a term object for taxonomy_term_edit_access(). Use machine name and
+ // vid to ensure compatibility with vid based and machine name based
+ // access checks. See http://drupal.org/node/995156
+ $term = new stdClass();
+ $term->vid = $values->{$this->aliases['vid']};
+ $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']};
+ if (taxonomy_term_edit_access($term)) {
+ $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
+ $tid = $this->get_value($values, 'tid');
+ return l($text, 'taxonomy/term/'. $tid . '/edit', array('query' => drupal_get_destination()));
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc
new file mode 100644
index 0000000..4a6c7a4
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc
@@ -0,0 +1,142 @@
+<?php
+
+/**
+ * Field handler to display all taxonomy terms of a node.
+ *
+ * @ingroup views_field_handlers
+ */
+class views_handler_field_term_node_tid extends views_handler_field_prerender_list {
+ function init(&$view, &$options) {
+ parent::init($view, $options);
+ // @todo: Wouldn't it be possible to use $this->base_table and no if here?
+ if ($view->base_table == 'node_revision') {
+ $this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid');
+ }
+ else {
+ $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
+ }
+
+ // Convert legacy vids option to machine name vocabularies.
+ if (!empty($this->options['vids'])) {
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($this->options['vids'] as $vid) {
+ if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+ $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+ }
+ }
+ }
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+
+ $options['link_to_taxonomy'] = array('default' => TRUE);
+ $options['limit'] = array('default' => FALSE);
+ $options['vocabularies'] = array('default' => array());
+
+ return $options;
+ }
+
+ /**
+ * Provide "link to term" option.
+ */
+ function options_form(&$form, &$form_state) {
+ $form['link_to_taxonomy'] = array(
+ '#title' => t('Link this field to its term page'),
+ '#type' => 'checkbox',
+ '#default_value' => !empty($this->options['link_to_taxonomy']),
+ );
+
+ $form['limit'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Limit terms by vocabulary'),
+ '#default_value'=> $this->options['limit'],
+ '#fieldset' => 'more',
+ );
+
+ $options = array();
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($vocabularies as $voc) {
+ $options[$voc->machine_name] = check_plain($voc->name);
+ }
+
+ $form['vocabularies'] = array(
+ '#prefix' => '<div><div id="edit-options-vocabularies">',
+ '#suffix' => '</div></div>',
+ '#type' => 'checkboxes',
+ '#title' => t('Vocabularies'),
+ '#options' => $options,
+ '#default_value' => $this->options['vocabularies'],
+ '#dependency' => array('edit-options-limit' => array(TRUE)),
+ '#fieldset' => 'more',
+ );
+
+ parent::options_form($form, $form_state);
+ }
+
+ /**
+ * Add this term to the query
+ */
+ function query() {
+ $this->add_additional_fields();
+ }
+
+ function pre_render(&$values) {
+ $this->field_alias = $this->aliases['nid'];
+ $nids = array();
+ foreach ($values as $result) {
+ if (!empty($result->{$this->aliases['nid']})) {
+ $nids[] = $result->{$this->aliases['nid']};
+ }
+ }
+
+ if ($nids) {
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->innerJoin('taxonomy_index', 'tn', 'td.tid = tn.tid');
+ $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->fields('td');
+ $query->addField('tn', 'nid', 'node_nid');
+ $query->addField('tv', 'name', 'vocabulary');
+ $query->addField('tv', 'machine_name', 'vocabulary_machine_name');
+ $query->orderby('td.weight');
+ $query->orderby('td.name');
+ $query->condition('tn.nid', $nids);
+ $query->addTag('term_access');
+ $vocabs = array_filter($this->options['vocabularies']);
+ if (!empty($this->options['limit']) && !empty($vocabs)) {
+ $query->condition('tv.machine_name', $vocabs);
+ }
+ $result = $query->execute();
+
+ foreach ($result as $term) {
+ $this->items[$term->node_nid][$term->tid]['name'] = check_plain($term->name);
+ $this->items[$term->node_nid][$term->tid]['tid'] = $term->tid;
+ $this->items[$term->node_nid][$term->tid]['vocabulary_machine_name'] = check_plain($term->vocabulary_machine_name);
+ $this->items[$term->node_nid][$term->tid]['vocabulary'] = check_plain($term->vocabulary);
+
+ if (!empty($this->options['link_to_taxonomy'])) {
+ $this->items[$term->node_nid][$term->tid]['make_link'] = TRUE;
+ $this->items[$term->node_nid][$term->tid]['path'] = 'taxonomy/term/' . $term->tid;
+ }
+ }
+ }
+ }
+
+ function render_item($count, $item) {
+ return $item['name'];
+ }
+
+ function document_self_tokens(&$tokens) {
+ $tokens['[' . $this->options['id'] . '-tid' . ']'] = t('The taxonomy term ID for the term.');
+ $tokens['[' . $this->options['id'] . '-name' . ']'] = t('The taxonomy term name for the term.');
+ $tokens['[' . $this->options['id'] . '-vocabulary-machine-name' . ']'] = t('The machine name for the vocabulary the term belongs to.');
+ $tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = t('The name for the vocabulary the term belongs to.');
+ }
+
+ function add_self_tokens(&$tokens, $item) {
+ foreach(array('tid', 'name', 'vocabulary_machine_name', 'vocabulary') as $token) {
+ // Replace _ with - for the vocabulary machine name.
+ $tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token). ']'] = isset($item[$token]) ? $item[$token] : '';
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc
new file mode 100644
index 0000000..25f9a7b
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc
@@ -0,0 +1,349 @@
+<?php
+
+/**
+ * Filter by term id.
+ *
+ * @ingroup views_filter_handlers
+ */
+class views_handler_filter_term_node_tid extends views_handler_filter_many_to_one {
+ // Stores the exposed input for this filter.
+ var $validated_exposed_input = NULL;
+
+ function init(&$view, &$options) {
+ parent::init($view, $options);
+ if (!empty($this->definition['vocabulary'])) {
+ $this->options['vocabulary'] = $this->definition['vocabulary'];
+ }
+
+ // Convert legacy vid option to machine name vocabulary.
+ if (isset($this->options['vid']) && !empty($this->options['vid']) & empty($this->options['vocabulary'])) {
+ $vocabularies = taxonomy_get_vocabularies();
+ $vid = $this->options['vid'];
+ if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+ $this->options['vocabulary'] = $vocabularies[$vid]->machine_name;
+ }
+ }
+ }
+
+ function has_extra_options() { return TRUE; }
+
+ function get_value_options() { /* don't overwrite the value options */ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+
+ $options['type'] = array('default' => 'textfield');
+ $options['limit'] = array('default' => TRUE);
+ $options['vocabulary'] = array('default' => 0);
+ $options['hierarchy'] = array('default' => 0);
+ $options['error_message'] = array('default' => TRUE);
+
+ return $options;
+ }
+
+ function extra_options_form(&$form, &$form_state) {
+ $vocabularies = taxonomy_get_vocabularies();
+ $options = array();
+ foreach ($vocabularies as $voc) {
+ $options[$voc->machine_name] = check_plain($voc->name);
+ }
+
+ if ($this->options['limit']) {
+ // We only do this when the form is displayed.
+ if (empty($this->options['vocabulary'])) {
+ $first_vocabulary = reset($vocabularies);
+ $this->options['vocabulary'] = $first_vocabulary->machine_name;
+ }
+
+ if (empty($this->definition['vocabulary'])) {
+ $form['vocabulary'] = array(
+ '#type' => 'radios',
+ '#title' => t('Vocabulary'),
+ '#options' => $options,
+ '#description' => t('Select which vocabulary to show terms for in the regular options.'),
+ '#default_value' => $this->options['vocabulary'],
+ );
+ }
+ }
+
+ $form['type'] = array(
+ '#type' => 'radios',
+ '#title' => t('Selection type'),
+ '#options' => array('select' => t('Dropdown'), 'textfield' => t('Autocomplete')),
+ '#default_value' => $this->options['type'],
+ );
+
+ $form['hierarchy'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show hierarchy in dropdown'),
+ '#default_value' => !empty($this->options['hierarchy']),
+ '#dependency' => array('radio:options[type]' => array('select')),
+ );
+ }
+
+ function value_form(&$form, &$form_state) {
+ $vocabulary = taxonomy_vocabulary_machine_name_load($this->options['vocabulary']);
+ if (empty($vocabulary) && $this->options['limit']) {
+ $form['markup'] = array(
+ '#markup' => '<div class="form-item">' . t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
+ );
+ return;
+ }
+
+ if ($this->options['type'] == 'textfield') {
+ $default = '';
+ if ($this->value) {
+ $result = db_select('taxonomy_term_data', 'td')
+ ->fields('td')
+ ->condition('td.tid', $this->value)
+ ->execute();
+ foreach ($result as $term) {
+ if ($default) {
+ $default .= ', ';
+ }
+ $default .= $term->name;
+ }
+ }
+
+ $form['value'] = array(
+ '#title' => $this->options['limit'] ? t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->name)) : t('Select terms'),
+ '#type' => 'textfield',
+ '#default_value' => $default,
+ );
+
+ if ($this->options['limit']) {
+ $form['value']['#autocomplete_path'] = 'admin/views/ajax/autocomplete/taxonomy/' . $vocabulary->vid;
+ }
+ }
+ else {
+ if (!empty($this->options['hierarchy']) && $this->options['limit']) {
+ $tree = taxonomy_get_tree($vocabulary->vid);
+ $options = array();
+
+ if ($tree) {
+ foreach ($tree as $term) {
+ $choice = new stdClass();
+ $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name);
+ $options[] = $choice;
+ }
+ }
+ }
+ else {
+ $options = array();
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->fields('td');
+ $query->orderby('tv.weight');
+ $query->orderby('tv.name');
+ $query->orderby('td.weight');
+ $query->orderby('td.name');
+ $query->addTag('term_access');
+ if ($this->options['limit']) {
+ $query->condition('tv.machine_name', $vocabulary->machine_name);
+ }
+ $result = $query->execute();
+ foreach ($result as $term) {
+ $options[$term->tid] = $term->name;
+ }
+ }
+
+ $default_value = (array) $this->value;
+
+ if (!empty($form_state['exposed'])) {
+ $identifier = $this->options['expose']['identifier'];
+
+ if (!empty($this->options['expose']['reduce'])) {
+ $options = $this->reduce_value_options($options);
+
+ if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
+ $default_value = array();
+ }
+ }
+
+ if (empty($this->options['expose']['multiple'])) {
+ if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
+ $default_value = 'All';
+ }
+ elseif (empty($default_value)) {
+ $keys = array_keys($options);
+ $default_value = array_shift($keys);
+ }
+ else {
+ $copy = $default_value;
+ $default_value = array_shift($copy);
+ }
+ }
+ }
+ $form['value'] = array(
+ '#type' => 'select',
+ '#title' => $this->options['limit'] ? t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->name)) : t('Select terms'),
+ '#multiple' => TRUE,
+ '#options' => $options,
+ '#size' => min(9, count($options)),
+ '#default_value' => $default_value,
+ );
+
+ if (!empty($form_state['exposed']) && isset($identifier) && !isset($form_state['input'][$identifier])) {
+ $form_state['input'][$identifier] = $default_value;
+ }
+ }
+
+
+ if (empty($form_state['exposed'])) {
+ // Retain the helper option
+ $this->helper->options_form($form, $form_state);
+ }
+ }
+
+ function value_validate($form, &$form_state) {
+ // We only validate if they've chosen the text field style.
+ if ($this->options['type'] != 'textfield') {
+ return;
+ }
+
+ $values = drupal_explode_tags($form_state['values']['options']['value']);
+ $tids = $this->validate_term_strings($form['value'], $values);
+
+ if ($tids) {
+ $form_state['values']['options']['value'] = $tids;
+ }
+ }
+
+ function accept_exposed_input($input) {
+ if (empty($this->options['exposed'])) {
+ return TRUE;
+ }
+
+ // If view is an attachment and is inheriting exposed filters, then assume
+ // exposed input has already been validated
+ if (!empty($this->view->is_attachment) && $this->view->display_handler->uses_exposed()) {
+ $this->validated_exposed_input = (array) $this->view->exposed_raw_input[$this->options['expose']['identifier']];
+ }
+
+ // If it's non-required and there's no value don't bother filtering.
+ if (!$this->options['expose']['required'] && empty($this->validated_exposed_input)) {
+ return FALSE;
+ }
+
+ $rc = parent::accept_exposed_input($input);
+ if ($rc) {
+ // If we have previously validated input, override.
+ if (isset($this->validated_exposed_input)) {
+ $this->value = $this->validated_exposed_input;
+ }
+ }
+
+ return $rc;
+ }
+
+ function exposed_validate(&$form, &$form_state) {
+ if (empty($this->options['exposed'])) {
+ return;
+ }
+
+ $identifier = $this->options['expose']['identifier'];
+
+ // We only validate if they've chosen the text field style.
+ if ($this->options['type'] != 'textfield') {
+ if ($form_state['values'][$identifier] != 'All') {
+ $this->validated_exposed_input = (array) $form_state['values'][$identifier];
+ }
+ return;
+ }
+
+ if (empty($this->options['expose']['identifier'])) {
+ return;
+ }
+
+ $values = drupal_explode_tags($form_state['values'][$identifier]);
+
+ $tids = $this->validate_term_strings($form[$identifier], $values);
+ if ($tids) {
+ $this->validated_exposed_input = $tids;
+ }
+ }
+
+ /**
+ * Validate the user string. Since this can come from either the form
+ * or the exposed filter, this is abstracted out a bit so it can
+ * handle the multiple input sources.
+ *
+ * @param $form
+ * The form which is used, either the views ui or the exposed filters.
+ * @param $values
+ * The taxonomy names which will be converted to tids.
+ *
+ * @return array
+ * The taxonomy ids fo all validated terms.
+ */
+ function validate_term_strings(&$form, $values) {
+ if (empty($values)) {
+ return array();
+ }
+
+ $tids = array();
+ $names = array();
+ $missing = array();
+ foreach ($values as $value) {
+ $missing[strtolower($value)] = TRUE;
+ $names[] = $value;
+ }
+
+ if (!$names) {
+ return FALSE;
+ }
+
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->fields('td');
+ $query->condition('td.name', $names);
+ $query->condition('tv.machine_name', $this->options['vocabulary']);
+ $query->addTag('term_access');
+ $result = $query->execute();
+ foreach ($result as $term) {
+ unset($missing[strtolower($term->name)]);
+ $tids[] = $term->tid;
+ }
+
+ if ($missing && !empty($this->options['error_message'])) {
+ form_error($form, format_plural(count($missing), 'Unable to find term: @terms', 'Unable to find terms: @terms', array('@terms' => implode(', ', array_keys($missing)))));
+ }
+ elseif ($missing && empty($this->options['error_message'])) {
+ $tids = array(0);
+ }
+
+ return $tids;
+ }
+
+ function value_submit($form, &$form_state) {
+ // prevent array_filter from messing up our arrays in parent submit.
+ }
+
+ function expose_form(&$form, &$form_state) {
+ parent::expose_form($form, $form_state);
+ if ($this->options['type'] != 'select') {
+ unset($form['expose']['reduce']);
+ }
+ $form['error_message'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display error message'),
+ '#default_value' => !empty($this->options['error_message']),
+ );
+ }
+
+ function admin_summary() {
+ // set up $this->value_options for the parent summary
+ $this->value_options = array();
+
+ if ($this->value) {
+ $result = db_select('taxonomy_term_data', 'td')
+ ->fields('td')
+ ->condition('td.tid', $this->value)
+ ->execute();
+ foreach ($result as $term) {
+ $this->value_options[$term->tid] = $term->name;
+ }
+ }
+ return parent::admin_summary();
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc
new file mode 100644
index 0000000..3955269
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc
@@ -0,0 +1,94 @@
+<?php
+/**
+ * Filter handler for taxonomy terms with depth.
+ *
+ * This handler is actually part of the node table and has some restrictions,
+ * because it uses a subquery to find nodes with.
+ *
+ * @ingroup views_filter_handlers
+ */
+class views_handler_filter_term_node_tid_depth extends views_handler_filter_term_node_tid {
+ function operator_options($which = 'title') {
+ return array(
+ 'or' => t('Is one of'),
+ );
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+
+ $options['depth'] = array('default' => 0);
+
+ return $options;
+ }
+
+ function extra_options_form(&$form, &$form_state) {
+ parent::extra_options_form($form, $form_state);
+
+ $form['depth'] = array(
+ '#type' => 'weight',
+ '#title' => t('Depth'),
+ '#default_value' => $this->options['depth'],
+ '#description' => t('The depth will match nodes tagged with terms in the hierarchy. For example, if you have the term "fruit" and a child term "apple", with a depth of 1 (or higher) then filtering for the term "fruit" will get nodes that are tagged with "apple" as well as "fruit". If negative, the reverse is true; searching for "apple" will also pick up nodes tagged with "fruit" if depth is -1 (or lower).'),
+ );
+ }
+
+ function query() {
+ // If no filter values are present, then do nothing.
+ if (count($this->value) == 0) {
+ return;
+ }
+ elseif (count($this->value) == 1) {
+ // Somethis $this->value is an array with a single element so convert it.
+ if (is_array($this->value)) {
+ $this->value = current($this->value);
+ }
+ $operator = '=';
+ }
+ else {
+ $operator = 'IN';# " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")";
+ }
+
+ // The normal use of ensure_my_table() here breaks Views.
+ // So instead we trick the filter into using the alias of the base table.
+ // See http://drupal.org/node/271833
+ // If a relationship is set, we must use the alias it provides.
+ if (!empty($this->relationship)) {
+ $this->table_alias = $this->relationship;
+ }
+ // If no relationship, then use the alias of the base table.
+ elseif (isset($this->query->table_queue[$this->query->base_table]['alias'])) {
+ $this->table_alias = $this->query->table_queue[$this->query->base_table]['alias'];
+ }
+ // This should never happen, but if it does, we fail quietly.
+ else {
+ return;
+ }
+
+ // Now build the subqueries.
+ $subquery = db_select('taxonomy_index', 'tn');
+ $subquery->addField('tn', 'nid');
+ $where = db_or()->condition('tn.tid', $this->value, $operator);
+ $last = "tn";
+
+ if ($this->options['depth'] > 0) {
+ $subquery->leftJoin('taxonomy_term_hierarchy', 'th', "th.tid = tn.tid");
+ $last = "th";
+ foreach (range(1, abs($this->options['depth'])) as $count) {
+ $subquery->leftJoin('taxonomy_term_hierarchy', "th$count", "$last.parent = th$count.tid");
+ $where->condition("th$count.tid", $this->value, $operator);
+ $last = "th$count";
+ }
+ }
+ elseif ($this->options['depth'] < 0) {
+ foreach (range(1, abs($this->options['depth'])) as $count) {
+ $subquery->leftJoin('taxonomy_term_hierarchy', "th$count", "$last.tid = th$count.parent");
+ $where->condition("th$count.tid", $this->value, $operator);
+ $last = "th$count";
+ }
+ }
+
+ $subquery->condition($where);
+ $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $subquery, 'IN');
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc
new file mode 100644
index 0000000..5d2c9f5
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Filter by vocabulary machine name.
+ *
+ * @ingroup views_filter_handlers
+ */
+class views_handler_filter_vocabulary_machine_name extends views_handler_filter_in_operator {
+ function get_value_options() {
+ if (isset($this->value_options)) {
+ return;
+ }
+
+ $this->value_options = array();
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($vocabularies as $voc) {
+ $this->value_options[$voc->machine_name] = $voc->name;
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc
new file mode 100644
index 0000000..a02f7b2
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Filter by vocabulary id.
+ *
+ * @ingroup views_filter_handlers
+ */
+class views_handler_filter_vocabulary_vid extends views_handler_filter_in_operator {
+ function get_value_options() {
+ if (isset($this->value_options)) {
+ return;
+ }
+
+ $this->value_options = array();
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($vocabularies as $voc) {
+ $this->value_options[$voc->vid] = $voc->name;
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
new file mode 100644
index 0000000..1855cae
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc
@@ -0,0 +1,95 @@
+<?php
+/**
+ * @file
+ * Views' relationship handlers.
+ */
+
+
+/**
+ * Relationship handler to return the taxonomy terms of nodes.
+ *
+ * @ingroup views_relationship_handlers
+ */
+class views_handler_relationship_node_term_data extends views_handler_relationship {
+ function init(&$view, &$options) {
+ parent::init($view, $options);
+
+ // Convert legacy vids option to machine name vocabularies.
+ if (!empty($this->options['vids'])) {
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($this->options['vids'] as $vid) {
+ if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+ $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+ }
+ }
+ }
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['vocabularies'] = array('default' => array());
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ $vocabularies = taxonomy_get_vocabularies();
+ $options = array();
+ foreach ($vocabularies as $voc) {
+ $options[$voc->machine_name] = check_plain($voc->name);
+ }
+
+ $form['vocabularies'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Vocabularies'),
+ '#options' => $options,
+ '#default_value' => $this->options['vocabularies'],
+ '#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.'),
+ );
+ parent::options_form($form, $form_state);
+ }
+
+ /**
+ * Called to implement a relationship in a query.
+ */
+ function query() {
+ $this->ensure_my_table();
+
+ $def = $this->definition;
+ $def['table'] = 'taxonomy_term_data';
+
+ if (!array_filter($this->options['vocabularies'])) {
+ $term_node = $this->query->add_table('taxonomy_index', $this->relationship);
+ $def['left_table'] = 'taxonomy_index';
+ $def['left_field'] = 'tid';
+ $def['field'] = 'tid';
+ $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
+ }
+ else {
+ // If vocabularies are supplied join a subselect instead
+ $def['left_table'] = $this->table_alias;
+ $def['left_field'] = 'nid';
+ $def['field'] = 'nid';
+ $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
+
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->addJoin($def['type'], 'taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->addJoin($def['type'], 'taxonomy_index', 'tn', 'tn.tid = td.tid');
+ $query->condition('tv.machine_name', array_filter($this->options['vocabularies']));
+ $query->addTag('term_access');
+ $query->fields('td');
+ $query->fields('tn', array('nid'));
+ $def['table formula'] = $query;
+ }
+
+ $join = new views_join();
+
+ $join->definition = $def;
+ $join->construct();
+ $join->adjusted = TRUE;
+
+ // use a short alias for this:
+ $alias = $def['table'] . '_' . $this->table;
+
+ $this->alias = $this->query->add_relationship($alias, $join, 'taxonomy_term_data', $this->relationship);
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
new file mode 100644
index 0000000..17ee634
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
@@ -0,0 +1,150 @@
+<?php
+/**
+ * @file
+ * Taxonomy tid default argument.
+ */
+
+class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_default {
+ function init(&$view, &$argument, $options) {
+ parent::init($view, $argument, $options);
+
+ // Convert legacy vids option to machine name vocabularies.
+ if (!empty($this->options['vids'])) {
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($this->options['vids'] as $vid) {
+ if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+ $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+ }
+ }
+ }
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+
+ $options['term_page'] = array('default' => TRUE);
+ $options['node'] = array('default' => FALSE);
+ $options['anyall'] = array('default' => ',');
+ $options['limit'] = array('default' => FALSE);
+ $options['vocabularies'] = array('default' => array());
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ $form['term_page'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Load default filter from term page'),
+ '#default_value' => $this->options['term_page'],
+ );
+ $form['node'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Load default filter from node page, that\'s good for related taxonomy blocks'),
+ '#default_value' => $this->options['node'],
+ );
+
+ $form['limit'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Limit terms by vocabulary'),
+ '#default_value'=> $this->options['limit'],
+ '#process' => array('form_process_checkbox', 'ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-argument-default-taxonomy-tid-node' => array(1),
+ ),
+ );
+
+ $options = array();
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($vocabularies as $voc) {
+ $options[$voc->machine_name] = check_plain($voc->name);
+ }
+
+ $form['vocabularies'] = array(
+ '#prefix' => '<div><div id="edit-options-vids">',
+ '#suffix' => '</div></div>',
+ '#type' => 'checkboxes',
+ '#title' => t('Vocabularies'),
+ '#options' => $options,
+ '#default_value' => $this->options['vocabularies'],
+ '#process' => array('form_process_checkboxes', 'ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-argument-default-taxonomy-tid-limit' => array(1),
+ 'edit-options-argument-default-taxonomy-tid-node' => array(1),
+ ),
+ );
+
+ $form['anyall'] = array(
+ '#type' => 'radios',
+ '#title' => t('Multiple-value handling'),
+ '#default_value'=> $this->options['anyall'],
+ '#process' => array('form_process_radios', 'ctools_dependent_process'),
+ '#options' => array(
+ ',' => t('Filter to items that share all terms'),
+ '+' => t('Filter to items that share any term'),
+ ),
+ '#dependency' => array(
+ 'edit-options-argument-default-taxonomy-tid-node' => array(1),
+ ),
+ );
+ }
+
+ function options_submit(&$form, &$form_state, &$options = array()) {
+ // Filter unselected items so we don't unnecessarily store giant arrays.
+ $options['vocabularies'] = array_filter($options['vocabularies']);
+ }
+
+ function get_argument() {
+ // Load default argument from taxonomy page.
+ if (!empty($this->options['term_page'])) {
+ if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
+ return arg(2);
+ }
+ }
+ // Load default argument from node.
+ if (!empty($this->options['node'])) {
+ foreach (range(1, 3) as $i) {
+ $node = menu_get_object('node', $i);
+ if (!empty($node)) {
+ break;
+ }
+ }
+ // Just check, if a node could be detected.
+ if ($node) {
+ $taxonomy = array();
+ $fields = field_info_instances('node', $node->type);
+ foreach ($fields as $name => $info) {
+ $field_info = field_info_field($name);
+ if ($field_info['type'] == 'taxonomy_term_reference') {
+ $items = field_get_items('node', $node, $name);
+ if (is_array($items)) {
+ foreach ($items as $item) {
+ $taxonomy[$item['tid']] = $field_info['settings']['allowed_values'][0]['vocabulary'];
+ }
+ }
+ }
+ }
+ if (!empty($this->options['limit'])) {
+ $tids = array();
+ // filter by vocabulary
+ foreach ($taxonomy as $tid => $vocab) {
+ if (!empty($this->options['vocabularies'][$vocab])) {
+ $tids[] = $tid;
+ }
+ }
+ return implode($this->options['anyall'], $tids);
+ }
+ // Return all tids.
+ else {
+ return implode($this->options['anyall'], array_keys($taxonomy));
+ }
+ }
+ }
+
+ // If the current page is a view that takes tid as an argument,
+ // find the tid argument and return it.
+ $views_page = views_get_page_view();
+ if ($views_page && isset($views_page->argument['tid'])) {
+ return $views_page->argument['tid']->argument;
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc
new file mode 100644
index 0000000..c81c619
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc
@@ -0,0 +1,221 @@
+<?php
+/**
+ * @file
+ * Contains the 'taxonomy term' argument validator plugin.
+ */
+
+/**
+ * Validate whether an argument is an acceptable node.
+ */
+class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument_validate {
+ function init(&$view, &$argument, $options) {
+ parent::init($view, $argument, $options);
+
+ // Convert legacy vids option to machine name vocabularies.
+ if (!empty($this->options['vids'])) {
+ $vocabularies = taxonomy_get_vocabularies();
+ foreach ($this->options['vids'] as $vid) {
+ if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+ $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+ }
+ }
+ }
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['vocabularies'] = array('default' => array());
+ $options['type'] = array('default' => 'tid');
+ $options['transform'] = array('default' => FALSE);
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ $vocabularies = taxonomy_get_vocabularies();
+ $options = array();
+ foreach ($vocabularies as $voc) {
+ $options[$voc->machine_name] = check_plain($voc->name);
+ }
+
+ $form['vocabularies'] = array(
+ '#type' => 'checkboxes',
+ '#prefix' => '<div id="edit-options-validate-argument-vocabulary-wrapper">',
+ '#suffix' => '</div>',
+ '#title' => t('Vocabularies'),
+ '#options' => $options,
+ '#default_value' => $this->options['vocabularies'],
+ '#description' => t('If you wish to validate for specific vocabularies, check them; if none are checked, all terms will pass.'),
+ );
+
+ $form['type'] = array(
+ '#type' => 'select',
+ '#title' => t('Filter value type'),
+ '#options' => array(
+ 'tid' => t('Term ID'),
+ 'tids' => t('Term IDs separated by , or +'),
+ 'name' => t('Term name'),
+ 'convert' => t('Term name converted to Term ID'),
+ ),
+ '#default_value' => $this->options['type'],
+ '#description' => t('Select the form of this filter value; if using term name, it is generally more efficient to convert it to a term ID and use Taxonomy: Term ID rather than Taxonomy: Term Name" as the filter.'),
+ );
+
+ $form['transform'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Transform dashes in URL to spaces in term name filter values'),
+ '#default_value' => $this->options['transform'],
+ );
+ }
+
+ function options_submit(&$form, &$form_state, &$options = array()) {
+ // Filter unselected items so we don't unnecessarily store giant arrays.
+ $options['vocabularies'] = array_filter($options['vocabularies']);
+ }
+
+ function convert_options(&$options) {
+ if (!isset($options['vocabularies']) && !empty($this->argument->options['validate_argument_vocabulary'])) {
+ $options['vocabularies'] = $this->argument->options['validate_argument_vocabulary'];
+ $options['type'] = $this->argument->options['validate_argument_type'];
+ $options['transform'] = isset($this->argument->options['validate_argument_transform']) ? $this->argument->options['validate_argument_transform'] : FALSE;
+ }
+ }
+
+ function validate_argument($argument) {
+ $vocabularies = array_filter($this->options['vocabularies']);
+ $type = $this->options['type'];
+ $transform = $this->options['transform'];
+
+ switch ($type) {
+ case 'tid':
+ if (!is_numeric($argument)) {
+ return FALSE;
+ }
+
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->fields('td');
+ $query->fields('tv', array('machine_name'));
+ $query->condition('td.tid', $argument);
+ $query->addTag('term_access');
+ $term = $query->execute()->fetchObject();
+ if (!$term) {
+ return FALSE;
+ }
+ $this->argument->validated_title = check_plain($term->name);
+ return empty($vocabularies) || !empty($vocabularies[$term->machine_name]);
+
+ case 'tids':
+ // An empty argument is not a term so doesn't pass.
+ if (empty($argument)) {
+ return FALSE;
+ }
+
+ $tids = new stdClass();
+ $tids->value = $argument;
+ $tids = views_break_phrase($argument, $tids);
+ if ($tids->value == array(-1)) {
+ return FALSE;
+ }
+
+ $test = drupal_map_assoc($tids->value);
+ $titles = array();
+
+ // check, if some tids already verified
+ static $validated_cache = array();
+ foreach ($test as $tid) {
+ if (isset($validated_cache[$tid])) {
+ if ($validated_cache[$tid] === FALSE) {
+ return FALSE;
+ }
+ else {
+ $titles[] = $validated_cache[$tid];
+ unset($test[$tid]);
+ }
+ }
+ }
+
+ // if unverified tids left - verify them and cache results
+ if (count($test)) {
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->fields('td');
+ $query->fields('tv', array('machine_name'));
+ $query->condition('td.tid', $test);
+
+ $result = $query->execute();
+
+ foreach ($result as $term) {
+ if ($vocabularies && empty($vocabularies[$term->machine_name])) {
+ $validated_cache[$term->tid] = FALSE;
+ return FALSE;
+ }
+
+ $titles[] = $validated_cache[$term->tid] = check_plain($term->name);
+ unset($test[$term->tid]);
+ }
+ }
+
+ // Remove duplicate titles
+ $titles = array_unique($titles);
+
+ $this->argument->validated_title = implode($tids->operator == 'or' ? ' + ' : ', ', $titles);
+ // If this is not empty, we did not find a tid.
+ return empty($test);
+
+ case 'name':
+ case 'convert':
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->fields('td');
+ $query->fields('tv', array('machine_name'));
+ if (!empty($vocabularies)) {
+ $query->condition('tv.machine_name', $vocabularies);
+ }
+ if ($transform) {
+ $query->where("replace(td.name, ' ', '-') = :name", array(':name' => $argument));
+ }
+ else {
+ $query->condition('td.name', $argument);
+ }
+ $term = $query->execute()->fetchObject();
+
+ if ($term && (empty($vocabularies) || !empty($vocabularies[$term->machine_name]))) {
+ if ($type == 'convert') {
+ $this->argument->argument = $term->tid;
+ }
+ $this->argument->validated_title = check_plain($term->name);
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+
+ function process_summary_arguments(&$args) {
+ $type = $this->options['type'];
+ $transform = $this->options['transform'];
+ $vocabularies = array_filter($this->options['vocabularies']);
+
+ if ($type == 'convert') {
+ $arg_keys = array_flip($args);
+
+ $query = db_select('taxonomy_term_data', 'td');
+ $query->condition('tid', $args);
+ $query->addField('td', 'tid', 'tid');
+ if (!empty($vocabularies)) {
+ $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+ $query->condition('tv.machine_name', $vocabularies);
+ }
+ if ($transform) {
+ $query->addExpression("REPLACE(td.name, ' ', '-')", 'name');
+ }
+ else {
+ $query->addField('td', 'name', 'name');
+ }
+
+ foreach ($query->execute()->fetchAllKeyed() as $tid => $term) {
+ $args[$arg_keys[$tid]] = $term;
+ }
+ }
+ }
+}