Projet

Général

Profil

Paste
Télécharger (4,55 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / link / views / link.views.inc @ 87dbc3bf

1
<?php
2
/**
3
 * @file
4
 * Contains functions handling views integration.
5
 */
6

    
7
/**
8
 * Implementation of hook_views_handlers().
9
 */
10
/*function link_views_handlers() {
11
  return array(
12
    'info' => array(
13
      'path' => drupal_get_path('module', 'link') .'/views',
14
    ),
15
    'handlers' => array(
16
      'link_views_handler_argument_target' => array(
17
        'parent' => 'views_handler_argument',
18
      ),
19
      'link_views_handler_filter_protocol' => array(
20
        'parent' => 'views_handler_filter_string',
21
      ),
22
    ),
23
  );
24
}*/
25

    
26
/**
27
 * Return CCK Views data for the link_field_settings($op == 'views data').
28
 *
29
 * @TODO: Is there some way to tell views I have formatters for it?
30
 */
31
/*function link_views_content_field_data($field) {
32
  // Build the automatic views data provided for us by CCK.
33
  // This creates all the information necessary for the "url" field.
34
  $data = content_views_field_views_data($field);
35

    
36
  $db_info = content_database_info($field);
37
  $table_alias = content_views_tablename($field);
38
  $field_types = _content_field_types();
39

    
40
  // Tweak the automatic views data for the link "url" field.
41
  // Set the filter title to "@label URL"
42
  $data[$table_alias][$field['field_name'] .'_url']['filter']['title'] = t('@label URL', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']);
43
  // Remove the argument handling for URLs.
44
  unset($data[$table_alias][$field['field_name'] .'_url']['argument']);
45

    
46
  // Build out additional views data for the link "title" field.
47
  $data[$table_alias][$field['field_name'] .'_title'] = array(
48
    'group' => t('Content'),
49
    'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
50
    'help' =>  $data[$table_alias][$field['field_name'] .'_url']['help'],
51
    'argument' => array(
52
      'field' => $db_info['columns']['title']['column'],
53
      'tablename' => $db_info['table'],
54
      'handler' => 'content_handler_argument_string',
55
      'click sortable' => TRUE,
56
      'name field' => '', // TODO, mimic content.views.inc :)
57
      'content_field_name' => $field['field_name'],
58
      'allow_empty' => TRUE,
59
    ),
60
    'filter' => array(
61
      'field' => $db_info['columns']['title']['column'],
62
      'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))),
63
      'tablename' => $db_info['table'],
64
      'handler' => 'content_handler_filter_string',
65
      'additional fields' => array(),
66
      'content_field_name' => $field['field_name'],
67
      'allow_empty' => TRUE,
68
    ),
69
    'sort' => array(
70
      'field' => $db_info['columns']['title']['column'],
71
      'tablename' => $db_info['table'],
72
      'handler' => 'content_handler_sort',
73
      'content_field_name' => $field['field_name'],
74
      'allow_empty' => TRUE,
75
    ),
76
  );
77

    
78
  // Build out additional Views filter for the link "protocol" pseudo field.
79
  // TODO: Add a protocol argument.
80
  $data[$table_alias][$field['field_name'] .'_protocol'] = array(
81
    'group' => t('Content'),
82
    'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
83
    'help' =>  $data[$table_alias][$field['field_name'] .'_url']['help'],
84
    'filter' => array(
85
      'field' => $db_info['columns']['url']['column'],
86
      'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))),
87
      'tablename' => $db_info['table'],
88
      'handler' => 'link_views_handler_filter_protocol',
89
      'additional fields' => array(),
90
      'content_field_name' => $field['field_name'],
91
      'allow_empty' => TRUE,
92
    ),
93
  );
94

    
95
  // Build out additional Views argument for the link "target" pseudo field.
96
  // TODO: Add a target filter.
97
  $data[$table_alias][$field['field_name'] .'_target'] = array(
98
    'group' => t('Content'),
99
    'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
100
    'help' =>  $data[$table_alias][$field['field_name'] .'_url']['help'],
101
    'argument' => array(
102
      'field' => $db_info['columns']['attributes']['column'],
103
      'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
104
      'tablename' => $db_info['table'],
105
      'handler' => 'link_views_handler_argument_target',
106
      'additional fields' => array(),
107
      'content_field_name' => $field['field_name'],
108
      'allow_empty' => TRUE,
109
    ),
110
  );
111

    
112
  return $data;
113
}*/