Revert r55800 "bug 19646 Localization of img_auth.php - with enhancements"
[lhc/web/wiklou.git] / includes / EditPage.php
index 3bc1037..42c74c9 100644 (file)
@@ -365,7 +365,7 @@ class EditPage {
        function edit() {
                global $wgOut, $wgRequest, $wgEnableJS2system;
                // Allow extensions to modify/prevent this form or submission
-               if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) {
+               if ( !wfRunHooks( 'AlternateEdit', array( $this ) ) ) {
                        return;
                }
 
@@ -675,7 +675,7 @@ class EditPage {
                wfProfileOut( $fname );
 
                // Allow extensions to modify form data
-               wfRunHooks( 'EditPage::importFormData', array( &$this, $request ) );
+               wfRunHooks( 'EditPage::importFormData', array( $this, $request ) );
        }
 
        /**
@@ -767,7 +767,7 @@ class EditPage {
                wfProfileIn( $fname );
                wfProfileIn( "$fname-checks" );
 
-               if ( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) )
+               if ( !wfRunHooks( 'EditPage::attemptSave', array( $this ) ) )
                {
                        wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
                        return self::AS_HOOK_ERROR;
@@ -886,10 +886,14 @@ class EditPage {
                        }
 
                        // Run post-section-merge edit filter
-                       if ( !wfRunHooks( 'EditFilterMerged', array( &$this, $this->textbox1, &$this->hookError, $this->summary ) ) ) {
+                       if ( !wfRunHooks( 'EditFilterMerged', array( $this, $this->textbox1, &$this->hookError, $this->summary ) ) ) {
                                # Error messages etc. could be handled within the hook...
                                wfProfileOut( $fname );
                                return self::AS_HOOK_ERROR;
+                       } elseif ( $this->hookError != '' ) {
+                               # ...or the hook could be expecting us to produce an error
+                               wfProfileOut( $fname );
+                               return self::AS_HOOK_ERROR_EXPECTED;
                        }
                        
                        # Handle the user preference to force summaries here. Check if it's not a redirect.
@@ -974,10 +978,14 @@ class EditPage {
                $oldtext = $this->mArticle->getContent();
 
                // Run post-section-merge edit filter
-               if ( !wfRunHooks( 'EditFilterMerged', array( &$this, $text, &$this->hookError, $this->summary ) ) ) {
+               if ( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError, $this->summary ) ) ) {
                        # Error messages etc. could be handled within the hook...
                        wfProfileOut( $fname );
                        return self::AS_HOOK_ERROR;
+               } elseif ( $this->hookError != '' ) {
+                       # ...or the hook could be expecting us to produce an error
+                       wfProfileOut( $fname );
+                       return self::AS_HOOK_ERROR_EXPECTED;
                }
 
                # Handle the user preference to force summaries here, but not for null edits
@@ -1245,16 +1253,15 @@ class EditPage {
                } else {
                        if ( $this->isCssJsSubpage ) {
                                # Check the skin exists
-                               if ( $this->isValidCssJsSubpage ) {
-                                       if ( $this->formtype !== 'preview' ) {
-                                               if ( $this->isCssSubpage )
-                                                       $wgOut->addWikiMsg( 'usercssyoucanpreview' );
-                                               if ( $this->isJsSubpage )
-                                                       $wgOut->addWikiMsg( 'userjsyoucanpreview' );
-                                       }
-                               } else {
+                               if ( !$this->isValidCssJsSubpage ) {
                                        $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
                                }
+                               if ( $this->formtype !== 'preview' ) {
+                                       if ( $this->isCssSubpage )
+                                               $wgOut->addWikiMsg( 'usercssyoucanpreview' );
+                                       if ( $this->isJsSubpage )
+                                               $wgOut->addWikiMsg( 'userjsyoucanpreview' );
+                               }
                        }
                }
 
@@ -1314,7 +1321,7 @@ class EditPage {
                $cancel = $sk->link(
                        $wgTitle,
                        wfMsgExt( 'cancel', array( 'parseinline' ) ),
-                       array(),
+                       array( 'id' => 'mw-editform-cancel' ),
                        array(),
                        array( 'known', 'noclasses' )
                );
@@ -1410,11 +1417,13 @@ class EditPage {
                                                                                'maxlength' => '200',
                                                                                'tabindex' => '1'
                                                                        ) );
+                       } else {
+                               $summaryhiddens .= Xml::hidden( 'wpIgnoreBlankSummary', true ); # bug 18699
                        }
                        $editsummary = "<div class='editOptions'>\n";
                        global $wgParser;
                        $formattedSummary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $this->summary ) );
-                       $subjectpreview = $summarytext && $this->preview ?
+                       $subjectpreview = $summarytext && ( $this->preview || $this->diff ) ?
                                "<div class=\"mw-summary-preview\">". wfMsgExt('subject-preview', 'parseinline') . $sk->commentBlock( $formattedSummary, $this->mTitle, true )."</div>\n" : '';
                        $summarypreview = '';
                } else {
@@ -1441,7 +1450,7 @@ class EditPage {
                                                        . $editsummary . '<br/>';
 
                        $summarypreview = '';
-                       if ( $summarytext && $this->preview ) {
+                       if ( $summarytext && ( $this->preview || $this->diff ) ) {
                                $summarypreview =
                                        Xml::tags( 'div',
                                                array( 'class' => 'mw-summary-preview' ),
@@ -1580,6 +1589,12 @@ END
 END
 );
 
+               if (!$this->preview) {
+                       $wgOut->addHTML( Xml::tags( 'div',
+                                                                               array( 'class' => 'catlinks catlinks-allhidden',
+                                                                                               'id' => 'catlinks' ), ' ' ) );
+               }
+
                if ( $this->isConflict && wfRunHooks( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) {
                        $wgOut->wrapWikiMsg( '==$1==', "yourdiff" );
 
@@ -1705,14 +1720,7 @@ END
        function doLivePreviewScript() {
                global $wgOut, $wgTitle;
                $wgOut->addScriptFile( 'preview.js' );
-               $liveAction = $wgTitle->getLocalUrl( array(
-                       'action' => $this->action,
-                       'wpPreview' => 'true',
-                       'live' => 'true'
-               ) );
-               return "return !lpDoPreview(" .
-                       "editform.wpTextbox1.value," .
-                       '"' . $liveAction . '"' . ")";
+               return "";
        }
 
        protected function showTosSummary() {
@@ -2055,7 +2063,7 @@ END
         * @return string
         */
        static function getEditToolbar() {
-               global $wgStylePath, $wgContLang, $wgLang, $wgJsMimeType;
+               global $wgStylePath, $wgContLang, $wgLang;
 
                /**
                 * toolarray an array of arrays which each include the filename of
@@ -2170,9 +2178,9 @@ END
                        )
                );
                $toolbar = "<div id='toolbar'>\n";
-               $toolbar.="<script type='$wgJsMimeType'>\n/*<![CDATA[*/\n";
 
-               foreach($toolarray as $tool) {
+               $script = '';
+               foreach ( $toolarray as $tool ) {
                        $params = array(
                                $image = $wgStylePath.'/common/images/'.$tool['image'],
                                // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
@@ -2188,11 +2196,11 @@ END
 
                        $paramList = implode( ',',
                                array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
-                       $toolbar.="addButton($paramList);\n";
+                       $script .= "addButton($paramList);\n";
                }
+               $toolbar .= Html::inlineScript( "\n$script\n" );
 
-               $toolbar.="/*]]>*/\n</script>";
-               $toolbar.="\n</div>";
+               $toolbar .= "\n</div>";
 
                wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
 
@@ -2270,6 +2278,8 @@ END
 
                ++$tabindex; // use the same for preview and live preview
                if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
+                       $this->doLivePreviewScript(); // Add to output
+                       
                        $temp = array(
                                'id'        => 'wpPreview',
                                'name'      => 'wpPreview',
@@ -2290,8 +2300,8 @@ END
                                'value'     => wfMsg('showlivepreview'),
                                'accesskey' => wfMsg('accesskey-preview'),
                                'title'     => '',
-                               'onclick'   => $this->doLivePreviewScript(),
                        );
+                       
                        $buttons['live'] = Xml::element('input', $temp, '');
                } else {
                        $temp = array(
@@ -2322,36 +2332,6 @@ END
                return $buttons;
        }
 
-       /**
-        * Output preview text only. This can be sucked into the edit page
-        * via JavaScript, and saves the server time rendering the skin as
-        * well as theoretically being more robust on the client (doesn't
-        * disturb the edit box's undo history, won't eat your text on
-        * failure, etc).
-        *
-        * @todo This doesn't include category or interlanguage links.
-        *       Would need to enhance it a bit, <s>maybe wrap them in XML
-        *       or something...</s> that might also require more skin
-        *       initialization, so check whether that's a problem.
-        */
-       function livePreview() {
-               global $wgOut;
-               $wgOut->disable();
-               header( 'Content-type: text/xml; charset=utf-8' );
-               header( 'Cache-control: no-cache' );
-
-               $previewText = $this->getPreviewText();
-               #$categories = $skin->getCategoryLinks();
-
-               $s =
-               '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" .
-               Xml::tags( 'livepreview', null,
-                       Xml::element( 'preview', null, $previewText )
-                       #.      Xml::element( 'category', null, $categories )
-               );
-               echo $s;
-       }
-
 
        /**
         * Get a diff between the current contents of the edit box and the