function doBeforeContent() { global $wgOut, $wgTitle; $s = ""; $qb = $this->qbSetting(); $mainPageObj = Title::newMainPage(); $s .= "\n<div id='content'>\n<div id='topbar'>" . "<table width='100%' border='0' cellspacing='0' cellpadding='8'><tr>"; $s .= "<td class='top' align='left' valign='middle' nowrap='nowrap'>"; $s .= "<a href=\"" . $mainPageObj->escapeLocalURL() . "\">"; $s .= "<span id='sitetitle'>" . wfMsg("sitetitle") . "</span></a>"; $s .= "</td><td class='top' align='right' valign='bottom' width='100%'>"; $s .= $this->sysLinks(); $s .= "</td></tr><tr><td valign='top'>"; $s .= "<font size='-1'><span id='sitesub'>"; $s .= htmlspecialchars(wfMsg("sitesubtitle")) . "</span></font>"; $s .= "</td><td align='right'>"; $s .= "<font size='-1'><span id='langlinks'>"; $s .= str_replace("<br />", "", $this->otherLanguages()); $cat = $this->getCategoryLinks(); if ($cat) { $s .= "<br />{$cat}\n"; } $s .= "<br />" . $this->pageTitleLinks(); $s .= "</span></font>"; $s .= "</td></tr></table>\n"; $s .= "\n</div>\n<div id='article'>"; $notice = wfGetSiteNotice(); if ($notice) { $s .= "\n<div id='siteNotice'>{$notice}</div>\n"; } $s .= $this->pageTitle(); $s .= $this->pageSubtitle() . "\n"; return $s; }
function doBeforeContent() { $s = "\n<div id='content'>\n<div id='top'>\n"; $s .= '<div id="logo">' . $this->logoText('right') . '</div>'; $s .= $this->pageTitle(); $s .= $this->pageSubtitle() . "\n"; $s .= '<div id="topbar">'; $s .= $this->topLinks() . "\n<br />"; $notice = wfGetSiteNotice(); if ($notice) { $s .= "\n<div id='siteNotice'>{$notice}</div>\n"; } $s .= $this->pageTitleLinks(); $ol = $this->otherLanguages(); if ($ol) { $s .= '<br />' . $ol; } $cat = $this->getCategoryLinks(); if ($cat) { $s .= '<br />' . $cat; } $s .= "<br clear='all' /></div><hr />\n</div>\n"; $s .= "\n<div id='article'>"; return $s; }
function doBeforeContent() { $qb = $this->qbSetting(); $mainPageObj = Title::newMainPage(); $s = "\n<div id='content'>\n<div id='topbar'>" . '<table width="100%" border="0" cellspacing="0" cellpadding="8"><tr>'; $s .= '<td class="top" align="left" valign="middle" nowrap="nowrap">'; $s .= '<a href="' . $mainPageObj->escapeLocalURL() . '">'; $s .= '<span id="sitetitle">' . wfMsg('sitetitle') . '</span></a>'; $s .= '</td><td class="top" align="right" valign="bottom" width="100%">'; $s .= $this->sysLinks(); $s .= '</td></tr><tr><td valign="top">'; $s .= '<font size="-1"><span id="sitesub">'; $s .= htmlspecialchars(wfMsg('sitesubtitle')) . '</span></font>'; $s .= '</td><td align="right">'; $s .= '<font size="-1"><span id="langlinks">'; $s .= str_replace('<br />', '', $this->otherLanguages()); $cat = $this->getCategoryLinks(); if ($cat) { $s .= "<br />{$cat}\n"; } $s .= '<br />' . $this->pageTitleLinks(); $s .= '</span></font>'; $s .= "</td></tr></table>\n"; $s .= "\n</div>\n<div id='article'>"; $notice = wfGetSiteNotice(); if ($notice) { $s .= "\n<div id='siteNotice'>{$notice}</div>\n"; } $s .= $this->pageTitle(); $s .= $this->pageSubtitle() . "\n"; return $s; }
function doBeforeContent() { global $wgOut; $s = ""; $qb = $this->qbSetting(); $mainPageObj = Title::newMainPage(); $s .= file_get_contents('../wwwroot/templates/header.html'); $title = htmlspecialchars($wgOut->getPageTitle()); $s = str_replace('{PAGE_TITLE}', $title, $s); $s .= '<tr><td>'; $s .= '<table border="0" cellpadding="0" cellspacing="0" width="760">'; $s .= '<tr>'; $s .= '<td bgcolor="#20292E" width="1"><img src="/images/pixel.gif" height="10" width="1" /><br /></td>'; $s .= '<td bgcolor="#4C626F" width="758">'; $s .= "\n<div id='content'>\n"; //$s .= '<table border="0" cellpadding="0" cellspacing="0" width="758"><tr>'; //$s .= '<td width="10"><img src="/images/pixel.gif" height="10" width="10" /><br /></td>'; //$s .= '<td width="738">'; $s .= "<div id='article'>"; $notice = wfGetSiteNotice(); if( $notice ) { $s .= "\n<div id='siteNotice'>$notice</div>\n"; } //$s .= $this->pageTitle(); // $s .= $this->pageSubtitle() . "\n"; return $s; }
function doBeforeContent() { global $wgUser, $wgOut, $wgTitle; $s = "\n<div id='content'>\n<div id='topbar'>"; $s .= $this->logoText("right"); $s .= $this->pageTitle(); $s .= $this->pageSubtitle() . "\n"; $s .= $this->topLinks() . "\n<br />"; $notice = wfGetSiteNotice(); if ($notice) { $s .= "\n<div id='siteNotice'>{$notice}</div>\n"; } $s .= $this->pageTitleLinks(); $ol = $this->otherLanguages(); if ($ol) { $s .= "<br />" . $ol; } $cat = $this->getCategoryLinks(); if ($cat) { $s .= "<br />" . $cat; } $s .= "<br clear='all' /><hr />\n</div>\n"; $s .= "\n<div id='article'>"; return $s; }
function doBeforeContent() { global $wgContLang; $fname = 'Skin::doBeforeContent'; wfProfileIn($fname); $s = ''; $qb = $this->qbSetting(); if ($langlinks = $this->otherLanguages()) { $rows = 2; $borderhack = ''; } else { $rows = 1; $langlinks = false; $borderhack = 'class="top"'; } $s .= "\n<div id='content'>\n<div id='topbar'>\n" . "<table border='0' cellspacing='0' width='98%'>\n<tr>\n"; $shove = $qb != 0; $left = $qb == 1 || $qb == 3; if ($wgContLang->isRTL()) { $left = !$left; } if (!$shove) { $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" . $this->logoText() . '</td>'; } elseif ($left) { $s .= $this->getQuickbarCompensator($rows); } $l = $wgContLang->isRTL() ? 'right' : 'left'; $s .= "<td {$borderhack} align='{$l}' valign='top'>\n"; $s .= $this->topLinks(); $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n"; $r = $wgContLang->isRTL() ? "left" : "right"; $s .= "</td>\n<td {$borderhack} valign='top' align='{$r}' nowrap='nowrap'>"; $s .= $this->nameAndLogin(); $s .= "\n<br />" . $this->searchForm() . "</td>"; if ($langlinks) { $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">{$langlinks}</td>\n"; } if ($shove && !$left) { # Right $s .= $this->getQuickbarCompensator($rows); } $s .= "</tr>\n</table>\n</div>\n"; $s .= "\n<div id='article'>\n"; $notice = wfGetSiteNotice(); if ($notice) { $s .= "\n<div id='siteNotice'>{$notice}</div>\n"; } $s .= $this->pageTitle(); $s .= $this->pageSubtitle(); $s .= $this->getCategories(); wfProfileOut($fname); return $s; }
function getHTML() { global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgOutputEncoding; global $wgSitename, $wgServer, $wgMessageCache, $wgLogo; # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky. # Hard coding strings instead. $noconnect = "<p><strong>Sorry! This site is experiencing technical difficulties.</strong></p><p>Try waiting a few minutes and reloading.</p><p><small>(Can't contact the database server: \$1)</small></p>"; $mainpage = 'Main Page'; $searchdisabled = <<<EOT <p style="margin: 1.5em 2em 1em">{$wgSitename} search is disabled for performance reasons. You can search via Google in the meantime. <span style="font-size: 89%; display: block; margin-left: .2em">Note that their indexes of {$wgSitename} content may be out of date.</span></p>', EOT; $googlesearch = "\n<!-- SiteSearch Google -->\n<FORM method=GET action=\"http://www.google.com/search\">\n<TABLE bgcolor=\"#FFFFFF\"><tr><td>\n<A HREF=\"http://www.google.com/\">\n<IMG SRC=\"http://www.google.com/logos/Logo_40wht.gif\"\nborder=\"0\" ALT=\"Google\"></A>\n</td>\n<td>\n<INPUT TYPE=text name=q size=31 maxlength=255 value=\"\$1\">\n<INPUT type=submit name=btnG VALUE=\"Google Search\">\n<font size=-1>\n<input type=hidden name=domains value=\"{$wgServer}\"><br /><input type=radio name=sitesearch value=\"\"> WWW <input type=radio name=sitesearch value=\"{$wgServer}\" checked> {$wgServer} <br />\n<input type='hidden' name='ie' value='\$2'>\n<input type='hidden' name='oe' value='\$2'>\n</font>\n</td></tr></TABLE>\n</FORM>\n<!-- SiteSearch Google -->"; $cachederror = "The following is a cached copy of the requested page, and may not be up to date. "; # No database access if (is_object($wgMessageCache)) { $wgMessageCache->disable(); } if (trim($this->error) == '') { $this->error = $this->db->getProperty('mServer'); } $text = str_replace('$1', $this->error, $noconnect); $text .= wfGetSiteNotice(); if ($wgUseFileCache) { if ($wgTitle) { $t =& $wgTitle; } else { if ($title) { $t = Title::newFromURL($title); } elseif (@$_REQUEST['search']) { $search = $_REQUEST['search']; return $searchdisabled . str_replace(array('$1', '$2'), array(htmlspecialchars($search), $wgInputEncoding), $googlesearch); } else { $t = Title::newFromText($mainpage); } } $cache = new CacheManager($t); if ($cache->isFileCached()) { $msg = '<p style="color: red"><b>' . $msg . "<br />\n" . $cachederror . "</b></p>\n"; $tag = '<div id="article">'; $text = str_replace($tag, $tag . $msg, $cache->fetchPageText()); } } return $text; }
/** * initialize various variables and generate the template * * @param OutputPage $out * @access public */ function outputPage(&$out) { global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut; global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage; global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest; global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; global $wgUseTrackbacks; $fname = 'SkinTemplate::outputPage'; wfProfileIn($fname); extract($wgRequest->getValues('oldid', 'diff')); wfProfileIn("{$fname}-init"); $this->initPage($out); $this->mTitle =& $wgTitle; $this->mUser =& $wgUser; $tpl = $this->setupTemplate($this->template, 'skins'); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); #} wfProfileOut("{$fname}-init"); wfProfileIn("{$fname}-stuff"); $this->thispage = $this->mTitle->getPrefixedDbKey(); $this->thisurl = $this->mTitle->getPrefixedURL(); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL; $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); $userPage = $wgUser->getUserPage(); $this->userpage = $userPage->getPrefixedText(); $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage); $this->usercss = $this->userjs = $this->userjsprev = false; $this->setupUserCss(); $this->setupUserJs(); $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut("{$fname}-stuff"); wfProfileIn("{$fname}-stuff2"); $tpl->set('title', $wgOut->getPageTitle()); $tpl->set('pagetitle', $wgOut->getHTMLTitle()); $tpl->setRef("thispage", $this->thispage); $subpagestr = $this->subPageSubtitle(); $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle()); $undelete = $this->getUndeleteLink(); $tpl->set("undelete", !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : ''); $tpl->set('catlinks', $this->getCategories()); if ($wgOut->isSyndicated()) { $feeds = array(); foreach ($wgFeedClasses as $format => $class) { $feeds[$format] = array('text' => $format, 'href' => $wgRequest->appendQuery("feed={$format}"), 'ttip' => wfMsg('tooltip-' . $format)); } $tpl->setRef('feeds', $feeds); } else { $tpl->set('feeds', false); } if ($wgUseTrackbacks && $out->isArticleRelated()) { $tpl->set('trackbackhtml', $wgTitle->trackbackRDF()); } $tpl->setRef('mimetype', $wgMimeType); $tpl->setRef('jsmimetype', $wgJsMimeType); $tpl->setRef('charset', $wgOutputEncoding); $tpl->set('headlinks', $out->getHeadLinks()); $tpl->setRef('headscripts', $out->getScript()); $tpl->setRef('wgScript', $wgScript); $tpl->setRef('skinname', $this->skinname); $tpl->setRef('stylename', $this->stylename); $tpl->set('printable', $wgRequest->getBool('printable')); $tpl->setRef('loggedin', $this->loggedin); $tpl->set('nsclass', 'ns-' . $this->mTitle->getNamespace()); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); $tpl->set( "exists", $this->mTitle->getArticleID() != 0 ); $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" ); $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" ); $tpl->set( "helppage", wfMsg('helppage')); */ $tpl->set('searchaction', $this->escapeSearchLink()); $tpl->set('search', trim($wgRequest->getVal('search'))); $tpl->setRef('stylepath', $wgStylePath); $tpl->setRef('logopath', $wgLogo); $tpl->setRef("lang", $wgContLanguageCode); $tpl->set('dir', $wgContLang->isRTL() ? "rtl" : "ltr"); $tpl->set('rtl', $wgContLang->isRTL()); $tpl->set('langname', $wgContLang->getLanguageName($wgContLanguageCode)); $tpl->setRef('username', $this->username); $tpl->setRef('userpage', $this->userpage); $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']); $tpl->setRef('usercss', $this->usercss); $tpl->setRef('userjs', $this->userjs); $tpl->setRef('userjsprev', $this->userjsprev); global $wgUseSiteJs; if ($wgUseSiteJs) { if ($this->loggedin) { $tpl->set('jsvarurl', $this->makeUrl('-', 'action=raw&smaxage=0&gen=js')); } else { $tpl->set('jsvarurl', $this->makeUrl('-', 'action=raw&gen=js')); } } else { $tpl->set('jsvarurl', false); } if ($wgUser->getNewtalk()) { global $wgShowNewtalkForUserOrUserTalkPage; if ($wgShowNewtalkForUserOrUserTalkPage) { $newmsg_usertalk = false; $newmsg_user = false; $usertitle = Title::newFromText($this->userpage); if ($wgUser->checkNotificationPendingForArticleOrTalk($usertitle, NS_USER_TALK, $lvr)) { $diff_oldid = $lvr != 0 ? "diff=0&oldid={$lvr}" : ''; $ns_usertalk = $wgContLang->getNsText(NS_USER_TALK); $newmsg_usertalklink = $this->makeKnownLink($ns_usertalk . ':' . $this->username, wfMsg('newmsg_usertalk')); $newmsg_usertalklvrlink = $this->makeKnownLink($ns_usertalk . ':' . $this->username, wfMsg('diff-to-lvr'), $diff_oldid, '', '', '', wfMsg('diff-to-lvr_tooltiptext')); $newmsg_usertalk = true; } if ($wgUser->checkNotificationPendingForArticleOrTalk($usertitle, NS_USER, $lvr)) { $diff_oldid = $lvr != 0 ? "diff=0&oldid={$lvr}" : ''; $ns_user = $wgContLang->getNsText(NS_USER); $newmsg_userlink = $this->makeKnownLink($ns_user . ':' . $this->username, wfMsg('newmsg_user')); $newmsg_userlvrlink = $this->makeKnownLink($ns_user . ':' . $this->username, wfMsg('diff-to-lvr'), $diff_oldid, '', '', '', wfMsg('diff-to-lvr_tooltiptext')); $newmsg_user = true; } switch (true) { case $newmsg_user && $newmsg_usertalk: $str = $newmsg_userlink . ' (' . $newmsg_userlvrlink . ') ' . wfMsg('newmsg_and') . ' ' . $newmsg_usertalklink . ' (' . $newmsg_usertalklvrlink . ')'; break; case !$newmsg_user && $newmsg_usertalk: $str = $newmsg_usertalklink . ' (' . $newmsg_usertalklvrlink . ')'; break; case $newmsg_user && !$newmsg_usertalk: $str = $newmsg_userlink . ' (' . $newmsg_userlvrlink . ')'; break; default: # this is the case for anon talk $str = $this->makeKnownLink($wgContLang->getNsText(NS_USER_TALK) . ':' . $this->username, wfMsg('newmsg_usertalk')); } $ntl = wfMsg('newmsg', $str); } else { /* OLD METHOD */ if ($wgUser->getNewtalk()) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); if (!$usertalktitle->equals($this->mTitle)) { $ntl = wfMsg('newmessages', $this->makeKnownLinkObj($usertalktitle, wfMsg('newmessageslink'))); # Disable Cache $wgOut->setSquidMaxage(0); } } else { $ntl = ''; } } } wfProfileOut("{$fname}-stuff2"); wfProfileIn("{$fname}-stuff3"); $tpl->setRef('newtalk', $ntl); $tpl->setRef('skin', $this); $tpl->set('logo', $this->logoText()); if ($wgOut->isArticle() and (!isset($oldid) or isset($diff)) and 0 != $wgArticle->getID()) { if (!$wgDisableCounters) { $viewcount = $wgLang->formatNum($wgArticle->getCount()); if ($viewcount) { $tpl->set('viewcount', wfMsg("viewcount", $viewcount)); } else { $tpl->set('viewcount', false); } } else { $tpl->set('viewcount', false); } if ($wgPageShowWatchingUsers) { $dbr =& wfGetDB(DB_SLAVE); extract($dbr->tableNames('watchlist')); $sql = "SELECT COUNT(*) AS n FROM {$watchlist}\n\t\t\t\t\tWHERE wl_title='" . $dbr->strencode($this->mTitle->getDBKey()) . "' AND wl_namespace=" . $this->mTitle->getNamespace(); $res = $dbr->query($sql, 'SkinPHPTal::outputPage'); $x = $dbr->fetchObject($res); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { $tpl->set('numberofwatchingusers', ' ' . wfMsg('number_of_watching_users_pageview', $numberofwatchingusers)); } else { $tpl->set('numberofwatchingusers', false); } } else { $tpl->set('numberofwatchingusers', false); } $tpl->set('copyright', $this->getCopyright()); $this->credits = false; if (isset($wgMaxCredits) && $wgMaxCredits != 0) { require_once "Credits.php"; $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $tpl->set('lastmod', $this->lastModified()); } $tpl->setRef('credits', $this->credits); } elseif (isset($oldid) && !isset($diff)) { $tpl->set('copyright', $this->getCopyright()); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } else { $tpl->set('copyright', false); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } wfProfileOut("{$fname}-stuff3"); wfProfileIn("{$fname}-stuff4"); $tpl->set('copyrightico', $this->getCopyrightIcon()); $tpl->set('poweredbyico', $this->getPoweredBy()); $tpl->set('disclaimer', $this->disclaimerLink()); $tpl->set('about', $this->aboutLink()); $tpl->setRef('debug', $out->mDebugtext); $tpl->set('reporttime', $out->reportTime()); $tpl->set('sitenotice', wfGetSiteNotice()); $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n"; $out->mBodytext .= $printfooter; $tpl->setRef('bodytext', $out->mBodytext); # Language links $language_urls = array(); if (!$wgHideInterlanguageLinks) { foreach ($wgOut->getLanguageLinks() as $l) { $tmp = explode(':', $l, 2); $class = 'interwiki-' . $tmp[0]; unset($tmp); $nt = Title::newFromText($l); $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'class' => $class); } } if (count($language_urls)) { $tpl->setRef('language_urls', $language_urls); } else { $tpl->set('language_urls', false); } wfProfileOut("{$fname}-stuff4"); # Personal toolbar $tpl->set('personal_urls', $this->buildPersonalUrls()); $content_actions = $this->buildContentActionUrls(); $tpl->setRef('content_actions', $content_actions); // XXX: attach this from javascript, same with section editing if ($this->iseditable && $wgUser->getOption("editondblclick")) { $tpl->set('body_ondblclick', 'document.location = "' . $content_actions['edit']['href'] . '";'); } else { $tpl->set('body_ondblclick', false); } if ($this->iseditable && $wgUser->getOption('editsectiononrightclick')) { $tpl->set('body_onload', 'setupRightClickEdit()'); } else { $tpl->set('body_onload', false); } $tpl->set('sidebar', $this->buildSidebar()); $tpl->set('nav_urls', $this->buildNavUrls()); // execute template wfProfileIn("{$fname}-execute"); $res = $tpl->execute(); wfProfileOut("{$fname}-execute"); // result may be an error $this->printOrError($res); wfProfileOut($fname); }
function sitenotice() { // Perhaps this could be given special dependencies using our knowledge of what // wfGetSiteNotice() depends on. return cbt_value(wfGetSiteNotice(), 'dynamic'); }
/** * initialize various variables and generate the template * * @param OutputPage $out * @public */ function outputPage(&$out) { global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut; global $wgScript, $wgStylePath, $wgContLanguageCode; global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest; global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; global $wgUseTrackbacks; global $wgDBname; $fname = 'SkinTemplate::outputPage'; wfProfileIn($fname); // Hook that allows last minute changes to the output page, e.g. // adding of CSS or Javascript by extensions. wfRunHooks('BeforePageDisplay', array(&$out)); extract($wgRequest->getValues('oldid', 'diff')); wfProfileIn("{$fname}-init"); $this->initPage($out); $this->mTitle =& $wgTitle; $this->mUser =& $wgUser; $tpl = $this->setupTemplate($this->template, 'skins'); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); #} wfProfileOut("{$fname}-init"); wfProfileIn("{$fname}-stuff"); $this->thispage = $this->mTitle->getPrefixedDbKey(); $this->thisurl = $this->mTitle->getPrefixedURL(); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL; $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); $userPage = $wgUser->getUserPage(); $this->userpage = $userPage->getPrefixedText(); if ($wgUser->isLoggedIn() || $this->showIPinHeader()) { $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage); } else { # This won't be used in the standard skins, but we define it to preserve the interface # To save time, we check for existence $this->userpageUrlDetails = $this->makeKnownUrlDetails($this->userpage); } $this->usercss = $this->userjs = $this->userjsprev = false; $this->setupUserCss(); $this->setupUserJs(); $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut("{$fname}-stuff"); wfProfileIn("{$fname}-stuff2"); $tpl->set('title', $wgOut->getPageTitle()); $tpl->set('pagetitle', $wgOut->getHTMLTitle()); $tpl->set('displaytitle', $wgOut->mPageLinkTitle); $tpl->setRef("thispage", $this->thispage); $subpagestr = $this->subPageSubtitle(); $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle()); $undelete = $this->getUndeleteLink(); $tpl->set("undelete", !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : ''); $tpl->set('catlinks', $this->getCategories()); if ($wgOut->isSyndicated()) { $feeds = array(); foreach ($wgFeedClasses as $format => $class) { $feeds[$format] = array('text' => $format, 'href' => $wgRequest->appendQuery("feed={$format}")); } $tpl->setRef('feeds', $feeds); } else { $tpl->set('feeds', false); } if ($wgUseTrackbacks && $out->isArticleRelated()) { $tpl->set('trackbackhtml', $wgTitle->trackbackRDF()); } $tpl->setRef('mimetype', $wgMimeType); $tpl->setRef('jsmimetype', $wgJsMimeType); $tpl->setRef('charset', $wgOutputEncoding); $tpl->set('headlinks', $out->getHeadLinks()); $tpl->set('headscripts', $out->getScript()); $tpl->setRef('wgScript', $wgScript); $tpl->setRef('skinname', $this->skinname); $tpl->setRef('stylename', $this->stylename); $tpl->set('printable', $wgRequest->getBool('printable')); $tpl->setRef('loggedin', $this->loggedin); $tpl->set('nsclass', 'ns-' . $this->mTitle->getNamespace()); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); $tpl->set( "exists", $this->mTitle->getArticleID() != 0 ); $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" ); $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" ); $tpl->set( "helppage", wfMsg('helppage')); */ $tpl->set('searchaction', $this->escapeSearchLink()); $tpl->set('search', trim($wgRequest->getVal('search'))); $tpl->setRef('stylepath', $wgStylePath); $tpl->setRef('logopath', $wgLogo); $tpl->setRef("lang", $wgContLanguageCode); $tpl->set('dir', $wgContLang->isRTL() ? "rtl" : "ltr"); $tpl->set('rtl', $wgContLang->isRTL()); $tpl->set('langname', $wgContLang->getLanguageName($wgContLanguageCode)); $tpl->set('showjumplinks', $wgUser->getOption('showjumplinks')); $tpl->setRef('username', $this->username); $tpl->setRef('userpage', $this->userpage); $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']); $tpl->set('pagecss', $this->setupPageCss()); $tpl->setRef('usercss', $this->usercss); $tpl->setRef('userjs', $this->userjs); $tpl->setRef('userjsprev', $this->userjsprev); global $wgUseSiteJs; if ($wgUseSiteJs) { if ($this->loggedin) { $tpl->set('jsvarurl', $this->makeUrl('-', 'action=raw&smaxage=0&gen=js')); } else { $tpl->set('jsvarurl', $this->makeUrl('-', 'action=raw&gen=js')); } } else { $tpl->set('jsvarurl', false); } $newtalks = $wgUser->getNewMessageLinks(); if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); if (!$usertalktitle->equals($this->mTitle)) { $ntl = wfMsg('youhavenewmessages', $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessageslink'), 'redirect=no'), $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessagesdifflink'), 'diff=cur')); # Disable Cache $wgOut->setSquidMaxage(0); } } else { if (count($newtalks)) { $sep = str_replace("_", " ", wfMsgHtml("newtalkseperator")); $msgs = array(); foreach ($newtalks as $newtalk) { $msgs[] = wfElement("a", array('href' => $newtalk["link"]), $newtalk["wiki"]); } $parts = implode($sep, $msgs); $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts); $wgOut->setSquidMaxage(0); } else { $ntl = ''; } } wfProfileOut("{$fname}-stuff2"); wfProfileIn("{$fname}-stuff3"); $tpl->setRef('newtalk', $ntl); $tpl->setRef('skin', $this); $tpl->set('logo', $this->logoText()); if ($wgOut->isArticle() and (!isset($oldid) or isset($diff)) and 0 != $wgArticle->getID()) { if (!$wgDisableCounters) { $viewcount = $wgLang->formatNum($wgArticle->getCount()); if ($viewcount) { $tpl->set('viewcount', wfMsgExt('viewcount', array('parseinline'), $viewcount)); } else { $tpl->set('viewcount', false); } } else { $tpl->set('viewcount', false); } if ($wgPageShowWatchingUsers) { $dbr =& wfGetDB(DB_SLAVE); extract($dbr->tableNames('watchlist')); $sql = "SELECT COUNT(*) AS n FROM {$watchlist}\n\t\t\t\t\tWHERE wl_title='" . $dbr->strencode($this->mTitle->getDBKey()) . "' AND wl_namespace=" . $this->mTitle->getNamespace(); $res = $dbr->query($sql, 'SkinTemplate::outputPage'); $x = $dbr->fetchObject($res); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { $tpl->set('numberofwatchingusers', wfMsg('number_of_watching_users_pageview', $numberofwatchingusers)); } else { $tpl->set('numberofwatchingusers', false); } } else { $tpl->set('numberofwatchingusers', false); } $tpl->set('copyright', $this->getCopyright()); $this->credits = false; if (isset($wgMaxCredits) && $wgMaxCredits != 0) { require_once "Credits.php"; $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $tpl->set('lastmod', $this->lastModified()); } $tpl->setRef('credits', $this->credits); } elseif (isset($oldid) && !isset($diff)) { $tpl->set('copyright', $this->getCopyright()); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } else { $tpl->set('copyright', false); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } wfProfileOut("{$fname}-stuff3"); wfProfileIn("{$fname}-stuff4"); $tpl->set('copyrightico', $this->getCopyrightIcon()); $tpl->set('poweredbyico', $this->getPoweredBy()); $tpl->set('disclaimer', $this->disclaimerLink()); $tpl->set('privacy', $this->privacyLink()); $tpl->set('about', $this->aboutLink()); $tpl->setRef('debug', $out->mDebugtext); $tpl->set('reporttime', $out->reportTime()); $tpl->set('sitenotice', wfGetSiteNotice()); $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n"; $out->mBodytext .= $printfooter; $tpl->setRef('bodytext', $out->mBodytext); # Language links $language_urls = array(); if (!$wgHideInterlanguageLinks) { foreach ($wgOut->getLanguageLinks() as $l) { $tmp = explode(':', $l, 2); $class = 'interwiki-' . $tmp[0]; unset($tmp); $nt = Title::newFromText($l); $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'class' => $class); } } if (count($language_urls)) { $tpl->setRef('language_urls', $language_urls); } else { $tpl->set('language_urls', false); } wfProfileOut("{$fname}-stuff4"); // WERELATE - added trees $tpl->setRef('trees', $this->getTrees()); # Personal toolbar $tpl->set('personal_urls', $this->buildPersonalUrls()); $content_actions = $this->buildContentActionUrls(); $tpl->setRef('content_actions', $content_actions); // XXX: attach this from javascript, same with section editing if ($this->iseditable && $wgUser->getOption("editondblclick")) { $tpl->set('body_ondblclick', 'document.location = "' . $content_actions['edit']['href'] . '";'); } else { $tpl->set('body_ondblclick', false); } if ($this->iseditable && $wgUser->getOption('editsectiononrightclick')) { $tpl->set('body_onload', 'setupRightClickEdit()'); } else { $tpl->set('body_onload', false); } $tpl->set('sidebar', $this->buildSidebar()); $tpl->set('nav_urls', $this->buildNavUrls()); // execute template wfProfileIn("{$fname}-execute"); $res = $tpl->execute(); wfProfileOut("{$fname}-execute"); // result may be an error $this->printOrError($res); wfProfileOut($fname); }
/** * initialize various variables and generate the template * * @param $out OutputPage */ function outputPage(OutputPage $out) { global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang; global $wgScript, $wgStylePath, $wgContLanguageCode; global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces; global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; global $wgUseTrackbacks, $wgUseSiteJs; global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames; wfProfileIn(__METHOD__); $oldid = $wgRequest->getVal('oldid'); $diff = $wgRequest->getVal('diff'); wfProfileIn(__METHOD__ . "-init"); $this->initPage($out); $this->setMembers(); $tpl = $this->setupTemplate($this->template, 'skins'); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); #} wfProfileOut(__METHOD__ . "-init"); wfProfileIn(__METHOD__ . "-stuff"); $this->thispage = $this->mTitle->getPrefixedDbKey(); $this->thisurl = $this->mTitle->getPrefixedURL(); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL; $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); if ($wgUser->isLoggedIn() || $this->showIPinHeader()) { $this->userpageUrlDetails = self::makeUrlDetails($this->userpage); } else { # This won't be used in the standard skins, but we define it to preserve the interface # To save time, we check for existence $this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage); } $this->userjs = $this->userjsprev = false; $this->setupUserCss($out); $this->setupUserJs($out->isUserJsAllowed()); $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut(__METHOD__ . "-stuff"); wfProfileIn(__METHOD__ . "-stuff2"); $tpl->set('title', $out->getPageTitle()); $tpl->set('pagetitle', $out->getHTMLTitle()); $tpl->set('displaytitle', $out->mPageLinkTitle); $tpl->set('pageclass', $this->getPageClasses($this->mTitle)); $tpl->set('skinnameclass', "skin-" . Sanitizer::escapeClass($this->getSkinName())); $nsname = isset($wgCanonicalNamespaceNames[$this->mTitle->getNamespace()]) ? $wgCanonicalNamespaceNames[$this->mTitle->getNamespace()] : $this->mTitle->getNsText(); $tpl->set('nscanonical', $nsname); $tpl->set('nsnumber', $this->mTitle->getNamespace()); $tpl->set('titleprefixeddbkey', $this->mTitle->getPrefixedDBKey()); $tpl->set('titletext', $this->mTitle->getText()); $tpl->set('articleid', $this->mTitle->getArticleId()); $tpl->set('currevisionid', isset($wgArticle) ? $wgArticle->getLatest() : 0); $tpl->set('isarticle', $out->isArticle()); $tpl->setRef("thispage", $this->thispage); $subpagestr = $this->subPageSubtitle(); $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle()); $undelete = $this->getUndeleteLink(); $tpl->set("undelete", !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : ''); $tpl->set('catlinks', $this->getCategories()); if ($out->isSyndicated()) { $feeds = array(); foreach ($out->getSyndicationLinks() as $format => $link) { $feeds[$format] = array('text' => wfMsg("feed-{$format}"), 'href' => $link); } $tpl->setRef('feeds', $feeds); } else { $tpl->set('feeds', false); } if ($wgUseTrackbacks && $out->isArticleRelated()) { $tpl->set('trackbackhtml', $wgTitle->trackbackRDF()); } else { $tpl->set('trackbackhtml', null); } $tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace); $tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces); $tpl->setRef('mimetype', $wgMimeType); $tpl->setRef('jsmimetype', $wgJsMimeType); $tpl->setRef('charset', $wgOutputEncoding); $tpl->set('headlinks', $out->getHeadLinks()); $tpl->set('headscripts', $out->getScript()); $tpl->set('csslinks', $out->buildCssLinks()); $tpl->setRef('wgScript', $wgScript); $tpl->setRef('skinname', $this->skinname); $tpl->set('skinclass', get_class($this)); $tpl->setRef('stylename', $this->stylename); $tpl->set('printable', $wgRequest->getBool('printable')); $tpl->set('handheld', $wgRequest->getBool('handheld')); $tpl->setRef('loggedin', $this->loggedin); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); $tpl->set( "exists", $this->mTitle->getArticleID() != 0 ); $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" ); $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" ); $tpl->set( "helppage", wfMsg('helppage')); */ $tpl->set('searchaction', $this->escapeSearchLink()); $tpl->set('search', trim($wgRequest->getVal('search'))); $tpl->setRef('stylepath', $wgStylePath); $tpl->setRef('articlepath', $wgArticlePath); $tpl->setRef('scriptpath', $wgScriptPath); $tpl->setRef('serverurl', $wgServer); $tpl->setRef('logopath', $wgLogo); $tpl->setRef("lang", $wgContLanguageCode); $tpl->set('dir', $wgContLang->isRTL() ? "rtl" : "ltr"); $tpl->set('rtl', $wgContLang->isRTL()); $tpl->set('langname', $wgContLang->getLanguageName($wgContLanguageCode)); $tpl->set('showjumplinks', $wgUser->getOption('showjumplinks')); $tpl->set('username', $wgUser->isAnon() ? NULL : $this->username); $tpl->setRef('userpage', $this->userpage); $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']); $tpl->set('userlang', $wgLang->getCode()); $tpl->set('pagecss', $this->setupPageCss()); $tpl->setRef('usercss', $this->usercss); $tpl->setRef('userjs', $this->userjs); $tpl->setRef('userjsprev', $this->userjsprev); if ($wgUseSiteJs) { $jsCache = $this->loggedin ? '&smaxage=0' : ''; $tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName()))); } else { $tpl->set('jsvarurl', false); } $newtalks = $wgUser->getNewMessageLinks(); if (count($newtalks) == 1 && $newtalks[0]["wiki"] === wfWikiID()) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); if (!$usertalktitle->equals($this->mTitle)) { $ntl = wfMsg('youhavenewmessages', $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessageslink'), 'redirect=no'), $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessagesdifflink'), 'diff=cur')); # Disable Cache $out->setSquidMaxage(0); } } else { if (count($newtalks)) { $sep = str_replace("_", " ", wfMsgHtml("newtalkseparator")); $msgs = array(); foreach ($newtalks as $newtalk) { $msgs[] = Xml::element("a", array('href' => $newtalk["link"]), $newtalk["wiki"]); } $parts = implode($sep, $msgs); $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts); $out->setSquidMaxage(0); } else { $ntl = ''; } } wfProfileOut(__METHOD__ . "-stuff2"); wfProfileIn(__METHOD__ . "-stuff3"); $tpl->setRef('newtalk', $ntl); $tpl->setRef('skin', $this); $tpl->set('logo', $this->logoText()); if ($out->isArticle() and (!isset($oldid) or isset($diff)) and $wgArticle and 0 != $wgArticle->getID()) { if (!$wgDisableCounters) { $viewcount = $wgLang->formatNum($wgArticle->getCount()); if ($viewcount) { $tpl->set('viewcount', wfMsgExt('viewcount', array('parseinline'), $viewcount)); } else { $tpl->set('viewcount', false); } } else { $tpl->set('viewcount', false); } if ($wgPageShowWatchingUsers) { $dbr = wfGetDB(DB_SLAVE); $watchlist = $dbr->tableName('watchlist'); $sql = "SELECT COUNT(*) AS n FROM {$watchlist}\n\t\t\t\t\tWHERE wl_title='" . $dbr->strencode($this->mTitle->getDBkey()) . "' AND wl_namespace=" . $this->mTitle->getNamespace(); $res = $dbr->query($sql, 'SkinTemplate::outputPage'); $x = $dbr->fetchObject($res); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { $tpl->set('numberofwatchingusers', wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($numberofwatchingusers))); } else { $tpl->set('numberofwatchingusers', false); } } else { $tpl->set('numberofwatchingusers', false); } $tpl->set('copyright', $this->getCopyright()); $this->credits = false; if ($wgMaxCredits != 0) { $this->credits = Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $tpl->set('lastmod', $this->lastModified()); } $tpl->setRef('credits', $this->credits); } elseif (isset($oldid) && !isset($diff)) { $tpl->set('copyright', $this->getCopyright()); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } else { $tpl->set('copyright', false); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } wfProfileOut(__METHOD__ . "-stuff3"); wfProfileIn(__METHOD__ . "-stuff4"); $tpl->set('copyrightico', $this->getCopyrightIcon()); $tpl->set('poweredbyico', $this->getPoweredBy()); $tpl->set('disclaimer', $this->disclaimerLink()); $tpl->set('privacy', $this->privacyLink()); $tpl->set('about', $this->aboutLink()); $tpl->setRef('debug', $out->mDebugtext); $tpl->set('reporttime', wfReportTime()); $tpl->set('sitenotice', wfGetSiteNotice()); $tpl->set('bottomscripts', $this->bottomScripts()); $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n"; $out->mBodytext .= $printfooter; $tpl->setRef('bodytext', $out->mBodytext); # Language links $language_urls = array(); if (!$wgHideInterlanguageLinks) { foreach ($out->getLanguageLinks() as $l) { $tmp = explode(':', $l, 2); $class = 'interwiki-' . $tmp[0]; unset($tmp); $nt = Title::newFromText($l); if ($nt) { $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'class' => $class); } } } if (count($language_urls)) { $tpl->setRef('language_urls', $language_urls); } else { $tpl->set('language_urls', false); } wfProfileOut(__METHOD__ . "-stuff4"); wfProfileIn(__METHOD__ . "-stuff5"); # Personal toolbar $tpl->set('personal_urls', $this->buildPersonalUrls()); $content_actions = $this->buildContentActionUrls(); $tpl->setRef('content_actions', $content_actions); // XXX: attach this from javascript, same with section editing if ($this->iseditable && $wgUser->getOption("editondblclick")) { $encEditUrl = Xml::escapeJsString($this->mTitle->getLocalUrl($this->editUrlOptions())); $tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";'); } else { $tpl->set('body_ondblclick', false); } $tpl->set('body_onload', false); $tpl->set('sidebar', $this->buildSidebar()); $tpl->set('nav_urls', $this->buildNavUrls()); // original version by hansm if (!wfRunHooks('SkinTemplateOutputPageBeforeExec', array(&$this, &$tpl))) { wfDebug(__METHOD__ . ': Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!'); } // allow extensions adding stuff after the page content. // See Skin::afterContentHook() for further documentation. $tpl->set('dataAfterContent', $this->afterContentHook()); wfProfileOut(__METHOD__ . "-stuff5"); // execute template wfProfileIn(__METHOD__ . "-execute"); $res = $tpl->execute(); wfProfileOut(__METHOD__ . "-execute"); // result may be an error $this->printOrError($res); wfProfileOut(__METHOD__); }
/** * Standard fail function, called by default when a connection cannot be * established. * Displays the file cache if possible */ function wfEmergencyAbort(&$conn, $error) { global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgOutputEncoding; global $wgSitename, $wgServer, $wgMessageCache, $wgLogo; # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky. # Hard coding strings instead. $noconnect = "<h1><img src='{$wgLogo}' style='float:left;margin-right:1em' alt=''>{$wgSitename} has a problem</h1><p><strong>Sorry! This site is experiencing technical difficulties.</strong></p><p>Try waiting a few minutes and reloading.</p><p><small>(Can't contact the database server: \$1)</small></p>"; $mainpage = 'Main Page'; $searchdisabled = <<<EOT <p style="margin: 1.5em 2em 1em">{$wgSitename} search is disabled for performance reasons. You can search via Google in the meantime. <span style="font-size: 89%; display: block; margin-left: .2em">Note that their indexes of {$wgSitename} content may be out of date.</span></p>', EOT; $googlesearch = "\n<!-- SiteSearch Google -->\n<FORM method=GET action=\"http://www.google.com/search\">\n<TABLE bgcolor=\"#FFFFFF\"><tr><td>\n<A HREF=\"http://www.google.com/\">\n<IMG SRC=\"http://www.google.com/logos/Logo_40wht.gif\"\nborder=\"0\" ALT=\"Google\"></A>\n</td>\n<td>\n<INPUT TYPE=text name=q size=31 maxlength=255 value=\"\$1\">\n<INPUT type=submit name=btnG VALUE=\"Google Search\">\n<font size=-1>\n<input type=hidden name=domains value=\"{$wgServer}\"><br /><input type=radio name=sitesearch value=\"\"> WWW <input type=radio name=sitesearch value=\"{$wgServer}\" checked> {$wgServer} <br />\n<input type='hidden' name='ie' value='\$2'>\n<input type='hidden' name='oe' value='\$2'>\n</font>\n</td></tr></TABLE>\n</FORM>\n<!-- SiteSearch Google -->"; $cachederror = "The following is a cached copy of the requested page, and may not be up to date. "; if (!headers_sent()) { header('HTTP/1.0 500 Internal Server Error'); header('Content-type: text/html; charset=' . $wgOutputEncoding); /* Don't cache error pages! They cause no end of trouble... */ header('Cache-control: none'); header('Pragma: nocache'); } # No database access if (is_object($wgMessageCache)) { $wgMessageCache->disable(); } $msg = wfGetSiteNotice(); if ($msg == '') { $msg = str_replace('$1', htmlspecialchars($error), $noconnect); } $text = $msg; if ($wgUseFileCache) { if ($wgTitle) { $t =& $wgTitle; } else { if ($title) { $t = Title::newFromURL($title); } elseif (@$_REQUEST['search']) { $search = $_REQUEST['search']; echo $searchdisabled; echo str_replace(array('$1', '$2'), array(htmlspecialchars($search), $wgInputEncoding), $googlesearch); wfErrorExit(); } else { $t = Title::newFromText($mainpage); } } $cache = new CacheManager($t); if ($cache->isFileCached()) { $msg = '<p style="color: red"><b>' . $msg . "<br />\n" . $cachederror . "</b></p>\n"; $tag = '<div id="article">'; $text = str_replace($tag, $tag . $msg, $cache->fetchPageText()); } } echo $text; wfErrorExit(); }
/** * initialize various variables and generate the template * * @param $out OutputPage */ function outputPage(OutputPage $out) { global $wgArticle, $wgUser, $wgLang, $wgContLang; global $wgScript, $wgStylePath, $wgContLanguageCode; global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version; global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments; global $wgArticlePath, $wgScriptPath, $wgServer; wfProfileIn(__METHOD__); $oldid = $wgRequest->getVal('oldid'); $diff = $wgRequest->getVal('diff'); $action = $wgRequest->getVal('action', 'view'); wfProfileIn(__METHOD__ . '-init'); $this->initPage($out); $this->setMembers(); $tpl = $this->setupTemplate($this->template, 'skins'); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); #} wfProfileOut(__METHOD__ . '-init'); wfProfileIn(__METHOD__ . '-stuff'); $this->thispage = $this->mTitle->getPrefixedDBkey(); $this->thisurl = $this->mTitle->getPrefixedURL(); $query = array(); if (!$wgRequest->wasPosted()) { $query = $wgRequest->getValues(); unset($query['title']); unset($query['returnto']); unset($query['returntoquery']); } $this->thisquery = wfUrlencode(wfArrayToCGI($query)); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL; $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); if ($wgUser->isLoggedIn() || $this->showIPinHeader()) { $this->userpageUrlDetails = self::makeUrlDetails($this->userpage); } else { # This won't be used in the standard skins, but we define it to preserve the interface # To save time, we check for existence $this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage); } $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut(__METHOD__ . '-stuff'); wfProfileIn(__METHOD__ . '-stuff-head'); if ($this->useHeadElement) { $pagecss = $this->setupPageCss(); if ($pagecss) { $out->addInlineStyle($pagecss); } } else { $this->setupUserCss($out); $tpl->set('pagecss', $this->setupPageCss()); $tpl->setRef('usercss', $this->usercss); $this->userjs = $this->userjsprev = false; $this->setupUserJs($out->isUserJsAllowed()); $tpl->setRef('userjs', $this->userjs); $tpl->setRef('userjsprev', $this->userjsprev); if ($wgUseSiteJs) { $jsCache = $this->loggedin ? '&smaxage=0' : ''; $tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName()))); } else { $tpl->set('jsvarurl', false); } $tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace); $tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces); $tpl->set('html5version', $wgHtml5Version); $tpl->set('headlinks', $out->getHeadLinks()); $tpl->set('csslinks', $out->buildCssLinks()); if ($wgUseTrackbacks && $out->isArticleRelated()) { $tpl->set('trackbackhtml', $out->getTitle()->trackbackRDF()); } else { $tpl->set('trackbackhtml', null); } } wfProfileOut(__METHOD__ . '-stuff-head'); wfProfileIn(__METHOD__ . '-stuff2'); $tpl->set('title', $out->getPageTitle()); $tpl->set('pagetitle', $out->getHTMLTitle()); $tpl->set('displaytitle', $out->mPageLinkTitle); $tpl->set('pageclass', $this->getPageClasses($this->mTitle)); $tpl->set('skinnameclass', 'skin-' . Sanitizer::escapeClass($this->getSkinName())); $nsname = MWNamespace::exists($this->mTitle->getNamespace()) ? MWNamespace::getCanonicalName($this->mTitle->getNamespace()) : $this->mTitle->getNsText(); $tpl->set('nscanonical', $nsname); $tpl->set('nsnumber', $this->mTitle->getNamespace()); $tpl->set('titleprefixeddbkey', $this->mTitle->getPrefixedDBKey()); $tpl->set('titletext', $this->mTitle->getText()); $tpl->set('articleid', $this->mTitle->getArticleId()); $tpl->set('currevisionid', isset($wgArticle) ? $wgArticle->getLatest() : 0); $tpl->set('isarticle', $out->isArticle()); $tpl->setRef('thispage', $this->thispage); $subpagestr = $this->subPageSubtitle(); $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle()); $undelete = $this->getUndeleteLink(); $tpl->set('undelete', !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : ''); $tpl->set('catlinks', $this->getCategories()); if ($out->isSyndicated()) { $feeds = array(); foreach ($out->getSyndicationLinks() as $format => $link) { $feeds[$format] = array('text' => wfMsg("feed-{$format}"), 'href' => $link); } $tpl->setRef('feeds', $feeds); } else { $tpl->set('feeds', false); } $tpl->setRef('mimetype', $wgMimeType); $tpl->setRef('jsmimetype', $wgJsMimeType); $tpl->setRef('charset', $wgOutputEncoding); $tpl->setRef('wgScript', $wgScript); $tpl->setRef('skinname', $this->skinname); $tpl->set('skinclass', get_class($this)); $tpl->setRef('stylename', $this->stylename); $tpl->set('printable', $out->isPrintable()); $tpl->set('handheld', $wgRequest->getBool('handheld')); $tpl->setRef('loggedin', $this->loggedin); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); $tpl->set( "exists", $this->mTitle->getArticleID() != 0 ); $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" ); $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" ); $tpl->set( "helppage", wfMsg('helppage')); */ $tpl->set('searchaction', $this->escapeSearchLink()); $tpl->set('searchtitle', SpecialPage::getTitleFor('Search')->getPrefixedDBKey()); $tpl->set('search', trim($wgRequest->getVal('search'))); $tpl->setRef('stylepath', $wgStylePath); $tpl->setRef('articlepath', $wgArticlePath); $tpl->setRef('scriptpath', $wgScriptPath); $tpl->setRef('serverurl', $wgServer); $tpl->setRef('logopath', $wgLogo); $tpl->setRef('lang', $wgContLanguageCode); $tpl->set('dir', $wgContLang->getDir()); $tpl->set('rtl', $wgContLang->isRTL()); $tpl->set('capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : ''); $tpl->set('langname', $wgContLang->getLanguageName($wgContLanguageCode)); $tpl->set('showjumplinks', $wgUser->getOption('showjumplinks')); $tpl->set('username', $wgUser->isAnon() ? null : $this->username); $tpl->setRef('userpage', $this->userpage); $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']); $tpl->set('userlang', $wgLang->getCode()); // Users can have their language set differently than the // content of the wiki. For these users, tell the web browser // that interface elements are in a different language. $tpl->set('userlangattributes', ''); $tpl->set('specialpageattributes', ''); $lang = $wgLang->getCode(); $dir = $wgLang->getDir(); if ($lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir()) { $attrs = " lang='{$lang}' dir='{$dir}'"; $tpl->set('userlangattributes', $attrs); // The content of SpecialPages should be presented in the // user's language. Content of regular pages should not be touched. if ($this->mTitle->isSpecialPage()) { $tpl->set('specialpageattributes', $attrs); } } $newtalks = $wgUser->getNewMessageLinks(); $ntl = ''; if (count($newtalks) == 1 && $newtalks[0]['wiki'] === wfWikiID()) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); if (!$usertalktitle->equals($this->mTitle)) { $newmessageslink = $this->link($usertalktitle, wfMsgHtml('newmessageslink'), array(), array('redirect' => 'no'), array('known', 'noclasses')); $newmessagesdifflink = $this->link($usertalktitle, wfMsgHtml('newmessagesdifflink'), array(), array('diff' => 'cur'), array('known', 'noclasses')); $ntl = wfMsg('youhavenewmessages', $newmessageslink, $newmessagesdifflink); # Disable Cache $out->setSquidMaxage(0); } } else { if (count($newtalks)) { // _>" " for BC <= 1.16 $sep = str_replace('_', ' ', wfMsgHtml('newtalkseparator')); $msgs = array(); foreach ($newtalks as $newtalk) { $msgs[] = Xml::element('a', array('href' => $newtalk['link']), $newtalk['wiki']); } $parts = implode($sep, $msgs); $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts); $out->setSquidMaxage(0); } } wfProfileOut(__METHOD__ . '-stuff2'); wfProfileIn(__METHOD__ . '-stuff3'); $tpl->setRef('newtalk', $ntl); $tpl->setRef('skin', $this); $tpl->set('logo', $this->logoText()); if ($out->isArticle() and (!isset($oldid) or isset($diff)) and $wgArticle and 0 != $wgArticle->getID()) { if (!$wgDisableCounters) { $viewcount = $wgLang->formatNum($wgArticle->getCount()); if ($viewcount) { $tpl->set('viewcount', wfMsgExt('viewcount', array('parseinline'), $viewcount)); } else { $tpl->set('viewcount', false); } } else { $tpl->set('viewcount', false); } if ($wgPageShowWatchingUsers) { $dbr = wfGetDB(DB_SLAVE); $watchlist = $dbr->tableName('watchlist'); $res = $dbr->select('watchlist', array('COUNT(*) AS n'), array('wl_title' => $dbr->strencode($this->mTitle->getDBkey()), 'wl_namespace' => $this->mTitle->getNamespace()), __METHOD__); $x = $dbr->fetchObject($res); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { $tpl->set('numberofwatchingusers', wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($numberofwatchingusers))); } else { $tpl->set('numberofwatchingusers', false); } } else { $tpl->set('numberofwatchingusers', false); } $tpl->set('copyright', $this->getCopyright()); $this->credits = false; if ($wgMaxCredits != 0) { $this->credits = Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $tpl->set('lastmod', $this->lastModified()); } $tpl->setRef('credits', $this->credits); } elseif (isset($oldid) && !isset($diff)) { $tpl->set('copyright', $this->getCopyright()); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } else { $tpl->set('copyright', false); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } wfProfileOut(__METHOD__ . '-stuff3'); wfProfileIn(__METHOD__ . '-stuff4'); $tpl->set('copyrightico', $this->getCopyrightIcon()); $tpl->set('poweredbyico', $this->getPoweredBy()); $tpl->set('disclaimer', $this->disclaimerLink()); $tpl->set('privacy', $this->privacyLink()); $tpl->set('about', $this->aboutLink()); if ($wgDebugComments) { $tpl->setRef('debug', $out->mDebugtext); } else { $tpl->set('debug', ''); } $tpl->set('reporttime', wfReportTime()); $tpl->set('sitenotice', wfGetSiteNotice()); $tpl->set('bottomscripts', $this->bottomScripts()); $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n"; $out->mBodytext .= $printfooter . $this->generateDebugHTML(); $tpl->setRef('bodytext', $out->mBodytext); # Language links $language_urls = array(); if (!$wgHideInterlanguageLinks) { foreach ($out->getLanguageLinks() as $l) { $tmp = explode(':', $l, 2); $class = 'interwiki-' . $tmp[0]; unset($tmp); $nt = Title::newFromText($l); if ($nt) { $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'class' => $class); } } } if (count($language_urls)) { $tpl->setRef('language_urls', $language_urls); } else { $tpl->set('language_urls', false); } wfProfileOut(__METHOD__ . '-stuff4'); wfProfileIn(__METHOD__ . '-stuff5'); # Personal toolbar $tpl->set('personal_urls', $this->buildPersonalUrls()); $content_actions = $this->buildContentActionUrls(); $tpl->setRef('content_actions', $content_actions); $tpl->set('sidebar', $this->buildSidebar()); $tpl->set('nav_urls', $this->buildNavUrls()); // Set the head scripts near the end, in case the above actions resulted in added scripts if ($this->useHeadElement) { $tpl->set('headelement', $out->headElement($this)); } else { $tpl->set('headscripts', $out->getScript()); } // original version by hansm if (!wfRunHooks('SkinTemplateOutputPageBeforeExec', array(&$this, &$tpl))) { wfDebug(__METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n"); } // allow extensions adding stuff after the page content. // See Skin::afterContentHook() for further documentation. $tpl->set('dataAfterContent', $this->afterContentHook()); wfProfileOut(__METHOD__ . '-stuff5'); // execute template wfProfileIn(__METHOD__ . '-execute'); $res = $tpl->execute(); wfProfileOut(__METHOD__ . '-execute'); // result may be an error $this->printOrError($res); wfProfileOut(__METHOD__); }