~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/cck/includes/views/content.views_convert.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: content.views_convert.inc,v 1.1.2.4 2008/10/06 15:11:39 karens Exp $
 
3
 
 
4
/**
 
5
 * @file
 
6
 * Field conversion for fields handled by this module.
 
7
 */
 
8
 
 
9
/**
 
10
 * Implementation of hook_views_convert().
 
11
 *
 
12
 * Intervene to convert field values from the Views 1 format to the
 
13
 * Views 2 format. Intervene only if $view->add_item() won't produce
 
14
 * the right results, usually needed to set field options or values.
 
15
 */
 
16
function content_views_convert($display, $type, &$view, $views_field) {
 
17
  static $views_fields;
 
18
 
 
19
  if (empty($views_fields)) {
 
20
    $views_fields = array();
 
21
    $types = content_types();
 
22
    foreach ($types as $ctype) {
 
23
      foreach ($ctype['fields'] as $field) {
 
24
        $module = $field['module'];
 
25
        $result = module_invoke($module, 'field_settings', 'views data', $field);
 
26
        if (empty($result)) {
 
27
          // The views field name had the column name appended,
 
28
          // like field_name_value or field_username_uid.
 
29
          $column = array_shift(array_keys($field['columns']));
 
30
          $views_fields[$field['field_name'] .'_'. $column] = $field;
 
31
        }
 
32
      }
 
33
    }
 
34
  }
 
35
 
 
36
  // Is this a field that CCK should handle? If not, return.
 
37
  if (!in_array($views_field['field'], array_keys($views_fields))) {
 
38
    return;
 
39
  }
 
40
 
 
41
  // Now update values, options, etc. to those selected in the imported view.
 
42
  switch ($type) {
 
43
    case 'field':
 
44
      $view->display[$display]->display_options['fields'][$views_field['field']]['format'] = $views_field['options'];
 
45
      if ($views_field['handler'] == 'content_views_field_handler_group') {
 
46
        $view->display[$display]->display_options['fields'][$views_field['field']]['multiple']['group'] = 1;
 
47
      }
 
48
      else {
 
49
        $view->display[$display]->display_options['fields'][$views_field['field']]['multiple']['group'] = 0;
 
50
      }
 
51
      return;
 
52
 
 
53
    case 'filter':
 
54
      // TODO
 
55
      return;
 
56
 
 
57
    case 'exposed_filter':
 
58
      // TODO
 
59
      return;
 
60
 
 
61
    case 'argument':
 
62
      // TODO
 
63
      return;
 
64
 
 
65
    case 'sort':
 
66
      // TODO
 
67
      break;
 
68
 
 
69
  }
 
70
  return;
 
71
}
 
 
b'\\ No newline at end of file'