comparison forum/Themes/classic/BoardIndex.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; BoardIndex
3
4 function template_main()
5 {
6 global $context, $settings, $options, $txt, $scripturl, $modSettings;
7
8 // Show some statistics next to the link tree if SP1 info is off.
9 echo '
10 <table width="100%" cellpadding="3" cellspacing="0">
11 <tr>
12 <td valign="bottom">', theme_linktree(), '</td>
13 <td align="right">';
14 if (!$settings['show_sp1_info'])
15 echo '
16 ', $txt[19], ': ', $context['common_stats']['total_members'], ' &nbsp;&#8226;&nbsp; ', $txt[95], ': ', $context['common_stats']['total_posts'], ' &nbsp;&#8226;&nbsp; ', $txt[64], ': ', $context['common_stats']['total_topics'], '
17 ', ($settings['show_latest_member'] ? '<br />' . $txt[201] . ' <b>' . $context['common_stats']['latest_member']['link'] . '</b>' . $txt[581] : '');
18 echo '
19 </td>
20 </tr>
21 </table>';
22
23 // Show the news fader? (assuming there are things to show...)
24 if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
25 {
26 echo '
27 <div class="tborder" style="border-bottom: 0;">
28 <div class="titlebg" align="center" style="padding: 5px 5px 5px 5px;">', $txt[102], '</div>
29 </div>
30 <table border="0" width="100%" cellspacing="0" cellpadding="5" class="tborder" style="border-bottom: 0;">
31 <tr>
32 <td class="windowbg2" valign="middle" align="center" height="60">';
33
34 // Prepare all the javascript settings.
35 echo '
36 <div id="smfFadeScroller" style="width: 90%; padding: 2px;"><b>', $context['news_lines'][0], '</b></div>
37 <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
38 // The fading delay (in ms.)
39 var smfFadeDelay = ', empty($settings['newsfader_time']) ? 5000 : $settings['newsfader_time'], ';
40 // Fade from... what text color? To which background color?
41 var smfFadeFrom = {"r": 0, "g": 0, "b": 0}, smfFadeTo = {"r": 248, "g": 248, "b": 248};
42 // Surround each item with... anything special?
43 var smfFadeBefore = "<b>", smfFadeAfter = "</b>";
44
45 if (typeof(document.getElementById(\'smfFadeScroller\').currentStyle) != "undefined")
46 {
47 var foreColor = document.getElementById(\'smfFadeScroller\').currentStyle.color.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
48 smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};
49
50 var backEl = document.getElementById(\'smfFadeScroller\');
51 while (backEl.currentStyle.backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined")
52 backEl = backEl.parentNode;
53
54 var backColor = backEl.currentStyle.backgroundColor.match(/#([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/);
55 smfFadeTo = {"r": eval("0x" + backColor[1]), "g": eval("0x" + backColor[2]), "b": eval("0x" + backColor[3])};
56 }
57 else if (typeof(window.opera) == "undefined" && typeof(document.defaultView) != "undefined")
58 {
59 var foreColor = document.defaultView.getComputedStyle(document.getElementById(\'smfFadeScroller\'), null).color.match(/rgb\((\d+), (\d+), (\d+)\)/);
60 smfFadeFrom = {"r": parseInt(foreColor[1]), "g": parseInt(foreColor[2]), "b": parseInt(foreColor[3])};
61
62 var backEl = document.getElementById(\'smfFadeScroller\');
63 while (document.defaultView.getComputedStyle(backEl, null).backgroundColor == "transparent" && typeof(backEl.parentNode) != "undefined" && typeof(backEl.parentNode.tagName) != "undefined")
64 backEl = backEl.parentNode;
65
66 var backColor = document.defaultView.getComputedStyle(backEl, null).backgroundColor.match(/rgb\((\d+), (\d+), (\d+)\)/);
67 smfFadeTo = {"r": parseInt(backColor[1]), "g": parseInt(backColor[2]), "b": parseInt(backColor[3])};
68 }
69
70 // List all the lines of the news for display.
71 var smfFadeContent = new Array(
72 "', implode('",
73 "', $context['fader_news_lines']), '"
74 );
75 // ]]></script>
76 <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/fader.js"></script>
77 </td>
78 </tr>
79 </table>';
80 }
81
82 // Show the "Board name Topics Posts Last Post" header.
83 echo '
84 <table border="0" width="100%" cellspacing="1" cellpadding="5" class="bordercolor">
85 <tr class="titlebg">
86 <td colspan="2">', $txt[20], '</td>
87 <td width="6%" align="center">', $txt[330], '</td>
88 <td width="6%" align="center">', $txt[21], '</td>
89 <td width="22%" align="center">', $txt[22], '</td>
90 </tr>';
91
92 /* Each category in categories is made up of:
93 id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
94 new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down iamge),
95 and boards. (see below.) */
96 foreach ($context['categories'] as $category)
97 {
98 // Show the category's name, and let them collapse it... if they feel like it.
99 echo '
100 <tr>
101 <td colspan="5" class="catbg" height="18">';
102
103 // If this category even can collapse, show a link to collapse it.
104 if ($category['can_collapse'])
105 echo '
106 <a href="', $category['collapse_href'], '">', $category['collapse_image'], '</a>';
107
108 echo '
109 ', $category['link'], '
110 </td>
111 </tr>';
112
113 // Only if it's NOT collapsed..
114 if (!$category['is_collapsed'])
115 {
116 /* Each board in each category's boards has:
117 new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
118 children (see below.), link_children (easier to use.), children_new (are they new?),
119 topics (# of), posts (# of), link, href, and last_post. (see below.) */
120 foreach ($category['boards'] as $board)
121 {
122 echo '
123 <tr>
124 <td class="windowbg" width="6%" align="center" valign="top"><img src="', $settings['images_url'], $board['new'] ? '/on.gif" alt="' . $txt[333] . '" title="' . $txt[333] : '/off.gif" alt="' . $txt[334] . '" title="' . $txt[334], '" border="0" /></td>
125 <td class="windowbg2" align="left" width="60%">
126 <a name="b', $board['id'], '"></a>
127 <b>', $board['link'], '</b><br />
128 ', $board['description'];
129
130 // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
131 if (!empty($board['moderators']))
132 echo '<i class="smalltext"><br />
133 ', count($board['moderators']) == 1 ? $txt[298] : $txt[299], ': ', implode(', ', $board['link_moderators']), '</i>';
134
135 // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
136 if (!empty($board['children']))
137 {
138 // Sort the links into an array with new boards bold so it can be imploded.
139 $children = array();
140 /* Each child in each board's children has:
141 id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
142 foreach ($board['children'] as $child)
143 $children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];
144
145 echo '
146 <i class="smalltext"><br />
147 ', $txt['parent_boards'], ': ', implode(', ', $children), '</i>';
148 }
149
150 echo '
151 </td>
152 <td class="windowbg" valign="middle" align="center" width="6%">', $board['topics'], '</td>
153 <td class="windowbg" valign="middle" align="center" width="6%">', $board['posts'], '</td>';
154
155 /* The board's and children's 'last_post's have:
156 time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
157 link, href, subject, start (where they should go for the first unread post.),
158 and member. (which has id, name, link, href, username in it.) */
159 echo '
160 <td class="windowbg2" valign="middle" width="22%">
161 <span class="smalltext">
162 ', $board['last_post']['time'], '<br />
163 ', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
164 ', $txt[525], ' ', $board['last_post']['member']['link'], '
165 </span>
166 </td>
167 </tr>';
168 }
169 }
170 }
171
172 // Show the "New Posts" and "No New Posts" legend.
173 if ($context['user']['is_logged'])
174 {
175 echo '
176 <tr class="titlebg">
177 <td colspan="2" align="left">
178 <img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new_some.gif" alt="' . $txt[333] . '" border="0" />&nbsp;&nbsp;<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new_none.gif" alt="' . $txt[334] . '" border="0" />
179 </td>
180 <td colspan="3" align="right" class="smalltext">';
181 // Show the mark all as read button?
182 if ($settings['show_mark_read'])
183 echo '
184 <a href="', $scripturl, '?action=markasread;sa=all;sesc=' . $context['session_id'] . '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/markread.gif" alt="' . $txt[452] . '" border="0" />' : $txt[452]), '</a>';
185 echo '
186 </td>
187 </tr>';
188 }
189
190 echo '
191 </table>';
192
193 // Here's where the "Info Center" starts...
194 echo '
195 <br />
196 <br />
197 <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
198 <tr class="titlebg">
199 <td align="center" colspan="2">', $txt[685], '</td>
200 </tr>';
201
202 // This is the "Recent Posts" bar.
203 if (!empty($settings['number_recent_posts']))
204 {
205 echo '
206 <tr>
207 <td class="catbg" colspan="2">', $txt[214], '</td>
208 </tr>
209 <tr>
210 <td class="windowbg" width="20" valign="middle" align="center">
211 <a href="', $scripturl, '?action=recent">
212 <img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" border="0" /></a>
213 </td>
214 <td class="windowbg2">';
215
216 // Only show one post.
217 if ($settings['number_recent_posts'] == 1)
218 {
219 // latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
220 echo '
221 <b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b><br />
222 <span class="smalltext">
223 ', $txt[234], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt[235], ' (', $context['latest_post']['time'], ')<br />
224 </span>';
225 }
226 // Show lots of posts.
227 elseif (!empty($context['latest_posts']))
228 {
229 echo '
230 <table width="100%" border="0">';
231 /* Each post in latest_posts has:
232 board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
233 subject, short_subject (shortened with...), time, link, and href. */
234 foreach ($context['latest_posts'] as $post)
235 echo '
236 <tr>
237 <td align="right" valign="top" nowrap="nowrap">[', $post['board']['link'], ']</td>
238 <td valign="top">', $post['link'], ' ', $txt[525], ' ', $post['poster']['link'], '</td>
239 <td align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
240 </tr>';
241 echo '
242 </table>';
243 }
244 echo '
245 </td>
246 </tr>';
247 }
248
249 // Show information about events, birthdays, and holidays on the calendar.
250 if ($context['show_calendar'])
251 {
252 echo '
253 <tr>
254 <td class="catbg" colspan="2">', $context['calendar_only_today'] ? $txt['calendar47b'] : $txt['calendar47'], '</td>
255 </tr><tr>
256 <td class="windowbg" width="20" valign="middle" align="center">
257 <a href="', $scripturl, '?action=calendar">
258 <img src="', $settings['images_url'], '/icons/calendar.gif" border="0" width="20" alt="', $txt['calendar24'], '" /></a>
259 </td>
260 <td class="windowbg2" width="100%">
261 <span class="smalltext">';
262
263 // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
264 if (!empty($context['calendar_holidays']))
265 echo '
266 <span style="color: #', $modSettings['cal_holidaycolor'], ';">', $txt['calendar5'], ' ', implode(', ', $context['calendar_holidays']), '</span><br />';
267
268 // People's birthdays. Like mine. And yours, I guess. Kidding.
269 if (!empty($context['calendar_birthdays']))
270 {
271 echo '
272 <span style="color: #', $modSettings['cal_bdaycolor'], ';">', $context['calendar_only_today'] ? $txt['calendar3'] : $txt['calendar3b'], '</span> ';
273 /* Each member in calendar_birthdays has:
274 id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) */
275 foreach ($context['calendar_birthdays'] as $member)
276 echo '
277 <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<b>' : '', $member['name'], $member['is_today'] ? '</b>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '<br />' : ', ';
278 }
279 // Events like community get-togethers.
280 if (!empty($context['calendar_events']))
281 {
282 echo '
283 <span style="color: #', $modSettings['cal_eventcolor'], ';">', $context['calendar_only_today'] ? $txt['calendar4'] : $txt['calendar4b'], '</span> ';
284 /* Each event in calendar_events should have:
285 title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
286 foreach ($context['calendar_events'] as $event)
287 echo '
288 ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<b>' . $event['title'] . '</b>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : ', ';
289
290 // Show a little help text to help them along ;).
291 if ($context['calendar_can_edit'])
292 echo '
293 (<a href="', $scripturl, '?action=helpadmin;help=calendar_how_edit" onclick="return reqWin(this.href);">', $txt['calendar_how_edit'], '</a>)';
294 }
295 echo '
296 </span>
297 </td>
298 </tr>';
299 }
300
301 // Show a member bar. Not heavily ornate, but functional at least.
302 if ($settings['show_member_bar'])
303 {
304 echo '
305 <tr>
306 <td class="catbg" colspan="2">', $txt[331], '</td>
307 </tr>
308 <tr>
309 <td class="windowbg" width="20" valign="middle" align="center">
310 ', $context['show_member_list'] ? '<a href="' . $scripturl . '?action=mlist">' : '', '<img src="', $settings['images_url'], '/icons/members.gif" border="0" width="20" alt="', $txt[332], '" />', $context['show_member_list'] ? '</a>' : '', '
311 </td>
312 <td class="windowbg2" width="100%">
313 <b>', $context['show_member_list'] ? '<a href="' . $scripturl . '?action=mlist">' . $txt[332] . '</a>' : $txt[332], '</b><br />
314 <span class="smalltext">', $txt[200], '</span>
315 </td>
316 </tr>';
317 }
318
319 // Show YaBB SP1 style information...
320 if ($settings['show_sp1_info'])
321 {
322 echo '
323 <tr>
324 <td class="catbg" colspan="2">', $txt[645], '</td>
325 </tr>
326 <tr>
327 <td class="windowbg" width="20" valign="middle" align="center">
328 <a href="', $scripturl, '?action=stats">
329 <img src="', $settings['images_url'], '/icons/info.gif" alt="', $txt[645], '" border="0" /></a>
330 </td>
331 <td class="windowbg2" width="100%">
332 <table border="0" width="90%"><tr>
333 <td class="smalltext">
334 ', $txt[490], ': <b>', $context['common_stats']['total_topics'], '</b> &nbsp;&nbsp;&nbsp;&nbsp; ', $txt[489], ': <b>', $context['common_stats']['total_posts'], '</b><br />
335 ', !empty($context['latest_post']) ? $txt[659] . ':
336 &quot;' . $context['latest_post']['link'] . '&quot; (' . $context['latest_post']['time'] . ')<br />' : '', '
337 <a href="', $scripturl, '?action=recent">', $txt[234], '</a>', $context['show_stats'] ? '<br />
338 <a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
339 </td>
340 <td class="smalltext">
341 ', $txt[488], ': <b>', $context['show_member_list'] ? '<a href="' . $scripturl . '?action=mlist">' . $context['common_stats']['total_members'] . '</a>' : $context['common_stats']['total_members'], '</b><br />
342 ', $txt[656], ': <b>', $context['common_stats']['latest_member']['link'], '</b><br />';
343 // If they are logged in, show their unread message count, etc..
344 if ($context['user']['is_logged'] && $context['allow_pm'])
345 echo '
346 ', $txt['smf199'], ': <b><a href="', $scripturl, '?action=pm">', $context['user']['messages'], '</a></b> ', $txt['newmessages3'], ': <b><a href="', $scripturl, '?action=pm">', $context['user']['unread_messages'], '</a></b>';
347 echo '
348 </td>
349 </tr></table>
350 </td>
351 </tr>';
352 }
353
354 // "Users online" - in order of activity.
355 echo '
356 <tr>
357 <td class="catbg" colspan="2">', $txt[158], '</td>
358 </tr><tr>
359 <td class="windowbg" width="20" valign="middle" align="center">
360 ', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt[158], '" border="0" />', $context['show_who'] ? '</a>' : '', '
361 </td>
362 <td class="windowbg2" width="100%">';
363
364 if ($context['show_who'])
365 echo '
366 <a href="', $scripturl, '?action=who">';
367
368 echo $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
369
370 // Handle hidden users and buddies.
371 if (!empty($context['num_users_hidden']) || ($context['show_buddies'] && !empty($context['show_buddies'])))
372 {
373 echo ' (';
374
375 // Show the number of buddies online?
376 if ($context['show_buddies'])
377 echo $context['num_buddies'], ' ', $context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies'];
378
379 // How about hidden users?
380 if (!empty($context['num_users_hidden']))
381 echo $context['show_buddies'] ? ', ' : '', $context['num_users_hidden'] . ' ' . $txt['hidden'];
382
383 echo ')';
384 }
385
386 if ($context['show_who'])
387 echo '</a>';
388
389 echo '
390 <span class="smalltext">';
391
392 // Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
393 if (!empty($context['users_online']))
394 echo '
395 ', $txt[140], ':<br />', implode(', ', $context['list_users_online']);
396
397 echo '
398 <br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
399 <a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
400 </span>
401 </td>
402 </tr>';
403
404 // If they are logged in, but SP1 style information is off... show a personal message bar.
405 if ($context['user']['is_logged'] && !$settings['show_sp1_info'])
406 {
407 echo '
408 <tr>
409 <td class="catbg" colspan="2">', $txt[159], '</td>
410 </tr><tr>
411 <td class="windowbg" width="20" valign="middle" align="center">
412 ', $context['allow_pm'] ? '<a href="' . $scripturl . '?action=pm">' : '', '<img src="', $settings['images_url'], '/message_sm.gif" alt="', $txt[159], '" border="0" />', $context['allow_pm'] ? '</a>' : '', '
413 </td>
414 <td class="windowbg2" valign="top">
415 <b><a href="', $scripturl, '?action=pm">', $txt[159], '</a></b><br />
416 <span class="smalltext">
417 ', $txt[660], ' ', $context['user']['messages'], ' ', $context['user']['messages'] == 1 ? $txt[471] : $txt[153], '.... ', $txt[661], $context['allow_pm'] ? ' <a href="' . $scripturl . '?action=pm">' . $txt[662] . '</a>' : '', ' ', $txt[663], '
418 </span>
419 </td>
420 </tr>';
421 }
422
423 // Show the login bar. (it's only true if they are logged out anyway.)
424 if ($context['show_login_bar'])
425 {
426 echo '
427 <tr>
428 <td class="catbg" colspan="2">
429 ', $txt[34], ' <a href="', $scripturl, '?action=reminder" class="smalltext">(' . $txt[315] . ')</a>
430 </td>
431 </tr>
432 <tr>
433 <td class="windowbg" width="20" align="center">
434 <a href="', $scripturl, '?action=login">
435 <img src="', $settings['images_url'], '/icons/login.gif" alt="', $txt[34], '" border="0" /></a>
436 </td>
437 <td class="windowbg2" valign="middle">
438 <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
439 <table border="0" cellpadding="2" cellspacing="0" align="center" width="100%"><tr>
440 <td valign="middle" align="left">
441 <label for="user"><b>', $txt[35], ':</b><br /><input type="text" name="user" id="user" size="15" /></label>
442 </td>
443 <td valign="middle" align="left">
444 <label for="passwrd"><b>', $txt[36], ':</b><br /><input type="password" name="passwrd" id="passwrd" size="15" /></label>
445 </td>
446 <td valign="middle" align="left">
447 <label for="cookielength"><b>', $txt[497], ':</b><br /><input type="text" name="cookielength" id="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" /></label>
448 </td>
449 <td valign="middle" align="left">
450 <label for="cookieneverexp"><b>', $txt[508], ':</b><br /><input type="checkbox" name="cookieneverexp" id="cookieneverexp" checked="checked" class="check" /></label>
451 </td>
452 <td valign="middle" align="left">
453 <input type="submit" value="', $txt[34], '" />
454 </td>
455 </tr></table>
456 </form>
457 </td>
458 </tr>';
459 }
460
461 echo '
462 </table>';
463 }
464
465 ?>