Merge "New hook for readonly editpages"
[lhc/web/wiklou.git] / includes / EditPage.php
index f57fc60..d0bd7c7 100644 (file)
@@ -511,6 +511,8 @@ class EditPage {
                        throw new PermissionsError( $action, $permErrors );
                }
 
+               wfRunHooks( 'EditPage::showReadOnlyForm:initial', array( $this, &$wgOut ) );
+
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->setPageTitle( wfMessage( 'viewsource-title', $this->getContextTitle()->getPrefixedText() ) );
                $wgOut->addBacklinkSubtitle( $this->getContextTitle() );
@@ -910,14 +912,15 @@ class EditPage {
                                $preload = $wgRequest->getVal( 'preload',
                                        // Custom preload text for new sections
                                        $this->section === 'new' ? 'MediaWiki:addsection-preload' : '' );
+                               $params = $wgRequest->getArray( 'preloadparams', array() );
 
-                               $content = $this->getPreloadedContent( $preload );
+                               $content = $this->getPreloadedContent( $preload, $params );
                        }
                // For existing pages, get text based on "undo" or section parameters.
                } else {
                        if ( $this->section != '' ) {
                                // Get section edit text (returns $def_text for invalid sections)
-                               $orig = $this->getOriginalContent();
+                               $orig = $this->getOriginalContent( $wgUser );
                                $content = $orig ? $orig->getSection( $this->section ) : null;
 
                                if ( !$content ) {
@@ -999,7 +1002,7 @@ class EditPage {
                                }
 
                                if ( $content === false ) {
-                                       $content = $this->getOriginalContent();
+                                       $content = $this->getOriginalContent( $wgUser );
                                }
                        }
                }
@@ -1020,9 +1023,10 @@ class EditPage {
         * 'missing-revision' message.
         *
         * @since 1.19
+        * @param User $user The user to get the revision for
         * @return Content|null
         */
-       private function getOriginalContent() {
+       private function getOriginalContent( User $user ) {
                if ( $this->section == 'new' ) {
                        return $this->getCurrentContent();
                }
@@ -1035,7 +1039,7 @@ class EditPage {
 
                        return $handler->makeEmptyContent();
                }
-               $content = $revision->getContent();
+               $content = $revision->getContent( Revision::FOR_THIS_USER, $user );
                return $content;
        }
 
@@ -1116,12 +1120,13 @@ class EditPage {
         * an earlier setPreloadText() or by loading the given page.
         *
         * @param string $preload representing the title to preload from.
+        * @param Array $params Parameters to use (interface-message style) in the preloaded text
         *
         * @return Content
         *
         * @since 1.21
         */
-       protected function getPreloadedContent( $preload ) {
+       protected function getPreloadedContent( $preload, $params = array() ) {
                global $wgUser;
 
                if ( !empty( $this->mPreloadContent ) ) {
@@ -1175,7 +1180,7 @@ class EditPage {
                        $content = $converted;
                }
 
-               return $content->preloadTransform( $title, $parserOptions );
+               return $content->preloadTransform( $title, $parserOptions, $params );
        }
 
        /**
@@ -1341,8 +1346,8 @@ class EditPage {
         * Run hooks that can filter edits just before they get saved.
         *
         * @param Content $content the Content to filter.
-        * @param Status  $status for reporting the outcome to the caller
-        * @param User    $user the user performing the edit
+        * @param Status $status For reporting the outcome to the caller
+        * @param User $user The user performing the edit
         *
         * @return bool
         */
@@ -1734,7 +1739,7 @@ class EditPage {
                                        return $status;
                                }
                        } elseif ( !$this->allowBlankSummary
-                               && !$content->equals( $this->getOriginalContent() )
+                               && !$content->equals( $this->getOriginalContent( $wgUser ) )
                                && !$content->isRedirect()
                                && md5( $this->summary ) == $this->autoSumm
                        ) {
@@ -2603,11 +2608,11 @@ class EditPage {
        }
 
        /**
-        * @param $isSubjectPreview Boolean: true if this is the section subject/title
-        *                          up top, or false if this is the comment summary
-        *                          down below the textarea
+        * @param bool $isSubjectPreview true if this is the section subject/title
+        *   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
+        * @return string
         */
        protected function showSummaryInput( $isSubjectPreview, $summary = "" ) {
                global $wgOut, $wgContLang;
@@ -2629,11 +2634,11 @@ class EditPage {
        }
 
        /**
-        * @param $isSubjectPreview Boolean: true if this is the section subject/title
-        *                          up top, or false if this is the comment summary
-        *                          down below the textarea
+        * @param bool $isSubjectPreview true if this is the section subject/title
+        *   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
+        * @return string
         */
        protected function getSummaryPreview( $isSubjectPreview, $summary = "" ) {
                // avoid spaces in preview, gets always trimmed on save
@@ -3417,15 +3422,6 @@ HTML
                                'tip'    => wfMessage( 'media_tip' )->text(),
                                'key'    => 'M'
                        ) : false,
-                       class_exists( 'MathRenderer' ) ? array(
-                               'image'  => $wgLang->getImageFile( 'button-math' ),
-                               'id'     => 'mw-editbutton-math',
-                               'open'   => "<math>",
-                               'close'  => "</math>",
-                               'sample' => wfMessage( 'math_sample' )->text(),
-                               'tip'    => wfMessage( 'math_tip' )->text(),
-                               'key'    => 'C'
-                       ) : false,
                        array(
                                'image'  => $wgLang->getImageFile( 'button-nowiki' ),
                                'id'     => 'mw-editbutton-nowiki',