Added iterator interface to ResultWrapper. No support in Oracle yet. Updated document...
[lhc/web/wiklou.git] / includes / ImagePage.php
index 46846ec..3265b7f 100644 (file)
@@ -108,7 +108,7 @@ class ImagePage extends Article {
                        <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
                        <li><a href="#filehistory">' . wfMsgHtml( 'imghistory' ) . '</a></li>
                        <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
-                       ($metadata ? '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
+                       ($metadata ? ' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
                </ul>';
                return $r;
        }
@@ -274,7 +274,7 @@ class ImagePage extends Article {
                                        if ( $page > 1 ) {
                                                $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
                                                $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
-                                               $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $link, $label, 'none', 
+                                               $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none', 
                                                        array( 'page' => $page - 1 ) );
                                        } else {
                                                $thumb1 = '';
@@ -460,6 +460,8 @@ EOT
                } else { $s=''; }
                $wgOut->addHTML( $s );
 
+               $this->img->resetHistory();     // free db resources
+
                # Exist check because we don't want to show this on pages where an image
                # doesn't exist along with the noimage message, that would suck. -ævar
                if( $wgUseExternalEditor && $this->img->exists() ) {
@@ -502,6 +504,12 @@ EOT
        {
                global $wgUser, $wgOut, $wgRequest;
 
+               if ( !$this->img->exists() || !$this->img->isLocal() ) {
+                       # Use standard article deletion
+                       Article::delete();
+                       return;
+               }
+
                $confirm = $wgRequest->wasPosted();
                $reason = $wgRequest->getVal( 'wpReason' );
                $image = $wgRequest->getVal( 'image' );
@@ -533,7 +541,7 @@ EOT
                # Deleting old images doesn't require confirmation
                if ( !is_null( $oldimage ) || $confirm ) {
                        if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
-                               $this->doDelete( $reason );
+                               $this->doDeleteImage( $reason );
                        } else {
                                $wgOut->showFatalError( wfMsg( 'sessionfailure' ) );
                        }
@@ -552,9 +560,12 @@ EOT
 
        /*
         * Delete an image.
+        * Called doDeleteImage() not doDelete() so that Article::delete() doesn't 
+        * call back to here.
+        *
         * @param $reason User provided reason for deletion.
         */
-       function doDelete( $reason ) {
+       function doDeleteImage( $reason ) {
                global $wgOut, $wgRequest;
 
                $oldimage = $wgRequest->getVal( 'oldimage' );
@@ -655,16 +666,14 @@ EOT
                }
 
                $sourcePath = $this->img->getArchiveVirtualUrl( $oldimage );
-               $result = $this->img->publish( $sourcePath );
+               $comment = wfMsg( "reverted" );
+               $result = $this->img->upload( $sourcePath, $comment, $comment );
 
                if ( WikiError::isError( $result ) ) {
                        $this->showError( $result );
                        return;
                }
 
-               # Record upload and update metadata cache
-               $this->img->recordUpload( $result, wfMsg( "reverted" ) );
-
                $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
                $wgOut->addHTML( wfMsg( 'imagereverted' ) );
@@ -785,4 +794,4 @@ class ImageHistoryList {
 }
 
 
-?>
+