Merge "Ensure that expiry times are given as integers"
[lhc/web/wiklou.git] / includes / EditPage.php
index 0a61a7e..70eb909 100644 (file)
@@ -639,26 +639,6 @@ class EditPage {
                }
        }
 
-       /**
-        * Show a read-only error
-        * Parameters are the same as OutputPage:readOnlyPage()
-        * Redirect to the article page if redlink=1
-        * @deprecated since 1.19; use displayPermissionsError() instead
-        */
-       function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
-               wfDeprecated( __METHOD__, '1.19' );
-
-               global $wgRequest, $wgOut;
-               if ( $wgRequest->getBool( 'redlink' ) ) {
-                       // The edit page was reached via a red link.
-                       // Redirect to the article page and let them click the edit tab if
-                       // they really want a permission error.
-                       $wgOut->redirect( $this->mTitle->getFullURL() );
-               } else {
-                       $wgOut->readOnlyPage( $source, $protected, $reasons, $action );
-               }
-       }
-
        /**
         * Should we show a preview when the edit form is first shown?
         *
@@ -978,29 +958,6 @@ class EditPage {
                return true;
        }
 
-       /**
-        * Fetch initial editing page content.
-        *
-        * @param string|bool $def_text
-        * @return string|bool String on success, $def_text for invalid sections
-        * @private
-        * @deprecated since 1.21, get WikiPage::getContent() instead.
-        */
-       function getContent( $def_text = false ) {
-               ContentHandler::deprecated( __METHOD__, '1.21' );
-
-               if ( $def_text !== null && $def_text !== false && $def_text !== '' ) {
-                       $def_content = $this->toEditContent( $def_text );
-               } else {
-                       $def_content = false;
-               }
-
-               $content = $this->getContentObject( $def_content );
-
-               // Note: EditPage should only be used with text based content anyway.
-               return $this->toEditText( $content );
-       }
-
        /**
         * @param Content|null $def_content The default value to return
         *
@@ -1188,20 +1145,6 @@ class EditPage {
                }
        }
 
-       /**
-        * Use this method before edit() to preload some text into the edit box
-        *
-        * @param string $text
-        * @deprecated since 1.21, use setPreloadedContent() instead.
-        */
-       public function setPreloadedText( $text ) {
-               ContentHandler::deprecated( __METHOD__, "1.21" );
-
-               $content = $this->toEditContent( $text );
-
-               $this->setPreloadedContent( $content );
-       }
-
        /**
         * Use this method before edit() to preload some content into the edit box
         *
@@ -1213,25 +1156,6 @@ class EditPage {
                $this->mPreloadContent = $content;
        }
 
-       /**
-        * Get the contents to be preloaded into the box, either set by
-        * an earlier setPreloadText() or by loading the given page.
-        *
-        * @param string $preload Representing the title to preload from.
-        *
-        * @return string
-        *
-        * @deprecated since 1.21, use getPreloadedContent() instead
-        */
-       protected function getPreloadedText( $preload ) {
-               ContentHandler::deprecated( __METHOD__, "1.21" );
-
-               $content = $this->getPreloadedContent( $preload );
-               $text = $this->toEditText( $content );
-
-               return $text;
-       }
-
        /**
         * Get the contents to be preloaded into the box, either set by
         * an earlier setPreloadText() or by loading the given page.
@@ -1544,9 +1468,8 @@ class EditPage {
                        $cleanSummary = $wgParser->stripSectionName( $this->summary );
                        return wfMessage( 'newsectionsummary' )
                                ->rawParams( $cleanSummary )->inContentLanguage()->text();
-               } else {
-                       return $this->summary;
                }
+               return $this->summary;
        }
 
        /**
@@ -2022,28 +1945,6 @@ class EditPage {
                }
        }
 
-       /**
-        * Attempts to merge text content with base and current revisions
-        *
-        * @param string $editText
-        *
-        * @return bool
-        * @deprecated since 1.21, use mergeChangesIntoContent() instead
-        */
-       function mergeChangesInto( &$editText ) {
-               ContentHandler::deprecated( __METHOD__, "1.21" );
-
-               $editContent = $this->toEditContent( $editText );
-
-               $ok = $this->mergeChangesIntoContent( $editContent );
-
-               if ( $ok ) {
-                       $editText = $this->toEditText( $editContent );
-                       return true;
-               }
-               return false;
-       }
-
        /**
         * Attempts to do 3-way merge of edit content with a base revision
         * and current content, in case of edit conflict, in whichever way appropriate
@@ -3282,7 +3183,7 @@ HTML
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
-               global $wgOut;
+               global $wgOut, $wgUseMediaWikiUIEverywhere;
                $wgOut->addHTML( "<div class='editOptions'>\n" );
 
                if ( $this->section != 'new' ) {
@@ -3310,8 +3211,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" );
@@ -3353,15 +3260,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
                );
        }
@@ -3625,7 +3537,6 @@ HTML
        /**
         * Shows a bulletin board style toolbar for common editing functions.
         * It can be disabled in the user preferences.
-        * The necessary JavaScript code can be found in skins/common/edit.js.
         *
         * @return string
         */
