comparison forum/Themes/classic/MessageIndex.template.php @ 76:e3e11437ecea website

Add forum code
author Chris Cannam
date Sun, 07 Jul 2013 11:25:48 +0200
parents
children
comparison
equal deleted inserted replaced
75:72f59aa7e503 76:e3e11437ecea
1 <?php
2 // Version: 1.1; MessageIndex
3
4 function template_main()
5 {
6 global $context, $settings, $options, $scripturl, $modSettings, $txt;
7
8 echo '
9 <table width="100%" cellpadding="3" cellspacing="0">
10 <tr>
11 <td><a name="top"></a>', theme_linktree(), '</td>';
12 if (!empty($settings['display_who_viewing']))
13 {
14 echo '
15 <td class="smalltext" align="right">';
16 if ($settings['display_who_viewing'] == 1)
17 echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt[19];
18 else
19 echo empty($context['view_members_list']) ? '0 ' . $txt[19] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
20 echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board'], '</td>';
21 }
22 echo '
23 </tr>
24 </table>';
25
26 if (isset($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0))
27 {
28 echo '
29 <table border="0" width="100%" cellspacing="1" cellpadding="5" class="bordercolor">
30 <tr class="titlebg">
31 <td colspan="2">', $txt[20], '</td>
32 <td width="6%" align="center">', $txt[330], '</td>
33 <td width="6%" align="center">', $txt[21], '</td>
34 <td width="22%" align="center">', $txt[22], '</td>
35 </tr>';
36 foreach ($context['boards'] as $board)
37 {
38 echo '
39 <tr>
40 <td class="windowbg" width="6%" align="center" valign="top">', $board['new'] ? '<img src="' . $settings['images_url'] . '/on.gif" alt="' . $txt[333] . '" title="' . $txt[333] . '" border="0" />' : '<img src="' . $settings['images_url'] . '/off.gif" alt="' . $txt[334] . '" title="' . $txt[334] . '" border="0" />', '</td>
41 <td class="windowbg2" align="left" width="60%">
42 <a name="b' . $board['id'] . '"></a>
43 <b>' . $board['link'] . '</b><br />
44 ' . $board['description'];
45
46 if (!empty($board['moderators']))
47 echo '<br />
48 <i class="smalltext">', count($board['moderators']) == 1 ? $txt[298] : $txt[299], ': ', implode(', ', $board['link_moderators']), '</i>';
49
50 if (!empty($board['children']))
51 {
52 $children = array();
53 foreach ($board['children'] as $child)
54 {
55 if ($child['new'])
56 $children[] = '<b>' . $child['link'] . '</b>';
57 else
58 $children[] = $child['link'];
59 }
60
61 echo '
62 <br />
63 <br /><i class="smalltext">', $txt['parent_boards'], ': ', implode(', ', $children), '</i>';
64 }
65
66 echo '
67 </td>
68 <td class="windowbg" valign="middle" align="center" width="6%">
69 ', $board['topics'], '
70 </td>
71 <td class="windowbg" valign="middle" align="center" width="6%">
72 ', $board['posts'], '
73 </td>
74 <td class="windowbg2" valign="middle" width="22%">
75 <span class="smalltext">
76 ', $board['last_post']['time'], '<br />
77 ', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
78 ', $txt[525], ' ', $board['last_post']['member']['link'], '
79 </span>
80 </td>
81 </tr>';
82 }
83 echo '
84 </table>
85 <br />';
86 }
87
88 if (!empty($options['show_board_desc']) && $context['description'] != '')
89 {
90 echo '
91 <table width="100%" cellpadding="6" cellspacing="0" border="0" class="tborder" style="border-width: 1px 1px 0 1px;">
92 <tr>
93 <td align="left" class="catbg" width="100%" height="24">
94 <span class="smalltext">', $context['description'], '</span>
95 </td>
96 </tr>
97 </table>';
98 }
99
100 if (!$context['no_topic_listing'])
101 {
102 echo '
103 <table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-width: 1px 1px 0 1px;">
104 <tr>
105 <td align="left" class="catbg" width="100%" height="30">
106 <table cellpadding="3" cellspacing="0" width="100%">
107 <tr>
108 <td><b>', $txt[139], ':</b> ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#bot">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/go_down.gif" alt="' . $txt['topbottom5'] . '" border="0" align="top" />' : $txt['topbottom5']) . '</a>' : '', '</td>
109 <td align="right" nowrap="nowrap" style="font-size: smaller;">', theme_show_buttons(), '</td>
110 </tr>
111 </table>
112 </td>
113 </tr>
114 </table>';
115
116 // If Quick Moderation is enabled (and set to checkboxes - 1) start the form.
117 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
118 echo '
119 <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">';
120
121 echo '
122 <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
123 <tr class="titlebg">';
124 if (!empty($context['topics']))
125 {
126 echo '
127 <td width="9%" colspan="2"></td>
128 <td width="42%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
129 <td width="14%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
130 <td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
131 <td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
132 <td width="22%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>';
133 if (!empty($options['display_quick_mod']))
134 echo '
135 <td width="8%" valign="middle" align="center">', $options['display_quick_mod'] != 1 ? '&nbsp;' : '
136 <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="check" />
137 ', '</td>';
138 }
139 else
140 echo '
141 <td width="100%" colspan="7"><b>', $txt[151], '</b></td>';
142 echo '
143 </tr>';
144
145 foreach ($context['topics'] as $topic)
146 {
147 echo '
148 <tr>
149 <td class="windowbg2" valign="middle" align="center" width="5%">
150 <img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" /></td>
151 <td class="windowbg2" valign="middle" align="center" width="4%">
152 <img src="', $settings[$context['icon_sources'][$topic['first_post']['icon']]], '/post/', $topic['first_post']['icon'], '.gif" alt="" border="0" align="middle" /></td>
153 <td class="windowbg" valign="middle" width="42%">
154 ', $topic['first_post']['link'], ' ', $topic['new'] && $context['user']['is_logged'] ? '<a href="' . $scripturl . '?topic=' . $topic['id'] . '.msg' . $topic['new_from'] . '#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>' : '', ' <span class="smalltext">', $topic['pages'], '</span></td>
155 <td class="windowbg2" valign="middle" width="14%">
156 ', $topic['first_post']['member']['link'], '</td>
157 <td class="windowbg" valign="middle" width="4%" align="center">
158 ', $topic['replies'], '</td>
159 <td class="windowbg" valign="middle" width="4%" align="center">
160 ', $topic['views'], '</td>
161 <td class="windowbg2" valign="middle" width="22%">
162 <span class="smalltext">', $topic['last_post']['time'], '<br />', $txt[525], ' ', $topic['last_post']['member']['link'], '</span></td>';
163
164 // Show the quick moderation options?
165 if (!empty($options['display_quick_mod']))
166 {
167 echo '
168 <td class="windowbg" valign="middle" align="center" width="8%">';
169 if ($options['display_quick_mod'] == 1)
170 echo '
171 <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="check" />';
172 else
173 {
174 if ($topic['quick_mod']['remove'])
175 echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=remove;sesc=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_remove.gif" width="16" alt="', $txt[63], '" title="', $txt[63], '" border="0" /></a>';
176 if ($topic['quick_mod']['lock'])
177 echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=lock;sesc=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_lock.gif" width="16" alt="', $txt['smf279'], '" title="', $txt['smf279'], '" border="0" /></a>';
178 if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
179 echo '<br />';
180 if ($topic['quick_mod']['sticky'])
181 echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=sticky;sesc=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_sticky.gif" width="16" alt="', $txt['smf277'], '" title="', $txt['smf277'], '" border="0" /></a>';
182 if ($topic['quick_mod']['move'])
183 echo '<a href="', $scripturl, '?action=movetopic;board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><img src="', $settings['images_url'], '/icons/quick_move.gif" width="16" alt="', $txt[132], '" title="', $txt[132], '" border="0" /></a>';
184 }
185 echo '</td>';
186 }
187 echo '
188 </tr>';
189 }
190
191 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
192 {
193 echo '
194 <tr class="titlebg">
195 <td colspan="8" align="right">
196 <select name="qaction"', $context['can_move'] ? ' onchange="this.form.moveItTo.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
197 <option value="">--------</option>', $context['can_remove'] ? '
198 <option value="remove">' . $txt['quick_mod_remove'] . '</option>' : '', $context['can_lock'] ? '
199 <option value="lock">' . $txt['quick_mod_lock'] . '</option>' : '', $context['can_sticky'] ? '
200 <option value="sticky">' . $txt['quick_mod_sticky'] . '</option>' : '', $context['can_move'] ? '
201 <option value="move">' . $txt['quick_mod_move'] . ': </option>' : '', $context['can_merge'] ? '
202 <option value="merge">' . $txt['quick_mod_merge'] . '</option>' : '', '
203 <option value="markread">', $txt['quick_mod_markread'], '</option>
204 </select>';
205
206 if ($context['can_move'])
207 {
208 echo '
209 <select id="moveItTo" name="move_to" disabled="disabled">';
210 foreach ($context['jump_to'] as $category)
211 foreach ($category['boards'] as $board)
212 {
213 if (!$board['is_current'])
214 echo '
215 <option value="', $board['id'], '"', !empty($board['selected']) ? ' selected="selected"' : '', '>', str_repeat('-', $board['child_level'] + 1), ' ', $board['name'], '</option>';
216 }
217 echo '
218 </select>';
219 }
220
221 echo '
222 <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return this.form.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" />
223 </td>
224 </tr>';
225 }
226
227 echo '
228 </table>';
229
230 // Finish off the form - again, if Quick Moderation is being done with checkboxes. (1)
231 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
232 echo '
233 <input type="hidden" name="sc" value="', $context['session_id'], '" />
234 </form>';
235
236 echo '
237 <table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-width: 0 1px 1px 1px;">
238 <tr>
239 <td align="left" class="catbg" width="100%" height="30">
240 <table cellpadding="3" cellspacing="0" width="100%">
241 <tr>
242 <td><a name="bot"></a><b>', $txt[139], ':</b> ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#top">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/go_up.gif" alt="' . $txt['topbottom4'] . '" border="0" align="top" />' : $txt['topbottom4']) . '</a>' : '', '</td>
243 <td align="right" nowrap="nowrap" style="font-size: smaller;">', theme_show_buttons(), '</td>
244 </tr>
245 </table>
246 </td>
247 </tr>
248 </table>';
249 }
250
251 echo '
252 <table cellpadding="0" cellspacing="0" width="100%">';
253 if ($settings['linktree_inline'])
254 echo '
255 <tr>
256 <td colspan="3" valign="bottom">', theme_linktree(), '<br /><br /></td>
257 </tr>';
258
259 echo '
260 <tr>';
261
262 if (!$context['no_topic_listing'])
263 {
264 echo '
265 <td class="smalltext" align="left" style="padding-top: 1ex;">', !empty($modSettings['enableParticipation']) ? '
266 <img src="' . $settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' . $txt['participation_caption'] . '<br />' : '', '
267 <img src="' . $settings['images_url'] . '/topic/normal_post.gif" alt="" align="middle" /> ' . $txt[457] . '<br />
268 <img src="' . $settings['images_url'] . '/topic/hot_post.gif" alt="" align="middle" /> ' . $txt[454] . '<br />
269 <img src="' . $settings['images_url'] . '/topic/veryhot_post.gif" alt="" align="middle" /> ' . $txt[455] . '
270 </td>
271 <td class="smalltext" align="left" valign="top" style="padding-top: 1ex;">
272 <img src="' . $settings['images_url'] . '/topic/normal_post_locked.gif" alt="" align="middle" /> ' . $txt[456] . '<br />' . ($modSettings['enableStickyTopics'] == '1' ? '
273 <img src="' . $settings['images_url'] . '/topic/normal_post_sticky.gif" alt="" align="middle" /> ' . $txt['smf96'] . '<br />' : '') . ($modSettings['pollMode'] == '1' ? '
274 <img src="' . $settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' . $txt['smf43'] : '') . '
275 </td>';
276 }
277
278 echo '
279 <td class="smalltext" align="right" valign="middle">
280 <form action="', $scripturl, '" method="get" accept-charset="', $context['character_set'], '">
281 <label for="jumpto">' . $txt[160] . '</label>:
282 <select name="jumpto" id="jumpto" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 || this.options[this.selectedIndex].value.substr(0, 1) != \'?\' ? 0 : 1);">
283 <option value="">' . $txt[251] . ':</option>';
284
285 // Show each category - they all have an id, name, and the boards in them.
286 foreach ($context['jump_to'] as $category)
287 {
288 // Show the category name with a link to the category. (index.php#id)
289 echo '
290 <option value="" disabled="disabled">-----------------------------</option>
291 <option value="#', $category['id'], '">', $category['name'], '</option>
292 <option value="" disabled="disabled">-----------------------------</option>';
293
294 /* Now go through each board - they all have:
295 id, name, child_level (how many parents they have, basically...), and is_current. (is this the current board?) */
296 foreach ($category['boards'] as $board)
297 {
298 // Show some more =='s if this is a child, so as to make it look nice.
299 echo '
300 <option value="?board=', $board['id'], '.0"', $board['is_current'] ? ' selected="selected"' : '', '> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>';
301 }
302 }
303
304 echo '
305 </select>&nbsp;
306 <input type="button" value="', $txt[161], '" onclick="if (this.form.jumpto.options[this.form.jumpto.selectedIndex].value) window.location.href = \'', $scripturl, '\' + this.form.jumpto.options[this.form.jumpto.selectedIndex].value;" />
307 </form>
308 </td>
309 </tr>
310 </table>';
311 }
312
313 function theme_show_buttons()
314 {
315 global $context, $settings, $options, $txt, $scripturl;
316
317 $buttonArray = array();
318
319 // If they are logged in, and the mark read buttons are enabled..
320 if ($context['user']['is_logged'] && $settings['show_mark_read'])
321 $buttonArray[] = '<a href="' . $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;sesc=' . $context['session_id'] . '">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/markread.gif" alt="' . $txt[300] . '" border="0" />' : $txt[300]) . '</a>';
322
323 // If the user has permission to show the notification button... ask them if they're sure, though.
324 if ($context['can_mark_notify'])
325 $buttonArray[] = '<a href="' . $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';sesc=' . $context['session_id'] . '" onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/notify.gif" alt="' . $txt[131] . '" border="0" />' : $txt[131]) . '</a>';
326
327 // Are they allowed to post new topics?
328 if ($context['can_post_new'])
329 $buttonArray[] = '<a href="' . $scripturl . '?action=post;board=' . $context['current_board'] . '.0">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new_topic.gif" alt="' . $txt[33] . '" border="0" />' : $txt[33]) . '</a>';
330
331 // How about new polls, can the user post those?
332 if ($context['can_post_poll'])
333 $buttonArray[] = '<a href="' . $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new_poll.gif" alt="' . $txt['smf20'] . '" border="0" />' : $txt['smf20']) . '</a>';
334
335 return implode($context['menu_separator'], $buttonArray);
336 }
337
338 ?>