Mercurial > hg > vamp-website
comparison forum/Sources/BoardIndex.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 | |
3 /** | |
4 * Simple Machines Forum (SMF) | |
5 * | |
6 * @package SMF | |
7 * @author Simple Machines http://www.simplemachines.org | |
8 * @copyright 2011 Simple Machines | |
9 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
10 * | |
11 * @version 2.0 | |
12 */ | |
13 | |
14 if (!defined('SMF')) | |
15 die('Hacking attempt...'); | |
16 | |
17 /* The single function this file contains is used to display the main | |
18 board index. It uses just the following functions: | |
19 | |
20 void BoardIndex() | |
21 - shows the board index. | |
22 - uses the BoardIndex template, and main sub template. | |
23 - may use the boardindex subtemplate for wireless support. | |
24 - updates the most online statistics. | |
25 - is accessed by ?action=boardindex. | |
26 | |
27 void CollapseCategory() | |
28 - collapse or expand a category | |
29 */ | |
30 | |
31 // Show the board index! | |
32 function BoardIndex() | |
33 { | |
34 global $txt, $user_info, $sourcedir, $modSettings, $context, $settings, $scripturl; | |
35 | |
36 // For wireless, we use the Wireless template... | |
37 if (WIRELESS) | |
38 $context['sub_template'] = WIRELESS_PROTOCOL . '_boardindex'; | |
39 else | |
40 loadTemplate('BoardIndex'); | |
41 | |
42 // Set a canonical URL for this page. | |
43 $context['canonical_url'] = $scripturl; | |
44 | |
45 // Do not let search engines index anything if there is a random thing in $_GET. | |
46 if (!empty($_GET)) | |
47 $context['robot_no_index'] = true; | |
48 | |
49 // Retrieve the categories and boards. | |
50 require_once($sourcedir . '/Subs-BoardIndex.php'); | |
51 $boardIndexOptions = array( | |
52 'include_categories' => true, | |
53 'base_level' => 0, | |
54 'parent_id' => 0, | |
55 'set_latest_post' => true, | |
56 'countChildPosts' => !empty($modSettings['countChildPosts']), | |
57 ); | |
58 $context['categories'] = getBoardIndex($boardIndexOptions); | |
59 | |
60 // Get the user online list. | |
61 require_once($sourcedir . '/Subs-MembersOnline.php'); | |
62 $membersOnlineOptions = array( | |
63 'show_hidden' => allowedTo('moderate_forum'), | |
64 'sort' => 'log_time', | |
65 'reverse_sort' => true, | |
66 ); | |
67 $context += getMembersOnlineStats($membersOnlineOptions); | |
68 | |
69 $context['show_buddies'] = !empty($user_info['buddies']); | |
70 | |
71 // Are we showing all membergroups on the board index? | |
72 if (!empty($settings['show_group_key'])) | |
73 $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); | |
74 | |
75 // Track most online statistics? (Subs-MembersOnline.php) | |
76 if (!empty($modSettings['trackStats'])) | |
77 trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); | |
78 | |
79 // Retrieve the latest posts if the theme settings require it. | |
80 if (isset($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1) | |
81 { | |
82 $latestPostOptions = array( | |
83 'number_posts' => $settings['number_recent_posts'], | |
84 ); | |
85 $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); | |
86 } | |
87 | |
88 $settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0; | |
89 $settings['show_member_bar'] &= allowedTo('view_mlist'); | |
90 $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); | |
91 $context['show_member_list'] = allowedTo('view_mlist'); | |
92 $context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']); | |
93 | |
94 // Load the calendar? | |
95 if (!empty($modSettings['cal_enabled']) && allowedTo('calendar_view')) | |
96 { | |
97 // Retrieve the calendar data (events, birthdays, holidays). | |
98 $eventOptions = array( | |
99 'include_holidays' => $modSettings['cal_showholidays'] > 1, | |
100 'include_birthdays' => $modSettings['cal_showbdays'] > 1, | |
101 'include_events' => $modSettings['cal_showevents'] > 1, | |
102 'num_days_shown' => empty($modSettings['cal_days_for_index']) || $modSettings['cal_days_for_index'] < 1 ? 1 : $modSettings['cal_days_for_index'], | |
103 ); | |
104 $context += cache_quick_get('calendar_index_offset_' . ($user_info['time_offset'] + $modSettings['time_offset']), 'Subs-Calendar.php', 'cache_getRecentEvents', array($eventOptions)); | |
105 | |
106 // Whether one or multiple days are shown on the board index. | |
107 $context['calendar_only_today'] = $modSettings['cal_days_for_index'] == 1; | |
108 | |
109 // This is used to show the "how-do-I-edit" help. | |
110 $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); | |
111 } | |
112 else | |
113 $context['show_calendar'] = false; | |
114 | |
115 $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); | |
116 } | |
117 | |
118 // Collapse or expand a category | |
119 function CollapseCategory() | |
120 { | |
121 global $user_info, $sourcedir, $context; | |
122 | |
123 // Just in case, no need, no need. | |
124 $context['robot_no_index'] = true; | |
125 | |
126 checkSession('request'); | |
127 | |
128 if (!isset($_GET['sa'])) | |
129 fatal_lang_error('no_access', false); | |
130 | |
131 // Check if the input values are correct. | |
132 if (in_array($_REQUEST['sa'], array('expand', 'collapse', 'toggle')) && isset($_REQUEST['c'])) | |
133 { | |
134 // And collapse/expand/toggle the category. | |
135 require_once($sourcedir . '/Subs-Categories.php'); | |
136 collapseCategories(array((int) $_REQUEST['c']), $_REQUEST['sa'], array($user_info['id'])); | |
137 } | |
138 | |
139 // And go back to the board index. | |
140 BoardIndex(); | |
141 } | |
142 | |
143 ?> |