Follow-up on r56284: LogEventsList::showLogExtract gets associative array for additio...
[lhc/web/wiklou.git] / includes / EditPage.php
index 23eb600..bf7bb63 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;
                }
 
@@ -385,14 +385,14 @@ class EditPage {
                }
 
                if ( wfReadOnly() && $this->save ) {
-                               // Force preview
-                               $this->save = false;
-                               $this->preview = true;
+                       // Force preview
+                       $this->save = false;
+                       $this->preview = true;
                }
 
                $wgOut->addScriptFile( 'edit.js' );
 
-               if($wgEnableJS2system)
+               if( $wgEnableJS2system )
                    $wgOut->addScriptClass( 'editPage' );
 
                $permErrors = $this->getEditPermissionErrors();
@@ -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 ) );
        }
 
        /**
@@ -730,7 +730,12 @@ class EditPage {
                }
                # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
-                       $this->showLogs( $wgOut );
+                       LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(), 
+                               '', array( 'lim' => 10, 
+                                          'conds' => array( "log_action != 'revision'" ), 
+                                          'showIfEmpty' => false, 
+                                          'msgKey' => array( 'recreate-moveddeleted-warn') ) 
+                       );
                }
        }
 
@@ -767,7 +772,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 +891,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 +983,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
@@ -1269,10 +1282,8 @@ class EditPage {
                                $noticeMsg = 'protectedpagewarning';
                                $classes[] = 'mw-textarea-protected';
                        }
-                       $wgOut->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
-                       $wgOut->addWikiMsg( $noticeMsg );
-                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1 );
-                       $wgOut->addHTML( "</div>\n" );
+                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 
+                               array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) );
                }
                if ( $this->mTitle->isCascadeProtected() ) {
                        # Is this page under cascading protection from some source pages?
@@ -1581,6 +1592,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" );
 
@@ -2318,36 +2335,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
@@ -2497,42 +2484,6 @@ END
                $wgOut->addWikiMsg( 'nocreatetext' );
        }
 
-       /**
-        * If there are rows in the deletion/move log for this page, show them,
-        * along with a nice little note for the user
-        *
-        * @param OutputPage $out
-        */
-       protected function showLogs( $out ) {
-               global $wgUser;
-               $loglist = new LogEventsList( $wgUser->getSkin(), $out );
-               $pager = new LogPager( $loglist, array('move', 'delete'), false,
-                       $this->mTitle->getPrefixedText(), '', array( "log_action != 'revision'" ) );
-
-               $count = $pager->getNumRows();
-               if ( $count > 0 ) {
-                       $pager->mLimit = 10;
-                       $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
-                       $out->addWikiMsg( 'recreate-moveddeleted-warn' );
-                       $out->addHTML(
-                               $loglist->beginLogEventsList() .
-                               $pager->getBody() .
-                               $loglist->endLogEventsList()
-                       );
-                       if($count > 10){
-                               $out->addHTML( $wgUser->getSkin()->link(
-                                       SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'log-fulllog' ),
-                                       array(),
-                                       array( 'page' => $this->mTitle->getPrefixedText() ) ) );
-                       }
-                       $out->addHTML( '</div>' );
-                       return true;
-               }
-               
-               return false;
-       }
-
        /**
         * Attempt submission
         * @return bool false if output is done, true if the rest of the form should be displayed