From 805d1a071d5630c97923485568fbe1c4cc009760 Mon Sep 17 00:00:00 2001 From: Rotem Liss Date: Fri, 20 Oct 2006 16:30:27 +0000 Subject: [PATCH] Some cleanup: code style, whitespace, docs, using single apostrophe, using __METHOD__ instead of . --- includes/SpecialAllmessages.php | 115 +++++++++++++++----------------- 1 file changed, 53 insertions(+), 62 deletions(-) diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 6e3f65880a..d6126da236 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -1,12 +1,12 @@ getText( 'ot' ); $navText = wfMsg( 'allmessagestext' ); @@ -42,39 +41,35 @@ function wfSpecialAllmessages() { } $wgMessageCache->enableTransform(); - wfProfileOut( "$fname-setup" ); + wfProfileOut( __METHOD__ . '-setup' ); - wfProfileIn( "$fname-output" ); - if ($ot == 'php') { - $navText .= makePhp($messages); - $wgOut->addHTML('PHP | HTML
'.htmlspecialchars($navText).'
'); + wfProfileIn( __METHOD__ . '-output' ); + if ( $ot == 'php' ) { + $navText .= makePhp( $messages ); + $wgOut->addHTML( 'PHP | HTML
' . htmlspecialchars( $navText ) . '
' ); } else { - $wgOut->addHTML( 'PHP | HTML' ); + $wgOut->addHTML( 'PHP | HTML' ); $wgOut->addWikiText( $navText ); $wgOut->addHTML( makeHTMLText( $messages ) ); } - wfProfileOut( "$fname-output" ); + wfProfileOut( __METHOD__ . '-output' ); - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); } /** - * + * Create the messages array, formatted in PHP to copy to language files. + * @param $messages Messages array. + * @return The PHP messages array. + * @todo Make suitable for language files. */ -function makePhp($messages) { +function makePhp( $messages ) { global $wgLang; $txt = "\n\n\$messages = array(\n"; foreach( $messages as $key => $m ) { - if($wgLang->getCode() != 'en' and $m['msg'] == $m['enmsg'] ) { - //if (strstr($m['msg'],"\n")) { - // $txt.='/* '; - // $comment=' */'; - //} else { - // $txt .= '#'; - // $comment = ''; - //} + if( $wgLang->getCode() != 'en' && $m['msg'] == $m['enmsg'] ) { continue; - } elseif ( wfEmptyMsg( $key, $m['msg'] ) ) { + } else if ( wfEmptyMsg( $key, $m['msg'] ) ) { $m['msg'] = ''; $comment = ' #empty'; } else { @@ -87,12 +82,13 @@ function makePhp($messages) { } /** - * + * Create a list of messages, formatted in HTML as a list of messages and values and showing differences between the default language file message and the message in MediaWiki: namespace. + * @param $messages Messages array. + * @return The HTML list of messages. */ function makeHTMLText( $messages ) { global $wgLang, $wgContLang, $wgUser; - $fname = "makeHTMLText"; - wfProfileIn( $fname ); + wfProfileIn( __METHOD__ ); $sk =& $wgUser->getSkin(); $talk = $wgLang->getNsText( NS_TALK ); @@ -102,29 +98,29 @@ function makeHTMLText( $messages ) { $input = wfElement( 'input', array( 'type' => 'text', 'id' => 'allmessagesinput', - 'onkeyup' => 'allmessagesfilter()',), - ''); + 'onkeyup' => 'allmessagesfilter()' + ), '' ); $checkbox = wfElement( 'input', array( 'type' => 'button', 'value' => wfMsgHtml( 'allmessagesmodified' ), 'id' => 'allmessagescheckbox', - 'onclick' => 'allmessagesmodified()',), - ''); + 'onclick' => 'allmessagesmodified()' + ), '' ); - $txt = ''; + $txt = ''; - $txt .= " - + $txt .= ' +
- - + + - - "; + + '; + + wfProfileIn( __METHOD__ . "-check" ); - wfProfileIn( "$fname-check" ); # This is a nasty hack to avoid doing independent existence checks # without sending the links and table through the slow wiki parser. $pageExists = array( @@ -139,31 +135,29 @@ function makeHTMLText( $messages ) { $pageExists[$s->page_namespace][$s->page_title] = true; } $dbr->freeResult( $res ); - wfProfileOut( "$fname-check" ); + wfProfileOut( __METHOD__ . "-check" ); - wfProfileIn( "$fname-output" ); + wfProfileIn( __METHOD__ . "-output" ); $i = 0; foreach( $messages as $key => $m ) { - $title = $wgLang->ucfirst( $key ); - if($wgLang->getCode() != $wgContLang->getCode()) - $title.= '/' . $wgLang->getCode(); + if( $wgLang->getCode() != $wgContLang->getCode() ) { + $title .= '/' . $wgLang->getCode(); + } $titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title ); $talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title ); - $changed = ($m['statmsg'] != $m['msg']); + $changed = ( $m['statmsg'] != $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 ) . "" ); + $pageLink = $sk->makeKnownLinkObj( $titleObj, "" . htmlspecialchars( $key ) . '' ); } else { - $pageLink = $sk->makeBrokenLinkObj( $titleObj, "" . htmlspecialchars( $key ) . "" ); + $pageLink = $sk->makeBrokenLinkObj( $titleObj, "" . htmlspecialchars( $key ) . '' ); } if( isset( $pageExists[NS_MEDIAWIKI_TALK][$title] ) ) { $talkLink = $sk->makeKnownLinkObj( $talkPage, htmlspecialchars( $talk ) ); @@ -174,38 +168,35 @@ function makeHTMLText( $messages ) { $anchor = 'msg_' . htmlspecialchars( strtolower( $title ) ); $anchor = ""; - if($changed) { - + if( $changed ) { $txt .= " - - + - + "; } else { - $txt .= " - + "; - } - $i++; + $i++; } - $txt .= "
" . wfMsgHtml('allmessagesname') . "" . wfMsgHtml('allmessagesdefault') . "' . wfMsgHtml( 'allmessagesname' ) . '' . wfMsgHtml( 'allmessagesdefault' ) . '
" . wfMsgHtml('allmessagescurrent') . "
' . wfMsgHtml( 'allmessagescurrent' ) . '
+
$anchor$pageLink
$talkLink
$message
$mw
$anchor$pageLink
$talkLink
$mw
"; - wfProfileOut( "$fname-output" ); + $txt .= ''; + wfProfileOut( __METHOD__ . '-output' ); - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); return $txt; } -- 2.20.1