SpecialVersion: Handle Closures in $wgHooks nicer
[lhc/web/wiklou.git] / includes / EditPage.php
index 3600fb2..0ca2f80 100644 (file)
@@ -1671,6 +1671,7 @@ class EditPage {
                        }
                }
 
+               $changingContentModel = false;
                if ( $this->contentModel !== $this->mTitle->getContentModel() ) {
                        if ( !$wgContentHandlerUseDB ) {
                                $status->fatal( 'editpage-cannot-use-custom-model' );
@@ -1679,7 +1680,10 @@ class EditPage {
                        } elseif ( !$wgUser->isAllowed( 'editcontentmodel' ) ) {
                                $status->setResult( false, self::AS_NO_CHANGE_CONTENT_MODEL );
                                return $status;
+
                        }
+                       $changingContentModel = true;
+                       $oldContentModel = $this->mTitle->getContentModel();
                }
 
                if ( $this->changeTags ) {
@@ -1978,9 +1982,39 @@ class EditPage {
                        } );
                }
 
+               // If the content model changed, add a log entry
+               if ( $changingContentModel ) {
+                       $this->addContentModelChangeLogEntry(
+                               $wgUser,
+                               $oldContentModel,
+                               $this->contentModel,
+                               $this->summary
+                       );
+               }
+
                return $status;
        }
 
+       /**
+        * @param Title $title
+        * @param string $oldModel
+        * @param string $newModel
+        * @param string $reason
+        */
+       protected function addContentModelChangeLogEntry( User $user, $oldModel, $newModel, $reason ) {
+               $log = new ManualLogEntry( 'contentmodel', 'change' );
+               $log->setPerformer( $user );
+               $log->setTarget( $this->mTitle );
+               $log->setComment( $reason );
+               $log->setParameters( array(
+                       '4::oldmodel' => $oldModel,
+                       '5::newmodel' => $newModel
+               ) );
+               $logid = $log->insert();
+               $log->publish( $logid );
+       }
+
+
        /**
         * Register the change of watch status
         */
@@ -2511,7 +2545,7 @@ class EditPage {
                $wgOut->addHTML( $this->editFormTextBeforeContent );
 
                if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) {
-                       $wgOut->addHTML( EditPage::getEditToolbar() );
+                       $wgOut->addHTML( EditPage::getEditToolbar( $this->mTitle ) );
                }
 
                if ( $this->blankArticle ) {
@@ -3411,7 +3445,7 @@ HTML
 
                $this->deletedSinceEdit = false;
 
-               if ( $this->mTitle->isDeletedQuick() ) {
+               if ( !$this->mTitle->exists() && $this->mTitle->isDeletedQuick() ) {
                        $this->lastDelete = $this->getLastDelete();
                        if ( $this->lastDelete ) {
                                $deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp );
@@ -3652,13 +3686,18 @@ HTML
         * Shows a bulletin board style toolbar for common editing functions.
         * It can be disabled in the user preferences.
         *
+        * @param $title Title object for the page being edited (optional)
         * @return string
         */
-       static function getEditToolbar() {
+       static function getEditToolbar( $title = null ) {
                global $wgContLang, $wgOut;
                global $wgEnableUploads, $wgForeignFileRepos;
 
                $imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
+               $showSignature = true;
+               if ( $title ) {
+                        $showSignature = MWNamespace::wantSignatures( $title->getNamespace() );
+               }
 
                /**
                 * $toolarray is an array of arrays each of which includes the
@@ -3726,13 +3765,13 @@ HTML
                                'sample' => wfMessage( 'nowiki_sample' )->text(),
                                'tip'    => wfMessage( 'nowiki_tip' )->text(),
                        ),
-                       array(
+                       $showSignature ? array(
                                'id'     => 'mw-editbutton-signature',
                                'open'   => '--~~~~',
                                'close'  => '',
                                'sample' => '',
                                'tip'    => wfMessage( 'sig_tip' )->text(),
-                       ),
+                       ) : false,
                        array(
                                'id'     => 'mw-editbutton-hr',
                                'open'   => "\n----\n",