From f8cd489c66dce1ea88d9e07867559e749dd4bda6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sun, 8 Oct 2006 13:50:25 +0000 Subject: [PATCH] * Made messages used in Special:Preferences either plain text or wikitext (toggles) --- RELEASE-NOTES | 1 + includes/SpecialPreferences.php | 94 +++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 41 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4381ae4806..eb4d72ae5a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -272,6 +272,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 7508) Added option to compress HTML pages by dumpHTML.php * (bug 7519) Add plural in SpecialWatchlist * (bug 7459) Magic word variables are always case sensitive +* Made messages used in Special:Preferences either plain text or wikitext (toggles) == Languages updated == diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 5eadf3d62c..7cd38e504d 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -409,6 +409,8 @@ class PreferencesForm { if ( empty($name) ) $name = wfMsg( 'blanknamespace' ); + $name = htmlspecialchars( $name ); + $r1 .= "
\n"; } return $r1; @@ -416,10 +418,17 @@ class PreferencesForm { function getToggle( $tname, $trailer = false, $disabled = false ) { - global $wgUser, $wgLang; + global $wgUser, $wgLang, $wgOut; $this->mUsedToggles[$tname] = true; - $ttext = $wgLang->getUserToggle( $tname ); + if ( $tname !== 'highlightbroken' ) { + $ttext = $wgOut->parse( $wgLang->getUserToggle( $tname ), false, true ); + if( preg_match( "~^

(.*)\n?

$~", $ttext, $m = array() ) ) { + $ttext = $m[1]; + } + } else { + $ttext = $wgLang->getUserToggle( $tname ); + } $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : ''; $disabled = $disabled ? ' disabled="disabled"' : ''; @@ -502,12 +511,14 @@ class PreferencesForm { if ($wgEmailAuthentication && ($this->mUserEmail != '') ) { if( $wgUser->getEmailAuthenticationTimestamp() ) { - $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'
'; + $emailauthenticated = htmlspecialchars( wfMsg( 'emailauthenticated', + $wgLang->timeanddate( $wgUser->getEmailAuthenticationTimestamp(), true ) + ) ) .'
'; $disableEmailPrefs = false; } else { $disableEmailPrefs = true; $skin = $wgUser->getSkin(); - $emailauthenticated = wfMsg('emailnotauthenticated').'
' . + $emailauthenticated = wfMsgHtml( 'emailnotauthenticated' ) . '
' . $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ), wfMsg( 'emailconfirmlink' ) ); } @@ -537,18 +548,18 @@ class PreferencesForm { # User data # - $wgOut->addHTML( "
\n" . wfMsg('prefs-personal') . "\n\n"); + $wgOut->addHTML( "
\n" . wfMsgHtml('prefs-personal') . "\n
\n"); $wgOut->addHTML( $this->addRow( - wfMsg( 'username'), + wfMsgHtml( 'username'), $wgUser->getName() ) ); $wgOut->addHTML( $this->addRow( - wfMsg( 'uid' ), + wfMsgHtml( 'uid' ), $wgUser->getID() ) ); @@ -557,7 +568,7 @@ class PreferencesForm { if ($wgAllowRealName) { $wgOut->addHTML( $this->addRow( - '', + '', "mRealName}\" size='25' />" ) ); @@ -565,7 +576,7 @@ class PreferencesForm { if ($wgEnableEmail) { $wgOut->addHTML( $this->addRow( - '', + '', "mUserEmail}\" size='25' />" ) ); @@ -584,7 +595,7 @@ class PreferencesForm { $wgOut->addHTML( $this->addRow( - '', + '', "mNick}\" size='25' />" ) . $invalidSig . @@ -600,7 +611,7 @@ class PreferencesForm { * Make sure the site language is in the list; a custom language code * might not have a defined name... */ - $languages = $wgLang->getLanguageNames( true ); + $languages = $wgLang->getLanguageNames( false ); if( !array_key_exists( $wgContLanguageCode, $languages ) ) { $languages[$wgContLanguageCode] = $wgContLanguageCode; } @@ -614,13 +625,14 @@ class PreferencesForm { $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode; $selbox = null; foreach($languages as $code => $name) { + $name = htmlspecialchars( $name ); global $IP; $sel = ($code == $selectedLang)? ' selected="selected"' : ''; $selbox .= "\n"; } $wgOut->addHTML( $this->addRow( - '', + '', "" ) ); @@ -658,18 +670,18 @@ class PreferencesForm { $this->mNewpass = htmlspecialchars( $this->mNewpass ); $this->mRetypePass = htmlspecialchars( $this->mRetypePass ); - $wgOut->addHTML( '
' . wfMsg( 'changepassword' ) . '
'); + $wgOut->addHTML( '
' . wfMsgHtml( 'changepassword' ) . '
'); $wgOut->addHTML( $this->addRow( - '', + '', "mOldpass}\" size='20' />" ) . $this->addRow( - '', + '', "mNewpass}\" size='20' />" ) . $this->addRow( - '', + '', "mRetypePass}\" size='20' />" ) . "
\n" . @@ -679,7 +691,7 @@ class PreferencesForm { # # Enotif if ($wgEnableEmail) { - $wgOut->addHTML( '
' . wfMsg( 'email' ) . '' ); + $wgOut->addHTML( '
' . wfMsgHtml( 'email' ) . '' ); $wgOut->addHTML( $emailauthenticated. $enotifrevealaddr. @@ -687,7 +699,7 @@ class PreferencesForm { $enotifusertalkpages. $enotifminoredits ); if ($wgEnableUserEmail) { - $emf = wfMsg( 'allowemail' ); + $emf = wfMsgHtml( 'allowemail' ); $disabled = $disableEmailPrefs ? ' disabled="disabled"' : ''; $wgOut->addHTML( "
" ); @@ -703,7 +715,7 @@ class PreferencesForm { $tips[] = wfMsg( 'prefs-help-realname' ); if( $wgEnableEmail ) $tips[] = wfMsg( 'prefs-help-email' ); - $wgOut->addHtml( '
' . implode( '
', $tips ) . '
' ); + $wgOut->addWikitext( '
' . implode( '
', $tips ) . '
' ); } $wgOut->addHTML( '
' ); @@ -711,7 +723,7 @@ class PreferencesForm { # Quickbar # if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') { - $wgOut->addHtml( "
\n" . wfMsg( 'qbsettings' ) . "\n" ); + $wgOut->addHtml( "
\n" . wfMsgHtml( 'qbsettings' ) . "\n" ); for ( $i = 0; $i < count( $qbs ); ++$i ) { if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; } else { $checked = ""; } @@ -726,9 +738,9 @@ class PreferencesForm { # Skin # - $wgOut->addHTML( "
\n\n" . wfMsg('skin') . "\n" ); + $wgOut->addHTML( "
\n\n" . wfMsgHtml('skin') . "\n" ); $mptitle = Title::newMainPage(); - $previewtext = wfMsg('skinpreview'); + $previewtext = wfMsgHtml('skinpreview'); # Only show members of Skin::getSkinNames() rather than # $skinNames (skins is all skin names from Language.php) $validSkinNames = Skin::getSkinNames(); @@ -742,7 +754,7 @@ class PreferencesForm { $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey")); $previewlink = "$previewtext"; if( $skinkey == $wgDefaultSkin ) - $sn .= ' (' . wfMsg( 'default' ) . ')'; + $sn .= ' (' . wfMsgHtml( 'default' ) . ')'; $wgOut->addHTML( " $previewlink
\n" ); } $wgOut->addHTML( "
\n\n" ); @@ -751,10 +763,10 @@ class PreferencesForm { # global $wgUseTeX; if( $wgUseTeX ) { - $wgOut->addHTML( "
\n" . wfMsg('math') . '' ); + $wgOut->addHTML( "
\n" . wfMsgHtml('math') . '' ); foreach ( $mathopts as $k => $v ) { $checked = $k == $this->mMath ? ' checked="checked"' : ''; - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( "
\n" ); } $wgOut->addHTML( "
\n\n" ); } @@ -762,8 +774,8 @@ class PreferencesForm { # Files # $wgOut->addHTML("
- " . wfMsg( 'files' ) . " -
"); $imageLimitOptions = null; foreach ( $wgImageLimits as $index => $limits ) { @@ -773,7 +785,7 @@ class PreferencesForm { $imageThumbOptions = null; $wgOut->addHTML( "{$imageLimitOptions}
-
"); foreach ( $wgThumbLimits as $index => $size ) { $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : ''; $imageThumbOptions .= "\n"; @@ -785,10 +797,10 @@ class PreferencesForm { # Date/Time # - $wgOut->addHTML( "
\n" . wfMsg( 'datetime' ) . "\n" ); + $wgOut->addHTML( "
\n" . wfMsgHtml( 'datetime' ) . "\n" ); if ($dateopts) { - $wgOut->addHTML( "
\n" . wfMsg( 'dateformat' ) . "\n" ); + $wgOut->addHTML( "
\n" . wfMsgHtml( 'dateformat' ) . "\n" ); $idCnt = 0; $epoch = '20010115161234'; # Wikipedia day foreach( $dateopts as $key ) { @@ -808,22 +820,22 @@ class PreferencesForm { $nowlocal = $wgLang->time( $now = wfTimestampNow(), true ); $nowserver = $wgLang->time( $now, false ); - $wgOut->addHTML( '
' . wfMsg( 'timezonelegend' ). '' . - $this->addRow( wfMsg( 'servertime' ), $nowserver ) . - $this->addRow( wfMsg( 'localtime' ), $nowlocal ) . + $wgOut->addHTML( '
' . wfMsgHtml( 'timezonelegend' ). '
' . + $this->addRow( wfMsgHtml( 'servertime' ), $nowserver ) . + $this->addRow( wfMsgHtml( 'localtime' ), $nowlocal ) . $this->addRow( - '', + '', "mHourDiff ) . "\" size='6' />" ) . "
- -
¹" . wfMsg( 'timezonetext' ) . "
+
¹" . wfMsgHtml( 'timezonetext' ) . "
\n\n" ); # Editing # global $wgLivePreview, $wgUseRCPatrol; - $wgOut->addHTML( '
' . wfMsg( 'textboxsize' ) . ' + $wgOut->addHTML( '
' . wfMsgHtml( 'textboxsize' ) . '
' . wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) . ' ' . @@ -849,7 +861,7 @@ class PreferencesForm { ); $this->mUsedToggles['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it - $wgOut->addHTML( '
' . htmlspecialchars(wfMsg('prefs-rc')) . '' . + $wgOut->addHTML( '
' . wfMsgHtml('prefs-rc') . '' . wfInputLabel( wfMsg( 'recentchangescount' ), 'wpRecent', 'wpRecent', 3, $this->mRecent ) . $this->getToggles( array( @@ -872,7 +884,7 @@ class PreferencesForm { $wgOut->addHTML( '
' ); # Search - $wgOut->addHTML( '
' . wfMsg( 'searchresultshead' ) . '' . + $wgOut->addHTML( '
' . wfMsgHtml( 'searchresultshead' ) . '
' . $this->addRow( wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ), wfInput( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) ) @@ -885,11 +897,11 @@ class PreferencesForm { wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ), wfInput( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) ) ) . - "
" . wfMsg( 'defaultns' ) . "$ps
" ); + "
" . wfMsgHtml( 'defaultns' ) . "$ps
" ); # Misc # - $wgOut->addHTML('
' . wfMsg('prefs-misc') . ''); + $wgOut->addHTML('
' . wfMsgHtml('prefs-misc') . ''); $wgOut->addHTML( wfInputLabel( wfMsg( 'stubthreshold' ), 'wpStubs', 'wpStubs', 6, $this->mStubs ) ); $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) ); -- 2.20.1