Stripping CVS keywords
[project/filefield.git] / views / filefield.views_convert.inc
1 <?php
2
3 /**
4 * @file
5 * Field conversion for fields handled by this module.
6 */
7
8 /**
9 * Implementation of hook_views_convert().
10 */
11 function filefield_views_convert($display, $type, &$view, $field, $id = NULL) {
12 static $filefield_fields;
13 static $filefield_filters;
14 static $filefield_arguments;
15 if (!isset($filefield_fields)) {
16 $filefield_fields = $filefield_filters = $filefield_arguments = array();
17 foreach (content_fields() as $content_field) {
18 if ($content_field['module'] == 'filefield') {
19 $result = module_invoke('filefield', 'field_settings', 'views data', $content_field);
20 if (!empty($result)) {
21 foreach ($result as $table => $fields) {
22 unset($fields['table']);
23 foreach ($fields as $filefield_field => $definition) {
24 switch ($filefield_field) {
25 case $content_field['field_name'] .'_fid':
26 $filefield_fields[$filefield_field] = array(
27 'table' => $table,
28 'field' => $filefield_field,
29 );
30 $filefield_arguments['content: '. $content_field['field_name']] = &$filefield_fields[$filefield_field];
31 break;
32 case $content_field['field_name'] .'_list':
33 $filefield_filters[$content_field['field_name'] .'_fid_not null'] = array(
34 'table' => $table,
35 'field' => $filefield_field,
36 );
37 break;
38 }
39 }
40 }
41 }
42 }
43 }
44 }
45 switch ($type) {
46 case 'field':
47 if (isset($filefield_fields[$field['field']])) {
48 $multiple = array();
49 switch ($field['handler']) {
50 case 'content_views_field_handler_ungroup':
51 $view->set_item_option($display, 'field', $id, 'multiple', array('group' => FALSE));
52 break;
53 case 'content_views_field_handler_last':
54 $multiple['multiple_reversed'] = TRUE;
55 case 'content_views_field_handler_first':
56 $multiple['multiple_number'] = 1;
57 $view->set_item_option($display, 'field', $id, 'multiple', $multiple);
58 break;
59 }
60 $view->set_item_option($display, 'field', $id, 'format', $field['options']);
61 }
62 break;
63 case 'filter':
64 if (isset($filefield_filters[$field['field']])) {
65 $filter = $filefield_filters[$field['field']];
66 $item = $view->get_item($display, 'filter', $id);
67 $item['value'] = $field['value'];
68 $item['table'] = $filter['table'];
69 $item['field'] = $filter['field'];
70 $view->set_item($display, 'filter', $id, $item);
71 }
72 break;
73 case 'argument':
74 if (isset($filefield_arguments[$field['type']])) {
75 $argument = $filefield_arguments[$field['type']];
76 $options = $field['argoptions'];
77 $view->add_item($display, 'argument', $argument['table'], $argument['field'], $options, $field['id']);
78 }
79 break;
80 }
81 }