Projet

Général

Profil

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

root / drupal7 / sites / all / modules / advanced_forum / plugins / content_types / forum_list.inc @ 13c3c9b4

1
<?php
2
/**
3
 * @file
4
 * Forum list.
5
 */
6

    
7
/**
8
 * Plugins are described by creating a $plugin array which will be used
9
 * by the system that includes this file.
10
 */
11
$plugin = array(
12
  'single' => TRUE,
13
  'title' => t('Forum list'),
14
  'icon' => 'icon_forum.png',
15
  'description' => t('A list of forums for the forum.'),
16
  'required context' => new ctools_context_required(t('Forum'), 'forum'),
17
  'category' => t('Forum'),
18
  'defaults' => array(),
19
);
20

    
21
/**
22
 * Render the content.
23
 */
24
function advanced_forum_forum_list_content_type_render(
25
  $subtype,
26
  $conf,
27
  $panel_args,
28
  $context
29
) {
30
  if (!empty($context) && empty($context->data)) {
31
    return;
32
  }
33

    
34
  $tid = 0;
35
  if (!empty($context)) {
36
    $tid = $context->data->tid;
37
  }
38

    
39
  $block = new stdClass();
40
  $block->module = 'forum-list';
41
  $block->delta = $tid;
42

    
43
  _advanced_forum_add_files();
44

    
45
  $forum_term = advanced_forum_forum_load($tid);
46
  $forums = isset($forum_term->forums) ? $forum_term->forums : array();
47

    
48
  if (empty($forums)) {
49
    return $block;
50
  }
51
  // No parents on the main forum page.
52
  $block->content = theme(
53
    'forum_list',
54
    array(
55
      'forums' => $forums,
56
      'parents' => empty($context->parents) ? array() : $context->parents,
57
      'tid' => $tid,
58
    )
59
  );
60

    
61
  if (user_access('administer forums')) {
62
    $block->admin_links['administer_forums'] = array(
63
      'title' => t('Administer forums'),
64
      'alt' => t("Add, delete or modify forums"),
65
      'href' => "admin/structure/forum",
66
    );
67

    
68
    if ($tid) {
69
      $block->admin_links['edit_forum'] = array(
70
        'title' => t('Edit forum'),
71
        'alt' => t("Modify this forum"),
72
        'href' => "admin/structure/forum/edit/" . ($context->data->container ? 'container/' : 'forum/') . $tid,
73
        'query' => drupal_get_destination(),
74
      );
75
    }
76
  }
77

    
78
  return $block;
79
}
80

    
81
/**
82
 * Returns an edit form for the custom type.
83
 */
84
function advanced_forum_forum_list_content_type_edit_form($form, &$form_state) {
85
  return $form;
86
}
87

    
88
/**
89
 * Submit callback.
90
 */
91
function advanced_forum_forum_list_content_type_edit_form_submit(
92
  $form,
93
  &$form_state
94
) {
95
  // Copy everything from our defaults.
96
  foreach (array_keys($form_state['plugin']['defaults']) as $key) {
97
    $form_state['conf'][$key] = $form_state['values'][$key];
98
  }
99
}
100

    
101
/**
102
 * Callback for admin title.
103
 */
104
function advanced_forum_forum_list_content_type_admin_title(
105
  $subtype,
106
  $conf,
107
  $context
108
) {
109
  return t('"@s" forum list', array('@s' => $context->identifier));
110
}