本文整理汇总了PHP中HTMLFileCache类的典型用法代码示例。如果您正苦于以下问题:PHP HTMLFileCache类的具体用法?PHP HTMLFileCache怎么用?PHP HTMLFileCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTMLFileCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purge
/**
* Purge the cache for backlinking pages (that is, pages containing
* a reference to the Title associated with this task)
*
* @param string|array $tables
*/
public function purge($tables)
{
global $wgUseFileCache, $wgUseSquid;
$affectedTitles = $this->getAffectedTitles((array) $tables);
$affectedCount = count($affectedTitles);
$this->info("Purge Request", ['title' => $this->title->getPrefixedText(), 'count' => $affectedCount, 'tables' => $tables]);
// abort if no pages link to the associated Title
if ($affectedCount == 0) {
return 0;
}
$dbw = wfGetDB(DB_MASTER);
(new \WikiaSQL())->UPDATE('page')->SET('page_touched', $dbw->timestamp())->WHERE('page_id')->IN(array_map(function ($t) {
return $t->getArticleID();
}, $affectedTitles))->run($dbw);
// Update squid/varnish
if ($wgUseSquid) {
\SquidUpdate::newFromTitles($affectedTitles)->doUpdate();
}
// Update file cache
if ($wgUseFileCache) {
foreach ($affectedTitles as $title) {
\HTMLFileCache::clearFileCache($title);
}
}
return $affectedCount;
}
示例2: purge
/**
* Purge the cache for pages containing gallery tags
*/
public function purge()
{
global $wgUseFileCache, $wgUseSquid;
$totalGalleryPageCount = 0;
// Keeps track of actual existing titles with gallery
$dbGalleryCount = $this->getGalleryPageCount();
// All counts including those with missing titles
// Paginate the operation to prevent db/memory overload
for ($limitCount = 0; $limitCount < $dbGalleryCount; $limitCount += self::PAGE_COUNT_LIMIT) {
$galleryPageIds = $this->getGalleryPageIds($limitCount);
$galleryPageTitles = \Title::newFromIDs($galleryPageIds);
$galleryPageCount = count($galleryPageTitles);
// abort if no pages were found
if ($galleryPageCount == 0) {
continue;
}
// Update squid/varnish/parser cache
if ($wgUseSquid) {
foreach ($galleryPageTitles as $title) {
$title->purgeSquid();
}
}
// Update file cache if used
if ($wgUseFileCache) {
foreach ($galleryPageTitles as $title) {
\HTMLFileCache::clearFileCache($title);
}
}
$totalGalleryPageCount += $galleryPageCount;
}
$this->info('Gallery page purge request', ['title' => __METHOD__, 'count' => $totalGalleryPageCount]);
return $totalGalleryPageCount;
}
示例3: doPurgeHtmlCache
/**
* @since 2.1
*/
public function doPurgeHtmlCache()
{
foreach ($this->titles as $title) {
$title->touchLinks();
// @see MW 1.19 Title::invalidateCache
\HTMLFileCache::clearFileCache($title);
}
}
示例4: invalidateTitles
/**
* Invalidate an array (or iterator) of Title objects, right now
* @param $titleArray array
*/
protected function invalidateTitles($titleArray)
{
global $wgUseFileCache, $wgUseSquid;
$dbw = wfGetDB(DB_MASTER);
$timestamp = $dbw->timestamp();
# Get all IDs in this query into an array
$ids = array();
foreach ($titleArray as $title) {
$ids[] = $title->getArticleID();
}
if (!$ids) {
return;
}
# Update page_touched
$batches = array_chunk($ids, $this->mRowsPerQuery);
foreach ($batches as $batch) {
$dbw->update('page', array('page_touched' => $timestamp), array('page_id' => $batch), __METHOD__);
}
# Update squid
if ($wgUseSquid) {
$u = SquidUpdate::newFromTitles($titleArray);
$u->doUpdate();
}
# Update file cache
if ($wgUseFileCache) {
foreach ($titleArray as $title) {
HTMLFileCache::clearFileCache($title);
}
}
}
示例5: isFileCacheable
/**
* Check if the page can be cached
* @return bool
*/
public function isFileCacheable()
{
$cacheable = false;
if (HTMLFileCache::useFileCache($this->getContext())) {
$cacheable = $this->mPage->getID() && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
// Extension may have reason to disable file caching on some pages.
if ($cacheable) {
$cacheable = Hooks::run('IsFileCacheable', array(&$this));
}
}
return $cacheable;
}
示例6: onView
/**
* Print the history page for an article.
*/
function onView()
{
$out = $this->getOutput();
$request = $this->getRequest();
/**
* Allow client caching.
*/
if ($out->checkLastModified($this->page->getTouched())) {
return;
// Client cache fresh and headers sent, nothing more to do.
}
wfProfileIn(__METHOD__);
$this->preCacheMessages();
$config = $this->context->getConfig();
# Fill in the file cache if not set already
$useFileCache = $config->get('UseFileCache');
if ($useFileCache && HTMLFileCache::useFileCache($this->getContext())) {
$cache = HTMLFileCache::newFromTitle($this->getTitle(), 'history');
if (!$cache->isCacheGood()) {
ob_start(array(&$cache, 'saveToFileCache'));
}
}
// Setup page variables.
$out->setFeedAppendQuery('action=history');
$out->addModules('mediawiki.action.history');
if ($config->get('UseMediaWikiUIEverywhere')) {
$out = $this->getOutput();
$out->addModuleStyles(array('mediawiki.ui.input', 'mediawiki.ui.checkbox'));
}
// Handle atom/RSS feeds.
$feedType = $request->getVal('feed');
if ($feedType) {
$this->feed($feedType);
wfProfileOut(__METHOD__);
return;
}
// Fail nicely if article doesn't exist.
if (!$this->page->exists()) {
$out->addWikiMsg('nohistory');
# show deletion/move log if there is an entry
LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
wfProfileOut(__METHOD__);
return;
}
/**
* Add date selector to quickly get to a certain time
*/
$year = $request->getInt('year');
$month = $request->getInt('month');
$tagFilter = $request->getVal('tagfilter');
$tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
/**
* Option to show only revisions that have been (partially) hidden via RevisionDelete
*/
if ($request->getBool('deleted')) {
$conds = array('rev_deleted != 0');
} else {
$conds = array();
}
if ($this->getUser()->isAllowed('deletedhistory')) {
$checkDeleted = Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deleted', 'mw-show-deleted-only', $request->getBool('deleted')) . "\n";
} else {
$checkDeleted = '';
}
// Add the general form
$action = htmlspecialchars(wfScript());
$out->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset($this->msg('history-fieldset-title')->text(), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year == null ? MWTimestamp::getLocalInstance()->format('Y') : $year, $month) . ' ' . ($tagSelector ? implode(' ', $tagSelector) . ' ' : '') . $checkDeleted . Xml::submitButton($this->msg('allpagessubmit')->text()) . "\n" . '</fieldset></form>');
wfRunHooks('PageHistoryBeforeList', array(&$this->page, $this->getContext()));
// Create and output the list.
$pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
$out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
$out->preventClickjacking($pager->getPreventClickjacking());
wfProfileOut(__METHOD__);
}
示例7: invalidateTitles
/**
* Invalidate an array (or iterator) of Title objects, right now
* @param $titleArray array
*/
protected function invalidateTitles($titleArray)
{
global $wgUseFileCache, $wgUseSquid;
$dbw = wfGetDB(DB_MASTER);
$timestamp = $dbw->timestamp();
# Get all IDs in this query into an array
$ids = array();
foreach ($titleArray as $title) {
$ids[] = $title->getArticleID();
}
if (!$ids) {
return;
}
# Don't invalidated pages that were already invalidated
$touchedCond = isset($this->params['rootJobTimestamp']) ? array("page_touched < " . $dbw->addQuotes($dbw->timestamp($this->params['rootJobTimestamp']))) : array();
# Update page_touched
$batches = array_chunk($ids, $this->rowsPerQuery);
foreach ($batches as $batch) {
$dbw->update('page', array('page_touched' => $timestamp), array('page_id' => $batch) + $touchedCond, __METHOD__);
}
# Update squid
if ($wgUseSquid) {
$u = SquidUpdate::newFromTitles($titleArray);
$u->doUpdate();
}
# Update file cache
if ($wgUseFileCache) {
foreach ($titleArray as $title) {
HTMLFileCache::clearFileCache($title);
}
}
}
示例8: invalidateCache
/**
* Updates page_touched for this page; called from LinksUpdate.php
*
* @return Bool true if the update succeded
*/
public function invalidateCache()
{
if (wfReadOnly()) {
return;
}
$dbw = wfGetDB(DB_MASTER);
$success = $dbw->update('page', array('page_touched' => $dbw->timestamp()), $this->pageCond(), __METHOD__);
HTMLFileCache::clearFileCache($this);
return $success;
}
示例9: while
// Go through each page and save the output
while ($blockEnd <= $end) {
// Get the pages
$res = $dbr->select('page', array('page_namespace', 'page_title', 'page_id'), array('page_namespace' => $wgContentNamespaces, "page_id BETWEEN {$blockStart} AND {$blockEnd}"), array('ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY'));
while ($row = $dbr->fetchObject($res)) {
$rebuilt = false;
$wgTitle = Title::makeTitleSafe($row->page_namespace, $row->page_title);
if (null == $wgTitle) {
echo "Page {$row->page_id} bad title\n";
continue;
// broken title?
}
$wgArticle = new Article($wgTitle);
// If the article is cacheable, then load it
if ($wgArticle->isFileCacheable()) {
$cache = new HTMLFileCache($wgTitle);
if ($cache->isFileCacheGood()) {
if ($overwrite) {
$rebuilt = true;
} else {
echo "Page {$row->page_id} already cached\n";
continue;
// done already!
}
}
ob_start(array(&$cache, 'saveToFileCache'));
// save on ob_end_clean()
$wgUseFileCache = false;
// hack, we don't want $wgArticle fiddling with filecache
$wgArticle->view();
@$wgOut->output();
示例10: execute
public function execute()
{
global $wgUseFileCache, $wgReadOnly, $wgContentNamespaces, $wgRequestTime;
global $wgOut;
if (!$wgUseFileCache) {
$this->error("Nothing to do -- \$wgUseFileCache is disabled.", true);
}
$wgReadOnly = 'Building cache';
// avoid DB writes (like enotif/counters)
$start = $this->getOption('start', "0");
if (!ctype_digit($start)) {
$this->error("Invalid value for start parameter.", true);
}
$start = intval($start);
$end = $this->getOption('end', "0");
if (!ctype_digit($end)) {
$this->error("Invalid value for end parameter.", true);
}
$end = intval($end);
$this->output("Building content page file cache from page {$start}!\n");
$dbr = $this->getDB(DB_SLAVE);
$overwrite = $this->getOption('overwrite', false);
$start = $start > 0 ? $start : $dbr->selectField('page', 'MIN(page_id)', false, __FUNCTION__);
$end = $end > 0 ? $end : $dbr->selectField('page', 'MAX(page_id)', false, __FUNCTION__);
if (!$start) {
$this->error("Nothing to do.", true);
}
$_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip';
// hack, no real client
# Do remaining chunk
$end += $this->mBatchSize - 1;
$blockStart = $start;
$blockEnd = $start + $this->mBatchSize - 1;
$dbw = $this->getDB(DB_MASTER);
// Go through each page and save the output
while ($blockEnd <= $end) {
// Get the pages
$res = $dbr->select('page', array('page_namespace', 'page_title', 'page_id'), array('page_namespace' => $wgContentNamespaces, "page_id BETWEEN {$blockStart} AND {$blockEnd}"), array('ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY'));
$this->beginTransaction($dbw, __METHOD__);
// for any changes
foreach ($res as $row) {
$rebuilt = false;
$wgRequestTime = microtime(true);
# bug 22852
$title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
if (null == $title) {
$this->output("Page {$row->page_id} has bad title\n");
continue;
// broken title?
}
$context = new RequestContext();
$context->setTitle($title);
$article = Article::newFromTitle($title, $context);
$context->setWikiPage($article->getPage());
$wgOut = $context->getOutput();
// set display title
// If the article is cacheable, then load it
if ($article->isFileCacheable()) {
$cache = HTMLFileCache::newFromTitle($title, 'view');
if ($cache->isCacheGood()) {
if ($overwrite) {
$rebuilt = true;
} else {
$this->output("Page {$row->page_id} already cached\n");
continue;
// done already!
}
}
ob_start(array(&$cache, 'saveToFileCache'));
// save on ob_end_clean()
$wgUseFileCache = false;
// hack, we don't want $article fiddling with filecache
$article->view();
MediaWiki\suppressWarnings();
// header notices
$wgOut->output();
MediaWiki\restoreWarnings();
$wgUseFileCache = true;
ob_end_clean();
// clear buffer
if ($rebuilt) {
$this->output("Re-cached page {$row->page_id}\n");
} else {
$this->output("Cached page {$row->page_id}\n");
}
} else {
$this->output("Page {$row->page_id} not cacheable\n");
}
}
$this->commitTransaction($dbw, __METHOD__);
// commit any changes (just for sanity)
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
}
$this->output("Done!\n");
}
示例11: view
function view()
{
global $wgOut, $wgScript;
if (isset($_SERVER['SCRIPT_URL'])) {
# Normally we use PHP_SELF to get the URL to the script
# as it was called, minus the query string.
#
# Some sites use Apache rewrite rules to handle subdomains,
# and have PHP set up in a weird way that causes PHP_SELF
# to contain the rewritten URL instead of the one that the
# outside world sees.
#
# If in this mode, use SCRIPT_URL instead, which mod_rewrite
# provides containing the "before" URL.
$url = $_SERVER['SCRIPT_URL'];
} else {
$url = $_SERVER['PHP_SELF'];
}
if (strcmp($wgScript, $url)) {
# Internet Explorer will ignore the Content-Type header if it
# thinks it sees a file extension it recognizes. Make sure that
# all raw requests are done through the script node, which will
# have eg '.php' and should remain safe.
#
# We used to redirect to a canonical-form URL as a general
# backwards-compatibility / good-citizen nice thing. However
# a lot of servers are set up in buggy ways, resulting in
# redirect loops which hang the browser until the CSS load
# times out.
#
# Just return a 403 Forbidden and get it over with.
wfHttpError(403, 'Forbidden', 'Raw pages must be accessed through the primary script entry point.');
return;
}
header("Content-type: " . $this->mContentType . '; charset=' . $this->mCharset);
# allow the client to cache this for 24 hours
$mode = $this->mPrivateCache ? 'private' : 'public';
header('Cache-Control: ' . $mode . ', s-maxage=' . $this->mSmaxage . ', max-age=' . $this->mMaxage);
if (HTMLFileCache::useFileCache()) {
$cache = new HTMLFileCache($this->mTitle, 'raw');
if ($cache->isFileCacheGood()) {
$cache->loadFromFileCache();
$wgOut->disable();
return;
} else {
ob_start(array(&$cache, 'saveToFileCache'));
}
}
$text = $this->getRawText();
if (!wfRunHooks('RawPageViewBeforeOutput', array(&$this, &$text))) {
wfDebug(__METHOD__ . ': RawPageViewBeforeOutput hook broke raw page output.');
}
echo $text;
$wgOut->disable();
}
示例12: view
function view()
{
global $wgOut, $wgScript, $wgRequest;
if ($wgRequest->isPathInfoBad()) {
# Internet Explorer will ignore the Content-Type header if it
# thinks it sees a file extension it recognizes. Make sure that
# all raw requests are done through the script node, which will
# have eg '.php' and should remain safe.
#
# We used to redirect to a canonical-form URL as a general
# backwards-compatibility / good-citizen nice thing. However
# a lot of servers are set up in buggy ways, resulting in
# redirect loops which hang the browser until the CSS load
# times out.
#
# Just return a 403 Forbidden and get it over with.
wfHttpError(403, 'Forbidden', 'Invalid file extension found in PATH_INFO or QUERY_STRING. ' . 'Raw pages must be accessed through the primary script entry point.');
return;
}
header("Content-type: " . $this->mContentType . '; charset=' . $this->mCharset);
# allow the client to cache this for 24 hours
$mode = $this->mPrivateCache ? 'private' : 'public';
header('Cache-Control: ' . $mode . ', s-maxage=' . $this->mSmaxage . ', max-age=' . $this->mMaxage);
global $wgUseFileCache;
if ($wgUseFileCache and HTMLFileCache::useFileCache()) {
$cache = new HTMLFileCache($this->mTitle, 'raw');
if ($cache->isFileCacheGood()) {
$cache->loadFromFileCache();
$wgOut->disable();
return;
} else {
ob_start(array(&$cache, 'saveToFileCache'));
}
}
$text = $this->getRawText();
if (!wfRunHooks('RawPageViewBeforeOutput', array(&$this, &$text))) {
wfDebug(__METHOD__ . ": RawPageViewBeforeOutput hook broke raw page output.\n");
}
echo $text;
$wgOut->disable();
}
示例13: getHTML
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;
}
示例14: fileCachedPage
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 '';
}
}
示例15: getHTML
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;
}