Projet

Général

Profil

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

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

1
<?php
2
/**
3
 * @file
4
 * Forum topic 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 topic list'),
14
  'icon' => 'icon_forum.png',
15
  'description' => t('The list of all topics for a forum.'),
16
  'required context' => new ctools_context_required(t('Forum'), 'forum'),
17
  'category' => t('Forum'),
18
  'defaults' => array('show_sort' => TRUE),
19
);
20

    
21
/**
22
 * Render the content.
23
 */
24
function advanced_forum_forum_topic_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
  if (!empty($context->data->container)) {
35
    return;
36
  }
37

    
38
  $tid = 0;
39
  if (!empty($context)) {
40
    $tid = $context->data->tid;
41
  }
42

    
43
  $block = new stdClass();
44
  $block->module = 'forum-secondary-links';
45
  $block->delta = $tid;
46

    
47
  // By default this has no title.
48
  $block->title = '';
49
  _advanced_forum_add_files();
50

    
51
  // TODO: We could make these settings, but they're ignored if it isusing
52
  // the view, so we have to be careful about that.
53
  $forum_per_page = variable_get('forum_per_page', 25);
54
  $sortby = variable_get('forum_order', 1);
55

    
56
  $block->content = advanced_forum_get_topics(
57
    $tid,
58
    $sortby,
59
    $forum_per_page,
60
    !empty($conf['show_sort'])
61
  );
62

    
63
  return $block;
64
}
65

    
66
/**
67
 * Returns an edit form for the custom type.
68
 */
69
function advanced_forum_forum_topic_list_content_type_edit_form(
70
  $form,
71
  &$form_state
72
) {
73
  $conf = $form_state['conf'];
74
  $form['show_sort'] = array(
75
    '#type' => 'checkbox',
76
    '#title' => t('Show sort form'),
77
    '#description' => t(
78
      'If checked the sort form will appear at the top of the table. Uncheck this if you wish it to appear in a separate pane.'
79
    ),
80
    '#default_value' => !empty($conf['show_sort']),
81
  );
82

    
83
  return $form;
84
}
85

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

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