annotate forum/Sources/BoardIndex.php @ 87:df86d318892b website

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