/[drupal]/contributions/modules/views/modules/taxonomy.views_convert.inc
ViewVC logotype

Contents of /contributions/modules/views/modules/taxonomy.views_convert.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Tue Jun 30 19:14:27 2009 UTC (4 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-7--3
Changes since 1.3: +1 -3 lines
File MIME type: text/x-php
More Views convert updates from Darren Oh
1 <?php
2 //$Id: taxonomy.views_convert.inc,v 1.3 2009/06/02 20:31:00 merlinofchaos 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 taxonomy_views_convert($display, $type, &$view, $field, $id = NULL) {
17 switch ($type) {
18 case 'field':
19 if ($field['tablename'] == 'term_node' || !strncmp($field['tablename'], 'term_node_', 10)) {
20 switch ($field['field']) {
21 case 'name':
22 $item = $view->get_item($display, 'field', $id);
23 if ($field['options'] != 'nolink') {
24 $item['link_to_taxonomy'] = TRUE;
25 }
26 if (!empty($field['vocabulary'])) {
27 $item['limit'] = TRUE;
28 $item['vids'] = array($field['vocabulary']);
29 }
30 $view->set_item($display, 'field', $id, $item);
31 break;
32 }
33 }
34 elseif ($field['tablename'] == 'term_data') {
35 switch ($field['field']) {
36 case 'name':
37 if ($field['field'] == 'views_handler_field_tid_link') {
38 $view->set_item_option($display, 'field', $id, 'link_to_taxonomy', TRUE);
39 }
40 break;
41 }
42 }
43 break;
44 case 'filter':
45 if ($field['tablename'] == 'term_node' || !strncmp($field['tablename'], 'term_node_', 10)) {
46 switch ($field['field']) {
47 case 'tid':
48 $operators = array('AND' => 'and', 'OR' => 'or', 'NOR' => 'not');
49 $item = $view->get_item($display, 'filter', $id);
50 if ($vid = (integer) substr($field['tablename'], 10)) {
51 $item['table'] = 'term_node';
52 $item['vid'] = $vid;
53 }
54 else {
55 $item['limit'] = FALSE;
56 }
57 $item['operator'] = $operators[$field['operator']];
58 $item['type'] = 'select';
59 $view->set_item($display, 'filter', $id, $item);
60 break;
61 }
62 }
63 elseif ($field['tablename'] == 'term_data') {
64 switch ($field['field']) {
65 case 'vid':
66 $operators = array('AND' => 'in', 'OR' => 'in', 'NOR' => 'not in');
67 $view->set_item_option($display, 'filter', $id, 'operator', $operators[$field['operator']]);
68 break;
69 }
70 }
71 break;
72 case 'argument':
73 $options = $field['argoptions'];
74 switch ($field['type']) {
75 case 'taxid':
76 if (!empty($field['options'])) {
77 $options['depth'] = $field['options'];
78 }
79 $options['break_phrase'] = TRUE;
80 $view->add_item($display, 'argument', 'node', 'term_node_tid_depth', $options, $field['id']);
81 break;
82 case 'taxletter':
83 if (!empty($field['options'])) {
84 $options['glossary'] = TRUE;
85 $options['limit'] = $field['options'];
86 }
87 $view->add_item($display, 'argument', 'term_data', 'name', $options, $field['id']);
88 break;
89 case 'vocid':
90 $view->add_item($display, 'argument', 'vocabulary', 'vid', $options, $field['id']);
91 break;
92 }
93 break;
94 }
95 }

  ViewVC Help
Powered by ViewVC 1.1.2