-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageIndex.template.php
421 lines (363 loc) · 15.6 KB
/
MessageIndex.template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2022 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.1.2
*/
/**
* The main messageindex.
*/
function template_main()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;
echo '<div id="display_head">
<h2 class="display_title"><a href="', $scripturl, '?board=', $context['current_board'], '.0">', $context['name'], '</a></h2>';
if (isset($context['description']) && $context['description'] != '')
echo '
<p>', $context['description'], '</p>';
if (!empty($context['moderators']))
echo '
<p>', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.</p>';
if (!empty($settings['display_who_viewing']))
{
echo '
<p>';
// Show just numbers...?
if ($settings['display_who_viewing'] == 1)
echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
// Or show the actual people viewing the topic?
else
echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
// Now show how many guests are here too.
echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board'], '
</p>';
}
echo '
</div>';
if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0))
{
echo '
<div id="board_', $context['current_board'], '_childboards" class="boardindex_table">
<div class="main_container">
<div class="cat_bar">
<h3 class="catbg">', $txt['sub_boards'], '</h3>
</div>';
foreach ($context['boards'] as $board)
{
echo '
<div id="board_', $board['id'], '" class="board_container ', (!empty($board['css_class']) ? $board['css_class'] : ''), '">
<div class="board_icon">
', function_exists('template_bi_' . $board['type'] . '_icon') ? call_user_func('template_bi_' . $board['type'] . '_icon', $board) : template_bi_board_icon($board), '
</div>
<div class="board_info">
', function_exists('template_bi_' . $board['type'] . '_info') ? call_user_func('template_bi_' . $board['type'] . '_info', $board) : template_bi_board_info($board), '
</div><!-- .info -->';
// Show some basic information about the number of posts, etc.
echo '
<div class="board_stats">
', function_exists('template_bi_' . $board['type'] . '_stats') ? call_user_func('template_bi_' . $board['type'] . '_stats', $board) : template_bi_board_stats($board), '
</div>';
// Show the last post if there is one.
echo '
<div class="board_lastpost">
', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), '
</div>';
// Won't somebody think of the children!
function_exists('template_bi_' . $board['type'] . '_children') ? call_user_func('template_bi_' . $board['type'] . '_children', $board) : template_bi_board_children($board);
echo '
</div><!-- #board_[id] -->';
}
echo '
</div>
</div><!-- #board_[current_board]_childboards -->';
}
// Let them know why their message became unapproved.
if ($context['becomesUnapproved'])
echo '
<div class="noticebox">
', $txt['post_becomes_unapproved'], '
</div>';
// If this person can approve items and we have some awaiting approval tell them.
if (!empty($context['unapproved_posts_message']))
echo '
<div class="noticebox">
', $context['unapproved_posts_message'], '
</div>';
if (!$context['no_topic_listing'])
{
echo '
<div class="pagesection">
', $context['menu_separator'], '
<div class="pagelinks floatleft">
<a href="#bot" class="button">', $txt['go_down'], '</a>
', $context['page_index'], '
</div>
', template_button_strip($context['normal_buttons'], 'right'), '
</div>';
// If Quick Moderation is enabled start the form.
if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
echo '
<form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">';
echo '
<div id="messageindex">';
// No topics... just say, "sorry bub".
if (empty($context['topics']))
echo '
<div class="windowbg">', $txt['topic_alert_none'], '</div>';
$stickybar = false;
$normalbar = false;
foreach ($context['topics'] as $topic)
{
// Separate sticky topics from normal topics
if (!empty($settings['st_separate_sticky_locked'])) {
if ($topic['is_sticky'] && !$stickybar){
echo '
<div class="title_bar">
<h3 class="titlebg">
', $txt['st_sticky_topic'], '
</h3>
</div>';
$stickybar = true;
}
elseif (!$topic['is_sticky'] && $stickybar && !$normalbar) {
echo '
<div class="title_bar">
<h3 class="titlebg">
', $txt['st_normal_topic'], '
</h3>
</div>';
$normalbar = true;
}
}
// Contain the topic list
echo '
<div class="topic_container ', $topic['css_class'], '">
<div class="topic_icon">
<img src="', $topic['first_post']['icon_url'], '" alt="">
', $topic['is_posted_in'] ? '<span class="main_icons profile_sm"></span>' : '', '
</div>
<div class="topic_info', !empty($context['can_quick_mod']) ? '' : ' info_mod', '">
<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" ondblclick="oQuickModifyTopic.modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\');"' : ''), '>';
// Now we handle the icons
echo '
<div class="icons">';
if ($topic['is_watched'])
echo '
<span class="main_icons watch" title="', $txt['watching_this_topic'], '"></span>';
if ($topic['is_locked'])
echo '
<span class="main_icons lock"></span>';
if ($topic['is_sticky'])
echo '
<span class="main_icons sticky"></span>';
if ($topic['is_redirect'])
echo '
<span class="main_icons move"></span>';
if ($topic['is_poll'])
echo '
<span class="main_icons poll"></span>';
echo '
</div>';
echo '
<div class="topic_title">
', $topic['new'] && $context['user']['is_logged'] ? '<a href="' . $topic['new_href'] . '" id="newicon' . $topic['first_post']['id'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '
<span class="preview', $topic['is_sticky'] ? ' bold_text' : '', '" title="', $topic[(empty($modSettings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '">
<span id="msg_', $topic['first_post']['id'], '">', $topic['first_post']['link'], (!$topic['approved'] ? ' <em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>
</span>
</div>
<p class="started_by">
', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
</p>
', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="pagelinks">' . $topic['pages'] . '</span>' : '', '
</div><!-- #topic_[first_post][id] -->
</div><!-- .topic_info -->
<div class="topic_stats">
<p>
<strong>', $topic['replies'], '</strong> ', $txt['replies'], '<br>
<strong>', $topic['views'], '</strong> ', $txt['views'], '
</p>
</div>
<div class="topic_lastpost">
', !empty($settings['st_enable_avatars_topics']) && !empty($topic['last_post']['member']['avatar']) ? themecustoms_avatar($topic['last_post']['member']['avatar']['href'], $topic['last_post']['member']['id']) : '', '
<p>
', $txt['last_post'], ': ', $topic['last_post']['member']['link'], ', <a href="', $topic['last_post']['href'], '">', $topic['last_post']['time'], '</a>
</p>
</div>';
// Show the quick moderation options?
if (!empty($context['can_quick_mod']))
{
echo '
<div class="topic_moderation">';
if ($options['display_quick_mod'] == 1)
echo '
<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
else
{
// Check permissions on each and show only the ones they are allowed to use.
if ($topic['quick_mod']['remove'])
echo '
<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="main_icons delete" title="', $txt['remove_topic'], '"></span></a>';
if ($topic['quick_mod']['lock'])
echo '
<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="main_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
echo '
<br>';
if ($topic['quick_mod']['sticky'])
echo '
<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="main_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
if ($topic['quick_mod']['move'])
echo '
<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="main_icons move" title="', $txt['move_topic'], '"></span></a>';
}
echo '
</div><!-- .moderation -->';
}
echo '
</div><!-- .topic_container -->';
}
if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
{
echo '
<div class="righttext" id="quick_actions">
<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
<option value="">--------</option>';
foreach ($context['qmod_actions'] as $qmod_action)
if ($context['can_' . $qmod_action])
echo '
<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
echo '
</select>';
// Show a list of boards they can move the topic to.
if ($context['can_move'])
echo '
<span id="quick_mod_jump_to"></span>';
echo '
<input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction">
</div><!-- #quick_actions -->';
}
echo '
</div><!-- #messageindex -->';
// Finish off the form - again.
if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
echo '
<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
</form>';
echo '
<div class="pagesection">
<div class="pagelinks">
<a href="#main_content_section" class="button" id="bot">', $txt['go_up'], '</a>
', $context['page_index'], '
</div>
', template_button_strip($context['normal_buttons'], 'right'), '
</div>';
}
// Show breadcrumbs at the bottom too.
theme_linktree();
if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
echo '
<script>
if (typeof(window.XMLHttpRequest) != "undefined")
aJumpTo[aJumpTo.length] = new JumpTo({
sContainerId: "quick_mod_jump_to",
sClassName: "qaction",
sJumpToTemplate: "%dropdown_list%",
iCurBoardId: ', $context['current_board'], ',
iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
sCurBoardName: "', $context['jump_to']['board_name'], '",
sBoardChildLevelIndicator: "==",
sBoardPrefix: "=> ",
sCatSeparator: "-----------------------------",
sCatPrefix: "",
bNoRedirect: true,
bDisabled: true,
sCustomName: "move_to"
});
</script>';
// Javascript for inline editing.
echo '
<script>
var oQuickModifyTopic = new QuickModifyTopic({
aHidePrefixes: Array("lockicon", "stickyicon", "pages", "newicon"),
bMouseOnDiv: false,
});
</script>';
template_topic_legend();
// Lets pop the...
echo '
<div id="mobile_action" class="popup_container">
<div class="popup_window description">
<div class="popup_heading">', $txt['mobile_action'], '
<a href="javascript:void(0);" class="main_icons hide_popup"></a>
</div>
', template_button_strip($context['normal_buttons']), '
</div>
</div>';
}
/**
* Shows a legend for topic icons.
*/
function template_topic_legend()
{
global $context, $settings, $txt, $modSettings;
echo '
<div class="tborder" id="topic_icons">
<div class="information">
<p id="message_index_jump_to"></p>';
if (empty($context['no_topic_listing']))
echo '
<p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? '
<span class="main_icons profile_sm"></span> ' . $txt['participation_caption'] . '<br>' : '', '
' . ($modSettings['pollMode'] == '1' ? '<span class="main_icons poll"></span> ' . $txt['poll'] . '<br>' : '') . '
<span class="main_icons move"></span> ' . $txt['moved_topic'] . '<br>
</p>
<p>
<span class="main_icons lock"></span> ' . $txt['locked_topic'] . '<br>
<span class="main_icons sticky"></span> ' . $txt['sticky_topic'] . '<br>
<span class="main_icons watch"></span> ' . $txt['watching_topic'] . '<br>
</p>';
if (!empty($context['jump_to']))
echo '
<script>
if (typeof(window.XMLHttpRequest) != "undefined")
aJumpTo[aJumpTo.length] = new JumpTo({
sContainerId: "message_index_jump_to",
sJumpToTemplate: "<label class=\"smalltext jump_to\" for=\"%select_id%\">', $context['jump_to']['label'], '<" + "/label> %dropdown_list%",
iCurBoardId: ', $context['current_board'], ',
iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
sCurBoardName: "', $context['jump_to']['board_name'], '",
sBoardChildLevelIndicator: "==",
sBoardPrefix: "=> ",
sCatSeparator: "-----------------------------",
sCatPrefix: "",
sGoButtonLabel: "', $txt['quick_mod_go'], '"
});
</script>';
echo '
</div><!-- .information -->
</div><!-- #topic_icons -->';
}
/**
* Outputs the board lastposts for a standard board or a redirect.
* When on a mobile device, this may be hidden if no last post exists.
*
* @param array $board Current board information.
*/
function themecustoms_bi_board_lastpost(array $board) : void
{
global $settings, $txt;
// Will still add the class, in case the design depends on it.
if (!empty($board['last_post']['id']))
echo '
', !empty($settings['st_enable_avatars_boards']) && !empty($board['last_post']['member']['avatar']) ? themecustoms_avatar($board['last_post']['member']['avatar']['href'], $board['last_post']['member']['id']) : '', '
<p>
<span class="post">', sprintf($txt['post_by_member'], $board['last_post']['link'], $board['last_post']['member']['link']), '</span>
<span class="time">', timeformat($board['last_post']['timestamp']), '</span>
</p>';
}
?>