Stripping CVS keywords
[project/link.git] / views / link.views.inc
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 function link_views_content_field_data($field) {
30 // Build the automatic views data provided for us by CCK.
31 // This creates all the information necessary for the "url" field.
32 $data = content_views_field_views_data($field);
33
34 $db_info = content_database_info($field);
35 $table_alias = content_views_tablename($field);
36 $field_types = _content_field_types();
37
38 // Tweak the automatic views data for the link "url" field.
39 // Set the filter title to "@label URL"
40 $data[$table_alias][$field['field_name'] .'_url']['filter']['title'] = t('@label URL', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']);
41 // Remove the argument handling for URLs.
42 unset($data[$table_alias][$field['field_name'] .'_url']['argument']);
43
44 // Build out additional views data for the link "title" field.
45 $data[$table_alias][$field['field_name'] .'_title'] = array(
46 'group' => t('Content'),
47 'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
48 'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
49 'argument' => array(
50 'field' => $db_info['columns']['title']['column'],
51 'tablename' => $db_info['table'],
52 'handler' => 'content_handler_argument_string',
53 'click sortable' => TRUE,
54 'name field' => '', // TODO, mimic content.views.inc :)
55 'content_field_name' => $field['field_name'],
56 'allow_empty' => TRUE,
57 ),
58 'filter' => array(
59 'field' => $db_info['columns']['title']['column'],
60 'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))),
61 'tablename' => $db_info['table'],
62 'handler' => 'content_handler_filter_string',
63 'additional fields' => array(),
64 'content_field_name' => $field['field_name'],
65 'allow_empty' => TRUE,
66 ),
67 'sort' => array(
68 'field' => $db_info['columns']['title']['column'],
69 'tablename' => $db_info['table'],
70 'handler' => 'content_handler_sort',
71 'content_field_name' => $field['field_name'],
72 'allow_empty' => TRUE,
73 ),
74 );
75
76 // Build out additional Views filter for the link "protocol" pseudo field.
77 // TODO: Add a protocol argument.
78 $data[$table_alias][$field['field_name'] .'_protocol'] = array(
79 'group' => t('Content'),
80 'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
81 'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
82 'filter' => array(
83 'field' => $db_info['columns']['url']['column'],
84 'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))),
85 'tablename' => $db_info['table'],
86 'handler' => 'link_views_handler_filter_protocol',
87 'additional fields' => array(),
88 'content_field_name' => $field['field_name'],
89 'allow_empty' => TRUE,
90 ),
91 );
92
93 // Build out additional Views argument for the link "target" pseudo field.
94 // TODO: Add a target filter.
95 $data[$table_alias][$field['field_name'] .'_target'] = array(
96 'group' => t('Content'),
97 'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
98 'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
99 'argument' => array(
100 'field' => $db_info['columns']['attributes']['column'],
101 'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
102 'tablename' => $db_info['table'],
103 'handler' => 'link_views_handler_argument_target',
104 'additional fields' => array(),
105 'content_field_name' => $field['field_name'],
106 'allow_empty' => TRUE,
107 ),
108 );
109
110 return $data;
111 }