Fix retarded mistake in 57997, move break to within the if block or it defeats the...
[lhc/web/wiklou.git] / includes / EditPage.php
index 5709a98..7d4fccd 100644 (file)
@@ -83,6 +83,8 @@ class EditPage {
        public $editFormTextAfterWarn;
        public $editFormTextAfterTools;
        public $editFormTextBottom;
+       public $editFormTextAfterContent;
+       public $previewTextAfterContent;
 
        /* $didSave should be set to true whenever an article was succesfully altered. */
        public $didSave = false;
@@ -106,6 +108,8 @@ class EditPage {
                $this->editFormTextAfterWarn =
                $this->editFormTextAfterTools =
                $this->editFormTextBottom =
+               $this->editFormTextAfterContent =
+               $this->previewTextAfterContent =
                $this->mPreloadText = "";
        }
        
@@ -138,7 +142,7 @@ class EditPage {
                                $wgMessageCache->loadAllMessages( $lang );
                                $text = wfMsgGetKey( $message, false, $lang, false );
                                if( wfEmptyMsg( $message, $text ) )
-                                       $text = '';
+                                       $text = $this->getPreloadedText( $preload );
                        } else {
                                # If requested, preload some text.
                                $text = $this->getPreloadedText( $preload );
@@ -1547,6 +1551,8 @@ END
 END
 );
                $this->showTextbox1( $classes );
+               
+               $wgOut->addHTML( $this->editFormTextAfterContent );
 
                $wgOut->wrapWikiMsg( "<div id=\"editpage-copywarn\">\n$1\n</div>", $copywarnMsg );
                $wgOut->addHTML( <<<END
@@ -1870,7 +1876,7 @@ END
                        $wgOut->parse( $note ) . $conflict . "</div>\n";
 
                wfProfileOut( __METHOD__ );
-               return $previewhead . $previewHTML;
+               return $previewhead . $previewHTML . $this->previewTextAfterContent;
        }
        
        function getTemplates() {
@@ -2261,8 +2267,6 @@ END
         * @return array
         */
        public function getEditButtons(&$tabindex) {
-               global $wgLivePreview, $wgUser;
-
                $buttons = array();
 
                $temp = array(
@@ -2277,7 +2281,7 @@ END
                $buttons['save'] = Xml::element('input', $temp, '');
 
                ++$tabindex; // use the same for preview and live preview
-               if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
+               if ( $this->useLivePreview() ) {
                        $this->doLivePreviewScript(); // Add to output
                        
                        $temp = array(
@@ -2288,7 +2292,6 @@ END
                                'value'     => wfMsg('showpreview'),
                                'accesskey' => '',
                                'title'     => wfMsg( 'tooltip-preview' ).' ['.wfMsg( 'accesskey-preview' ).']',
-                               'style'     => 'display: none;',
                        );
                        $buttons['preview'] = Xml::element('input', $temp, '');
 
@@ -2300,6 +2303,7 @@ END
                                'value'     => wfMsg('showlivepreview'),
                                'accesskey' => wfMsg('accesskey-preview'),
                                'title'     => '',
+                               'style'     => 'display: none;',
                        );
                        
                        $buttons['live'] = Xml::element('input', $temp, '');
@@ -2332,6 +2336,21 @@ END
                return $buttons;
        }
 
+       /**
+        * Whether to use live preview for this page
+        * This disables live preview when editing css/js user subpages so that the
+        * user can preview them (bug 3421)
+        *
+        * @return Boolean
+        */
+       public function useLivePreview() {
+               global $wgLivePreview, $wgUser;
+
+               return $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) &&
+                       !( ( $this->mTitle->isCssSubpage() && $this->mTitle->userCanEditCssSubpage() ) ||
+                       ( $this->mTitle->isJsSubpage() && $this->mTitle->userCanEditCssSubpage() ) );
+       }
+
        /**
         * Output preview text only. This can be sucked into the edit page
         * via JavaScript, and saves the server time rendering the skin as