You are here

function draggableviews_views_data in DraggableViews 7

Same name and namespace in other branches
  1. 6.3 views/draggableviews.views.inc \draggableviews_views_data()

Implements hook_views_data. ().

File

views/draggableviews.views.inc, line 38
Derives the view style plugin

Code

function draggableviews_views_data() {
  $data = array();
  $base_tables = array(
    'nid' => 'node',
    'uid' => 'users',
    'cid' => 'comments',
    'vid' => 'node_revisions',
    'tid' => 'taxonomy_term_data',
  );
  foreach ($base_tables as $base_field => $base_table) {
    for ($i = 0; $i < 2; $i++) {
      $data['draggableviews_structure_' . $base_table . $i]['table'] = array(
        'group' => t('DraggableViews'),
        'join' => array(
          $base_table => array(
            'table' => 'draggableviews_structure',
            'left_field' => $base_field,
            'field' => 'nid',
            'extra' => array(
              array(
                'field' => 'delta',
                'operator' => '=',
                'value' => $i,
                'numeric' => TRUE,
              ),
            ),
          ),
        ),
      );
      $data['draggableviews_structure_' . $base_table . $i]['value' . $i] = array(
        'real field' => 'value',
        'title' => t($i == 0 ? 'Order' : 'Parent'),
        'field' => array(
          'handler' => 'views_handler_field',
          'help' => t('This value provided by draggableviews is unique for each view.'),
          'click sortable' => $i == 0 ? TRUE : FALSE,
          'draggableviews_delta' => $i,
        ),
      );
      if ($i == 0) {
        $data['draggableviews_structure_' . $base_table . $i]['value' . $i]['sort'] = array(
          'handler' => 'views_handler_sort',
          'help' => t('Sort by value'),
        );
      }
    }
  }
  return $data;
}