Projet

Général

Profil

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

root / drupal7 / sites / all / modules / advanced_forum / includes / views / advanced_forum.views.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Views integration for advanced_forum.
6
 */
7

    
8

    
9
/**
10
 * Loads the included views
11
 *
12
 * This function is used instead of views ability to autodiscover a views
13
 * export .inc because this allows us to put each view in its own file.
14
 * Thanks to Moshe and OG for the code.
15
 */
16
function advanced_forum_views_default_views() {
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
 * Use views_data_alter to add items to the node table that are
34
 * 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
 * Implementation of 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
 * Implementation of hook_views_data()
82
 */
83
function advanced_forum_views_data() {
84
  $data = array();
85
  // ----------------------------------------------------------------------
86
  // forum table
87

    
88
  // Have not defined $data['forum']['table']['group'] since
89
  // no fields are defined here yet.
90
  $data['forum']['table']['join'] = array(
91
    'node_revisions' => array(
92
      'left_field' => 'vid',
93
      'field' => 'vid',
94
    ),
95
    'node' => array(
96
      'left_field' => 'vid',
97
      'field' => 'vid',
98
    ),
99
  );
100

    
101
  return $data;
102
}