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