From 669d4e07f205cddbf3201253f7368270282df220 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 22 Aug 2004 22:22:54 +0000 Subject: [PATCH] * Fix notice in PHP output mode * Fix XML well-formedness error in header (escape those URLs!) * Redo 'HTML' mode to output HTML directly instead of wiki-HTML hybrid. This runs over 3 times faster and uses a lot less memory. However it still doesn't work with an 8mb memory_limit... --- includes/SpecialAllmessages.php | 69 +++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 4ef0bcc1c1..5f52b06fae 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -18,12 +18,12 @@ $messages[$key]['msg'] = wfMsg ( $key ); } if ($ot == 'html') { - $navText .= makeWikiText($messages); - $wgOut->addHTML('PHP | HTML'); - $wgOut->addWikiText($navText); + $wgOut->addHTML( 'PHP | HTML' ); + $wgOut->addWikiText( $navText ); + $wgOut->addHTML( makeHTMLText( $messages ) ); } else { $navText .= makePhp($messages); - $wgOut->addHTML('PHP | HTML
'.htmlspecialchars($navText).'
'); + $wgOut->addHTML('PHP | HTML
'.htmlspecialchars($navText).'
'); } return; } @@ -37,6 +37,7 @@ $comment=' */'; } else { $txt .= '#'; + $comment = ''; } } elseif ($m['msg'] == '<'.$key.'>'){ $m['msg'] = ''; @@ -50,33 +51,61 @@ return $txt; } - - function makeWikiText($messages) { - global $wgLang; + function makeHTMLText( $messages ) { + global $wgLang, $wgUser; + $sk =& $wgUser->getSkin(); $talk = $wgLang->getNsText( NS_TALK ); $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI ); $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK ); $txt = " - "; +
- '''Name''' - - '''Default text''' - - '''Current text''' -
+ + + + + "; + + # This is a nasty hack to avoid doing independent existence checks + # without sending the links and table through the slow wiki parser. + $pageExists = array( + NS_MEDIAWIKI => array(), + NS_MEDIAWIKI_TALK => array() + ); + $sql = "SELECT cur_namespace,cur_title FROM cur WHERE cur_namespace IN (" . NS_MEDIAWIKI . ", " . NS_MEDIAWIKI_TALK . ")"; + $dbr =& wfGetDB( DB_SLAVE ); + $res = $dbr->query( $sql ); + while( $s = $dbr->fetchObject( $res ) ) { + $pageExists[$s->cur_namespace][$s->cur_title] = true; + } + $dbr->freeResult( $res ); + foreach( $messages as $key => $m ) { - $titleObj = Title::newFromText( $key ); + $titleObj = Title::makeTitle( NS_MEDIAWIKI, $key ); + $talkPage = Title::makeTitle( NS_MEDIAWIKI_TALK, $key ); $title = $titleObj->getDBkey(); $colorIt = ($m['statmsg'] == $m['msg']) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\""; - $message = wfEscapeWikiText( $m['statmsg'] ); - $mw = wfEscapeWikiText( $m['msg'] ); + $message = htmlspecialchars( $m['statmsg'] ); + $mw = htmlspecialchars( $m['msg'] ); + + #$pageLink = $sk->makeLinkObj( $titleObj, htmlspecialchars( $key ) ); + #$talkLink = $sk->makeLinkObj( $talkPage, htmlspecialchars( $talk ) ); + if( isset( $pageExists[NS_MEDIAWIKI][$title] ) ) { + $pageLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( $key ) ); + } else { + $pageLink = $sk->makeBrokenLinkObj( $titleObj, htmlspecialchars( $key ) ); + } + if( isset( $pageExists[NS_MEDIAWIKI_TALK][$title] ) ) { + $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) ); + } else { + $talkLink = $sk->makeBrokenLinkObj( $talkPage, htmlspecialchars( $talk ) ); + } $txt .= "
NameDefault textCurrent text
- [[$mwnspace:$title|$key]]
- [[$mwtalk:$title|$talk]] + $pageLink
+ $talkLink
$message @@ -88,4 +117,4 @@ return $txt; } - ?> +?> -- 2.20.1