@@ -3642,11 +3553,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(
@@ -3656,7 +3562,6 @@ HTML
                                'close'  => '\'\'\'',
                                'sample' => wfMessage( 'bold_sample' )->text(),
                                'tip'    => wfMessage( 'bold_tip' )->text(),
-                               'key'    => 'B'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-italic' ),
@@ -3665,7 +3570,6 @@ HTML
                                'close'  => '\'\'',
                                'sample' => wfMessage( 'italic_sample' )->text(),
                                'tip'    => wfMessage( 'italic_tip' )->text(),
-                               'key'    => 'I'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-link' ),
@@ -3674,7 +3578,6 @@ HTML
                                'close'  => ']]',
                                'sample' => wfMessage( 'link_sample' )->text(),
                                'tip'    => wfMessage( 'link_tip' )->text(),
-                               'key'    => 'L'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-extlink' ),
@@ -3683,7 +3586,6 @@ HTML
                                'close'  => ']',
                                'sample' => wfMessage( 'extlink_sample' )->text(),
                                'tip'    => wfMessage( 'extlink_tip' )->text(),
-                               'key'    => 'X'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-headline' ),
@@ -3692,7 +3594,6 @@ HTML
                                'close'  => " ==\n",
                                'sample' => wfMessage( 'headline_sample' )->text(),
                                'tip'    => wfMessage( 'headline_tip' )->text(),
-                               'key'    => 'H'
                        ),
                        $imagesAvailable ? array(
                                'image'  => $wgLang->getImageFile( 'button-image' ),
@@ -3701,7 +3602,6 @@ HTML
                                'close'  => ']]',
                                'sample' => wfMessage( 'image_sample' )->text(),
                                'tip'    => wfMessage( 'image_tip' )->text(),
-                               'key'    => 'D',
                        ) : false,
                        $imagesAvailable ? array(
                                'image'  => $wgLang->getImageFile( 'button-media' ),
@@ -3710,7 +3610,6 @@ HTML
                                'close'  => ']]',
                                'sample' => wfMessage( 'media_sample' )->text(),
                                'tip'    => wfMessage( 'media_tip' )->text(),
-                               'key'    => 'M'
                        ) : false,
                        array(
                                'image'  => $wgLang->getImageFile( 'button-nowiki' ),
@@ -3719,7 +3618,6 @@ HTML
                                'close'  => "</nowiki>",
                                'sample' => wfMessage( 'nowiki_sample' )->text(),
                                'tip'    => wfMessage( 'nowiki_tip' )->text(),
-                               'key'    => 'N'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-sig' ),
@@ -3728,7 +3626,6 @@ HTML
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'sig_tip' )->text(),
-                               'key'    => 'Y'
                        ),
                        array(
                                'image'  => $wgLang->getImageFile( 'button-hr' ),
@@ -3737,7 +3634,6 @@ HTML
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'hr_tip' )->text(),
-                               'key'    => 'R'
                        )
                );
 
@@ -3790,7 +3686,7 @@ HTML
         * @return array
         */
        public function getCheckboxes( &$tabindex, $checked ) {
-               global $wgUser;
+               global $wgUser, $wgUseMediaWikiUIEverywhere;
 
                $checkboxes = array();
 
@@ -3804,11 +3700,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;
+                               }
                        }
                }
 
@@ -3820,11 +3724,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;
@@ -3839,6 +3750,8 @@ HTML
         * @return array
         */
        public function getEditButtons( &$tabindex ) {
+               global $wgUseMediaWikiUIEverywhere;
+
                $buttons = array();
 
                $attribs = array(
@@ -3848,6 +3761,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
@@ -3858,6 +3774,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'] = '';
 
@@ -3868,6 +3787,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 ) );
@@ -3904,40 +3826,6 @@ HTML
                echo $s;
        }
 
-       /**
-        * Call the stock "user is blocked" page
-        *
-        * @deprecated since 1.19; throw an exception directly instead
-        */
-       function blockedPage() {
-               wfDeprecated( __METHOD__, '1.19' );
-               global $wgUser;
-
-               throw new UserBlockedError( $wgUser->getBlock() );
-       }
-
-       /**
-        * Produce the stock "please login to edit pages" page
-        *
-        * @deprecated since 1.19; throw an exception directly instead
-        */
-       function userNotLoggedInPage() {
-               wfDeprecated( __METHOD__, '1.19' );
-               throw new PermissionsError( 'edit' );
-       }
-
-       /**
-        * Show an error page saying to the user that he has insufficient permissions
-        * to create a new page
-        *
-        * @deprecated since 1.19; throw an exception directly instead
-        */
-       function noCreatePermission() {
-               wfDeprecated( __METHOD__, '1.19' );
-               $permission = $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage';
-               throw new PermissionsError( $permission );
-       }
-
        /**
         * Creates a basic error page which informs the user that
         * they have attempted to edit a nonexistent section.