replace TYPE= with ENGINE=, (supported since 4.0, TYPE deprecated since 4.1)
[lhc/web/wiklou.git] / includes / EditPage.php
index 1aad75f..480533c 100644 (file)
@@ -26,6 +26,7 @@ class EditPage {
        var $mTokenOk = true;
        var $tooBig = false;
        var $kblength = false;
+       var $missingComment = false;
 
        # Form values
        var $save = false, $preview = false, $diff = false;
@@ -155,8 +156,8 @@ class EditPage {
         * the newly-edited page.
         */
        function edit() {
-               global $wgOut, $wgUser, $wgRequest, $wgTitle,
-                      $wgEmailConfirmToEdit;
+               global $wgOut, $wgUser, $wgRequest, $wgTitle;
+               global $wgEmailConfirmToEdit;
 
                if ( ! wfRunHooks( 'AlternateEdit', array( &$this  ) ) )
                        return;
@@ -250,7 +251,8 @@ class EditPage {
 
                $this->isConflict = false;
                // css / js subpages of user pages get a special treatment
-               $this->isCssJsSubpage = $wgTitle->isCssJsSubpage();
+               $this->isCssJsSubpage      = $wgTitle->isCssJsSubpage();
+               $this->isValidCssJsSubpage = $wgTitle->isValidCssJsSubpage();
 
                /* Notice that we can't use isDeleted, because it returns true if article is ever deleted
                 * no matter it's current state
@@ -629,6 +631,10 @@ class EditPage {
                wfProfileIn( "$fname-sectionanchor" );
                $sectionanchor = '';
                if( $this->section == 'new' ) {
+                       if ( $this->textbox1 == '' ) {
+                               $this->missingComment = true;
+                               return true;
+                       }
                        if( $this->summary != '' ) {
                                $sectionanchor = $this->sectionAnchor( $this->summary );
                        }
@@ -734,6 +740,11 @@ class EditPage {
                                $s = wfMsg( 'editing', $this->mTitle->getPrefixedText() );
                        }
                        $wgOut->setPageTitle( $s );
+
+                       if ( $this->missingComment ) {
+                               $wgOut->addWikiText( wfMsg( 'missingcommenttext' ) );
+                       }
+
                        if ( !$this->checkUnicodeCompliantBrowser() ) {
                                $wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );
                        }
@@ -747,12 +758,19 @@ class EditPage {
 
                if( wfReadOnly() ) {
                        $wgOut->addWikiText( wfMsg( 'readonlywarning' ) );
-               } else if ( $this->isCssJsSubpage and 'preview' != $this->formtype) {
-                       $wgOut->addWikiText( wfMsg( 'usercssjsyoucanpreview' ));
-               } else if( $wgUser->isAnon() && $this->formtype != 'preview' ) {
+               } elseif( $wgUser->isAnon() && $this->formtype != 'preview' ) {
                        $wgOut->addWikiText( wfMsg( 'anoneditwarning' ) );
+               } else {
+                       if( $this->isCssJsSubpage && $this->formtype != 'preview' ) {
+                               # Check the skin exists
+                               if( $this->isValidCssJsSubpage ) {
+                                       $wgOut->addWikiText( wfMsg( 'usercssjsyoucanpreview' ) );
+                               } else {
+                                       $wgOut->addWikiText( wfMsg( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ) );
+                               }
+                       }
                }
-               
+                       
                if( $this->mTitle->isProtected( 'edit' ) ) {
                        if( $this->mTitle->isSemiProtected() ) {
                                $notice = wfMsg( 'semiprotectedpagewarning' );
@@ -922,7 +940,7 @@ class EditPage {
                $buttons['diff'] = wfElement('input', $temp, '');
 
                global $wgLivePreview;
-               if ( $wgLivePreview ) {
+               if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
                        $temp = array(
                                'id'        => 'wpPreview',
                                'name'      => 'wpPreview',
@@ -1200,7 +1218,7 @@ END
                        } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) {
                                $previewtext = wfMsg('userjspreview');
                        }
-                        $parserOptions->setTidy(true);
+                       $parserOptions->setTidy(true);
                        $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
                        $wgOut->addHTML( $parserOutput->mText );
                        wfProfileOut( $fname );
@@ -1220,7 +1238,7 @@ END
                        }
 
                        if ( $this->mMetaData != "" ) $toparse .= "\n" . $this->mMetaData ;
-                        $parserOptions->setTidy(true);
+                       $parserOptions->setTidy(true);
                        $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ) ."\n\n",
                                        $wgTitle, $parserOptions );
 
@@ -1527,8 +1545,6 @@ END
         * @return string HTML
         */
        function getDiff() {
-               global $wgUser;
-
                require_once( 'DifferenceEngine.php' );
                $oldtext = $this->mArticle->fetchContent();
                $newtext = $this->mArticle->replaceSection(