Projet

Général

Profil

Paste
Télécharger (2,7 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / advanced_forum / includes / views / advanced_forum.views.inc @ 024de6ea

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
  if (variable_get('advanced_forum_autoload_views', TRUE)) {
17
    global $theme, $theme_path;
18
    $files = file_scan_directory(drupal_get_path('module', 'advanced_forum') . '/includes/views', '/\.view$/');
19
    $files += file_scan_directory(drupal_get_path('theme', variable_get('theme_default', 'garland')) . '/advanced_forum/views', '/\.view$/');
20

    
21
    foreach ($files as $absolute => $file) {
22
      $view = NULL;
23
      require $absolute;
24
      if (isset($view)) {
25
        $views[$view->name] = $view;
26
      }
27
    }
28

    
29
    return $views;
30
  }
31
}
32

    
33
/**
34
 * Use views_data_alter to add items to the node table that are relevant to topic icons.
35
 */
36
function advanced_forum_views_data_alter(&$data) {
37
  // Topic icon.
38
  $data['node']['topic_icon'] = array(
39
    'title' => t('Topic Icon'),
40
    'help' => t('Icon that shows new posts, hot, sticky, locked, etc.'),
41
    'field' => array(
42
      'handler' => 'advanced_forum_handler_field_node_topic_icon',
43
    ),
44
  );
45

    
46
  $data['node']['topic_pager'] = array(
47
    'title' => t('Topic Pager'),
48
    'help' => t('Small pager for individual topics.'),
49
    'field' => array(
50
      'handler' => 'advanced_forum_handler_field_node_topic_pager',
51
    ),
52
  );
53
}
54

    
55
/**
56
 * Implements hook_views_plugins().
57
 */
58
function advanced_forum_views_plugins() {
59
  $path = drupal_get_path('module', 'advanced_forum') . '/includes/views';
60
  return array(
61
    'style' => array(
62
      'forum_topic_list' => array(
63
        'parent' => 'table',
64
        'path' => $path,
65
        'title' => t('Forum topic list'),
66
        'help' => t('Displays the forum topic list as a view.'),
67
        'handler' => 'advanced_forum_plugin_style_forum_topic_list',
68
        'theme path' => drupal_get_path('module', 'advanced_forum') . '/includes',
69
        'theme file' => 'theme.inc',
70
        'theme' => 'advanced_forum_topic_list_view',
71
        'uses row plugin' => FALSE,
72
        'uses fields' => TRUE,
73
        'uses options' => TRUE,
74
        'type' => 'normal',
75
      ),
76
    ),
77
  );
78
}
79

    
80
/**
81
 * Implements hook_views_data().
82
 */
83
function advanced_forum_views_data() {
84
  $data = array();
85
  // Forum table.
86
  // Have not defined $data['forum']['table']['group'] since
87
  // no fields are defined here yet.
88
  $data['forum']['table']['join'] = array(
89
    'node_revisions' => array(
90
      'left_field' => 'vid',
91
      'field' => 'vid',
92
    ),
93
    'node' => array(
94
      'left_field' => 'vid',
95
      'field' => 'vid',
96
    ),
97
  );
98

    
99
  return $data;
100
}