Project

General

Profile

Download (2.15 KB) Statistics
| Branch: | Tag: | Revision:
1
Index: nodereference.module
2
===================================================================
3
RCS file: /cvs/drupal-contrib/contributions/modules/cck/nodereference.module,v
4
retrieving revision 1.25.2.31
5
diff -u -r1.25.2.31 nodereference.module
6
--- nodereference.module	11 Feb 2007 23:07:20 -0000	1.25.2.31
7
+++ nodereference.module	28 Feb 2007 13:36:01 -0000
8
@@ -491,3 +491,54 @@
9
   $options = $options + _nodereference_potential_references($filterinfo['extra']['field']);
10
   return $options;
11
 }
12
+
13
+/*
14
+ * Implementation of hook_views_fusion()
15
+ */
16
+function nodereference_views_fusion() {
17
+  $field_types = _content_field_types();
18
+  $return = array();
19
+  foreach (content_fields() as $field) {
20
+    if ($field['type'] == 'nodereference') {
21
+      $db_info = content_database_info($field);
22
+      $fusion = array(
23
+        'title' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .')',
24
+        'field' => $db_info['columns']['nid']['column'],
25
+      );
26
+      $return['node_data_'. $field['field_name']] = $fusion;
27
+      $fusion = array(
28
+        'title' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .') - reverse direction',
29
+        'field' => 'nid',
30
+      );
31
+      $return['node_data_'. $field['field_name'] .'_reverse'] = $fusion;
32
+    }
33
+  }
34
+  return $return;
35
+}
36
+
37
+/**
38
+ * Implementation of hook_views_tables().
39
+ * Exposes further table definitions to views, which are needed by views_fusion for using the nodereference reverse
40
+ */
41
+function nodereference_views_tables() {
42
+  $field_types = _content_field_types();
43
+  $tables = array();
44
+  foreach (content_fields() as $field) {
45
+    if ($field['type'] == 'nodereference') {
46
+      $db_info = content_database_info($field);
47
+      $tables['node_data_'. $field['field_name'] .'_reverse'] = array(
48
+        'name' => $db_info['table'],
49
+        'join' => array(
50
+          'left' => array(
51
+            'table' => 'node',
52
+            'field' => 'nid',
53
+          ),
54
+          'right' => array(
55
+            'field' => $db_info['columns']['nid']['column']
56
+          ),
57
+        ),
58
+      );
59
+    }
60
+  }
61
+  return $tables;
62
+}
(1-1/2)