1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
13c3c9b4
|
Assos Assos
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Forum list.
|
5 |
|
|
*/
|
6 |
85ad3d82
|
Assos Assos
|
|
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 |
13c3c9b4
|
Assos Assos
|
function advanced_forum_forum_list_content_type_render(
|
25 |
|
|
$subtype,
|
26 |
|
|
$conf,
|
27 |
|
|
$panel_args,
|
28 |
|
|
$context
|
29 |
|
|
) {
|
30 |
85ad3d82
|
Assos Assos
|
if (!empty($context) && empty($context->data)) {
|
31 |
|
|
return;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
13c3c9b4
|
Assos Assos
|
$tid = 0;
|
35 |
|
|
if (!empty($context)) {
|
36 |
85ad3d82
|
Assos Assos
|
$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 |
13c3c9b4
|
Assos Assos
|
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 |
85ad3d82
|
Assos Assos
|
'forums' => $forums,
|
56 |
|
|
'parents' => empty($context->parents) ? array() : $context->parents,
|
57 |
13c3c9b4
|
Assos Assos
|
'tid' => $tid,
|
58 |
|
|
)
|
59 |
|
|
);
|
60 |
85ad3d82
|
Assos Assos
|
|
61 |
13c3c9b4
|
Assos Assos
|
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 |
85ad3d82
|
Assos Assos
|
|
68 |
13c3c9b4
|
Assos Assos
|
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 |
85ad3d82
|
Assos Assos
|
);
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
13c3c9b4
|
Assos Assos
|
|
78 |
85ad3d82
|
Assos Assos
|
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 |
13c3c9b4
|
Assos Assos
|
/**
|
89 |
|
|
* Submit callback.
|
90 |
|
|
*/
|
91 |
|
|
function advanced_forum_forum_list_content_type_edit_form_submit(
|
92 |
|
|
$form,
|
93 |
|
|
&$form_state
|
94 |
|
|
) {
|
95 |
85ad3d82
|
Assos Assos
|
// 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 |
13c3c9b4
|
Assos Assos
|
/**
|
102 |
|
|
* Callback for admin title.
|
103 |
|
|
*/
|
104 |
|
|
function advanced_forum_forum_list_content_type_admin_title(
|
105 |
|
|
$subtype,
|
106 |
|
|
$conf,
|
107 |
|
|
$context
|
108 |
|
|
) {
|
109 |
85ad3d82
|
Assos Assos
|
return t('"@s" forum list', array('@s' => $context->identifier));
|
110 |
|
|
} |