URL-encode the content-disposition suggested filename for XML export data.
[lhc/web/wiklou.git] / includes / SpecialUndelete.php
index e450884..8f49a29 100644 (file)
@@ -4,21 +4,21 @@
  * Special page allowing users with the appropriate permissions to view
  * and restore deleted content
  *
- * @addtogroup Special pages
+ * @addtogroup SpecialPage
  */
 
 /**
- *
+ * Constructor
  */
 function wfSpecialUndelete( $par ) {
-    global $wgRequest;
+       global $wgRequest;
 
        $form = new UndeleteForm( $wgRequest, $par );
        $form->execute();
 }
 
 /**
- *
+ * Used to show archived pages and eventually restore them.
  * @addtogroup SpecialPage
  */
 class PageArchive {
@@ -114,7 +114,7 @@ class PageArchive {
         * if not a file page.
         *
         * @return ResultWrapper
-        * @fixme Does this belong in Image for fuller encapsulation?
+        * @todo Does this belong in Image for fuller encapsulation?
         */
        function listFiles() {
                if( $this->title->getNamespace() == NS_IMAGE ) {
@@ -269,7 +269,7 @@ class PageArchive {
                $restoreFiles = $restoreAll || !empty( $fileVersions );
                
                if( $restoreFiles && $this->title->getNamespace() == NS_IMAGE ) {
-                       $img = new Image( $this->title );
+                       $img = wfLocalFile( $this->title );
                        $filesRestored = $img->restore( $fileVersions );
                } else {
                        $filesRestored = 0;
@@ -319,8 +319,6 @@ class PageArchive {
         * @return int number of revisions restored
         */
        private function undeleteRevisions( $timestamps ) {
-               global $wgDBtype;
-
                $restoreAll = empty( $timestamps );
                
                $dbw = wfGetDB( DB_MASTER );
@@ -328,9 +326,7 @@ class PageArchive {
 
                # Does this page already exist? We'll have to update it...
                $article = new Article( $this->title );
-               $options = ( $wgDBtype == 'postgres' )
-                       ? '' // pg doesn't support this?
-                       : 'FOR UPDATE';
+               $options = 'FOR UPDATE';
                $page = $dbw->selectRow( 'page',
                        array( 'page_id', 'page_latest' ),
                        array( 'page_namespace' => $this->title->getNamespace(),
@@ -422,11 +418,10 @@ class PageArchive {
                }
 
                if( $revision ) {
-                       # FIXME: Update latest if newer as well...
-                       if( $newid ) {
-                               // Attach the latest revision to the page...
-                               $article->updateRevisionOn( $dbw, $revision, $previousRevId );
-                               
+                       // Attach the latest revision to the page...
+                       $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId );
+
+                       if( $newid || $wasnew ) {
                                // Update site stats, link tables, etc
                                $article->createUpdates( $revision );
                        }
@@ -456,7 +451,8 @@ class PageArchive {
 }
 
 /**
- *
+ * The HTML form for Special:Undelete, which allows users with the appropriate
+ * permissions to view and restore deleted content.
  * @addtogroup SpecialPage
  */
 class UndeleteForm {
@@ -616,7 +612,7 @@ class UndeleteForm {
                
                if( $this->mPreview ) {
                        $wgOut->addHtml( "<hr />\n" );
-                       $wgOut->addWikiTextTitle( $rev->getText(), $this->mTargetObj, false );
+                       $wgOut->addWikiTextTitleTidy( $rev->getText(), $this->mTargetObj, false );
                }
 
                $wgOut->addHtml(
@@ -853,4 +849,4 @@ class UndeleteForm {
        }
 }
 
-?>
+