Index: branches/extensionless-files/includes/FileRevertForm.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | |
66 | 66 | // Perform the reversion if appropriate |
67 | 67 | if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->archiveName ) ) { |
68 | | - $source = $this->file->getArchiveVirtualUrl( $this->archiveName ); |
| 68 | + $source = $this->file->getArchiveVirtualUrl( $this->getOldFile()->getArchiveFilename() ); |
69 | 69 | $comment = $wgRequest->getText( 'wpComment' ); |
70 | 70 | // TODO: Preserve file properties from database instead of reloading from file |
71 | 71 | $status = $this->file->upload( $source, $comment, $comment ); |
— | — | @@ -72,9 +72,10 @@ |
73 | 73 | $wgOut->addHTML( wfMsgExt( 'filerevert-success', 'parse', $this->title->getText(), |
74 | 74 | $wgLang->date( $this->getTimestamp(), true ), |
75 | 75 | $wgLang->time( $this->getTimestamp(), true ), |
76 | | - wfExpandUrl( $this->file->getArchiveUrl( $this->archiveName ) ) ) ); |
| 76 | + wfExpandUrl( $this->file->getArchiveUrl( $this->getOldFile()->getArchiveFilename() ) ) ) ); |
77 | 77 | $wgOut->returnToMain( false, $this->title ); |
78 | 78 | } else { |
| 79 | + wfDebugLog('filerevert', __METHOD__.": revert failed during upload. source: $source\n"); |
79 | 80 | $wgOut->addWikiText( $status->getWikiText() ); |
80 | 81 | } |
81 | 82 | return; |
— | — | @@ -96,7 +97,7 @@ |
97 | 98 | $form .= '<fieldset><legend>' . wfMsgHtml( 'filerevert-legend' ) . '</legend>'; |
98 | 99 | $form .= wfMsgExt( 'filerevert-intro', 'parse', $this->title->getText(), |
99 | 100 | $wgLang->date( $timestamp, true ), $wgLang->time( $timestamp, true ), |
100 | | - wfExpandUrl( $this->file->getArchiveUrl( $this->archiveName ) ) ); |
| 101 | + wfExpandUrl( $this->file->getArchiveUrl( $this->getOldFile()->getArchiveFilename() ) ) ); |
101 | 102 | $form .= '<p>' . Xml::inputLabel( wfMsg( 'filerevert-comment' ), 'wpComment', 'wpComment', |
102 | 103 | 60, wfMsgForContent( 'filerevert-defaultcomment', |
103 | 104 | $wgContLang->date( $timestamp, false, false ), $wgContLang->time( $timestamp, false, false ) ) ) . '</p>'; |
Index: branches/extensionless-files/includes/filerepo/FileRepo.php |
— | — | @@ -252,7 +252,8 @@ |
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | | - * Get the name of an image from its title object |
| 256 | + * Get the name of an image from its title object. Only use this for |
| 257 | + * generating hash keys. |
257 | 258 | */ |
258 | 259 | function getNameFromTitle( $title ) { |
259 | 260 | global $wgCapitalLinks; |
— | — | @@ -268,6 +269,15 @@ |
269 | 270 | return $name; |
270 | 271 | } |
271 | 272 | |
| 273 | + /** |
| 274 | + * Get the file name of an image from its title object, possibly with a |
| 275 | + * generated extension. |
| 276 | + * Stub function pending full implementation of bug 4421. |
| 277 | + */ |
| 278 | + function getFilenameFromTitle( $title , $mime = NULL ) { |
| 279 | + return $this->getNameFromTitle( $title ); |
| 280 | + } |
| 281 | + |
272 | 282 | static function getHashPathForLevel( $name, $levels ) { |
273 | 283 | if ( $levels == 0 ) { |
274 | 284 | return ''; |
Index: branches/extensionless-files/includes/filerepo/File.php |
— | — | @@ -140,7 +140,9 @@ |
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | | - * Return the name of this file |
| 144 | + * Return the name of this file for purposes of reading from the database |
| 145 | + * and generating hash keys. Use getFilename if you're interested in what |
| 146 | + * is actually on the disk |
145 | 147 | */ |
146 | 148 | public function getName() { |
147 | 149 | if ( !isset( $this->name ) ) { |
— | — | @@ -150,6 +152,14 @@ |
151 | 153 | } |
152 | 154 | |
153 | 155 | /** |
| 156 | + * Return the file name of this file |
| 157 | + * Stub function pending full implementation of bug 4421. |
| 158 | + */ |
| 159 | + public function getFilename() { |
| 160 | + return $this->getName(); |
| 161 | + } |
| 162 | + |
| 163 | + /** |
154 | 164 | * Get the file extension, e.g. "svg" |
155 | 165 | */ |
156 | 166 | function getExtension() { |
— | — | @@ -477,7 +487,7 @@ |
478 | 488 | } |
479 | 489 | $extension = $this->getExtension(); |
480 | 490 | list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( $extension, $this->getMimeType() ); |
481 | | - $thumbName = $this->handler->makeParamString( $params ) . '-' . $this->getName(); |
| 491 | + $thumbName = $this->handler->makeParamString( $params ) . '-' . $this->getFilename(); |
482 | 492 | if ( $thumbExt != $extension ) { |
483 | 493 | $thumbName .= ".$thumbExt"; |
484 | 494 | } |
— | — | @@ -748,6 +758,13 @@ |
749 | 759 | * Get the path of the file relative to the public zone root |
750 | 760 | */ |
751 | 761 | function getRel() { |
| 762 | + return $this->getHashPath() . $this->getFilename(); |
| 763 | + } |
| 764 | + |
| 765 | + /** |
| 766 | + * Get the path of the thumb directory relative to the public zone root |
| 767 | + */ |
| 768 | + function getThumbRel() { |
752 | 769 | return $this->getHashPath() . $this->getName(); |
753 | 770 | } |
754 | 771 | |
— | — | @@ -755,6 +772,13 @@ |
756 | 773 | * Get urlencoded relative path of the file |
757 | 774 | */ |
758 | 775 | function getUrlRel() { |
| 776 | + return $this->getHashPath() . rawurlencode( $this->getFilename() ); |
| 777 | + } |
| 778 | + |
| 779 | + /** |
| 780 | + * Get urlencoded relative path of the thumb directory |
| 781 | + */ |
| 782 | + function getThumbUrlRel() { |
759 | 783 | return $this->getHashPath() . rawurlencode( $this->getName() ); |
760 | 784 | } |
761 | 785 | |
— | — | @@ -776,10 +800,11 @@ |
777 | 801 | |
778 | 802 | /** Get the path of the thumbnail directory, or a particular file if $suffix is specified */ |
779 | 803 | function getThumbPath( $suffix = false ) { |
780 | | - $path = $this->repo->getZonePath('thumb') . '/' . $this->getRel(); |
| 804 | + $path = $this->repo->getZonePath('thumb') . '/' . $this->getThumbRel(); |
781 | 805 | if ( $suffix !== false ) { |
782 | 806 | $path .= '/' . $suffix; |
783 | 807 | } |
| 808 | + wfDebugLog( 'thumb', __METHOD__." path: {$path}\n" ); |
784 | 809 | return $path; |
785 | 810 | } |
786 | 811 | |
— | — | @@ -796,7 +821,7 @@ |
797 | 822 | |
798 | 823 | /** Get the URL of the thumbnail directory, or a particular file if $suffix is specified */ |
799 | 824 | function getThumbUrl( $suffix = false ) { |
800 | | - $path = $this->repo->getZoneUrl('thumb') . '/' . $this->getUrlRel(); |
| 825 | + $path = $this->repo->getZoneUrl('thumb') . '/' . $this->getThumbUrlRel(); |
801 | 826 | if ( $suffix !== false ) { |
802 | 827 | $path .= '/' . rawurlencode( $suffix ); |
803 | 828 | } |
— | — | @@ -816,7 +841,7 @@ |
817 | 842 | |
818 | 843 | /** Get the virtual URL for a thumbnail file or directory */ |
819 | 844 | function getThumbVirtualUrl( $suffix = false ) { |
820 | | - $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel(); |
| 845 | + $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getThumbUrlRel(); |
821 | 846 | if ( $suffix !== false ) { |
822 | 847 | $path .= '/' . rawurlencode( $suffix ); |
823 | 848 | } |
Index: branches/extensionless-files/includes/filerepo/OldLocalFile.php |
— | — | @@ -95,6 +95,14 @@ |
96 | 96 | return $this->archive_name; |
97 | 97 | } |
98 | 98 | |
| 99 | + /** |
| 100 | + * This function tacks on file extension to archive_name, if needed. |
| 101 | + * Stub function pending full implementation of bug 4421. |
| 102 | + */ |
| 103 | + public function getArchiveFilename() { |
| 104 | + return $this->getArchiveName(); |
| 105 | + } |
| 106 | + |
99 | 107 | function isOld() { |
100 | 108 | return true; |
101 | 109 | } |
— | — | @@ -131,11 +139,11 @@ |
132 | 140 | } |
133 | 141 | |
134 | 142 | function getRel() { |
135 | | - return 'archive/' . $this->getHashPath() . $this->getArchiveName(); |
| 143 | + return 'archive/' . $this->getHashPath() . $this->getArchiveFilename(); |
136 | 144 | } |
137 | 145 | |
138 | 146 | function getUrlRel() { |
139 | | - return 'archive/' . $this->getHashPath() . urlencode( $this->getArchiveName() ); |
| 147 | + return 'archive/' . $this->getHashPath() . urlencode( $this->getArchiveFilename() ); |
140 | 148 | } |
141 | 149 | |
142 | 150 | function upgradeRow() { |
Index: branches/extensionless-files/includes/ImagePage.php |
— | — | @@ -942,7 +942,7 @@ |
943 | 943 | ); |
944 | 944 | $row .= '<span class="history-deleted">'.$url.'</span>'; |
945 | 945 | } else { |
946 | | - $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img ); |
| 946 | + $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $file->getArchiveFilename() ); |
947 | 947 | $row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) ); |
948 | 948 | } |
949 | 949 | $row .= "</td>"; |