/** * Common actions for all methods in the class */ public function pre_dispatch() { global $context; $context['page_title'] = $context['forum_name']; if (isset($context['page_title_html_safe'])) { $context['page_title_html_safe'] = Util::htmlspecialchars(un_htmlspecialchars($context['page_title'])); } if (!empty($context['standalone'])) { setupMenuContext(); } }
function sportal_main() { global $smcFunc, $context, $sourcedir; if (WIRELESS) { redirectexit('action=forum'); } $context['page_title'] = $context['forum_name']; if (isset($context['page_title_html_safe'])) { $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])); } if (!empty($context['standalone'])) { setupMenuContext(); } $actions = array('addarticle' => array('PortalArticles.php', 'sportal_add_article'), 'articles' => array('PortalArticles.php', 'sportal_articles'), 'credits' => array('', 'sportal_credits'), 'pages' => array('PortalPages.php', 'sportal_pages'), 'removearticle' => array('PortalArticles.php', 'sportal_remove_article'), 'shoutbox' => array('PortalShoutbox.php', 'sportal_shoutbox')); if (!isset($_REQUEST['sa']) || !isset($actions[$_REQUEST['sa']])) { $_REQUEST['sa'] = 'articles'; } if (!empty($actions[$_REQUEST['sa']][0])) { require_once $sourcedir . '/' . $actions[$_REQUEST['sa']][0]; } $actions[$_REQUEST['sa']][1](); }
function setupThemeContext($forceload = false) { global $modSettings, $user_info, $scripturl, $context, $settings, $options, $txt, $maintenance; global $user_settings, $smcFunc; static $loaded = false; // Under SSI this function can be called more then once. That can cause some problems. // So only run the function once unless we are forced to run it again. if ($loaded && !$forceload) { return; } $loaded = true; $context['in_maintenance'] = !empty($maintenance); $context['current_time'] = timeformat(time(), false); $context['current_action'] = isset($_GET['action']) ? $_GET['action'] : ''; $context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest']; // Get some news... $context['news_lines'] = explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))); $context['fader_news_lines'] = array(); for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) { if (trim($context['news_lines'][$i]) == '') { continue; } // Clean it up for presentation ;). $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); // Gotta be special for the javascript. $context['fader_news_lines'][$i] = strtr(addslashes($context['news_lines'][$i]), array('/' => '\\/', '<a href=' => '<a hre" + "f=')); } $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; if (!$user_info['is_guest']) { $context['user']['messages'] =& $user_info['messages']; $context['user']['unread_messages'] =& $user_info['unread_messages']; // Personal message popup... if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { $context['user']['popup_messages'] = true; } else { $context['user']['popup_messages'] = false; } $_SESSION['unread_messages'] = $user_info['unread_messages']; if (allowedTo('moderate_forum')) { $context['unapproved_members'] = !empty($modSettings['registration_method']) && $modSettings['registration_method'] == 2 || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; } $context['show_open_reports'] = empty($user_settings['mod_prefs']) || $user_settings['mod_prefs'][0] == 1; $context['user']['avatar'] = array(); // Figure out the avatar... uploaded? if ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; } elseif (substr($user_info['avatar']['url'], 0, 7) == 'http://') { $context['user']['avatar']['href'] = $user_info['avatar']['url']; if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { if (!empty($modSettings['avatar_max_width_external'])) { $context['user']['avatar']['width'] = $modSettings['avatar_max_width_external']; } if (!empty($modSettings['avatar_max_height_external'])) { $context['user']['avatar']['height'] = $modSettings['avatar_max_height_external']; } } } elseif ($user_info['avatar']['url'] != '') { $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . htmlspecialchars($user_info['avatar']['url']); } if (!empty($context['user']['avatar'])) { $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '"' . (isset($context['user']['avatar']['width']) ? ' width="' . $context['user']['avatar']['width'] . '"' : '') . (isset($context['user']['avatar']['height']) ? ' height="' . $context['user']['avatar']['height'] . '"' : '') . ' alt="" class="avatar" />'; } // Figure out how long they've been logged in. $context['user']['total_time_logged_in'] = array('days' => floor($user_info['total_time_logged_in'] / 86400), 'hours' => floor($user_info['total_time_logged_in'] % 86400 / 3600), 'minutes' => floor($user_info['total_time_logged_in'] % 3600 / 60)); } else { $context['user']['messages'] = 0; $context['user']['unread_messages'] = 0; $context['user']['avatar'] = array(); $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); $context['user']['popup_messages'] = false; if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { $txt['welcome_guest'] .= $txt['welcome_guest_activate']; } // If we've upgraded recently, go easy on the passwords. if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { $context['disable_login_hashing'] = true; } elseif ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5']) { $context['disable_login_hashing'] = true; } } // Setup the main menu items. setupMenuContext(); if (empty($settings['theme_version'])) { $context['show_vBlogin'] = $context['show_quick_login']; } // This is here because old index templates might still use it. $context['show_news'] = !empty($settings['enable_news']); // This is done to allow theme authors to customize it as they want. $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); // Resize avatars the fancy, but non-GD requiring way. if ($modSettings['avatar_action_too_large'] == 'option_js_resize' && (!empty($modSettings['avatar_max_width_external']) || !empty($modSettings['avatar_max_height_external']))) { $context['html_headers'] .= ' <script type="text/javascript"><!-- // --><![CDATA[ var smf_avatarMaxWidth = ' . (int) $modSettings['avatar_max_width_external'] . '; var smf_avatarMaxHeight = ' . (int) $modSettings['avatar_max_height_external'] . ';'; if (!$context['browser']['is_ie'] && !$context['browser']['is_mac_ie']) { $context['html_headers'] .= ' window.addEventListener("load", smf_avatarResize, false);'; } else { $context['html_headers'] .= ' var window_oldAvatarOnload = window.onload; window.onload = smf_avatarResize;'; } // !!! Move this over to script.js? $context['html_headers'] .= ' // ]]></script>'; } // This looks weird, but it's because BoardIndex.php references the variable. $context['common_stats']['latest_member'] = array('id' => $modSettings['latestMember'], 'name' => $modSettings['latestRealName'], 'href' => $scripturl . '?action=profile;u=' . $modSettings['latestMember'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $modSettings['latestRealName'] . '</a>'); $context['common_stats'] = array('total_posts' => comma_format($modSettings['totalMessages']), 'total_topics' => comma_format($modSettings['totalTopics']), 'total_members' => comma_format($modSettings['totalMembers']), 'latest_member' => $context['common_stats']['latest_member']); if (empty($settings['theme_version'])) { $context['html_headers'] .= ' <script type="text/javascript"><!-- // --><![CDATA[ var smf_scripturl = "' . $scripturl . '"; // ]]></script>'; } if (!isset($context['page_title'])) { $context['page_title'] = ''; } // Set some specific vars. $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])); $context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? $smcFunc['htmlspecialchars']($modSettings['meta_keywords']) : ''; }
/** * Init all variables and load the settings from the database. * Check the requests and prepare the templates to load. */ function PortaMx($doinit = false) { global $context, $modSettings, $boardurl, $scripturl, $user_info, $maintenance, $language, $pmxCacheFunc, $sc, $cookiename, $txt; // we can exit on this... if (defined('PortaMx') || isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && empty($doinit)) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && !empty($user_info['possibly_robot'])) { redirectexit(); } else { return; } } define('PortaMx', 1); // no sign up for robots please !! if (!empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'signup') { redirectexit(); } if (empty($user_info['possibly_robot'])) { // portal enable/disable request ? if ((isset($_REQUEST['pmxportal']) || isset($_REQUEST['pmxsef'])) && allowedTo('admin_forum')) { $mode = 'pmx' . (isset($_REQUEST['pmxportal']) ? 'portal' : 'sef'); updateSettings(array($mode . '_disabled' => $_REQUEST[$mode] == 'off' ? '1' : '0')); redirectexit(); } // clear PortaMx cache request ? if (isset($_GET['action']) && isset($_GET['area']) && (in_array($_GET['action'], array('admin', 'portamx')) && $_GET['area'] == 'pmx_cache')) { if (isset($_GET[$_SESSION['session_var']]) && $_GET[$_SESSION['session_var']] == $sc) { $pmxCacheFunc['clean'](); $_SESSION['pmx_cache_cleared'] = true; } if (isset($_SESSION['pmx_last_request'])) { redirectexit($_SESSION['pmx_last_request']); } } elseif (pmx_checkECL_Cookie() && strpos($_SERVER['REQUEST_URL'], 'viewsmfile') === false) { $_SESSION['pmx_last_request'] = $_SERVER['REQUEST_URL']; } $lang = $pmxCacheFunc['get']($user_info['ip'] . '-lang'); if (!pmx_checkECL_Cookie()) { if ($lang === null) { // get browser language $browserlang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']) : ''; if (preg_match_all('~en\\b|de\\b~i', $browserlang, $temp) > 0) { $avail = array_keys(PortaMx_getLanguages()); if (in_array('de', $temp[0])) { if (in_array('german', $avail)) { $lang = 'german'; } elseif (in_array('german-utf8', $avail)) { $lang = 'german-utf8'; } } else { $lang = $language; } $_POST['language'] = $lang; $_POST['redir'] = pmx_http_build_query($_GET); } } else { $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $lang; } // need to releoad base language loadLanguage('index+Modifications'); } else { if ($lang !== null) { $_POST['language'] = $lang; $_POST['redir'] = pmx_http_build_query($_GET); } } // check if a language change requested if (!empty($_POST['language'])) { $pmxCacheFunc['clean'](); $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $_POST['language']; if (pmx_checkECL_Cookie()) { // Make it permanent for members. if (!empty($user_info['id'])) { updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); } else { $_SESSION['language'] = $user_info['language']; } } else { $pmxCacheFunc['put']($user_info['ip'] . '-lang', $language, 360, false); $_POST['redir'] = pmx_http_build_query($_GET); } if (isset($_POST['redir'])) { redirectexit($_POST['redir']); } } } if (empty($modSettings['pmx_eclmodal']) && !pmx_checkECL_Cookie() && (!empty($_REQUEST['action']) && $_REQUEST['action'] != 'xml' || !empty($_REQUEST['page']) || !empty($_REQUEST['cat']) || !empty($_REQUEST['art']))) { if (empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'login') { setupMenuContext(); pmx_ECL_Error($_REQUEST['action']); } else { redirectexit(); } } // redirect on illegal request if (!empty($_REQUEST['pmxportal']) || !empty($_REQUEST['pmxsef']) || !empty($_REQUEST['pmxerror']) && !empty($_REQUEST['action'])) { redirectexit('pmxerror=unknown'); } // check if a permanent theme change requested if (isset($_REQUEST['theme']) && isset($_REQUEST['pmxrd'])) { PortaMx_ChangeTheme($_REQUEST['theme'], $_REQUEST['pmxrd']); } // load all settings PortaMx_getSettings(); // shoutbox POST request? if (!empty($_POST['pmx_shout']) && !empty($_POST['shoutbox_id'])) { PortaMx_GetShoutbox($_POST['shoutbox_id']); if (pmx_checkECL_Cookie()) { $_SESSION['pmx_shoutreload'] = true; } exit; } // exit on follow actions $rqaction = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; if (isset($_REQUEST['xml']) || in_array($rqaction, array('jseditor', 'jsoption', '.xml', 'xmlhttp', 'verificationcode', 'printpage'))) { return; } // login with redirect .. correct SEF url if ($rqaction == 'login' && !empty($_SESSION['old_url']) && function_exists('pmxsef_query')) { $_SESSION['old_url'] = $scripturl . pmx_http_build_query(pmxsef_query(rawurldecode(ltrim(str_replace($boardurl, '', $_SESSION['old_url']), '/')))); } // check if a pmxscriptdebug/pmxspidertest requested $tmp = isset($_GET['pmxscriptdebug']) ? 'pmxscriptdebug' : (isset($_GET['pmxspidertest']) ? 'pmxspidertest' : ''); if (!empty($tmp) && in_array($_GET[$tmp], array('on', 'off'))) { if (allowPmx('pmx_admin')) { if ($tmp == 'pmxscriptdebug') { pmx_setcookie($tmp, $_GET[$tmp] == 'on' ? '1' : ''); unset($_GET[$tmp]); redirectexit(pmx_http_build_query($_GET)); } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'on' && !empty($modSettings['pmx_ecl'])) { $logCook = pmx_getcookie($cookiename); pmx_setcookie($tmp, $logCook); pmx_setcookie($cookiename, ''); pmx_setcookie('pmx_eclauth', ''); pmx_setcookie('PHPSESSID', ''); unset($logCook); redirectexit(); } } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'off' && pmx_getcookie('pmxspidertest')) { $udata = pmx_getcookie($tmp); if (isset($udata) && is_array($dtmp = unserialize($udata)) && count($dtmp == 4)) { pmx_setECL_Cookie(); pmx_setcookie($cookiename, $udata, $dtmp[2]); unset($dtmp); unset($udata); } pmx_setcookie('pmxspidertest', ''); redirectexit(); } } // load common javascript loadJavascriptFile(PortaMx_loadCompressed('PortaMx.js'), array('external' => true)); addInlineJavascript(' var pmx_restore_top = ' . intval(!empty($context['pmx']['settings']['restoretop'])) . ';'); if ($doinit || !empty($modSettings['pmxportal_disabled'])) { loadLanguage($context['pmx_templatedir'] . 'PortaMx'); loadCSSFile(PortaMx_loadCompressed('portamx.css'), array('external' => true)); return; } // on Admin or Moderate load admin language, css and javascript if (($rqaction == 'admin' || $rqaction == 'portamx') && isset($_REQUEST['area']) && in_array($_REQUEST['area'], explode(',', $context['pmx']['areas']))) { loadJavascriptFile(PortaMx_loadCompressed('PortaMxAdmin.js'), array('external' => true)); loadCSSFile(PortaMx_loadCompressed('portamx_admin.css'), array('external' => true)); loadLanguage($context['pmx_templatedir'] . 'Admin'); addInlineJavascript("\n\t" . 'BlockActive=\'' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '\';' . "\n\t" . 'BlockInactive=\'' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '\';'); } // Error request? if (!empty($_REQUEST['pmxerror'])) { return PmxError(); } // check Error request, Forum request $context['pmx']['forumReq'] = !empty($_REQUEST['action']) || !empty($context['current_board']) || !empty($context['current_topic']); if (empty($context['pmx']['forumReq']) && !empty($context['pmx']['settings']['other_actions'])) { $reqtyp = Pmx_StrToArray($context['pmx']['settings']['other_actions']); foreach ($reqtyp as $rtyp) { @(list($rtyp, $rval) = Pmx_StrToArray($rtyp, '=')); $context['pmx']['forumReq'] = $context['pmx']['forumReq'] || isset($_REQUEST[$rtyp]) && (is_null($rval) || $_REQUEST[$rtyp] == $rval); } } // check Page, category, article request $pmxRequestTypes = array('spage', 'art', 'cat', 'child'); $context['pmx']['pageReq'] = array(); foreach ($pmxRequestTypes as $type) { if (empty($_REQUEST['action']) && !empty($_REQUEST[$type])) { $context['pmx']['pageReq'][$type] = PortaMx_makeSafe($_REQUEST[$type]); } } // no request on forum or pages and no frontpage .. go to forum if (empty($context['pmx']['forumReq']) && empty($context['pmx']['pageReq']) && $context['pmx']['settings']['frontpage'] == 'none') { $_REQUEST['action'] = $_GET['action'] = 'community'; $context['pmx']['forumReq'] = true; } // Disable HighSlide on action? if (isset($_REQUEST['action']) && isset($context['pmx']['settings']['noHS_onaction'])) { $noHighSlide = isset($context['pmx']['settings']['noHS_onaction']) ? Pmx_StrToArray($context['pmx']['settings']['noHS_onaction']) : array(); if (in_array($_REQUEST['action'], $noHighSlide)) { $context['pmx']['settings']['disableHS'] = 1; } } // Admin panel/block hidding ? $hideRequest = array_intersect($context['pmx']['extracmd'], array_keys($_REQUEST)); if (!empty($hideRequest) && allowPmx('pmx_admin')) { @(list($hideRequest) = array_values($hideRequest)); $mode = substr($hideRequest, 5); $hidetyp = substr($hideRequest, 0, 5); $offparts = empty($modSettings['pmx_' . $hidetyp . 'off']) ? array() : Pmx_StrToArray($modSettings['pmx_' . $hidetyp . 'off']); if ($mode == 'off') { if ($hidetyp == 'panel') { $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? $context['pmx']['block_sides'] : array_merge($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']); } else { $offparts = array_merge($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest])); } } else { if ($hidetyp == 'panel') { $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']); } else { $offparts = $_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest])); } } updateSettings(array('pmx_' . $hidetyp . 'off' => implode(',', $offparts))); unset($_GET[$hideRequest]); redirectexit(pmx_http_build_query($_GET)); } // check all the actions and more... if (empty($context['pmx']['forumReq'])) { // if a redirect request, exit $requrl = strpos($_SERVER['REQUEST_URL'], substr($scripturl, 0, strrpos($scripturl, '/'))) === false ? $_SERVER['REQUEST_URL'] : $scripturl; if (substr($requrl, 0, strrpos($requrl, '/')) != substr($scripturl, 0, strrpos($scripturl, '/'))) { return; } // we use the frontpage ? $useFront = $context['pmx']['settings']['frontpage'] == 'none' && empty($context['pmx']['pageReq']) ? '' : 'frontpage'; // get all block on active panels they can view $context['pmx']['viewblocks'] = getPanelsToShow($useFront); // frontpage and/or Page blocks exist ? if (!empty($maintenance) && $context['pmx']['settings']['frontpage'] != 'none' || empty($useFront) || !empty($context['pmx']['show_pagespanel']) || !empty($context['pmx']['show_frontpanel']) && $context['pmx']['settings']['frontpage'] != 'none') { // setup headers PortaMx_headers('frontpage'); $context['robot_no_index'] = empty($context['pmx']['settings']['indexfront']); if ($context['pmx']['settings']['frontpage'] == 'fullsize') { loadTemplate($context['pmx_templatedir'] . 'Frontpage'); $context['template_layers'] = array('fronthtml', 'portamx'); call_integration_hook('integrate_load_theme'); } else { loadTemplate($context['pmx_templatedir'] . 'Mainindex'); $context['template_layers'][] = 'portamx'; } if (!empty($context['pmx']['pageReq']) || empty($context['pmx']['forumReq']) && $context['pmx']['settings']['frontpage'] != 'none') { loadTemplate($context['pmx_templatedir'] . 'PortaMx'); } } else { // page req error? if (!empty($context['pmx']['pageReq']) && empty($context['pmx']['show_pagespanel'])) { redirectexit('pmxerror=page'); } // else go to forum $_REQUEST['action'] = $_GET['action'] = !empty($maintenance) && empty($user_info['is_admin']) ? '' : 'community'; $context['pmx']['forumReq'] = true; $context['pmx']['viewblocks'] = null; } } if (!empty($context['pmx']['forumReq'])) { // get the action $action = isset($_REQUEST['action']) ? $_REQUEST['action'] == 'collapse' ? 'community' : $_REQUEST['action'] : (isset($_REQUEST['board']) ? 'boards' : (isset($_REQUEST['topic']) ? 'topics' : '')); // get all block on active panels they can view $context['pmx']['viewblocks'] = getPanelsToShow($action); // setup headers PortaMx_headers($action); // load the "Main" template on pages, cats or arts if (!empty($context['pmx']['pageReq'])) { loadTemplate($context['pmx_templatedir'] . 'PortaMx'); } loadTemplate($context['pmx_templatedir'] . 'Mainindex'); $context['template_layers'][] = 'portamx'; } // Load the Frame template loadTemplate($context['pmx_templatedir'] . 'Frames'); // supress these links if ECL not accepted if (!empty($rqaction) && !pmx_checkECL_Cookie() && isset($modSettings['pmx_eclmodalaction']) && in_array($rqaction, Pmx_StrToArray($modSettings['pmx_eclmodalaction']))) { pmx_ECL_Error('request'); } // Create the linktree return pmx_MakeLinktree(); }
function sp_menu($parameters, $id, $return_parameters = false) { global $context; $block_parameters = array(); if ($return_parameters) { return $block_parameters; } if (empty($context['menu_buttons'])) { setupMenuContext(); } echo ' <ul class="sp_list" id="sp_menu">'; foreach ($context['menu_buttons'] as $act => $button) { echo ' <li>', sp_embed_image('dot'), ' <a title="', $button['title'], '" href="', $button['href'], '">', $button['active_button'] ? '<strong>' : '', $button['title'], $button['active_button'] ? '</strong>' : '', '</a>'; if (!empty($button['sub_buttons'])) { echo ' <ul class="sp_list">'; foreach ($button['sub_buttons'] as $sub_button) { echo ' <li class="sp_list_indent">', sp_embed_image('dot'), ' <a title="', $sub_button['title'], '" href="', $sub_button['href'], '">', $sub_button['title'], '</a></li>'; } echo ' </ul>'; } echo '</li>'; } echo ' </ul>'; }
/** * Menu Block, creates a sidebar menu block based on the system main menu * @todo needs updating so it knows right vs left block for the flyout * * @param mixed[] $parameters - not used in this block * @param int $id - not used in this block * @param boolean $return_parameters if true returns the configuration options for the block */ function sp_menu($parameters, $id, $return_parameters = false) { global $context; $block_parameters = array(); if ($return_parameters) { return $block_parameters; } if (empty($context['menu_buttons'])) { setupMenuContext(); } echo ' <ul id="sp_menu" class="sp_list">'; foreach ($context['menu_buttons'] as $act => $button) { echo ' <li ', sp_embed_class('dot'), '> <a title="', strip_tags($button['title']), '" href="', $button['href'], '">', $button['active_button'] ? '<strong>' : '', $button['title'], $button['active_button'] ? '</strong>' : '', '</a>'; if (!empty($button['sub_buttons'])) { echo ' <ul class="sp_list">'; foreach ($button['sub_buttons'] as $sub_button) { echo ' <li ', sp_embed_class('dot', '', 'sp_list_indent'), '> <a title="', $sub_button['title'], '" href="', $sub_button['href'], '">', $sub_button['title'], '</a></li>'; } echo ' </ul>'; } echo '</li>'; } echo ' </ul>'; // Superfish the menu $javascript = "\n\t\$(document).ready(function() {\n\t\tif (use_click_menu)\n\t\t\t\$('#sp_menu').superclick({speed: 150, animation: {opacity:'show', height:'toggle'}, speedOut: 0, activeClass: 'sfhover'});\n\t\telse\n\t\t\t\$('#sp_menu').superfish({delay : 300, speed: 175, hoverClass: 'sfhover'});\n\t});"; addInlineJavascript($javascript, true); }
/** * Sets up the basic theme context stuff. * * @param bool $forceload = false */ function setupThemeContext($forceload = false) { global $modSettings, $user_info, $scripturl, $context, $settings, $options, $txt; global $user_settings; static $loaded = false; // Under SSI this function can be called more then once. That can cause some problems. // So only run the function once unless we are forced to run it again. if ($loaded && !$forceload) { return; } $loaded = true; $context['current_time'] = standardTime(time(), false); $context['current_action'] = isset($_GET['action']) ? $_GET['action'] : ''; $context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest']; // Get some news... $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) { if (trim($context['news_lines'][$i]) == '') { continue; } // Clean it up for presentation ;). $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); } if (!empty($context['news_lines'])) { $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; $context['upper_content_callbacks'][] = 'news_fader'; } if (!$user_info['is_guest']) { $context['user']['messages'] =& $user_info['messages']; $context['user']['unread_messages'] =& $user_info['unread_messages']; $context['user']['mentions'] =& $user_info['mentions']; // Personal message popup... if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { $context['user']['popup_messages'] = true; } else { $context['user']['popup_messages'] = false; } $_SESSION['unread_messages'] = $user_info['unread_messages']; $context['user']['avatar'] = array('href' => !empty($user_info['avatar']['href']) ? $user_info['avatar']['href'] : '', 'image' => !empty($user_info['avatar']['image']) ? $user_info['avatar']['image'] : ''); // @deprecated since 1.0.2 if (!empty($modSettings['avatar_max_width'])) { $context['user']['avatar']['width'] = $modSettings['avatar_max_width']; } // @deprecated since 1.0.2 if (!empty($modSettings['avatar_max_height'])) { $context['user']['avatar']['height'] = $modSettings['avatar_max_height']; } // Figure out how long they've been logged in. $context['user']['total_time_logged_in'] = array('days' => floor($user_info['total_time_logged_in'] / 86400), 'hours' => floor($user_info['total_time_logged_in'] % 86400 / 3600), 'minutes' => floor($user_info['total_time_logged_in'] % 3600 / 60)); } else { $context['user']['messages'] = 0; $context['user']['unread_messages'] = 0; $context['user']['mentions'] = 0; $context['user']['avatar'] = array(); $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); $context['user']['popup_messages'] = false; if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { $txt['welcome_guest'] .= $txt['welcome_guest_activate']; } $txt['welcome_guest'] = replaceBasicActionUrl($txt['welcome_guest']); // If we've upgraded recently, go easy on the passwords. if (!empty($modSettings['enable_password_conversion'])) { $context['disable_login_hashing'] = true; } } // Setup the main menu items. setupMenuContext(); if (empty($settings['theme_version'])) { $context['show_vBlogin'] = $context['show_quick_login']; } // This is here because old index templates might still use it. $context['show_news'] = !empty($settings['enable_news']); $context['additional_dropdown_search'] = prepareSearchEngines(); // This is done to allow theme authors to customize it as they want. $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); // Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. if ($context['show_pm_popup']) { addInlineJavascript(' $(document).ready(function(){ new smc_Popup({ heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', content: ' . JavaScriptEscape(sprintf($txt['show_personal_messages'], $context['user']['unread_messages'], $scripturl . '?action=pm')) . ', icon: elk_images_url + \'/im_sm_newmsg.png\' }); });', true); } // This looks weird, but it's because BoardIndex.controller.php references the variable. $context['common_stats']['latest_member'] = array('id' => $modSettings['latestMember'], 'name' => $modSettings['latestRealName'], 'href' => $scripturl . '?action=profile;u=' . $modSettings['latestMember'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $modSettings['latestRealName'] . '</a>'); $context['common_stats'] = array('total_posts' => comma_format($modSettings['totalMessages']), 'total_topics' => comma_format($modSettings['totalTopics']), 'total_members' => comma_format($modSettings['totalMembers']), 'latest_member' => $context['common_stats']['latest_member']); $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); if (empty($settings['theme_version'])) { addJavascriptVar(array('elk_scripturl' => '\'' . $scripturl . '\'')); } if (!isset($context['page_title'])) { $context['page_title'] = ''; } // Set some specific vars. $context['page_title_html_safe'] = Util::htmlspecialchars(un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); $context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? Util::htmlspecialchars($modSettings['meta_keywords']) : ''; // Load a custom CSS file? if (file_exists($settings['theme_dir'] . '/css/custom.css')) { loadCSSFile('custom.css'); } if (!empty($context['theme_variant']) && file_exists($settings['theme_dir'] . '/css/' . $context['theme_variant'] . '/custom' . $context['theme_variant'] . '.css')) { loadCSSFile($context['theme_variant'] . '/custom' . $context['theme_variant'] . '.css'); } }
function setupThemeContext($forceload = false) { global $modSettings, $user_info, $scripturl, $context, $settings, $options, $txt, $maintenance, $user_settings; static $loaded = false; // Under SSI this function can be called more then once. That can cause some problems. // So only run the function once unless we are forced to run it again. if ($loaded && !$forceload) { return; } $loaded = true; $context['in_maintenance'] = !empty($maintenance); $context['current_time'] = timeformat(time(), false); $context['current_action'] = isset($_GET['action']) ? $_GET['action'] : ''; $context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest']; if (!$user_info['is_guest']) { $context['user']['messages'] =& $user_info['messages']; $context['user']['unread_messages'] =& $user_info['unread_messages']; $_SESSION['unread_messages'] = $user_info['unread_messages']; if (allowedTo('moderate_forum')) { $context['unapproved_members'] = !empty($modSettings['registration_method']) && $modSettings['registration_method'] == 2 || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; } $context['show_open_reports'] = empty($user_settings['mod_prefs']) || $user_settings['mod_prefs'][0] == 1; $context['user']['avatar'] = array(); // Figure out the avatar... uploaded? if ($user_info['avatar']['url'] == 'gravatar') { $hash = md5(strtolower(trim($user_info['email']))); $context['user']['avatar']['image'] = '<img class="avatar" alt="avatar" src="http://www.gravatar.com/avatar/' . $hash . '" />'; $context['user']['avatar']['href'] = 'http://www.gravatar.com/avatar/' . $hash; $context['user']['avatar']['url'] = $context['user']['avatar']['href']; } else { if ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; } elseif (substr($user_info['avatar']['url'], 0, 7) == 'http://') { $context['user']['avatar']['href'] = $user_info['avatar']['url']; if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { if (!empty($modSettings['avatar_max_width_external'])) { $context['user']['avatar']['width'] = $modSettings['avatar_max_width_external']; } if (!empty($modSettings['avatar_max_height_external'])) { $context['user']['avatar']['height'] = $modSettings['avatar_max_height_external']; } } } elseif ($user_info['avatar']['url'] != '') { $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . htmlspecialchars($user_info['avatar']['url']); } } if (!empty($context['user']['avatar'])) { $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '"' . (isset($context['user']['avatar']['width']) ? ' width="' . $context['user']['avatar']['width'] . '"' : '') . (isset($context['user']['avatar']['height']) ? ' height="' . $context['user']['avatar']['height'] . '"' : '') . ' alt="" class="avatar" />'; } // Figure out how long they've been logged in. $context['user']['total_time_logged_in'] = array('days' => floor($user_info['total_time_logged_in'] / 86400), 'hours' => floor($user_info['total_time_logged_in'] % 86400 / 3600), 'minutes' => floor($user_info['total_time_logged_in'] % 3600 / 60)); } else { $context['user']['messages'] = 0; $context['user']['unread_messages'] = 0; $context['user']['avatar'] = array(); $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { $txt['welcome_guest_missed_activation'] = $txt['welcome_guest_activate']; } else { $txt['welcome_guest_missed_activation'] = ''; } // If we've upgraded recently, go easy on the passwords. if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { $context['disable_login_hashing'] = true; } } // Setup the main menu items. setupMenuContext(); // Resize avatars the fancy, but non-GD requiring way. if ($modSettings['avatar_action_too_large'] == 'option_js_resize' && (!empty($modSettings['avatar_max_width_external']) || !empty($modSettings['avatar_max_height_external']))) { $context['html_headers'] .= ' <script type="text/javascript"><!-- // --><![CDATA[ var smf_avatarMaxWidth = ' . (int) $modSettings['avatar_max_width_external'] . '; var smf_avatarMaxHeight = ' . (int) $modSettings['avatar_max_height_external'] . ';'; if (!$context['browser']['is_ie'] && !$context['browser']['is_mac_ie']) { $context['html_headers'] .= ' window.addEventListener("load", smf_avatarResize, false);'; } else { $context['html_headers'] .= ' var window_oldAvatarOnload = window.onload; window.onload = smf_avatarResize;'; } // !!! Move this over to script.js? $context['html_headers'] .= ' // ]]></script>'; } // This looks weird, but it's because BoardIndex.php references the variable. $context['common_stats']['latest_member'] = array('id' => $modSettings['latestMember'], 'name' => $modSettings['latestRealName'], 'href' => $scripturl . '?action=profile;u=' . $modSettings['latestMember'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $modSettings['latestRealName'] . '</a>'); $context['common_stats'] = array('total_posts' => comma_format($modSettings['totalMessages']), 'total_topics' => comma_format($modSettings['totalTopics']), 'total_members' => comma_format($modSettings['totalMembers']), 'latest_member' => $context['common_stats']['latest_member']); if (!isset($context['page_title'])) { $context['page_title'] = ''; } // Set some specific vars. $context['page_title_html_safe'] = $context['forum_name_html_safe'] . ' - ' . commonAPI::htmlspecialchars(un_htmlspecialchars($context['page_title'])); $context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? commonAPI::htmlspecialchars($modSettings['meta_keywords']) : ''; $context['page_description_html_safe'] = isset($context['meta_page_description']) ? commonAPI::htmlspecialchars(un_htmlspecialchars($context['meta_page_description'])) : $context['page_title_html_safe']; if (empty($modSettings['groupColorsFromTheme'])) { $context['html_headers'] .= $modSettings['groupColorsInline']; } }