[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/data/data_taxonomy/views/ -> data_taxonomy.views.inc (source)

   1  <?php
   2  /**
   3   * @file
   4   * Views hooks.
   5   */
   6  
   7  /**
   8   * Implementation of hook_views_data().
   9   */
  10  function data_taxonomy_views_data() {
  11    $data = array();
  12  
  13    $data['data_taxonomy']['table']['group']  = t('Data taxonomy');
  14    $data['data_taxonomy']['table']['title']  = t('Taxonomy');
  15    $data['data_taxonomy']['table']['join'] = array(
  16      'term_data' => array(
  17        'left_field' => 'tid',
  18        'field' => 'tid',
  19      ),
  20      'node' => array(
  21        'left_table' => 'term_node',
  22        'left_field' => 'tid',
  23        'field' => 'tid',
  24      ),
  25    );
  26    $data['data_taxonomy']['tid']['relationship'] = array(
  27      'title' => t('Term data.'),
  28      'help' => t('Relate data_taxonomy to a term data.'),
  29      'label' => t('Relate data_taxonomy to a term data.'),
  30      'base' => 'term_data',
  31      'base field' => 'tid',
  32    );
  33    $data['data_taxonomy']['tid_2'] = array(
  34      'relationship' => array(
  35        'handler' => 'views_handler_relationship',
  36        'title' => t('Nodes with term.'),
  37        'help' => t('Relate data taxonomy to all nodes with same term.'),
  38        'label' => t('Relate data taxonomy to nodes with term.'),
  39        'base' => 'term_node',
  40        'base field' => 'tid',
  41        'relationship field' => 'tid',
  42      ),
  43    );
  44    $data['data_taxonomy']['item_count'] = array(
  45      'title' => t('Item count'),
  46      'help' => t('A count of the number of data items related to this tid or nid.'),
  47      'field' => array(
  48        'handler' => 'data_taxonomy_views_handler_field_item_count',
  49      ),
  50    );
  51  
  52    $tables = data_get_all_tables();
  53    foreach ($tables as $table) {
  54      $meta = $table->get('meta');
  55  
  56      if (!empty($meta['data_taxonomy']['vocabularies'])) {
  57        $data['data_taxonomy']['table']['join'][$table->get('name')] = array(
  58          'left_field' => $meta['data_taxonomy']['id'],
  59          'field' => 'id',
  60        );
  61        // allow term data to join directly to affected data tables
  62        $data['term_data']['table']['join'][$table->get('name')] = array(
  63          'left_table' => 'data_taxonomy',
  64          'left_field' => 'tid',
  65          'field' => 'tid',
  66        );
  67        // don't want to overwrite any other relationships this might have...
  68        $data[$table->get('name')]['data_taxonomy_'. $meta['data_taxonomy']['id']]['relationship'] = array(
  69          'title' => t('Term tid.'),
  70          'help' => t('Relate a data record to a term tid.'),
  71          'label' => t('Relate a data record to a term tid.'),
  72          'base' => 'data_taxonomy',
  73          'base field' => 'id',
  74          'relationship field' => $meta['data_taxonomy']['id'],
  75        );
  76        $data[$table->get('name')]['data_taxonomy_form'] = array(
  77          'field' => array(
  78            'title' => t('Taxonomy form'),
  79            'help' => t('A taxonomy form for relating table records to taxonomy terms.'),
  80            'handler' => 'data_taxonomy_views_handler_field_form',
  81          ),
  82        );
  83      }
  84    }
  85    return $data;
  86  }
  87  
  88  /**
  89   * Implementation of hook_views_data_alter().
  90   *
  91   * Expose node table fields/filters for terms as base table.
  92   * @todo This really doesn't belong here.
  93   */
  94  function data_taxonomy_views_data_alter(&$data) {
  95    $data['node']['table']['join']['term_node'] = array(
  96      'left_table' => 'term_node',
  97      'left_field' => 'nid',
  98      'field' => 'nid',
  99    );
 100  }
 101  
 102  /**
 103   * Implementation of hook_views_handlers().
 104   */
 105  function data_taxonomy_views_handlers() {
 106    return array(
 107      'info' => array(
 108        'path' => drupal_get_path('module', 'data_taxonomy') .'/views',
 109      ),
 110      'handlers' => array(
 111        'data_taxonomy_views_handler_field_form' => array(
 112          'parent' => 'views_handler_field',
 113        ),
 114        'data_taxonomy_views_handler_field_item_count' => array(
 115          'parent' => 'views_handler_field',
 116        ),
 117      ),
 118    );
 119  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7