Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / EditPage.php
index 145eae2..a423f26 100644 (file)
@@ -185,7 +185,7 @@ class EditPage {
        private $mContextTitle = null;
 
        /** @var string */
-       protected $action = 'submit';
+       public $action = 'submit';
 
        /** @var bool */
        public $isConflict = false;
@@ -200,13 +200,13 @@ class EditPage {
        public $isJsSubpage = false;
 
        /** @var bool */
-       protected $isWrongCaseCssJsPage = false;
+       public $isWrongCaseCssJsPage = false;
 
        /** @var bool New page or new section */
-       protected $isNew = false;
+       public $isNew = false;
 
        /** @var bool */
-       protected $deletedSinceEdit;
+       public $deletedSinceEdit;
 
        /** @var string */
        public $formtype;
@@ -215,34 +215,34 @@ class EditPage {
        public $firsttime;
 
        /** @var bool|stdClass */
-       protected $lastDelete;
+       public $lastDelete;
 
        /** @var bool */
-       protected $mTokenOk = false;
+       public $mTokenOk = false;
 
        /** @var bool */
-       protected $mTokenOkExceptSuffix = false;
+       public $mTokenOkExceptSuffix = false;
 
        /** @var bool */
-       protected $mTriedSave = false;
+       public $mTriedSave = false;
 
        /** @var bool */
-       protected $incompleteForm = false;
+       public $incompleteForm = false;
 
        /** @var bool */
-       protected $tooBig = false;
+       public $tooBig = false;
 
        /** @var bool */
-       protected $kblength = false;
+       public $kblength = false;
 
        /** @var bool */
-       protected $missingComment = false;
+       public $missingComment = false;
 
        /** @var bool */
-       protected $missingSummary = false;
+       public $missingSummary = false;
 
        /** @var bool */
-       protected $allowBlankSummary = false;
+       public $allowBlankSummary = false;
 
        /** @var bool */
        protected $blankArticle = false;
@@ -251,19 +251,19 @@ class EditPage {
        protected $allowBlankArticle = false;
 
        /** @var string */
-       protected $autoSumm = '';
+       public $autoSumm = '';
 
        /** @var string */
        public $hookError = '';
 
        /** @var ParserOutput */
-       protected $mParserOutput;
+       public $mParserOutput;
 
        /** @var bool Has a summary been preset using GET parameter &summary= ? */
-       protected $hasPresetSummary = false;
+       public $hasPresetSummary = false;
 
        /** @var bool */
-       protected $mBaseRevision = false;
+       public $mBaseRevision = false;
 
        /** @var bool */
        public $mShowSummaryField = true;
@@ -277,16 +277,16 @@ class EditPage {
        public $preview = false;
 
        /** @var bool */
-       protected $diff = false;
+       public $diff = false;
 
        /** @var bool */
        public $minoredit = false;
 
        /** @var bool */
-       protected $watchthis = false;
+       public $watchthis = false;
 
        /** @var bool */
-       protected $recreate = false;
+       public $recreate = false;
 
        /** @var string */
        public $textbox1 = '';
@@ -298,7 +298,7 @@ class EditPage {
        public $summary = '';
 
        /** @var bool */
-       protected $nosummary = false;
+       public $nosummary = false;
 
        /** @var string */
        public $edittime = '';
@@ -310,13 +310,13 @@ class EditPage {
        public $sectiontitle = '';
 
        /** @var string */
-       protected $starttime = '';
+       public $starttime = '';
 
        /** @var int */
        public $oldid = 0;
 
        /** @var string */
-       protected $editintro = '';
+       public $editintro = '';
 
        /** @var null */
        public $scrolltop = null;
@@ -1892,8 +1892,14 @@ class EditPage {
                        ( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) |
                        ( $bot ? EDIT_FORCE_BOT : 0 );
 
-               $doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
-                                                                                                               false, null, $this->contentFormat );
+               $doEditStatus = $this->mArticle->doEditContent(
+                       $content,
+                       $this->summary,
+                       $flags,
+                       false,
+                       null,
+                       $content->getDefaultFormat()
+               );
 
                if ( !$doEditStatus->isOK() ) {
                        // Failure from doEdit()
@@ -1938,9 +1944,7 @@ class EditPage {
                        // Do this in its own transaction to reduce contention...
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->onTransactionIdle( function () use ( $dbw, $title, $watch, $wgUser, $fname ) {
-                               $dbw->begin( $fname );
                                WatchAction::doWatchOrUnwatch( $watch, $title, $wgUser );
-                               $dbw->commit( $fname );
                        } );
                }
        }
@@ -2226,11 +2230,7 @@ class EditPage {
         *   $this->allowNonTextContent is not true.
         */
        protected function toEditText( $content ) {
-               if ( $content === null || $content === false ) {
-                       return $content;
-               }
-
-               if ( is_string( $content ) ) {
+               if ( $content === null || $content === false || is_string( $content ) ) {
                        return $content;
                }
 
@@ -2425,9 +2425,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 +2610,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 +2765,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 +3106,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 +3190,7 @@ HTML
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
-               global $wgOut, $wgUseMediaWikiUIEverywhere;
+               global $wgOut;
                $wgOut->addHTML( "<div class='editOptions'>\n" );
 
                if ( $this->section != 'new' ) {
@@ -3215,10 +3222,9 @@ HTML
                        'target' => 'helpwindow',
                        'href' => $edithelpurl,
                );
-               if ( $wgUseMediaWikiUIEverywhere ) {
-                       $attrs['class'] = 'mw-ui-button mw-ui-quiet';
-               }
-               $edithelp = Html::element( 'a', $attrs, wfMessage( 'edithelp' )->text() ) .
+               $edithelp = Html::linkButton( wfMessage( 'edithelp' )->text(),
+                       $attrs, array( 'mw-ui-quiet' ) ) .
+                       wfMessage( 'word-separator' )->escaped() .
                        wfMessage( 'newwindow' )->parse();
 
                $wgOut->addHTML( "      <span class='cancelLink'>{$cancel}</span>\n" );
@@ -3260,20 +3266,16 @@ 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(),
-                       $attrs,
+                       Html::buttonAttributes( $attrs, array( 'mw-ui-quiet' ) ),
                        $cancelParams
                );
        }
@@ -3541,125 +3543,102 @@ HTML
         * @return string
         */
        static function getEditToolbar() {
-               global $wgStylePath, $wgContLang, $wgLang, $wgOut;
+               global $wgContLang, $wgOut;
                global $wgEnableUploads, $wgForeignFileRepos;
 
                $imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
 
                /**
                 * $toolarray is an array of arrays each of which includes the
-                * filename of the button image (without path), the opening
-                * tag, the closing tag, optionally a sample text that is
+                * opening tag, the closing tag, optionally a sample text that is
                 * 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.
+                * Images are defined in ResourceLoaderEditToolbarModule.
                 */
                $toolarray = array(
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-bold' ),
                                'id'     => 'mw-editbutton-bold',
                                'open'   => '\'\'\'',
                                'close'  => '\'\'\'',
                                'sample' => wfMessage( 'bold_sample' )->text(),
                                'tip'    => wfMessage( 'bold_tip' )->text(),
-                               'key'    => 'B'
                        ),
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-italic' ),
                                'id'     => 'mw-editbutton-italic',
                                'open'   => '\'\'',
                                'close'  => '\'\'',
                                'sample' => wfMessage( 'italic_sample' )->text(),
                                'tip'    => wfMessage( 'italic_tip' )->text(),
-                               'key'    => 'I'
                        ),
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-link' ),
                                'id'     => 'mw-editbutton-link',
                                'open'   => '[[',
                                'close'  => ']]',
                                'sample' => wfMessage( 'link_sample' )->text(),
                                'tip'    => wfMessage( 'link_tip' )->text(),
-                               'key'    => 'L'
                        ),
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-extlink' ),
                                'id'     => 'mw-editbutton-extlink',
                                'open'   => '[',
                                'close'  => ']',
                                'sample' => wfMessage( 'extlink_sample' )->text(),
                                'tip'    => wfMessage( 'extlink_tip' )->text(),
-                               'key'    => 'X'
                        ),
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-headline' ),
                                'id'     => 'mw-editbutton-headline',
                                'open'   => "\n== ",
                                'close'  => " ==\n",
                                'sample' => wfMessage( 'headline_sample' )->text(),
                                'tip'    => wfMessage( 'headline_tip' )->text(),
-                               'key'    => 'H'
                        ),
                        $imagesAvailable ? array(
-                               'image'  => $wgLang->getImageFile( 'button-image' ),
                                'id'     => 'mw-editbutton-image',
                                'open'   => '[[' . $wgContLang->getNsText( NS_FILE ) . ':',
                                'close'  => ']]',
                                'sample' => wfMessage( 'image_sample' )->text(),
                                'tip'    => wfMessage( 'image_tip' )->text(),
-                               'key'    => 'D',
                        ) : false,
                        $imagesAvailable ? array(
-                               'image'  => $wgLang->getImageFile( 'button-media' ),
                                'id'     => 'mw-editbutton-media',
                                'open'   => '[[' . $wgContLang->getNsText( NS_MEDIA ) . ':',
                                'close'  => ']]',
                                'sample' => wfMessage( 'media_sample' )->text(),
                                'tip'    => wfMessage( 'media_tip' )->text(),
-                               'key'    => 'M'
                        ) : false,
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-nowiki' ),
                                'id'     => 'mw-editbutton-nowiki',
                                'open'   => "<nowiki>",
                                'close'  => "</nowiki>",
                                'sample' => wfMessage( 'nowiki_sample' )->text(),
                                'tip'    => wfMessage( 'nowiki_tip' )->text(),
-                               'key'    => 'N'
                        ),
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-sig' ),
                                'id'     => 'mw-editbutton-signature',
                                'open'   => '--~~~~',
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'sig_tip' )->text(),
-                               'key'    => 'Y'
                        ),
                        array(
-                               'image'  => $wgLang->getImageFile( 'button-hr' ),
                                'id'     => 'mw-editbutton-hr',
                                'open'   => "\n----\n",
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'hr_tip' )->text(),
-                               'key'    => 'R'
                        )
                );
 
