Use protocol-relative URL for link to MediaWiki.org (as with the footer logo on each...
[lhc/web/wiklou.git] / includes / Preferences.php
index bfdc538..7126b2b 100644 (file)
@@ -171,7 +171,7 @@ class Preferences {
                asort( $userGroups );
                asort( $userMembers );
 
-               $lang = $context->getLang();
+               $lang = $context->getLanguage();
 
                $defaultPreferences['usergroups'] = array(
                        'type' => 'info',
@@ -485,7 +485,7 @@ class Preferences {
                        $defaultPreferences['commoncssjs'] = array(
                                'type' => 'info',
                                'raw' => true,
-                               'default' => $context->getLang()->pipeList( $linkTools ),
+                               'default' => $context->getLanguage()->pipeList( $linkTools ),
                                'label-message' => 'prefs-common-css-js',
                                'section' => 'rendering/skin',
                        );
@@ -493,7 +493,7 @@ class Preferences {
 
                $selectedSkin = $user->getOption( 'skin' );
                if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) {
-                       $settings = array_flip( $context->getLang()->getQuickbarSettings() );
+                       $settings = array_flip( $context->getLanguage()->getQuickbarSettings() );
 
                        $defaultPreferences['quickbar'] = array(
                                'type' => 'radio',
@@ -545,7 +545,7 @@ class Preferences {
 
                // Info
                $now = wfTimestampNow();
-               $lang = $context->getLang();
+               $lang = $context->getLanguage();
                $nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ),
                        $lang->time( $now, true ) );
                $nowserver = $lang->time( $now, false ) .
@@ -1082,7 +1082,7 @@ class Preferences {
                                $linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
                        }
 
-                       $display = $sn . ' ' . $context->msg( 'parentheses', $context->getLang()->pipeList( $linkTools ) )->text();
+                       $display = $sn . ' ' . $context->msg( 'parentheses', $context->getLanguage()->pipeList( $linkTools ) )->text();
                        $ret[$display] = $skinkey;
                }
 
@@ -1094,7 +1094,7 @@ class Preferences {
         * @return array
         */
        static function getDateOptions( IContextSource $context ) {
-               $dateopts = $context->getLang()->getDatePreferences();
+               $dateopts = $context->getLanguage()->getDatePreferences();
 
                $ret = array();
 
@@ -1115,7 +1115,7 @@ class Preferences {
                                if ( $key == 'default' ) {
                                        $formatted = $context->msg( 'datedefault' )->escaped();
                                } else {
-                                       $formatted = htmlspecialchars( $context->getLang()->timeanddate( $epoch, false, $key ) );
+                                       $formatted = htmlspecialchars( $context->getLanguage()->timeanddate( $epoch, false, $key ) );
                                }
                                $ret[$formatted] = $key;
                        }
@@ -1160,19 +1160,20 @@ class Preferences {
        }
 
        /**
-        * @param $signature
-        * @param $alldata
+        * @param $signature string
+        * @param $alldata array
+        * @param $form HTMLForm
         * @return bool|string
         */
-       static function validateSignature( $signature, $alldata ) {
+       static function validateSignature( $signature, $alldata, $form ) {
                global $wgParser, $wgMaxSigChars;
                if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
                        return Xml::element( 'span', array( 'class' => 'error' ),
-                               wfMessage( 'badsiglength' )->numParams( $wgMaxSigChars )->text() );
+                               $form->msg( 'badsiglength' )->numParams( $wgMaxSigChars )->text() );
                } elseif ( isset( $alldata['fancysig'] ) &&
                                $alldata['fancysig'] &&
                                false === $wgParser->validateSig( $signature ) ) {
-                       return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) );
+                       return Xml::element( 'span', array( 'class' => 'error' ), $form->msg( 'badsig' )->text() );
                } else {
                        return true;
                }
@@ -1181,9 +1182,10 @@ class Preferences {
        /**
         * @param $signature string
         * @param $alldata array
+        * @param $form HTMLForm
         * @return string
         */
-       static function cleanSignature( $signature, $alldata ) {
+       static function cleanSignature( $signature, $alldata, $form ) {
                global $wgParser;
                if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
                        $signature = $wgParser->cleanSig( $signature );
@@ -1195,23 +1197,6 @@ class Preferences {
                return $signature;
        }
 
-       /**
-        * @param $email
-        * @param $alldata
-        * @return bool|String
-        */
-       static function validateEmail( $email, $alldata ) {
-               if ( $email && !Sanitizer::validateEmail( $email ) ) {
-                       return wfMsgExt( 'invalidemailaddress', 'parseinline' );
-               }
-
-               global $wgEmailConfirmToEdit;
-               if ( $wgEmailConfirmToEdit && !$email ) {
-                       return wfMsgExt( 'noemailtitle', 'parseinline' );
-               }
-               return true;
-       }
-
        /**
         * @param $user User
         * @param $context IContextSource
@@ -1229,7 +1214,7 @@ class Preferences {
 
                $htmlForm->setModifiedUser( $user );
                $htmlForm->setId( 'mw-prefs-form' );
-               $htmlForm->setSubmitText( wfMsg( 'saveprefs' ) );
+               $htmlForm->setSubmitText( $context->msg( 'saveprefs' )->text() );
                # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
                $htmlForm->setSubmitTooltip( 'preferences-save' );
                $htmlForm->setSubmitID( 'prefsubmit' );
@@ -1425,7 +1410,7 @@ class Preferences {
                return Status::newGood();
        }
 
-       /*
+       /**
         * Try to set a user's email address.
         * This does *not* try to validate the address.
         * Caller is responsible for checking $wgAuth.
@@ -1487,6 +1472,9 @@ class Preferences {
 
 /** Some tweaks to allow js prefs to work */
 class PreferencesForm extends HTMLForm {
+       // Override default value from HTMLForm
+       protected $mSubSectionBeforeFields = false;
+       
        private $modifiedUser;
 
        public function setModifiedUser( $user ) {
@@ -1529,7 +1517,7 @@ class PreferencesForm extends HTMLForm {
 
                $t = SpecialPage::getTitleFor( 'Preferences', 'reset' );
 
-               $html .= "\n" . Linker::link( $t, wfMsgHtml( 'restoreprefs' ) );
+               $html .= "\n" . Linker::link( $t, $this->msg( 'restoreprefs' )->escaped() );
 
                $html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html );
 
@@ -1565,4 +1553,14 @@ class PreferencesForm extends HTMLForm {
        function getBody() {
                return $this->displaySection( $this->mFieldTree, '', 'mw-prefsection-' );
        }
+       
+       /**
+        * Get the <legend> for a given section key. Normally this is the
+        * prefs-$key message but we'll allow extensions to override it.
+        */
+       function getLegend( $key ) {
+               $legend = parent::getLegend( $key );
+               wfRunHooks( 'PreferencesGetLegend', array( $this, $key, &$legend ) );
+               return $legend;
+       }
 }