Fix live preview copying of existing category links
authorAndrew Garrett <werdna@users.mediawiki.org>
Tue, 25 Aug 2009 15:09:40 +0000 (15:09 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Tue, 25 Aug 2009 15:09:40 +0000 (15:09 +0000)
includes/Article.php
includes/EditPage.php
includes/Skin.php
skins/common/preview.js

index eca3883..eead44f 100644 (file)
@@ -2604,6 +2604,8 @@ class Article {
                $wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->addWikiMsg( 'confirmdeletetext' );
+               
+               wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
 
                if( $wgUser->isAllowed( 'suppressrevision' ) ) {
                        $suppress = "<tr id=\"wpDeleteSuppressRow\" name=\"wpDeleteSuppressRow\">
@@ -2703,14 +2705,14 @@ class Article {
                                $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
                                $wgOut->returnToMain( false );
                                wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id));
+                       }
+               } else {
+                       if( $error == '' ) {
+                               $wgOut->showFatalError( wfMsgExt( 'cannotdelete', array( 'parse' ) ) );
+                               $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
+                               LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() );
                        } else {
-                               if( $error == '' ) {
-                                       $wgOut->showFatalError( wfMsgExt( 'cannotdelete', array( 'parse' ) ) );
-                                       $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
-                                       LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() );
-                               } else {
-                                       $wgOut->showFatalError( $error );
-                               }
+                               $wgOut->showFatalError( $error );
                        }
                }
        }
index 456152f..d66f0c3 100644 (file)
@@ -1581,6 +1581,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 +2324,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
index ab41d29..c4c7c33 100644 (file)
@@ -902,14 +902,11 @@ END;
 
                $classes = 'catlinks';
 
-               if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
-                       strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
+               if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false ) {
                        $classes .= ' catlinks-allhidden';
                }
 
-               if( !empty( $catlinks ) ){
-                       return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
-               }
+               return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
        }
 
        function getQuickbarCompensator( $rows = 1 ) {
index b9fef56..5aaa85a 100644 (file)
@@ -33,7 +33,10 @@ function doLivePreview( e ) {
                                //  with the content of the loaded page
                                var copyContent = page.find( copyElements[i] ).contents();
                                $j(copyElements[i]).empty().append( copyContent );
+                               var newClasses = page.find( copyElements[i] ).attr('class');
+                               $j(copyElements[i]).attr( 'class', newClasses );
                        }
+                       
                        $j('#wikiPreview').slideDown();
                } );
 }