* Use call_user_func( $func ) rather than $func(), like wgHooks and parser hooks
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
index 722cd94..40366dc 100644 (file)
@@ -435,9 +435,9 @@ class PreferencesForm {
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
 
                if ( $this->mSuccess || 'success' == $status ) {
-                       $wgOut->addWikitext( '<div class="preferences-save-success"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
+                       $wgOut->addWikitext( '<div class="successbox"><strong>'. wfMsg( 'savedprefs' ) . '</strong></div>' );
                } else  if ( 'error' == $status ) {
-                       $wgOut->addWikitext( '<div class="error"><strong>' . $message  . '</strong></div>' );
+                       $wgOut->addWikitext( '<div class="errorbox"><strong>' . $message  . '</strong></div>' );
                } else if ( '' != $status ) {
                        $wgOut->addWikitext( $message . "\n----" );
                }
@@ -463,6 +463,7 @@ class PreferencesForm {
                # <FIXME>
                $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
                $this->mRealName = htmlspecialchars( $this->mRealName );
+               $rawNick = $this->mNick;
                $this->mNick = htmlspecialchars( $this->mNick );
                if ( !$this->mEmailFlag ) { $emfc = 'checked="checked"'; }
                else { $emfc = ''; }
@@ -539,11 +540,23 @@ class PreferencesForm {
                        );
                }
 
+               global $wgParser;
+               if( !empty( $this->mToggles['fancysig'] ) &&
+                       false === $wgParser->validateSig( $rawNick ) ) {
+                       $invalidSig = $this->addRow(
+                               '&nbsp;',
+                               '<span class="error">' . wfMsgHtml( 'badsig' ) . '<span>'
+                       );
+               } else {
+                       $invalidSig = '';
+               }
+               
                $wgOut->addHTML(
                        $this->addRow(
                                '<label for="wpNick">' . wfMsg( 'yournick' ) . '</label>',
                                "<input type='text' name='wpNick' id='wpNick' value=\"{$this->mNick}\" size='25' />"
                        ) .
+                       $invalidSig .
                        # FIXME: The <input> part should be where the &nbsp; is, getToggle() needs
                        # to be changed to out return its output in two parts. -ævar
                        $this->addRow(
@@ -552,12 +565,21 @@ class PreferencesForm {
                        )
                );
 
+               /**
+                * Make sure the site language is in the list; a custom language code
+                * might not have a defined name...
+                */
+               $languages = $wgLang->getLanguageNames();
+               if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
+                       $languages[$wgContLanguageCode] = $wgContLanguageCode;
+               }
+               ksort( $languages );
+               
                /**
                 * If a bogus value is set, default to the content language.
                 * Otherwise, no default is selected and the user ends up
                 * with an Afrikaans interface since it's first in the list.
                 */
-               $languages = $wgLang->getLanguageNames();
                $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
                $selbox = null;
                foreach($languages as $code => $name) {
@@ -579,11 +601,13 @@ class PreferencesForm {
                /* see if there are multiple language variants to choose from*/
                if(!$wgDisableLangConversion) {
                        $variants = $wgContLang->getVariants();
+                       $variantArray = array();
 
                        foreach($variants as $v) {
                                $v = str_replace( '_', '-', strtolower($v));
-                               if($name = $languages[$v]) {
-                                       $variantArray[$v] = $name;
+                               if( array_key_exists( $v, $languages ) ) {
+                                       // If it doesn't have a name, we'll pretend it doesn't exist
+                                       $variantArray[$v] = $languages[$v];
                                }
                        }
 
@@ -734,10 +758,16 @@ class PreferencesForm {
                if ($dateopts) {
                        $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
                        $idCnt = 0;
+                       $epoch = '20010115161234';
                        foreach($dateopts as $key => $option) {
+                               if( $key == MW_DATE_DEFAULT ) {
+                                       $formatted = wfMsgHtml( 'datedefault' );
+                               } else {
+                                       $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
+                               }
                                ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
                                $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
-                                       "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$option</label></div>\n" );
+                                       "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
                                $idCnt++;
                        }
                        $wgOut->addHTML( "</fieldset>\n" );
@@ -815,14 +845,14 @@ class PreferencesForm {
                );
                $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
                $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
-               $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always ' ) );
+               $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
                $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
                $uopt = $wgUser->getOption("underline");
-               $s0 = $uopt == 0 ? " selected=\"selected\"" : "";
-               $s1 = $uopt == 1 ? " selected=\"selected\"" : "";
-               $s2 = $uopt == 2 ? " selected=\"selected\"" : "";
+               $s0 = $uopt == 0 ? ' selected="selected"' : '';
+               $s1 = $uopt == 1 ? ' selected="selected"' : '';
+               $s2 = $uopt == 2 ? ' selected="selected"' : '';
                $wgOut->addHTML("
-<div class='toggle'><label for='wpOpunderline'>$msgUnderline</label> 
+<div class='toggle'><label for='wpOpunderline'>$msgUnderline</label>
 <select name='wpOpunderline' id='wpOpunderline'>
 <option value=\"0\"$s0>$msgUnderlinenever</option>
 <option value=\"1\"$s1>$msgUnderlinealways</option>
@@ -841,9 +871,9 @@ class PreferencesForm {
                $wgOut->addHTML( "
        <div id='prefsubmit'>
        <div>
-               <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
-               wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
-               <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
+               <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . "\" accesskey=\"".
+               wfMsgHtml('accesskey-save')."\" title=\"".wfMsgHtml('tooltip-save')."\" />
+               <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
        </div>
 
        </div>