1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Holds theme functions and template preprocesses.
|
6 |
|
|
* Other style related functions are in style.inc
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Theme function to display a link, optionally buttonized.
|
11 |
|
|
*/
|
12 |
|
|
function theme_advanced_forum_l(&$variables) {
|
13 |
|
|
$text = $variables['text'];
|
14 |
|
|
$path = empty($variables['path']) ? NULL : $variables['path'];
|
15 |
|
|
$options = empty($variables['options']) ? array() : $variables['options'];
|
16 |
|
|
$button_class = empty($variables['button_class']) ? NULL : $variables['button_class'];
|
17 |
|
|
|
18 |
|
|
$l = '';
|
19 |
|
|
if (!isset($options['attributes'])) {
|
20 |
|
|
$options['attributes'] = array();
|
21 |
|
|
}
|
22 |
|
|
if (!is_null($button_class)) {
|
23 |
|
|
// Buttonized link: add our button class and the span.
|
24 |
|
|
if (!isset($options['attributes']['class'])) {
|
25 |
|
|
$options['attributes']['class'] = array("af-button-$button_class");
|
26 |
|
|
}
|
27 |
|
|
else {
|
28 |
|
|
$options['attributes']['class'][] = "af-button-$button_class";
|
29 |
|
|
}
|
30 |
|
|
$options['html'] = TRUE;
|
31 |
13c3c9b4
|
Assos Assos
|
// @codingStandardsIgnoreStart
|
32 |
85ad3d82
|
Assos Assos
|
$l = l('<span>' . $text . '</span>', $path, $options);
|
33 |
13c3c9b4
|
Assos Assos
|
// @codingStandardsIgnoreEnd
|
34 |
85ad3d82
|
Assos Assos
|
}
|
35 |
|
|
else {
|
36 |
|
|
// Standard link: just send it through l().
|
37 |
|
|
$l = l($text, $path, $options);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
return $l;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* Theme function to show list of types that can be posted in forum.
|
45 |
|
|
*/
|
46 |
|
|
function theme_advanced_forum_node_type_create_list(&$variables) {
|
47 |
|
|
$forum_id = $variables['forum_id'];
|
48 |
|
|
|
49 |
|
|
// Get the list of node types to display links for.
|
50 |
|
|
$type_list = advanced_forum_node_type_create_list($forum_id);
|
51 |
|
|
|
52 |
|
|
$output = '';
|
53 |
|
|
if (is_array($type_list)) {
|
54 |
|
|
foreach ($type_list as $type => $item) {
|
55 |
|
|
$output .= '<div class="forum-add-node forum-add-' . $type . '">';
|
56 |
|
|
$output .= theme('advanced_forum_l', array(
|
57 |
|
|
'text' => t('New @node_type', array('@node_type' => $item['name'])),
|
58 |
|
|
'path' => $item['href'],
|
59 |
|
|
'options' => NULL,
|
60 |
13c3c9b4
|
Assos Assos
|
'button_class' => 'large',
|
61 |
|
|
));
|
62 |
85ad3d82
|
Assos Assos
|
$output .= '</div>';
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
else {
|
66 |
|
|
// User did not have access to create any node types in this fourm so
|
67 |
|
|
// we just return the denial text / login prompt.
|
68 |
|
|
$output = $type_list;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
return $output;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* Theme function to show simple author pane when not using Author Pane.
|
76 |
|
|
*/
|
77 |
|
|
function theme_advanced_forum_simple_author_pane(&$variables) {
|
78 |
|
|
$context = $variables['context'];
|
79 |
|
|
// Sending the context rather than the account makes it work for anon comments.
|
80 |
|
|
$name = theme('username', array('account' => $context));
|
81 |
|
|
|
82 |
|
|
$account = user_load($context->uid);
|
83 |
|
|
$picture = theme('user_picture', array('account' => $account));
|
84 |
|
|
|
85 |
|
|
return '<div class="author-pane">' . $name . $picture . '</div>';
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
/**
|
89 |
|
|
* Theme function to format the reply link at the top/bottom of topic.
|
90 |
|
|
*/
|
91 |
|
|
function theme_advanced_forum_reply_link(&$variables) {
|
92 |
|
|
$node = $variables['node'];
|
93 |
|
|
|
94 |
|
|
// Get the information about whether the user can reply and the link to do
|
95 |
|
|
// so if the user is allowed to.
|
96 |
|
|
$reply_link = advanced_forum_get_reply_link($node);
|
97 |
|
|
|
98 |
|
|
if (is_array($reply_link)) {
|
99 |
|
|
// Reply is allowed. Variable contains the link information.
|
100 |
|
|
$output = '<div class="topic-reply-allowed">';
|
101 |
|
|
$output .= theme('advanced_forum_l', array(
|
102 |
|
|
'text' => $reply_link['title'],
|
103 |
|
|
'path' => $reply_link['href'],
|
104 |
|
|
'options' => $reply_link['options'],
|
105 |
13c3c9b4
|
Assos Assos
|
'button_class' => 'large',
|
106 |
85ad3d82
|
Assos Assos
|
));
|
107 |
|
|
$output .= '</div>';
|
108 |
|
|
return $output;
|
109 |
|
|
}
|
110 |
|
|
elseif ($reply_link == 'reply-locked') {
|
111 |
|
|
// @TODO: The double span here is icky but I don't know how else to get
|
112 |
|
|
// around the fact that there's no "a" to put the button class on.
|
113 |
|
|
return '<div class="topic-reply-locked"><span class="af-button-large"><span>' . t('Topic locked') . '</span></span></div>';
|
114 |
|
|
}
|
115 |
|
|
elseif ($reply_link == 'reply-forbidden') {
|
116 |
|
|
// User is not allowed to reply to this topic.
|
117 |
|
|
return theme('comment_post_forbidden', array('node' => $node));
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
/**
|
122 |
|
|
* Theme function to a formatted list of subforums.
|
123 |
|
|
*
|
124 |
13c3c9b4
|
Assos Assos
|
* @param array $variables
|
125 |
85ad3d82
|
Assos Assos
|
* Array of subforums.
|
126 |
13c3c9b4
|
Assos Assos
|
*
|
127 |
|
|
* @return string
|
128 |
85ad3d82
|
Assos Assos
|
* Formatted list of subforums.
|
129 |
|
|
*/
|
130 |
|
|
function theme_advanced_forum_subforum_list(&$variables) {
|
131 |
|
|
$subforums = array();
|
132 |
|
|
foreach ($variables['subforum_list'] as $tid => $subforum) {
|
133 |
|
|
// Note: $subforum->name has not been run through check_plain because
|
134 |
|
|
// it ends up going through there when l() is called without the HTML
|
135 |
|
|
// option. If you change this to set HTML to TRUE, you must sanitize it.
|
136 |
|
|
$text = l($subforum->name, "forum/$tid");
|
137 |
|
|
$text .= ' (' . $subforum->total_posts;
|
138 |
|
|
|
139 |
|
|
if (empty($subforum->new_posts)) {
|
140 |
|
|
$text .= ')';
|
141 |
|
|
}
|
142 |
|
|
else {
|
143 |
|
|
$text .= ' - ' . l($subforum->new_posts_text, $subforum->new_posts_path, array('fragment' => 'new')) . ')';
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
$subforums[] = $text;
|
147 |
|
|
}
|
148 |
|
|
return implode(', ', $subforums);
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
/**
|
152 |
|
|
* Theme function to a formatted list of subcontainers.
|
153 |
|
|
*
|
154 |
13c3c9b4
|
Assos Assos
|
* @param array $variables
|
155 |
85ad3d82
|
Assos Assos
|
* Array of subcontainers.
|
156 |
13c3c9b4
|
Assos Assos
|
*
|
157 |
|
|
* @return string
|
158 |
85ad3d82
|
Assos Assos
|
* Formatted list of subcontainers.
|
159 |
|
|
*/
|
160 |
|
|
function theme_advanced_forum_subcontainer_list(&$variables) {
|
161 |
|
|
$subcontainers = array();
|
162 |
|
|
foreach ($variables['subcontainer_list'] as $tid => $subcontainer) {
|
163 |
|
|
// Note: $subcontainer->name has not been run through check_plain because
|
164 |
|
|
// it ends up going through there when l() is called without the HTML
|
165 |
|
|
// option. If you change this to set HTML to TRUE, you must sanitize it.
|
166 |
|
|
$text = l($subcontainer->name, "forum/$tid");
|
167 |
|
|
$text .= ' (' . $subcontainer->total_posts;
|
168 |
|
|
|
169 |
|
|
if (empty($subcontainer->new_posts)) {
|
170 |
|
|
$text .= ')';
|
171 |
|
|
}
|
172 |
|
|
else {
|
173 |
|
|
$text .= ' - ' . l($subforum->new_posts_text, $subforum->new_posts_path, array('fragment' => 'new')) . ')';
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
$subcontainers[] = $text;
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
return implode(', ', $subcontainers);
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
// TEMPLATE PREPROCESS ******************************************************/
|
183 |
|
|
|
184 |
|
|
/* * * FORUM OVERVIEW & TOPIC LIST PAGES ************************************* */
|
185 |
|
|
|
186 |
|
|
/**
|
187 |
|
|
* Preprocesses template variables for the forum template.
|
188 |
|
|
*/
|
189 |
|
|
function advanced_forum_preprocess_forums(&$variables) {
|
190 |
|
|
include_once drupal_get_path('module', 'advanced_forum') . '/includes/advanced_forum_preprocess_forums.inc';
|
191 |
|
|
_advanced_forum_preprocess_forums($variables);
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
/**
|
195 |
|
|
* Preprocesses template variables for the forum search form template.
|
196 |
|
|
*/
|
197 |
|
|
function advanced_forum_preprocess_advanced_forum_search_forum(&$variables) {
|
198 |
|
|
advanced_forum_add_template_suggestions("search_forum", $variables);
|
199 |
|
|
|
200 |
|
|
$variables['forum'] = !empty($variables['tid']) ? $variables['tid'] : 'All';
|
201 |
|
|
$variables['path'] = url('forum/search');
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
/**
|
205 |
|
|
* Preprocesses template variables for the search results template.
|
206 |
|
|
*/
|
207 |
|
|
function advanced_forum_preprocess_views_view_fields__advanced_forum_search(&$variables) {
|
208 |
|
|
_advanced_forum_add_files();
|
209 |
|
|
advanced_forum_add_template_suggestions("search_result", $variables);
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
/**
|
213 |
|
|
* Preprocesses template variables for the submitted by/in template.
|
214 |
|
|
*/
|
215 |
|
|
function advanced_forum_preprocess_forum_submitted(&$variables) {
|
216 |
|
|
advanced_forum_add_template_suggestions("submitted", $variables);
|
217 |
13c3c9b4
|
Assos Assos
|
// Avoid E_ALL warning.
|
218 |
85ad3d82
|
Assos Assos
|
$variables['topic_link'] = '';
|
219 |
|
|
|
220 |
|
|
if (isset($variables['topic']->node_title)) {
|
221 |
|
|
$nid = $variables['topic']->nid;
|
222 |
|
|
|
223 |
13c3c9b4
|
Assos Assos
|
// Make a fake node object to avoid the node load.
|
224 |
85ad3d82
|
Assos Assos
|
$node = new stdClass();
|
225 |
|
|
$node->nid = $nid;
|
226 |
|
|
$node->type = $variables['topic']->type;
|
227 |
|
|
|
228 |
13c3c9b4
|
Assos Assos
|
// Find the page of the first unread comment, if any.
|
229 |
85ad3d82
|
Assos Assos
|
$comment_count = db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
|
230 |
|
|
$new_replies = advanced_forum_reply_num_new($nid);
|
231 |
|
|
$query = advanced_forum_page_first_new($comment_count, $new_replies, $node);
|
232 |
|
|
|
233 |
13c3c9b4
|
Assos Assos
|
// Format the node title with a link.
|
234 |
85ad3d82
|
Assos Assos
|
$title_length = variable_get('advanced_forum_topic_title_length', 15);
|
235 |
|
|
if ($title_length == 0) {
|
236 |
|
|
$short_topic_title = $variables['topic']->node_title;
|
237 |
|
|
}
|
238 |
|
|
else {
|
239 |
|
|
$short_topic_title = truncate_utf8($variables['topic']->node_title, $title_length, TRUE, TRUE);
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
$variables['short_topic_title'] = $short_topic_title;
|
243 |
|
|
|
244 |
|
|
$fragment = ($new_replies) ? 'new' : NULL;
|
245 |
|
|
|
246 |
|
|
$variables['topic_link_fragment'] = $fragment;
|
247 |
|
|
$variables['topic_link_query'] = $query;
|
248 |
|
|
$variables['topic_link'] = l($short_topic_title, "node/$nid", array('query' => $query, 'fragment' => $fragment));
|
249 |
|
|
}
|
250 |
|
|
|
251 |
|
|
if (isset($variables['topic']->created)) {
|
252 |
|
|
$timestamp = $variables['topic']->created;
|
253 |
|
|
$interval = REQUEST_TIME - $timestamp;
|
254 |
|
|
$variables['time'] = format_interval($interval);
|
255 |
|
|
|
256 |
|
|
// For items posted more than $cutoff hours ago, offer an actual date.
|
257 |
|
|
$cutoff = variable_get('advanced_forum_time_ago_cutoff', 48) * 60 * 60;
|
258 |
|
|
if ($interval > $cutoff) {
|
259 |
|
|
$variables['date_posted'] = format_date($timestamp, 'short');
|
260 |
|
|
}
|
261 |
|
|
else {
|
262 |
|
|
unset($variables['date_posted']);
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
|
|
}
|
266 |
|
|
|
267 |
13c3c9b4
|
Assos Assos
|
/**
|
268 |
|
|
* Preprocess forum topic pager.
|
269 |
|
|
*/
|
270 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_advanced_forum_topic_pager(&$variables) {
|
271 |
|
|
$pagecount = $variables['pagecount'];
|
272 |
|
|
$topic = $variables['topic'];
|
273 |
|
|
|
274 |
|
|
// Get the information to assemble the pager. This returns an object with
|
275 |
|
|
// the following properties:
|
276 |
13c3c9b4
|
Assos Assos
|
// - initial_pages: Array of linked numbers for first set of pages
|
277 |
|
|
// - last_page_text: Linked text "Last page" (translatable)
|
278 |
|
|
// - last_page_number: Linked number pointing to the last page.
|
279 |
85ad3d82
|
Assos Assos
|
$topic_pager = advanced_forum_create_topic_pager($pagecount, $topic);
|
280 |
|
|
|
281 |
|
|
$variables['last_page_text'] = '';
|
282 |
|
|
|
283 |
|
|
if (!empty($topic_pager->initial_pages)) {
|
284 |
|
|
$variables['pages'] = $topic_pager->initial_pages;
|
285 |
|
|
if (!empty($topic_pager->last_page_text)) {
|
286 |
|
|
$variables['last_page'] = $topic_pager->last_page;
|
287 |
|
|
$variables['last_page_text'] = $topic_pager->last_page_text;
|
288 |
|
|
$variables['last_page_number'] = $topic_pager->last_page_number;
|
289 |
|
|
|
290 |
|
|
// If you prefer to end with the number, replace
|
291 |
|
|
// $topic_pager->last_page_text with $topic_pager->last_page_number
|
292 |
|
|
$variables['last_page_text'] = ' … ' . $topic_pager->last_page_text;
|
293 |
|
|
}
|
294 |
|
|
}
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
/**
|
298 |
13c3c9b4
|
Assos Assos
|
* Preprocess variables for advanced-forum.naked.post-edited.tpl.php.
|
299 |
85ad3d82
|
Assos Assos
|
*/
|
300 |
|
|
function advanced_forum_preprocess_advanced_forum_post_edited(&$variables) {
|
301 |
|
|
$editor = user_load($variables['who']);
|
302 |
|
|
|
303 |
|
|
$variables['edited_name'] = theme('username', array('account' => $editor));
|
304 |
|
|
$variables['edited_datetime'] = format_date($variables['when'], 'custom', variable_get('date_format_short', 'm/d/Y - H:i'));
|
305 |
|
|
$variables['edited_reason'] = empty($variables['why']) ? '' : $variables['why'];
|
306 |
|
|
}
|
307 |
|
|
|
308 |
13c3c9b4
|
Assos Assos
|
/**
|
309 |
|
|
* Preprocess forum shadow topic.
|
310 |
|
|
*/
|
311 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_advanced_forum_shadow_topic(&$variables) {
|
312 |
|
|
$nid = $variables['nid'];
|
313 |
|
|
|
314 |
|
|
$variables['new_forum_url'] = url("node/$nid");
|
315 |
13c3c9b4
|
Assos Assos
|
// Compatibility variable.
|
316 |
85ad3d82
|
Assos Assos
|
$variables['new_forum_link'] = l(t('View topic'), "node/$nid");
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
/* * * JUST FORUM OVERVIEW PAGE ********************************************** */
|
320 |
|
|
|
321 |
|
|
/**
|
322 |
|
|
* Preprocesses template variables for the forum legend template.
|
323 |
|
|
*/
|
324 |
|
|
function advanced_forum_preprocess_advanced_forum_forum_legend(&$variables) {
|
325 |
|
|
advanced_forum_add_template_suggestions("forum_legend", $variables);
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
/**
|
329 |
|
|
* Preprocesses template variables for the forum statistics template.
|
330 |
|
|
*/
|
331 |
|
|
function advanced_forum_preprocess_advanced_forum_statistics(&$variables) {
|
332 |
|
|
advanced_forum_add_template_suggestions("statistics", $variables);
|
333 |
|
|
|
334 |
|
|
$variables['topics'] = advanced_forum_statistics_topics();
|
335 |
|
|
$variables['posts'] = advanced_forum_statistics_replies() + $variables['topics'];
|
336 |
|
|
$variables['users'] = advanced_forum_statistics_users();
|
337 |
|
|
|
338 |
|
|
$authenticated_users = advanced_forum_statistics_online_users();
|
339 |
|
|
$variables['online_users'] = implode(', ', $authenticated_users);
|
340 |
|
|
$variables['current_users'] = advanced_forum_session_count(FALSE);
|
341 |
13c3c9b4
|
Assos Assos
|
// For backwards compatibility.
|
342 |
|
|
$variables['current_guests'] = 0;
|
343 |
85ad3d82
|
Assos Assos
|
$variables['current_total'] = $variables['current_users'] + $variables['current_guests'];
|
344 |
|
|
|
345 |
|
|
$latest_users = advanced_forum_statistics_latest_users();
|
346 |
|
|
$variables['latest_users'] = implode(', ', $latest_users);
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
/**
|
350 |
|
|
* Preprocesses template variables for the forum list template.
|
351 |
|
|
*/
|
352 |
|
|
function advanced_forum_preprocess_forum_list(&$variables) {
|
353 |
|
|
include_once drupal_get_path('module', 'advanced_forum') . '/includes/advanced_forum_preprocess_forum_list.inc';
|
354 |
|
|
_advanced_forum_preprocess_forum_list($variables);
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
/* * * JUST TOPIC LIST PAGES ************************************************* */
|
358 |
|
|
|
359 |
13c3c9b4
|
Assos Assos
|
/**
|
360 |
|
|
* Preprocess views forum topic list.
|
361 |
|
|
*/
|
362 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_views_view__advanced_forum_topic_list(&$variables) {
|
363 |
|
|
_advanced_forum_add_files();
|
364 |
|
|
advanced_forum_add_template_suggestions("topic_list_outer_view", $variables);
|
365 |
|
|
|
366 |
|
|
$variables['node_create_list'] = '';
|
367 |
|
|
$variables['forum_tools'] = '';
|
368 |
|
|
$variables['forum_jump'] = '';
|
369 |
|
|
|
370 |
|
|
$menu_item = menu_get_item();
|
371 |
|
|
|
372 |
|
|
if (!empty($menu_item) && $menu_item['access']) {
|
373 |
|
|
if (($menu_item['map'][0] == 'forum') && (!empty($menu_item['map'][1]))) {
|
374 |
|
|
$forum = $menu_item['map'][1];
|
375 |
|
|
if ($forum->vid == variable_get('forum_nav_vocabulary') && $forum->tid > 0) {
|
376 |
|
|
$variables['node_create_list'] = theme('advanced_forum_node_type_create_list', array('forum_id' => $forum->tid));
|
377 |
|
|
$variables['forum_description'] = $forum->description;
|
378 |
|
|
$variables['forum_tools'] = advanced_forum_forum_tools($forum->tid);
|
379 |
|
|
$variables['forum_jump'] = advanced_forum_forum_jump($forum->tid);
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
}
|
383 |
|
|
}
|
384 |
|
|
|
385 |
|
|
/**
|
386 |
|
|
* Display a view as a forum topic list style.
|
387 |
|
|
*/
|
388 |
|
|
function template_preprocess_advanced_forum_topic_list_view(&$variables) {
|
389 |
|
|
include_once drupal_get_path('module', 'advanced_forum') . '/includes/template_preprocess_advanced_forum_topic_list_view.inc';
|
390 |
|
|
_template_preprocess_advanced_forum_topic_list_view($variables);
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
/**
|
394 |
|
|
* Preprocesses template variables for the topic list template.
|
395 |
|
|
*/
|
396 |
|
|
function advanced_forum_preprocess_forum_topic_list(&$variables) {
|
397 |
|
|
advanced_forum_add_template_suggestions("topic_list", $variables);
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
/**
|
401 |
|
|
* Preprocesses template variables for the forum icon template.
|
402 |
|
|
*/
|
403 |
|
|
function advanced_forum_preprocess_forum_icon(&$variables) {
|
404 |
|
|
advanced_forum_add_template_suggestions("topic_icon", $variables);
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
/**
|
408 |
|
|
* Preprocesses template variables for the topic legend template.
|
409 |
|
|
*/
|
410 |
|
|
function advanced_forum_preprocess_advanced_forum_topic_legend(&$variables) {
|
411 |
|
|
advanced_forum_add_template_suggestions("topic_legend", $variables);
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
/* * * TOPIC PAGES *********************************************************** */
|
415 |
13c3c9b4
|
Assos Assos
|
/**
|
416 |
|
|
* Preprocess forum search topic.
|
417 |
|
|
*/
|
418 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_advanced_forum_search_topic(&$variables) {
|
419 |
|
|
advanced_forum_add_template_suggestions("search_topic", $variables);
|
420 |
|
|
|
421 |
|
|
$variables['path'] = url('node/' . $variables['node']->nid . '/search');
|
422 |
|
|
}
|
423 |
|
|
|
424 |
13c3c9b4
|
Assos Assos
|
/**
|
425 |
|
|
* Preprocess views forum search topic.
|
426 |
|
|
*/
|
427 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_views_view_fields__advanced_forum_search_topic(&$variables) {
|
428 |
|
|
_advanced_forum_add_files();
|
429 |
|
|
advanced_forum_add_template_suggestions("search_result", $variables);
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
/**
|
433 |
|
|
* Preprocesses template variables for the topic header template.
|
434 |
|
|
*/
|
435 |
|
|
function advanced_forum_preprocess_advanced_forum_topic_header(&$variables) {
|
436 |
|
|
advanced_forum_add_template_suggestions("topic_header", $variables);
|
437 |
|
|
|
438 |
|
|
$node = $variables['node'];
|
439 |
|
|
|
440 |
13c3c9b4
|
Assos Assos
|
// Reply link/button.
|
441 |
85ad3d82
|
Assos Assos
|
$variables['reply_link'] = theme('advanced_forum_reply_link', array('node' => $node));
|
442 |
|
|
|
443 |
|
|
// Total posts, including first post.
|
444 |
|
|
$posts = (empty($variables['comment_count'])) ? 1 : $variables['comment_count'] + 1;
|
445 |
|
|
$variables['total_posts_count'] = format_plural($posts, '1 post', '@count posts');
|
446 |
|
|
|
447 |
|
|
// Number of new posts on topic.
|
448 |
|
|
$variables['new_posts_count'] = advanced_forum_reply_num_new($node->nid);
|
449 |
|
|
|
450 |
|
|
// Link to first new post.
|
451 |
|
|
$variables['first_new_post_link'] = '';
|
452 |
|
|
if ($posts > 1) {
|
453 |
|
|
$variables['first_new_post_link'] = advanced_forum_first_new_post_link($variables['node'], $variables['comment_count']);
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
// Link to last post in topic.
|
457 |
|
|
$variables['last_post_link'] = advanced_forum_last_post_link($node);
|
458 |
|
|
|
459 |
13c3c9b4
|
Assos Assos
|
// Pager.
|
460 |
|
|
if (isset($variables['node']->comment_count)) {
|
461 |
85ad3d82
|
Assos Assos
|
pager_default_initialize($variables['node']->comment_count, variable_get('comment_default_per_page_' . $variables['node']->type, 50));
|
462 |
13c3c9b4
|
Assos Assos
|
}
|
463 |
85ad3d82
|
Assos Assos
|
|
464 |
|
|
$variables['pager'] = theme('pager');
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
/**
|
468 |
|
|
* Preprocesses template variables for the active poster template.
|
469 |
|
|
*/
|
470 |
|
|
function advanced_forum_preprocess_advanced_forum_active_poster(&$variables) {
|
471 |
|
|
advanced_forum_add_template_suggestions("active_poster", $variables);
|
472 |
|
|
|
473 |
|
|
$variables['account_name'] = theme('username', array('account' => $variables['account']));
|
474 |
|
|
$variables['picture'] = theme('advanced_forum_user_picture', array('account' => $variables['account']));
|
475 |
|
|
|
476 |
|
|
$node = $variables['last_post'];
|
477 |
|
|
$variables['last_post_title'] = l($node->title, "node/$node->nid");
|
478 |
|
|
$variables['last_post_date'] = format_date($node->created);
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
/**
|
482 |
|
|
* Preprocesses template variables for the author pane.
|
483 |
|
|
*/
|
484 |
|
|
function advanced_forum_preprocess_author_pane(&$variables) {
|
485 |
|
|
// Author pane is used in various places. Check the caller to make sure
|
486 |
|
|
// we are the one that called it.
|
487 |
|
|
if (!empty($variables['caller']) && $variables['caller'] == 'advanced_forum') {
|
488 |
|
|
advanced_forum_add_template_suggestions("author_pane", $variables);
|
489 |
|
|
}
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
/**
|
493 |
|
|
* Preprocesses template variables for the page template.
|
494 |
|
|
*/
|
495 |
|
|
function advanced_forum_preprocess_page(&$variables) {
|
496 |
|
|
if (arg(0) == 'forum') {
|
497 |
|
|
$variables['forum_page'] = TRUE;
|
498 |
|
|
}
|
499 |
|
|
elseif (arg(0) == 'node' && !empty($variables['node']) && advanced_forum_type_is_in_forum($variables['node']->type)) {
|
500 |
|
|
$variables['forum_page'] = TRUE;
|
501 |
|
|
}
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
/**
|
505 |
|
|
* Preprocesses template variables for the node template.
|
506 |
|
|
*/
|
507 |
|
|
function advanced_forum_preprocess_node(&$variables) {
|
508 |
|
|
if (advanced_forum_is_styled($variables['node'], $variables['teaser'], 'node')) {
|
509 |
|
|
include_once drupal_get_path('module', 'advanced_forum') . '/includes/advanced_forum_preprocess_node.inc';
|
510 |
|
|
_advanced_forum_preprocess_node($variables);
|
511 |
|
|
}
|
512 |
|
|
}
|
513 |
|
|
|
514 |
13c3c9b4
|
Assos Assos
|
/**
|
515 |
|
|
* Preprocess comment wrapper.
|
516 |
|
|
*/
|
517 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_comment_wrapper(&$variables) {
|
518 |
|
|
$variables['reply_link'] = '';
|
519 |
|
|
if (advanced_forum_is_styled($variables['node'], FALSE, 'comment-wrapper')) {
|
520 |
|
|
advanced_forum_add_template_suggestions("advanced_forum_comment_wrapper", $variables);
|
521 |
|
|
|
522 |
|
|
$form_on_seperate_page = variable_get('comment_form_location_' . $variables['node']->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE;
|
523 |
|
|
|
524 |
|
|
$comments_locked = $variables['node']->comment != COMMENT_NODE_OPEN;
|
525 |
|
|
|
526 |
|
|
if ($form_on_seperate_page || $comments_locked) {
|
527 |
|
|
// If the post is locked or the comment form is on a seperate page,
|
528 |
13c3c9b4
|
Assos Assos
|
// build the reply/locked link / button.
|
529 |
85ad3d82
|
Assos Assos
|
$variables['reply_link'] = theme('advanced_forum_reply_link', array('node' => $variables['node']));
|
530 |
|
|
}
|
531 |
|
|
}
|
532 |
|
|
}
|
533 |
|
|
|
534 |
|
|
/**
|
535 |
|
|
* Preprocesses template variables for the comment template.
|
536 |
|
|
*/
|
537 |
|
|
function advanced_forum_preprocess_comment(&$variables) {
|
538 |
|
|
if (advanced_forum_is_styled($variables['comment'], FALSE, 'comment')) {
|
539 |
|
|
include_once drupal_get_path('module', 'advanced_forum') . '/includes/advanced_forum_preprocess_comment.inc';
|
540 |
|
|
_advanced_forum_preprocess_comment($variables);
|
541 |
|
|
}
|
542 |
|
|
}
|
543 |
|
|
|
544 |
|
|
/* * * ORGANIC GROUPS ******************************************************** */
|
545 |
13c3c9b4
|
Assos Assos
|
/**
|
546 |
|
|
* Preprocess view forum group list.
|
547 |
|
|
*/
|
548 |
85ad3d82
|
Assos Assos
|
function advanced_forum_preprocess_views_view__advanced_forum_group_topic_list(&$variables) {
|
549 |
|
|
_advanced_forum_add_files();
|
550 |
|
|
advanced_forum_add_template_suggestions("group_topic_list_outer_view", $variables);
|
551 |
|
|
|
552 |
|
|
// Set a variable for displaying the topic legend.
|
553 |
|
|
$variables['topic_legend'] = theme('advanced_forum_topic_legend');
|
554 |
13c3c9b4
|
Assos Assos
|
} |