1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Holds the contents of a preprocess function moved into its own file
|
6 |
|
|
* to ease memory requirements and having too much code in one file.
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
13c3c9b4
|
Assos Assos
|
/**
|
10 |
|
|
* Preprocess node.
|
11 |
|
|
*/
|
12 |
85ad3d82
|
Assos Assos
|
function _advanced_forum_preprocess_node(&$variables) {
|
13 |
|
|
/* Shortcut variables */
|
14 |
|
|
$node = $variables['node'];
|
15 |
|
|
|
16 |
|
|
// Determine the template file to use for the node.
|
17 |
|
|
if (isset($_GET['page']) && $_GET['page'] > 0) {
|
18 |
|
|
// This is the repeated node on the top of subsequent pages.
|
19 |
|
|
// We send this to a special .tpl so people can adjust it to their needs.
|
20 |
|
|
advanced_forum_add_template_suggestions("post-repeated", $variables);
|
21 |
|
|
}
|
22 |
13c3c9b4
|
Assos Assos
|
elseif (arg(1) == 'reply' || (arg(0) == 'node' && arg(1) == 'add') || !empty($node->in_preview)) {
|
23 |
85ad3d82
|
Assos Assos
|
// 'reply' deals with the first post being shown when adding a comment.
|
24 |
|
|
// 'node/add' is when previewing a new forum post.
|
25 |
|
|
advanced_forum_add_template_suggestions("post-preview", $variables);
|
26 |
|
|
}
|
27 |
|
|
else {
|
28 |
13c3c9b4
|
Assos Assos
|
// Use our combined node/comment template file.
|
29 |
85ad3d82
|
Assos Assos
|
advanced_forum_add_template_suggestions("post", $variables);
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
/* Topic header */
|
33 |
|
|
$variables['top_post'] = TRUE;
|
34 |
|
|
|
35 |
13c3c9b4
|
Assos Assos
|
// Build the topic header.
|
36 |
85ad3d82
|
Assos Assos
|
$variables['topic_header'] = theme('advanced_forum_topic_header', array(
|
37 |
|
|
'node' => $node,
|
38 |
|
|
'comment_count' => isset($variables['comment_count']) ? $variables['comment_count'] : 0,
|
39 |
|
|
));
|
40 |
|
|
|
41 |
13c3c9b4
|
Assos Assos
|
if (!variable_get('advanced_forum_keep_classes', FALSE) || !is_array($variables['classes_array'])) {
|
42 |
|
|
// Add in our classes overwriting existing.
|
43 |
85ad3d82
|
Assos Assos
|
$variables['classes_array'] = array();
|
44 |
|
|
}
|
45 |
|
|
|
46 |
13c3c9b4
|
Assos Assos
|
$variables['classes_array'][] = 'forum-post clearfix';
|
47 |
85ad3d82
|
Assos Assos
|
|
48 |
|
|
// Add the current language to the classes for image handling.
|
49 |
|
|
global $language;
|
50 |
|
|
if (!empty($language->language)) {
|
51 |
|
|
$variables['classes_array'][] = $language->language;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
13c3c9b4
|
Assos Assos
|
// Add the poster's UID.
|
55 |
85ad3d82
|
Assos Assos
|
$variables['classes_array'][] = "posted-by-$node->uid";
|
56 |
|
|
|
57 |
|
|
/* Post ID */
|
58 |
13c3c9b4
|
Assos Assos
|
// Set the post ID for theming/targetting.
|
59 |
85ad3d82
|
Assos Assos
|
$variables['post_id'] = "post-$node->nid";
|
60 |
|
|
|
61 |
|
|
/* Linked post number */
|
62 |
|
|
if (!isset($post_number)) {
|
63 |
|
|
static $post_number = 1;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
$page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
|
67 |
|
|
|
68 |
|
|
// If this is the topic starting node, we need to start off the numbering.
|
69 |
13c3c9b4
|
Assos Assos
|
// Variable changed from post_link to permalink to match core variable.
|
70 |
|
|
// @codingStandardsIgnoreStart
|
71 |
85ad3d82
|
Assos Assos
|
$variables['permalink'] = l('#1', "node/$node->nid");
|
72 |
13c3c9b4
|
Assos Assos
|
// @codingStandardsIgnoreEnd
|
73 |
85ad3d82
|
Assos Assos
|
|
74 |
|
|
/* In reply to */
|
75 |
|
|
$variables['in_reply_to'] = "";
|
76 |
|
|
|
77 |
|
|
/* User information / author pane */
|
78 |
|
|
$variables['account'] = user_load($node->uid);
|
79 |
|
|
|
80 |
|
|
if (!module_exists('author_pane')) {
|
81 |
|
|
// If not using the Author Pane module, create a simple version with just
|
82 |
|
|
// name and photo. If using AP, that's handled down in the
|
83 |
|
|
// "uncached variables" section.
|
84 |
|
|
$variables['author_pane'] = theme('advanced_forum_simple_author_pane', array('context' => $node));
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
/* Reply link */
|
88 |
|
|
// Build the reply link / button. This isn't used in the default template
|
89 |
|
|
// but is provided as a convenience to people who want to customize theirs.
|
90 |
|
|
$variables['reply_link'] = theme('advanced_forum_reply_link', array('node' => $node));
|
91 |
|
|
|
92 |
|
|
/* Uncached variables */
|
93 |
|
|
if (!$variables['top_post'] && method_exists('views_plugin_cache', 'post_render') && !$variables['node']->in_preview) {
|
94 |
|
|
/* Author Pane */
|
95 |
|
|
if (module_exists('author_pane')) {
|
96 |
|
|
$variables['author_pane'] = '<!--post:author-pane-' . $node->uid . '-->';
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
/* Revisions */
|
100 |
|
|
if (!empty($variables['revision_timestamp']) && user_access('view last edited notice') && $variables['created'] != $variables['revision_timestamp']) {
|
101 |
|
|
$variables['post_edited'] = '<!--post:post-edited-' . $node->nid . '-->';
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
/* Signatures */
|
105 |
|
|
if (variable_get('user_signatures', 0)) {
|
106 |
13c3c9b4
|
Assos Assos
|
$variables['signature'] = '<!--post:signature-core-' . $node->uid . '-->';
|
107 |
85ad3d82
|
Assos Assos
|
}
|
108 |
|
|
|
109 |
|
|
/* User specific node theming class */
|
110 |
|
|
// Add class if the poster is the viewer.
|
111 |
|
|
$variables['classes_array'][] = "<!--post:poster-id-' . $node->uid . '-->";
|
112 |
|
|
}
|
113 |
|
|
else {
|
114 |
|
|
// Create variables normally.
|
115 |
|
|
/* Author Pane */
|
116 |
|
|
if (module_exists('author_pane')) {
|
117 |
|
|
$variables['author_pane'] = theme('author_pane', array(
|
118 |
|
|
'account' => $variables['account'],
|
119 |
|
|
'caller' => 'advanced_forum',
|
120 |
|
|
'picture_preset' => variable_get('advanced_forum_user_picture_preset', ''),
|
121 |
|
|
'context' => $node,
|
122 |
|
|
'disable_css' => TRUE,
|
123 |
|
|
'join_date_type' => variable_get('advanced_forum_author_pane_join_date_type', 'short'),
|
124 |
|
|
));
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
/* Revisions */
|
128 |
|
|
if (isset($variables['revision_timestamp']) && user_access('view last edited notice') && $variables['created'] != $variables['revision_timestamp']) {
|
129 |
|
|
$variables['post_edited'] = theme('advanced_forum_post_edited', array(
|
130 |
|
|
'who' => $variables['revision_uid'],
|
131 |
|
|
'when' => $variables['revision_timestamp'],
|
132 |
13c3c9b4
|
Assos Assos
|
'why' => $variables['log'],
|
133 |
85ad3d82
|
Assos Assos
|
));
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
/* Viewer is poster class */
|
137 |
|
|
global $user;
|
138 |
|
|
if ($user->uid > 0 && $user->uid == $node->uid) {
|
139 |
|
|
$variables['classes_array'][] = " post-by-viewer";
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
} |