Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -411,25 +411,23 @@ |
412 | 412 | |
413 | 413 | $sk = $wgUser->getSkin(); |
414 | 414 | |
415 | | - $line = $this->img->nextHistoryLine(); |
416 | | - |
417 | | - if ( $line ) { |
| 415 | + if ( $this->img ) { |
418 | 416 | $list = new ImageHistoryList( $sk, $this->img ); |
419 | | - $file = $this->repo->newFileFromRow( $line ); |
| 417 | + $file = $this->img; |
420 | 418 | $dims = $file->getDimensionsString(); |
421 | 419 | $s = $list->beginImageHistoryList() . |
422 | | - $list->imageHistoryLine( true, wfTimestamp(TS_MW, $line->img_timestamp), |
423 | | - $this->mTitle->getDBkey(), $line->img_user, |
424 | | - $line->img_user_text, $line->img_size, $line->img_description, |
| 420 | + $list->imageHistoryLine( true, wfTimestamp(TS_MW, $file->getTimestamp()), |
| 421 | + $this->mTitle->getDBkey(), $file->getUser('id'), |
| 422 | + $file->getUser('text'), $file->getSize(), $file->getDescription(), |
425 | 423 | $dims |
426 | 424 | ); |
427 | 425 | |
428 | | - while ( $line = $this->img->nextHistoryLine() ) { |
429 | | - $file = $this->repo->newFileFromRow( $line ); |
| 426 | + $hist = $this->img->getHistory(); |
| 427 | + foreach( $hist as $file ) { |
430 | 428 | $dims = $file->getDimensionsString(); |
431 | | - $s .= $list->imageHistoryLine( false, $line->oi_timestamp, |
432 | | - $line->oi_archive_name, $line->oi_user, |
433 | | - $line->oi_user_text, $line->oi_size, $line->oi_description, |
| 429 | + $s .= $list->imageHistoryLine( false, wfTimestamp(TS_MW, $file->getTimestamp()), |
| 430 | + $file->getArchiveName(), $file->getUser('id'), |
| 431 | + $file->getUser('text'), $file->getSize(), $file->getDescription(), |
434 | 432 | $dims |
435 | 433 | ); |
436 | 434 | } |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | /** |
7 | 7 | * Bump this number when serialized cache records may be incompatible. |
8 | 8 | */ |
9 | | -define( 'MW_FILE_VERSION', 4 ); |
| 9 | +define( 'MW_FILE_VERSION', 5 ); |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Class to represent a local file in the wiki's own database |
— | — | @@ -29,24 +29,26 @@ |
30 | 30 | /**#@+ |
31 | 31 | * @private |
32 | 32 | */ |
33 | | - var $fileExists, # does the file file exist on disk? (loadFromXxx) |
34 | | - $historyLine, # Number of line to return by nextHistoryLine() (constructor) |
35 | | - $historyRes, # result of the query for the file's history (nextHistoryLine) |
36 | | - $width, # \ |
37 | | - $height, # | |
38 | | - $bits, # --- returned by getimagesize (loadFromXxx) |
39 | | - $attr, # / |
40 | | - $media_type, # MEDIATYPE_xxx (bitmap, drawing, audio...) |
41 | | - $mime, # MIME type, determined by MimeMagic::guessMimeType |
42 | | - $major_mime, # Major mime type |
43 | | - $minor_mime, # Minor mime type |
44 | | - $size, # Size in bytes (loadFromXxx) |
45 | | - $metadata, # Handler-specific metadata |
46 | | - $timestamp, # Upload timestamp |
47 | | - $sha1, # SHA-1 base 36 content hash |
48 | | - $dataLoaded, # Whether or not all this has been loaded from the database (loadFromXxx) |
49 | | - $upgraded, # Whether the row was upgraded on load |
50 | | - $locked; # True if the image row is locked |
| 33 | + var $fileExists, # does the file file exist on disk? (loadFromXxx) |
| 34 | + $historyLine, # Number of line to return by nextHistoryLine() (constructor) |
| 35 | + $historyRes, # result of the query for the file's history (nextHistoryLine) |
| 36 | + $width, # \ |
| 37 | + $height, # | |
| 38 | + $bits, # --- returned by getimagesize (loadFromXxx) |
| 39 | + $attr, # / |
| 40 | + $media_type, # MEDIATYPE_xxx (bitmap, drawing, audio...) |
| 41 | + $mime, # MIME type, determined by MimeMagic::guessMimeType |
| 42 | + $major_mime, # Major mime type |
| 43 | + $minor_mime, # Minor mime type |
| 44 | + $size, # Size in bytes (loadFromXxx) |
| 45 | + $metadata, # Handler-specific metadata |
| 46 | + $timestamp, # Upload timestamp |
| 47 | + $sha1, # SHA-1 base 36 content hash |
| 48 | + $user, $user_text, # User, who uploaded the file |
| 49 | + $description, # Description of current revision of the file |
| 50 | + $dataLoaded, # Whether or not all this has been loaded from the database (loadFromXxx) |
| 51 | + $upgraded, # Whether the row was upgraded on load |
| 52 | + $locked; # True if the image row is locked |
51 | 53 | |
52 | 54 | /**#@-*/ |
53 | 55 | |
— | — | @@ -155,7 +157,7 @@ |
156 | 158 | |
157 | 159 | function getCacheFields( $prefix = 'img_' ) { |
158 | 160 | static $fields = array( 'size', 'width', 'height', 'bits', 'media_type', |
159 | | - 'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1' ); |
| 161 | + 'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1', 'user', 'user_text' ); |
160 | 162 | static $results = array(); |
161 | 163 | if ( $prefix == '' ) { |
162 | 164 | return $fields; |
— | — | @@ -382,6 +384,19 @@ |
383 | 385 | } |
384 | 386 | |
385 | 387 | /** |
| 388 | + * Returns ID or name of user who uploaded the file |
| 389 | + * |
| 390 | + * @param $type string 'text' or 'id' |
| 391 | + */ |
| 392 | + function getUser($type='text') { |
| 393 | + if( $type == 'text' ) { |
| 394 | + return $this->user_text; |
| 395 | + } elseif( $type == 'id' ) { |
| 396 | + return $this->user; |
| 397 | + } |
| 398 | + } |
| 399 | + |
| 400 | + /** |
386 | 401 | * Get handler-specific metadata |
387 | 402 | */ |
388 | 403 | function getMetadata() { |
— | — | @@ -559,6 +574,28 @@ |
560 | 575 | /** purgeDescription inherited */ |
561 | 576 | /** purgeEverything inherited */ |
562 | 577 | |
| 578 | + function getHistory($limit = null, $start = null, $end = null) { |
| 579 | + $dbr = $this->repo->getSlaveDB(); |
| 580 | + $conds = $opts = array(); |
| 581 | + $conds[] = "oi_name = '" . $this->title->getDBKey() . "'"; |
| 582 | + if( $start !== null ) { |
| 583 | + $conds[] = "oi_timestamp < '" . $dbr->timestamp( $start ) . "'"; |
| 584 | + } |
| 585 | + if( $end !== null ) { |
| 586 | + $conds[] = "oi_timestamp > '" . $dbr->timestamp( $end ). "'"; |
| 587 | + } |
| 588 | + if( $limit ) { |
| 589 | + $opts['LIMIT'] = $limit; |
| 590 | + } |
| 591 | + $opts['ORDER BY'] = 'oi_timestamp DESC'; |
| 592 | + $res = $dbr->select('oldimage', '*', $conds, __METHOD__, $opts); |
| 593 | + $r = array(); |
| 594 | + while( $row = $dbr->fetchObject($res) ) { |
| 595 | + $r[] = OldLocalFile::newFromRow($row, $this->repo); |
| 596 | + } |
| 597 | + return $r; |
| 598 | + } |
| 599 | + |
563 | 600 | /** |
564 | 601 | * Return the history of this file, line by line. |
565 | 602 | * starts with current version, then old versions. |
— | — | @@ -968,6 +1005,11 @@ |
969 | 1006 | return $html; |
970 | 1007 | } |
971 | 1008 | |
| 1009 | + function getDescription() { |
| 1010 | + $this->load(); |
| 1011 | + return $this->description; |
| 1012 | + } |
| 1013 | + |
972 | 1014 | function getTimestamp() { |
973 | 1015 | $this->load(); |
974 | 1016 | return $this->timestamp; |
Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -220,6 +220,14 @@ |
221 | 221 | public function getHeight( $page = 1 ) { return false; } |
222 | 222 | |
223 | 223 | /** |
| 224 | + * Returns ID or name of user who uploaded the file |
| 225 | + * STUB |
| 226 | + * |
| 227 | + * @param $type string 'text' or 'id' |
| 228 | + */ |
| 229 | + public function getUser( $type='text' ) { return null; } |
| 230 | + |
| 231 | + /** |
224 | 232 | * Get the duration of a media file in seconds |
225 | 233 | */ |
226 | 234 | public function getLength() { |
— | — | @@ -628,6 +636,18 @@ |
629 | 637 | } |
630 | 638 | |
631 | 639 | /** |
| 640 | + * Return a fragment of the history of file. |
| 641 | + * |
| 642 | + * STUB |
| 643 | + * @param $limit integer Limit of rows to return |
| 644 | + * @param $start timestamp Only revisions older than $start will be returned |
| 645 | + * @param $end timestamp Only revisions newer than $end will be returned |
| 646 | + */ |
| 647 | + function getHistory($limit = null, $start = null, $end = null) { |
| 648 | + return false; |
| 649 | + } |
| 650 | + |
| 651 | + /** |
632 | 652 | * Return the history of this file, line by line. Starts with current version, |
633 | 653 | * then old versions. Should return an object similar to an image/oldimage |
634 | 654 | * database row. |
— | — | @@ -994,6 +1014,14 @@ |
995 | 1015 | } |
996 | 1016 | |
997 | 1017 | /** |
| 1018 | + * Get discription of file revision |
| 1019 | + * STUB |
| 1020 | + */ |
| 1021 | + function getDescription() { |
| 1022 | + return null; |
| 1023 | + } |
| 1024 | + |
| 1025 | + /** |
998 | 1026 | * Get the 14-character timestamp of the file upload, or false if |
999 | 1027 | * it doesn't exist |
1000 | 1028 | */ |