-               $script = 'mw.loader.using("mediawiki.action.edit", function() {';
+               $script = 'mw.loader.using("mediawiki.toolbar", function () {';
                foreach ( $toolarray as $tool ) {
                        if ( !$tool ) {
                                continue;
                        }
 
                        $params = array(
-                               $wgStylePath . '/common/images/' . $tool['image'],
+                               // Images are defined in ResourceLoaderEditToolbarModule
+                               false,
                                // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
                                // Older browsers show a "speedtip" type message only for ALT.
                                // Ideally these should be different, realistically they
@@ -3674,12 +3653,6 @@ HTML
                        $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params );
                }
 
-               // This used to be called on DOMReady from mediawiki.action.edit, which
-               // ended up causing race conditions with the setup code above.
-               $script .= "\n" .
-                       "// Create button bar\n" .
-                       "$(function() { mw.toolbar.init(); } );\n";
-
                $script .= '});';
                $wgOut->addScript( Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) ) );
 
@@ -3765,47 +3738,33 @@ HTML
         * @return array
         */
        public function getEditButtons( &$tabindex ) {
-               global $wgUseMediaWikiUIEverywhere;
-
                $buttons = array();
 
                $attribs = array(
                        'id' => 'wpSave',
                        'name' => 'wpSave',
-                       'type' => 'submit',
                        '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, '' );
+               $buttons['save'] = Html::submitButton( wfMessage( 'savearticle' )->text(),
+                       $attribs, array( 'mw-ui-constructive' ) );
 
                ++$tabindex; // use the same for preview and live preview
                $attribs = array(
                        'id' => 'wpPreview',
                        'name' => 'wpPreview',
-                       'type' => 'submit',
                        '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['preview'] = Html::submitButton( wfMessage( 'showpreview' )->text(),
+                       $attribs );
                $buttons['live'] = '';
 
                $attribs = array(
                        'id' => 'wpDiff',
                        'name' => 'wpDiff',
-                       'type' => 'submit',
                        '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, '' );
+               $buttons['diff'] = Html::submitButton( wfMessage( 'showdiff' )->text(),
+                       $attribs );
 
                wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
                return $buttons;