function getHTML() { global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding; global $wgSitename, $wgServer, $wgMessageCache; # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky. # Hard coding strings instead. $noconnect = '<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins/WikiHow/main.css"; /*]]>*/</style>' . "<p style='padding-left:80px;'><strong>Sorry! This site is under going routine maintenance. </strong><br/>\n\t\t\t\t<br/><br/>\n\t\t\tThe maintenance will problem will likely be completed shortly, try waiting a few minutes and refreshing the page. <br/><br/>\n\t\t\t<b>Thanks for your patience.</b><br/><br/>\n\t\t\tIn the meantime, you can try accessing <a href='http://72.14.209.104/search?q=cache:" . $_SERVER['SCRIPT_URI'] . "'>Google's cached copy of this page</a>.\n\t\t\t<!-- (Can't contact the database server: \$1) -->\n\t\t\t</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 HTMLFileCache($t); if ($cache->isFileCached()) { // @todo, FIXME: $msg is not defined on the next line. $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; }
function getHTML() { global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding; global $wgSitename, $wgServer, $wgMessageCache; # 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 HTMLFileCache($t); if ($cache->isFileCached()) { // @todo, FIXME: $msg is not defined on the next line. $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; }
function fileCachedPage() { global $wgTitle, $wgLang, $wgOut; if ($wgOut->isDisabled()) { return; // Done already? } $mainpage = 'Main Page'; if ($wgLang instanceof Language) { $mainpage = htmlspecialchars($wgLang->getMessage('mainpage')); } if ($wgTitle) { $t =& $wgTitle; } else { $t = Title::newFromText($mainpage); } $cache = new HTMLFileCache($t); if ($cache->isFileCached()) { return $cache->fetchPageText(); } else { return ''; } }
/** * @return string */ private function fileCachedPage() { global $wgTitle, $wgOut; if ($wgOut->isDisabled()) { return; // Done already? } if ($wgTitle) { $t =& $wgTitle; } else { $t = Title::newFromText($this->msg('mainpage', 'Main Page')); } $cache = new HTMLFileCache($t); if ($cache->isFileCached()) { return $cache->fetchPageText(); } else { return ''; } }