1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Views integration for advanced_forum.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Loads the included views.
|
10
|
*
|
11
|
* This function is used instead of views ability to autodiscover a views
|
12
|
* export .inc because this allows us to put each view in its own file.
|
13
|
* Thanks to Moshe and OG for the code.
|
14
|
*/
|
15
|
function advanced_forum_views_default_views() {
|
16
|
global $theme, $theme_path;
|
17
|
$files = file_scan_directory(drupal_get_path('module', 'advanced_forum') . '/includes/views', '/\.view$/');
|
18
|
$files += file_scan_directory(drupal_get_path('theme', variable_get('theme_default', 'garland')) . '/advanced_forum/views', '/\.view$/');
|
19
|
|
20
|
foreach ($files as $absolute => $file) {
|
21
|
$view = NULL;
|
22
|
require $absolute;
|
23
|
if (isset($view)) {
|
24
|
$views[$view->name] = $view;
|
25
|
}
|
26
|
}
|
27
|
|
28
|
return $views;
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Use views_data_alter to add items to the node table that are relevant to topic icons.
|
33
|
*/
|
34
|
function advanced_forum_views_data_alter(&$data) {
|
35
|
// Topic icon.
|
36
|
$data['node']['topic_icon'] = array(
|
37
|
'title' => t('Topic Icon'),
|
38
|
'help' => t('Icon that shows new posts, hot, sticky, locked, etc.'),
|
39
|
'field' => array(
|
40
|
'handler' => 'advanced_forum_handler_field_node_topic_icon',
|
41
|
),
|
42
|
);
|
43
|
|
44
|
$data['node']['topic_pager'] = array(
|
45
|
'title' => t('Topic Pager'),
|
46
|
'help' => t('Small pager for individual topics.'),
|
47
|
'field' => array(
|
48
|
'handler' => 'advanced_forum_handler_field_node_topic_pager',
|
49
|
),
|
50
|
);
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* Implements hook_views_plugins().
|
55
|
*/
|
56
|
function advanced_forum_views_plugins() {
|
57
|
$path = drupal_get_path('module', 'advanced_forum') . '/includes/views';
|
58
|
return array(
|
59
|
'style' => array(
|
60
|
'forum_topic_list' => array(
|
61
|
'parent' => 'table',
|
62
|
'path' => $path,
|
63
|
'title' => t('Forum topic list'),
|
64
|
'help' => t('Displays the forum topic list as a view.'),
|
65
|
'handler' => 'advanced_forum_plugin_style_forum_topic_list',
|
66
|
'theme path' => drupal_get_path('module', 'advanced_forum') . '/includes',
|
67
|
'theme file' => 'theme.inc',
|
68
|
'theme' => 'advanced_forum_topic_list_view',
|
69
|
'uses row plugin' => FALSE,
|
70
|
'uses fields' => TRUE,
|
71
|
'uses options' => TRUE,
|
72
|
'type' => 'normal',
|
73
|
),
|
74
|
),
|
75
|
);
|
76
|
}
|
77
|
|
78
|
/**
|
79
|
* Implements hook_views_data().
|
80
|
*/
|
81
|
function advanced_forum_views_data() {
|
82
|
$data = array();
|
83
|
// Forum table.
|
84
|
// Have not defined $data['forum']['table']['group'] since
|
85
|
// no fields are defined here yet.
|
86
|
$data['forum']['table']['join'] = array(
|
87
|
'node_revisions' => array(
|
88
|
'left_field' => 'vid',
|
89
|
'field' => 'vid',
|
90
|
),
|
91
|
'node' => array(
|
92
|
'left_field' => 'vid',
|
93
|
'field' => 'vid',
|
94
|
),
|
95
|
);
|
96
|
|
97
|
return $data;
|
98
|
}
|