Merge "mediawiki.skinning: Remove obsolete #firstHeading selector"
[lhc/web/wiklou.git] / includes / EditPage.php
index f97e3f8..a14191a 100644 (file)
@@ -217,8 +217,13 @@ class EditPage {
        /** @var bool|stdClass */
        protected $lastDelete;
 
-       /** @var bool */
-       protected $mTokenOk = false;
+       /** @var bool
+        * This is public because SemanticForms uses it (bug 67522).
+        * However, please consider using this property publicly
+        * to be deprecated.
+        * @protected
+        */
+       public $mTokenOk = false;
 
        /** @var bool */
        protected $mTokenOkExceptSuffix = false;
@@ -2425,9 +2430,7 @@ class EditPage {
 
                $wgOut->addHTML( $this->editFormTextBeforeContent );
 
-               if ( $this->contentModel === CONTENT_MODEL_WIKITEXT &&
-                       $showToolbar && $wgUser->getOption( 'showtoolbar' ) )
-               {
+               if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) {
                        $wgOut->addHTML( EditPage::getEditToolbar() );
                }
 
@@ -2612,9 +2615,18 @@ class EditPage {
                        );
                } elseif ( $wgUser->isAnon() ) {
                        if ( $this->formtype != 'preview' ) {
-                               $wgOut->wrapWikiMsg( "<div id=\"mw-anon-edit-warning\">\n$1</div>", 'anoneditwarning' );
+                               $wgOut->wrapWikiMsg(
+                                       "<div id='mw-anon-edit-warning'>\n$1\n</div>",
+                                       array( 'anoneditwarning',
+                                               // Log-in link
+                                               '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
+                                               // Sign-up link
+                                               '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}' )
+                               );
                        } else {
-                               $wgOut->wrapWikiMsg( "<div id=\"mw-anon-preview-warning\">\n$1</div>", 'anonpreviewwarning' );
+                               $wgOut->wrapWikiMsg( "<div id=\"mw-anon-preview-warning\">\n$1</div>",
+                                       'anonpreviewwarning'
+                               );
                        }
                } else {
                        if ( $this->isCssJsSubpage ) {
@@ -2758,7 +2770,6 @@ class EditPage {
         *   up top, or false if this is the comment summary
         *   down below the textarea
         * @param string $summary The text of the summary to display
-        * @return string
         */
        protected function showSummaryInput( $isSubjectPreview, $summary = "" ) {
                global $wgOut, $wgContLang;
@@ -3100,6 +3111,7 @@ HTML
         * Get the copyright warning
         *
         * Renamed to getCopyrightWarning(), old name kept around for backwards compatibility
+        * @return string
         */
        protected function getCopywarn() {
                return self::getCopyrightWarning( $this->mTitle );
@@ -3183,7 +3195,7 @@ HTML
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
-               global $wgOut;
+               global $wgOut, $wgUseMediaWikiUIEverywhere;
                $wgOut->addHTML( "<div class='editOptions'>\n" );
 
                if ( $this->section != 'new' ) {
@@ -3211,8 +3223,14 @@ HTML
 
                $message = wfMessage( 'edithelppage' )->inContentLanguage()->text();
                $edithelpurl = Skin::makeInternalOrExternalUrl( $message );
-               $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
-                       wfMessage( 'edithelp' )->escaped() . '</a> ' .
+               $attrs = array(
+                       'target' => 'helpwindow',
+                       'href' => $edithelpurl,
+               );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attrs['class'] = 'mw-ui-button mw-ui-quiet';
+               }
+               $edithelp = Html::element( 'a', $attrs, wfMessage( 'edithelp' )->text() ) .
                        wfMessage( 'newwindow' )->parse();
 
                $wgOut->addHTML( "      <span class='cancelLink'>{$cancel}</span>\n" );
@@ -3254,15 +3272,20 @@ HTML
         * @return string
         */
        public function getCancelLink() {
+               global $wgUseMediaWikiUIEverywhere;
                $cancelParams = array();
                if ( !$this->isConflict && $this->oldid > 0 ) {
                        $cancelParams['oldid'] = $this->oldid;
                }
+               $attrs = array( 'id' => 'mw-editform-cancel' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attrs['class'] = 'mw-ui-button mw-ui-quiet';
+               }
 
                return Linker::linkKnown(
                        $this->getContextTitle(),
                        wfMessage( 'cancel' )->parse(),
-                       array( 'id' => 'mw-editform-cancel' ),
+                       $attrs,
                        $cancelParams
                );
        }
@@ -3542,11 +3565,6 @@ HTML
                 * inserted between the two when no selection is highlighted
                 * and.  The tip text is shown when the user moves the mouse
                 * over the button.
-                *
-                * Also here: accesskeys (key), which are not used yet until
-                * someone can figure out a way to make them work in
-                * IE. However, we should make sure these keys are not defined
-                * on the edit page.
                 */
                $toolarray = array(
                        array(
@@ -3556,7 +3574,6 @@ HTML
                                'close'  => '\'\'\'',
                                'sample' => wfMessage( 'bold_sample' )->text(),
                                'tip'    => wfMessage( 'bold_tip' )->text(),
-                               'key'    => 'B'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-italic' ),
@@ -3565,7 +3582,6 @@ HTML
                                'close'  => '\'\'',
                                'sample' => wfMessage( 'italic_sample' )->text(),
                                'tip'    => wfMessage( 'italic_tip' )->text(),
-                               'key'    => 'I'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-link' ),
@@ -3574,7 +3590,6 @@ HTML
                                'close'  => ']]',
                                'sample' => wfMessage( 'link_sample' )->text(),
                                'tip'    => wfMessage( 'link_tip' )->text(),
-                               'key'    => 'L'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-extlink' ),
@@ -3583,7 +3598,6 @@ HTML
                                'close'  => ']',
                                'sample' => wfMessage( 'extlink_sample' )->text(),
                                'tip'    => wfMessage( 'extlink_tip' )->text(),
-                               'key'    => 'X'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-headline' ),
@@ -3592,7 +3606,6 @@ HTML
                                'close'  => " ==\n",
                                'sample' => wfMessage( 'headline_sample' )->text(),
                                'tip'    => wfMessage( 'headline_tip' )->text(),
-                               'key'    => 'H'
                        ),
                        $imagesAvailable ? array(
                                'image'  => $wgLang->getImageFile( 'button-image' ),
@@ -3601,7 +3614,6 @@ HTML
                                'close'  => ']]',
                                'sample' => wfMessage( 'image_sample' )->text(),
                                'tip'    => wfMessage( 'image_tip' )->text(),
-                               'key'    => 'D',
                        ) : false,
                        $imagesAvailable ? array(
                                'image'  => $wgLang->getImageFile( 'button-media' ),
@@ -3610,7 +3622,6 @@ HTML
                                'close'  => ']]',
                                'sample' => wfMessage( 'media_sample' )->text(),
                                'tip'    => wfMessage( 'media_tip' )->text(),
-                               'key'    => 'M'
                        ) : false,
                        array(
                                'image'  => $wgLang->getImageFile( 'button-nowiki' ),
@@ -3619,7 +3630,6 @@ HTML
                                'close'  => "</nowiki>",
                                'sample' => wfMessage( 'nowiki_sample' )->text(),
                                'tip'    => wfMessage( 'nowiki_tip' )->text(),
-                               'key'    => 'N'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-sig' ),
@@ -3628,7 +3638,6 @@ HTML
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'sig_tip' )->text(),
-                               'key'    => 'Y'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-hr' ),
@@ -3637,7 +3646,6 @@ HTML
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'hr_tip' )->text(),
-                               'key'    => 'R'
                        )
                );
 
@@ -3690,7 +3698,7 @@ HTML
         * @return array
         */
        public function getCheckboxes( &$tabindex, $checked ) {
-               global $wgUser;
+               global $wgUser, $wgUseMediaWikiUIEverywhere;
 
                $checkboxes = array();
 
@@ -3704,11 +3712,19 @@ HTML
                                        'accesskey' => wfMessage( 'accesskey-minoredit' )->text(),
                                        'id' => 'wpMinoredit',
                                );
-                               $checkboxes['minor'] =
+                               $minorEditHtml =
                                        Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
                                        "&#160;<label for='wpMinoredit' id='mw-editpage-minoredit'" .
                                        Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ) ) .
                                        ">{$minorLabel}</label>";
+
+                               if ( $wgUseMediaWikiUIEverywhere ) {
+                                       $checkboxes['minor'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                                               $minorEditHtml .
+                                       Html::closeElement( 'div' );
+                               } else {
+                                       $checkboxes['minor'] = $minorEditHtml;
+                               }
                        }
                }
 
@@ -3720,11 +3736,18 @@ HTML
                                'accesskey' => wfMessage( 'accesskey-watch' )->text(),
                                'id' => 'wpWatchthis',
                        );
