<?php

/**
 * This is just a clipping of views_taxonomy.inc, lines 34-81, with name changes to
 * the $table key and the filter name, and the 'free tagging' flag unset so
 * that views_taxonomy_form() renders a select list instead of an autocomplete
 * field.
 */

/**
 * Implementation of views' hook_views_tables().
 */
function views_bonus_taxonomy_alt_views_tables() {
  if (module_exists('taxonomy')) {

    $vocabularies = taxonomy_get_vocabularies();
    foreach ($vocabularies as $voc) {
      if ($voc->tags) {
        unset($voc->tags);
        $tables["term_node_{$voc->vid}_alt"] = array(
          'name' => 'term_node',
          'provider' => 'internal',
          'join' => array(
            'left' => array(
              'table' => 'node',
              'field' => 'nid'
            ),
            'right' => array(
              'field' => 'nid'
            )
          ),
          'filters' => array(
            'tid' => array(
              'name' => t('Taxonomy_alt: Terms for @voc-name', array('@voc-name' => $voc->name)),
              'value' => views_taxonomy_form($voc),
              //views does handle this as array regardless what we state here due to the operators
              'value-type' => 'array', 
              'tags' => $voc->tags,
              'operator' => 'views_handler_operator_andor',
              'handler' => 'views_handler_filter_tid_custom',
              'option' => 'string',
              'vocabulary' => $voc->vid,
              'help' => t("Only terms associated with %voc-name will appear in the select box for this filter. When filtering by taxonomy term you may specify the 'depth' as an option. Please see the taxonomy help for more information.", array('%voc-name' => $voc->name)),
            ),
          )
        );
  
      }
    }

  }
  return $tables;
}
