/** * Create and return the HTML document * * @param string $content Main content for the page * @param array $information An array defining variables to be used when creating the output * string 'what' If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned * string 'pagetitle' Optional content for the page's <title> * string 'breadcrumbs' Optional content for the page's breadcrumb * string 'headercode' Optional code to go into the page's <head> * boolean 'rightblock' Whether or not to show blocks on right hand side default is no (-1) * array 'custom' An array defining custom function to be used to format Rightblocks * @see function COM_siteHeader * @see function COM_siteFooter * @return string Formated HTML document * */ function COM_createHTMLDocument(&$content = '', $information = array()) { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $_SCRIPTS, $_PAGE_TIMER, $relLinks; // Retrieve required variables from information array if (isset($information['what'])) { $what = $information['what']; } else { $what = 'menu'; } if (isset($information['pagetitle'])) { $pagetitle = $information['pagetitle']; } else { $pagetitle = ''; } if (isset($information['headercode'])) { $headercode = $information['headercode']; } else { $headercode = ''; } if (isset($information['breadcrumbs'])) { $breadcrumbs = $information['breadcrumbs']; } else { $breadcrumbs = ''; } if (isset($information['rightblock'])) { $rightblock = $information['rightblock']; } else { $rightblock = -1; } if (isset($information['custom'])) { $custom = $information['custom']; } else { $custom = ''; } // If the theme does not support the CSS layout then call the legacy functions (Geeklog 1.8.1 and older). if ($_CONF['supported_version_theme'] == '1.8.1') { return COM_siteHeader($what, $pagetitle, $headercode) . $content . COM_siteFooter($rightblock, $custom); } // If the theme implemented this for us then call their version instead. $function = $_CONF['theme'] . '_createHTMLDocument'; if (function_exists($function)) { return $function($content, $information); } // If we reach here then either we have the default theme OR // the current theme only needs the default variable substitutions switch ($_CONF['doctype']) { case 'html401transitional': $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; break; case 'html401strict': $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'; break; case 'xhtml10transitional': $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; break; case 'xhtml10strict': $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; break; case 'html5': case 'xhtml5': $doctype = '<!DOCTYPE html>'; break; default: // fallback: HTML 4.01 Transitional w/o system identifier $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; break; } // send out the charset header header('Content-Type: text/html; charset=' . COM_getCharset()); if (!empty($_CONF['frame_options'])) { header('X-FRAME-OPTIONS: ' . $_CONF['frame_options']); } $header = COM_newTemplate($_CONF['path_layout']); $header->set_file(array('header' => 'header.thtml', 'menunavigation' => 'menunavigation.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml')); $blocks = array('menuitem', 'menuitem_last', 'menuitem_none'); foreach ($blocks as $block) { $header->set_block('menunavigation', $block); } $header->parse('menu_elements', 'menunavigation', true); $header->set_var('doctype', $doctype . LB); if (XHTML == '') { $header->set_var('xmlns', ''); } else { $header->set_var('xmlns', ' xmlns="http://www.w3.org/1999/xhtml"'); } $feed_url = array(); if ($_CONF['backend'] == 1) { $baseurl = SYND_getFeedUrl(); $sql = 'SELECT format, filename, title, language FROM ' . $_TABLES['syndication'] . " WHERE (header_tid = 'all')"; if (!empty($topic)) { $sql .= " OR (header_tid = '" . DB_escapeString($topic) . "')"; } $result = DB_query($sql); $numRows = DB_numRows($result); for ($i = 0; $i < $numRows; $i++) { $A = DB_fetchArray($result); if (!empty($A['filename'])) { $format_type = SYND_getMimeType($A['format']); $format_name = SYND_getFeedType($A['format']); $feed_title = $format_name . ' Feed: ' . $A['title']; $feed_url[] = '<link rel="alternate" type="' . $format_type . '" hreflang="' . $A['language'] . '" href="' . $baseurl . $A['filename'] . '" title="' . htmlspecialchars($feed_title) . '"' . XHTML . '>'; } } } $header->set_var('feed_url', implode(LB, $feed_url)); // for backward compatibility only - use {feed_url} instead $feed = SYND_getDefaultFeedUrl(); if (COM_onFrontpage()) { $relLinks['canonical'] = '<link rel="canonical" href="' . $_CONF['site_url'] . '/"' . XHTML . '>'; } else { $relLinks['home'] = '<link rel="home" href="' . $_CONF['site_url'] . '/" title="' . $LANG01[90] . '"' . XHTML . '>'; } $loggedInUser = !COM_isAnonUser(); if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) { if (substr($_SERVER['PHP_SELF'], -strlen('/search.php')) != '/search.php' || isset($_GET['mode'])) { $relLinks['search'] = '<link rel="search" href="' . $_CONF['site_url'] . '/search.php" title="' . $LANG01[75] . '"' . XHTML . '>'; } } if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['directoryloginrequired'] == 0) { if (strpos($_SERVER['PHP_SELF'], '/article.php') !== false) { $relLinks['contents'] = '<link rel="contents" href="' . $_CONF['site_url'] . '/directory.php" title="' . $LANG01[117] . '"' . XHTML . '>'; } } if (!$_CONF['disable_webservices']) { $relLinks['service'] = '<link rel="service" ' . 'type="application/atomsvc+xml" ' . 'href="' . $_CONF['site_url'] . '/webservices/atom/?introspection" ' . 'title="' . $LANG01[130] . '"' . XHTML . '>'; } // TBD: add a plugin API and a lib-custom.php function $header->set_var('rel_links', implode(LB, $relLinks)); $pagetitle_siteslogan = false; if (empty($pagetitle)) { if (empty($topic)) { $pagetitle = $_CONF['site_slogan']; $pagetitle_siteslogan = true; } else { $pagetitle = stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$topic}'")); } } if (!empty($pagetitle)) { $header->set_var('page_site_splitter', ' - '); } else { $header->set_var('page_site_splitter', ''); } $header->set_var('page_title', $pagetitle); $header->set_var('site_name', $_CONF['site_name']); if (COM_onFrontpage() or $pagetitle_siteslogan) { $title_and_name = $_CONF['site_name']; if (!empty($pagetitle)) { $title_and_name .= ' - ' . $pagetitle; } } else { $title_and_name = ''; if (!empty($pagetitle)) { $title_and_name = $pagetitle . ' - '; } $title_and_name .= $_CONF['site_name']; } $header->set_var('page_title_and_site_name', $title_and_name); COM_setLangIdAndAttribute($header); $header->set_var('background_image', $_CONF['layout_url'] . '/images/bg.' . $_IMAGE_TYPE); $msg = rtrim($LANG01[67]) . ' ' . $_CONF['site_name']; if (!empty($_USER['username'])) { $msg .= ', ' . COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']); } $curtime = COM_getUserDateTimeFormat(); $header->set_var('welcome_msg', $msg); $header->set_var('datetime', $curtime[0]); $header->set_var('site_logo', $_CONF['layout_url'] . '/images/logo.' . $_IMAGE_TYPE); $header->set_var('theme', $_CONF['theme']); $header->set_var('datetime_html5', strftime('%FT%T', $curtime[1])); $header->set_var('charset', COM_getCharset()); $header->set_var('direction', $LANG_DIRECTION); $template_vars = array('rdf_file' => $feed, 'rss_url' => $feed, 'site_mail' => "mailto:{$_CONF['site_mail']}", 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'button_home' => $LANG_BUTTONS[1], 'button_contact' => $LANG_BUTTONS[2], 'button_contribute' => $LANG_BUTTONS[3], 'button_sitestats' => $LANG_BUTTONS[7], 'button_personalize' => $LANG_BUTTONS[8], 'button_search' => $LANG_BUTTONS[9], 'button_advsearch' => $LANG_BUTTONS[10], 'button_directory' => $LANG_BUTTONS[11]); $header->set_var($template_vars); // Get plugin menu options $plugin_menu = PLG_getMenuItems(); if ($_COM_VERBOSE) { COM_errorLog('num plugin menu items in header = ' . count($plugin_menu), 1); } // Now add nested template for menu items COM_renderMenu($header, $plugin_menu); if (count($plugin_menu) == 0) { $header->parse('plg_menu_elements', 'menuitem_none', true); } else { $count_plugin_menu = count($plugin_menu); for ($i = 1; $i <= $count_plugin_menu; $i++) { $header->set_var('menuitem_url', current($plugin_menu)); $header->set_var('menuitem_text', key($plugin_menu)); if ($i == $count_plugin_menu) { $header->parse('plg_menu_elements', 'menuitem_last', true); } else { $header->parse('plg_menu_elements', 'menuitem', true); } next($plugin_menu); } } // Call to plugins to set template variables in the header PLG_templateSetVars('header', $header); if ($_CONF['left_blocks_in_footer'] == 1) { $header->set_var('left_blocks', ''); $header->set_var('geeklog_blocks', ''); } else { $lblocks = ''; /* Check if an array has been passed that includes the name of a plugin * function or custom function * This can be used to take control over what blocks are then displayed */ if (is_array($what)) { $function = $what[0]; if (function_exists($function)) { $lblocks = $function($what[1], 'left'); } else { $lblocks = COM_showBlocks('left', $topic); } } else { if ($what != 'none') { // Now show any blocks -- need to get the topic if not on home page $lblocks = COM_showBlocks('left', $topic); } } if (empty($lblocks)) { $header->set_var('left_blocks', ''); $header->set_var('geeklog_blocks', ''); } else { $header->set_var('geeklog_blocks', $lblocks); $header->parse('left_blocks', 'leftblocks', true); $header->set_var('geeklog_blocks', ''); } } if ($_CONF['right_blocks_in_footer'] == 1) { $header->set_var('right_blocks', ''); $header->set_var('geeklog_blocks', ''); } else { $rblocks = ''; /* Check if an array has been passed that includes the name of a plugin * function or custom function * This can be used to take control over what blocks are then displayed */ if (is_array($what)) { $function = $what[0]; if (function_exists($function)) { $rblocks = $function($what[1], 'right'); } else { $rblocks = COM_showBlocks('right', $topic); } } else { if ($what != 'none') { // Now show any blocks -- need to get the topic if not on home page $rblocks = COM_showBlocks('right', $topic); } } if (empty($rblocks)) { $header->set_var('right_blocks', ''); $header->set_var('geeklog_blocks', ''); } else { $header->set_var('geeklog_blocks', $rblocks, true); $header->parse('right_blocks', 'rightblocks', true); } } // Set last topic session variable if ($topic == TOPIC_ALL_OPTION) { $topic = ''; // Do not save 'all' option. Nothing is the same thing } SESS_setVariable('topic', $topic); // Call any plugin that may want to include extra Meta tags // or Javascript functions $headercode .= PLG_getHeaderCode(); // Meta Tags // 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage if ($_CONF['meta_tags'] > 0) { $meta_description = ''; $meta_keywords = ''; $no_meta_description = 1; $no_meta_keywords = 1; //Find out if the meta tag description or keywords already exist in the headercode if ($headercode != '') { $pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im'; if (preg_match_all($pattern, $headercode, $matches, PREG_SET_ORDER)) { // Loop through all meta tags looking for description and keywords for ($i = 0; $i < count($matches) && ($no_meta_description == 1 || $no_meta_keywords == 1); $i++) { $str_matches = strtolower($matches[$i][0]); $pos = strpos($str_matches, 'name='); if (!(is_bool($pos) && !$pos)) { $name = trim(substr($str_matches, $pos + 5), '"'); $pos = strpos($name, '"'); $name = substr($name, 0, $pos); if (strcasecmp("description", $name) == 0) { $pos = strpos($str_matches, 'content='); if (!(is_bool($pos) && !$pos)) { $no_meta_description = 0; } } if (strcasecmp("keywords", $name) == 0) { $pos = strpos($str_matches, 'content='); if (!(is_bool($pos) && !$pos)) { $no_meta_keywords = 0; } } } } } } if (COM_onFrontpage() && $_CONF['meta_tags'] == 2) { // Display default meta tags only on home page if ($no_meta_description) { $meta_description = $_CONF['meta_description']; } if ($no_meta_keywords) { $meta_keywords = $_CONF['meta_keywords']; } } else { if ($_CONF['meta_tags'] == 1) { // Display default meta tags anywhere there are no tags if ($no_meta_description) { $meta_description = $_CONF['meta_description']; } if ($no_meta_keywords) { $meta_keywords = $_CONF['meta_keywords']; } } } if ($no_meta_description or $no_meta_keywords) { $headercode .= COM_createMetaTags($meta_description, $meta_keywords); } } $header->set_var('breadcrumb_trail', $breadcrumbs); COM_hit(); // Set template directory $footer = COM_newTemplate($_CONF['path_layout']); // Set template file $footer->set_file(array('footer' => 'footer.thtml', 'rightblocks' => 'rightblocks.thtml', 'leftblocks' => 'leftblocks.thtml')); $year = date('Y'); $copyrightyear = $year; if (!empty($_CONF['copyrightyear'])) { $copyrightyear = $_CONF['copyrightyear']; } if (!empty($_CONF['owner_name'])) { $copyrightname = $_CONF['owner_name']; } else { $copyrightname = $_CONF['site_name']; } $footer->set_var('copyright_notice', ' ' . $LANG01[93] . ' © ' . $copyrightyear . ' ' . $copyrightname . '<br' . XHTML . '> ' . $LANG01[94]); $footer->set_var('copyright_msg', $LANG01[93] . ' © ' . $copyrightyear . ' ' . $_CONF['site_name']); $footer->set_var('current_year', $year); $footer->set_var('lang_copyright', $LANG01[93]); $footer->set_var('trademark_msg', $LANG01[94]); $footer->set_var('powered_by', $LANG01[95]); $footer->set_var('geeklog_url', 'http://www.geeklog.net/'); $footer->set_var('geeklog_version', VERSION); $footer->set_var($template_vars); /* Right blocks. Argh. Don't talk to me about right blocks... * Right blocks will be displayed if Right_blocks_in_footer is set [1], * AND (this function has been asked to show them (first param) OR the * show_right_blocks conf variable has been set to override what the code * wants to do. * * If $custom sets an array (containing functionname and first argument) * then this is used instead of the default (COM_showBlocks) to render * the right blocks (and left). * * [1] - if it isn't, they'll be in the header already. * */ $displayRightBlocks = true; if ($_CONF['right_blocks_in_footer'] == 1) { if ($rightblock < 0 || !$rightblock) { if (isset($_CONF['show_right_blocks'])) { $displayRightBlocks = $_CONF['show_right_blocks']; } else { $displayRightBlocks = false; } } else { $displayRightBlocks = true; } } else { $displayRightBlocks = false; } if ($displayRightBlocks) { /* Check if an array has been passed that includes the name of a plugin * function or custom function. * This can be used to take control over what blocks are then displayed */ if (is_array($custom)) { $function = $custom['0']; if (function_exists($function)) { $rblocks = $function($custom['1'], 'right'); } else { $rblocks = COM_showBlocks('right', $topic); } } else { $rblocks = COM_showBlocks('right', $topic); } if (empty($rblocks)) { $footer->set_var('geeklog_blocks', ''); $footer->set_var('right_blocks', ''); } else { $footer->set_var('geeklog_blocks', $rblocks); $footer->parse('right_blocks', 'rightblocks', true); $footer->set_var('geeklog_blocks', ''); } } else { $footer->set_var('geeklog_blocks', ''); $footer->set_var('right_blocks', ''); } if ($_CONF['left_blocks_in_footer'] == 1) { $lblocks = ''; /* Check if an array has been passed that includes the name of a plugin * function or custom function * This can be used to take control over what blocks are then displayed */ if (is_array($custom)) { $function = $custom[0]; if (function_exists($function)) { $lblocks = $function($custom[1], 'left'); } } else { if ($what != 'none') { $lblocks = COM_showBlocks('left', $topic); } } if (empty($lblocks)) { $footer->set_var('left_blocks', ''); $footer->set_var('geeklog_blocks', ''); } else { $footer->set_var('geeklog_blocks', $lblocks); $footer->parse('left_blocks', 'leftblocks', true); $footer->set_var('geeklog_blocks', ''); } } // Global centerspan variable set in index.php if (isset($GLOBALS['centerspan'])) { $footer->set_var('centerblockfooter-span', '</td></tr></table>'); } $exectime = $_PAGE_TIMER->stopTimer(); $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92]; $footer->set_var('execution_time', $exectime); $footer->set_var('execution_textandtime', $exectext); /* Check leftblocks and rightblocks */ $layout_columns = 'left-center-right'; $emptylblocks = empty($lblocks); $emptyrblocks = empty($rblocks); if (!$emptylblocks && $emptyrblocks) { $layout_columns = 'left-center'; } if ($emptylblocks && !$emptyrblocks) { $layout_columns = 'center-right'; } if ($emptylblocks && $emptyrblocks) { $layout_columns = 'center'; } $header->set_var('layout_columns', $layout_columns); // All blocks, autotags, template files, etc, now have been rendered (since can be done in footer) so all scripts and css should be set now $headercode = $_SCRIPTS->getHeader() . $headercode; $header->set_var('plg_headercode', $headercode); $retval_header = $header->finish($header->parse('index_header', 'header')); // Call to plugins to set template variables in the footer PLG_templateSetVars('footer', $footer); // Call any plugin that may want to include extra JavaScript functions $plugin_footercode = PLG_getFooterCode(); // Retrieve any JavaScript libraries, variables and functions $footercode = $_SCRIPTS->getFooter(); // $_SCRIPTS code should be placed before plugin_footer_code but plugin_footer_code should still be allowed to set $_SCRIPTS $footercode .= $plugin_footercode; $footer->set_var('plg_footercode', $footercode); // Actually parse the template and make variable substitutions $footer->parse('index_footer', 'footer'); return $retval_header . $content . $footer->finish($footer->get_var('index_footer')); }
/** * Returns the site footer * * This loads the proper templates, does variable substitution and returns the * HTML for the site footer. * * @param boolean $rightblock Whether or not to show blocks on right hand side default is no * @param array $custom An array defining custom function to be used to format Rightblocks * @see function COM_siteHeader * @return string Formated HTML containing site footer and optionally right blocks * */ function COM_siteFooter($rightblock = -1, $custom = '') { global $_CONF, $_TABLES, $LANG01, $_PAGE_TIMER, $topic, $LANG_BUTTONS, $_SCRIPTS; // If the theme implemented this for us then call their version instead. $function = $_CONF['theme'] . '_siteFooter'; if (function_exists($function)) { return $function($rightblock, $custom); } COM_hit(); // Set template directory $footer = COM_newTemplate($_CONF['path_layout']); // Set template file $footer->set_file(array('footer' => 'footer.thtml', 'rightblocks' => 'rightblocks.thtml', 'leftblocks' => 'leftblocks.thtml')); // Needed to set for pre (instead of post) since JavaScript could contain // autotag labels (like in configuration search) $footer->preprocess_fn = 'PLG_replaceTags'; // Do variable assignments $footer->set_var('site_mail', "mailto:{$_CONF['site_mail']}"); $footer->set_var('site_name', $_CONF['site_name']); $footer->set_var('site_slogan', $_CONF['site_slogan']); $feed = SYND_getDefaultFeedUrl(); $footer->set_var('rdf_file', $feed); $footer->set_var('rss_url', $feed); $year = date('Y'); $copyrightyear = $year; if (!empty($_CONF['copyrightyear'])) { $copyrightyear = $_CONF['copyrightyear']; } if (!empty($_CONF['owner_name'])) { $copyrightname = $_CONF['owner_name']; } else { $copyrightname = $_CONF['site_name']; } $footer->set_var('copyright_notice', ' ' . $LANG01[93] . ' © ' . $copyrightyear . ' ' . $copyrightname . '<br' . XHTML . '> ' . $LANG01[94]); $footer->set_var('copyright_msg', $LANG01[93] . ' © ' . $copyrightyear . ' ' . $_CONF['site_name']); $footer->set_var('current_year', $year); $footer->set_var('lang_copyright', $LANG01[93]); $footer->set_var('trademark_msg', $LANG01[94]); $footer->set_var('powered_by', $LANG01[95]); $footer->set_var('geeklog_url', 'http://www.geeklog.net/'); $footer->set_var('geeklog_version', VERSION); // Now add variables for buttons like e.g. those used by the Yahoo theme $footer->set_var('button_home', $LANG_BUTTONS[1]); $footer->set_var('button_contact', $LANG_BUTTONS[2]); $footer->set_var('button_contribute', $LANG_BUTTONS[3]); $footer->set_var('button_sitestats', $LANG_BUTTONS[7]); $footer->set_var('button_personalize', $LANG_BUTTONS[8]); $footer->set_var('button_search', $LANG_BUTTONS[9]); $footer->set_var('button_advsearch', $LANG_BUTTONS[10]); $footer->set_var('button_directory', $LANG_BUTTONS[11]); /* Right blocks. Argh. Don't talk to me about right blocks... * Right blocks will be displayed if Right_blocks_in_footer is set [1], * AND (this function has been asked to show them (first param) OR the * show_right_blocks conf variable has been set to override what the code * wants to do. * * If $custom sets an array (containing functionname and first argument) * then this is used instead of the default (COM_showBlocks) to render * the right blocks (and left). * * [1] - if it isn't, they'll be in the header already. * */ $displayRightBlocks = true; if ($_CONF['right_blocks_in_footer'] == 1) { if ($rightblock < 0 || !$rightblock) { if (isset($_CONF['show_right_blocks'])) { $displayRightBlocks = $_CONF['show_right_blocks']; } else { $displayRightBlocks = false; } } else { $displayRightBlocks = true; } } else { $displayRightBlocks = false; } if ($displayRightBlocks) { /* Check if an array has been passed that includes the name of a plugin * function or custom function. * This can be used to take control over what blocks are then displayed */ if (is_array($custom)) { $function = $custom['0']; if (function_exists($function)) { $rblocks = $function($custom['1'], 'right'); } else { $rblocks = COM_showBlocks('right', $topic); } } else { $rblocks = COM_showBlocks('right', $topic); } if (empty($rblocks)) { $footer->set_var('geeklog_blocks', ''); $footer->set_var('right_blocks', ''); } else { $footer->set_var('geeklog_blocks', $rblocks); $footer->parse('right_blocks', 'rightblocks', true); $footer->set_var('geeklog_blocks', ''); } } else { $footer->set_var('geeklog_blocks', ''); $footer->set_var('right_blocks', ''); } if ($_CONF['left_blocks_in_footer'] == 1) { $lblocks = ''; /* Check if an array has been passed that includes the name of a plugin * function or custom function * This can be used to take control over what blocks are then displayed */ if (is_array($custom)) { $function = $custom[0]; if (function_exists($function)) { $lblocks = $function($custom[1], 'left'); } } else { $lblocks = COM_showBlocks('left', $topic); } if (empty($lblocks)) { $footer->set_var('left_blocks', ''); $footer->set_var('geeklog_blocks', ''); } else { $footer->set_var('geeklog_blocks', $lblocks); $footer->parse('left_blocks', 'leftblocks', true); $footer->set_var('geeklog_blocks', ''); } } // Global centerspan variable set in index.php if (isset($GLOBALS['centerspan'])) { $footer->set_var('centerblockfooter-span', '</td></tr></table>'); } $exectime = $_PAGE_TIMER->stopTimer(); $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92]; $footer->set_var('execution_time', $exectime); $footer->set_var('execution_textandtime', $exectext); // Call to plugins to set template variables in the footer PLG_templateSetVars('footer', $footer); // Call any plugin that may want to include extra JavaScript functions $plugin_footercode = PLG_getFooterCode(); // Retrieve any JavaScript libraries, variables and functions $footercode = $_SCRIPTS->getFooter(); // $_SCRIPTS code should be placed before plugin_footer_code but plugin_footer_code should still be allowed to set $_SCRIPTS $footercode .= $plugin_footercode; $footer->set_var('plg_footercode', $footercode); // Actually parse the template and make variable substitutions $footer->parse('index_footer', 'footer'); // Return resulting HTML return $footer->finish($footer->get_var('index_footer')); }
/** * Returns the site footer * * This loads the proper templates, does variable substitution and returns the * HTML for the site footer. * * @param boolean $rightblock Whether or not to show blocks on right hand side default is no * @param array $custom An array defining custom function to be used to format Rightblocks * @see function COM_siteHeader * @return string Formated HTML containing site footer and optionally right blocks * */ function COM_siteFooter($rightblock = -1, $custom = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG12, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $_PAGE_TIMER, $theme_what, $theme_pagetitle, $theme_headercode, $theme_layout, $_LOGO, $uiStyles; COM_hit(); if (isset($blockInterface['right'])) { $currentURL = COM_getCurrentURL(); if (strpos($currentURL, $_CONF['site_admin_url']) === 0) { if ($blockInterface['right']['location'] == 'right' || $blockInterface['right']['location'] == 'left') { $rightblocks = -1; } } } $function = $_USER['theme'] . '_siteFooter'; if (function_exists($function)) { return $function($rightblock, $custom); } $dt = new Date('now', $_USER['tzid']); $what = $theme_what; $pagetitle = $theme_pagetitle; $themecode = $theme_headercode; // Grab any content that was cached by the system $content = ob_get_contents(); ob_end_clean(); $theme = new Template($_CONF['path_layout']); $theme->set_file(array('header' => 'header.thtml', 'footer' => 'footer.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml')); $theme->set_var('num_search_results', $_CONF['num_search_results']); // get topic if not on home page if (!isset($_GET['topic'])) { if (isset($_GET['story'])) { $sid = COM_applyFilter($_GET['story']); } elseif (isset($_GET['sid'])) { $sid = COM_applyFilter($_GET['sid']); } elseif (isset($_POST['story'])) { $sid = COM_applyFilter($_POST['story']); } if (empty($sid) && $_CONF['url_rewrite'] && strpos($_SERVER['PHP_SELF'], 'article.php') !== false) { COM_setArgNames(array('story', 'mode')); $sid = COM_applyFilter(COM_getArgument('story')); } if (!empty($sid)) { $topic = DB_getItem($_TABLES['stories'], 'tid', "sid='" . DB_escapeString($sid) . "'"); } } else { $topic = COM_applyFilter($_GET['topic']); } $loggedInUser = !COM_isAnonUser(); $theme->set_var('site_name', $_CONF['site_name']); $theme->set_var('background_image', $_CONF['layout_url'] . '/images/bg.' . $_IMAGE_TYPE); $theme->set_var('site_mail', "mailto:{$_CONF['site_mail']}"); if ($_LOGO['display_site_slogan']) { $theme->set_var('site_slogan', $_CONF['site_slogan']); } $msg = $LANG01[67] . ' ' . $_CONF['site_name']; if (!empty($_USER['username']) && !COM_isAnonUser()) { $msg .= ', ' . COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']); } $curtime = $dt->format($dt->getUserFormat(), true); $theme->set_var('welcome_msg', $msg); $theme->set_var('datetime', $curtime); if ($_LOGO['use_graphic_logo'] == 1 && file_exists($_CONF['path_html'] . '/images/' . $_LOGO['logo_name'])) { $L = new Template($_CONF['path_layout']); $L->set_file(array('logo' => 'logo-graphic.thtml')); $imgInfo = @getimagesize($_CONF['path_html'] . '/images/' . $_LOGO['logo_name']); $dimension = $imgInfo[3]; $L->set_var('site_name', $_CONF['site_name']); $site_logo = $_CONF['site_url'] . '/images/' . $_LOGO['logo_name']; $L->set_var('site_logo', $site_logo); $L->set_var('dimension', $dimension); if ($imgInfo[1] != 100) { $delta = 100 - $imgInfo[1]; $newMargin = $delta; $L->set_var('delta', 'style="padding-top:' . $newMargin . 'px;"'); } else { $L->set_var('delta', ''); } if ($_LOGO['display_site_slogan']) { $L->set_var('site_slogan', $_CONF['site_slogan']); } $L->parse('output', 'logo'); $theme->set_var('logo_block', $L->finish($L->get_var('output'))); } else { if ($_LOGO['use_graphic_logo'] == 0) { $L = new Template($_CONF['path_layout']); $L->set_file(array('logo' => 'logo-text.thtml')); $L->set_var('site_name', $_CONF['site_name']); if ($_LOGO['display_site_slogan']) { $L->set_var('site_slogan', $_CONF['site_slogan']); } $L->parse('output', 'logo'); $theme->set_var('logo_block', $L->finish($L->get_var('output'))); } else { $theme->set_var('logo_block', ''); } } $theme->set_var('site_logo', $_CONF['layout_url'] . '/images/logo.' . $_IMAGE_TYPE); $theme->set_var(array('lang_login' => $LANG01[58], 'lang_myaccount' => $LANG01[48], 'lang_logout' => $LANG01[35], 'lang_newuser' => $LANG12[3])); $menu_navigation = displayMenu('navigation'); $menu_footer = displayMenu('footer'); $menu_header = displayMenu('header'); $theme->set_var(array('menu_navigation' => $menu_navigation, 'menu_footer' => $menu_footer, 'menu_header' => $menu_header, 'st_hmenu' => $menu_navigation, 'st_footer_menu' => $menu_footer, 'st_header_menu' => $menu_header)); $lblocks = ''; /* Check if an array has been passed that includes the name of a plugin * function or custom function * This can be used to take control over what blocks are then displayed */ if (is_array($what)) { $function = $what[0]; if (function_exists($function)) { $lblocks = $function($what[1], 'left'); } else { $lblocks = COM_showBlocks('left', $topic); } } else { if ($what != 'none') { // Now show any blocks -- need to get the topic if not on home page $lblocks = COM_showBlocks('left', $topic); } } /* Now build footer */ if (empty($lblocks)) { $theme->set_var('left_blocks', ''); $theme->set_var('glfusion_blocks', ''); } else { $theme->set_var('glfusion_blocks', $lblocks); } // Do variable assignments $theme->set_var('site_mail', "mailto:{$_CONF['site_mail']}"); $theme->set_var('site_slogan', $_CONF['site_slogan']); $rdf = substr_replace($_CONF['rdf_file'], $_CONF['site_url'], 0, strlen($_CONF['path_html']) - 1) . LB; $theme->set_var('rdf_file', $rdf); $theme->set_var('rss_url', $rdf); $year = date('Y'); $copyrightyear = $year; if (!empty($_CONF['copyrightyear'])) { if ($year == $_CONF['copyrightyear']) { $copyrightyear = $_CONF['copyrightyear']; } else { $copyrightyear = $_CONF['copyrightyear'] . " - " . $year; } } $theme->set_var('copyright_notice', $LANG01[93] . ' © ' . $copyrightyear . ' ' . $_CONF['site_name'] . ' • ' . $LANG01[94]); $theme->set_var('copyright_msg', $LANG01[93] . ' © ' . $copyrightyear . ' ' . $_CONF['site_name']); $theme->set_var('current_year', $year); $theme->set_var('lang_copyright', $LANG01[93]); $theme->set_var('trademark_msg', $LANG01[94]); $theme->set_var('powered_by', $LANG01[95]); $theme->set_var('glfusion_url', 'http://www.glfusion.org/'); $theme->set_var('glfusion_version', GVERSION); $theme->set_var('direction', empty($LANG_DIRECTION) ? 'ltr' : $LANG_DIRECTION); /* Check if an array has been passed that includes the name of a plugin * function or custom function. * This can be used to take control over what blocks are then displayed */ if (is_array($custom)) { $function = $custom['0']; if (function_exists($function)) { $rblocks = $function($custom['1'], 'right'); } } elseif ($rightblock == 1 || $_CONF['show_right_blocks'] == 1) { $rblocks = ''; $rblocks = COM_showBlocks('right', $topic); if (empty($rblocks)) { $theme->set_var('glfusion_rblocks', ''); $theme->set_var('right_blocks', ''); if (empty($lblocks)) { // using full_content $theme->set_var('centercolumn', $uiStyles['full_content']['content_class']); } else { // using left_content $theme->set_var('centercolumn', $uiStyles['left_content']['content_class']); $theme->set_var('footercolumn-l', $uiStyles['left_content']['left_class']); } } else { $theme->set_var('glfusion_rblocks', $rblocks); if (empty($lblocks)) { // using content_right $theme->set_var('centercolumn', $uiStyles['content_right']['content_class']); $theme->set_var('footercolumn-r', $uiStyles['content_right']['right_class']); } else { // using left_content_right $theme->set_var('centercolumn', $uiStyles['left_content_right']['content_class']); $theme->set_var('footercolumn-l', $uiStyles['left_content_right']['left_class']); $theme->set_var('footercolumn-r', $uiStyles['left_content_right']['right_class']); } } } else { $theme->set_var('glfusion_rblocks', ''); $theme->set_var('right_blocks', ''); if (empty($lblocks)) { // using full content $theme->set_var('centercolumn', $uiStyles['full_content']['content_class']); } else { // using left_content $theme->set_var('centercolumn', $uiStyles['left_content']['content_class']); $theme->set_var('footercolumn-l', $uiStyles['left_content']['left_class']); } } if (!empty($lblocks)) { $theme->parse('left_blocks', 'leftblocks', true); $theme->set_var('glfusion_blocks', ''); } if (!empty($rblocks)) { $theme->parse('right_blocks', 'rightblocks', true); $theme->set_var('glfusion_rblocks', ''); } $exectime = $_PAGE_TIMER->stopTimer(); $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92]; $theme->set_var('execution_time', $exectime); $theme->set_var('execution_textandtime', $exectext); $theme->set_var('content', $content); // grab header data from outputHandler $outputHandle = outputHandler::getInstance(); $theme->set_var(array('meta-header' => $outputHandle->renderHeader('meta'), 'css-header' => $outputHandle->renderHeader('style'), 'js-header' => $outputHandle->renderHeader('script'), 'raw-header' => $outputHandle->renderHeader('raw'))); if (SESS_isSet('glfusion.infoblock')) { $msgArray = @unserialize(SESS_getVar('glfusion.infoblock')); $msgTxt = COM_showMessageText($msgArray['msg'], '', $persist = false, $msgArray['type']); $theme->set_var('info_block', $msgTxt); SESS_unSet('glfusion.infoblock'); } // Call to plugins to set template variables in the footer PLG_templateSetVars('header', $theme); PLG_templateSetVars('footer', $theme); // Actually parse the template and make variable substitutions $theme->parse('index_footer', 'footer'); $tmp = $theme->finish($theme->parse('index_header', 'header')); echo $tmp; // send the header.thtml $retval = $theme->finish($theme->get_var('index_footer')); _js_out(); _css_out(); return $retval; }