-                       $checkboxes['watch'] =
+                       $watchThisHtml =
                                Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
                                "&#160;<label for='wpWatchthis' id='mw-editpage-watch'" .
                                Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ) ) .
                                ">{$watchLabel}</label>";
+                       if ( $wgUseMediaWikiUIEverywhere ) {
+                               $checkboxes['watch'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+                                       $watchThisHtml .
+                                       Html::closeElement( 'div' );
+                       } else {
+                               $checkboxes['watch'] = $watchThisHtml;
+                       }
                }
                wfRunHooks( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
                return $checkboxes;
@@ -3739,6 +3762,8 @@ HTML
         * @return array
         */
        public function getEditButtons( &$tabindex ) {
+               global $wgUseMediaWikiUIEverywhere;
+
                $buttons = array();
 
                $attribs = array(
@@ -3748,6 +3773,9 @@ HTML
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'savearticle' )->text(),
                ) + Linker::tooltipAndAccesskeyAttribs( 'save' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attribs['class'] = 'mw-ui-button mw-ui-constructive';
+               }
                $buttons['save'] = Xml::element( 'input', $attribs, '' );
 
                ++$tabindex; // use the same for preview and live preview
@@ -3758,6 +3786,9 @@ HTML
                        'tabindex' => $tabindex,
                        'value' => wfMessage( 'showpreview' )->text(),
                ) + Linker::tooltipAndAccesskeyAttribs( 'preview' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attribs['class'] = 'mw-ui-button mw-ui-progressive';
+               }
                $buttons['preview'] = Xml::element( 'input', $attribs, '' );
                $buttons['live'] = '';
 
@@ -3768,6 +3799,9 @@ HTML
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'showdiff' )->text(),
                ) + Linker::tooltipAndAccesskeyAttribs( 'diff' );
+               if ( $wgUseMediaWikiUIEverywhere ) {
+                       $attribs['class'] = 'mw-ui-button mw-ui-progressive';
+               }
                $buttons['diff'] = Xml::element( 'input', $attribs, '' );
 
                wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );