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