Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | protected $stableRev = null; |
11 | 11 | protected $pendingRevs = null; |
12 | 12 | protected $pageConfig = null; |
13 | | - protected $file = null; |
| 13 | + protected $imagePage = null; // for file pages |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Get a FlaggedArticle for a given title |
— | — | @@ -52,15 +52,29 @@ |
53 | 53 | */ |
54 | 54 | public function getFile() { |
55 | 55 | if ( $this->getTitle()->getNamespace() != NS_FILE ) { |
56 | | - return false; // not an file page |
| 56 | + return false; // not a file page |
57 | 57 | } |
58 | | - if ( is_null( $this->file ) ) { |
59 | | - $imagePage = new ImagePage( $this->getTitle() ); |
60 | | - $this->file = $imagePage->getFile(); |
| 58 | + if ( is_null( $this->imagePage ) ) { |
| 59 | + $this->imagePage = new ImagePage( $this->getTitle() ); |
61 | 60 | } |
62 | | - return $this->file; |
| 61 | + return $this->imagePage->getFile(); |
63 | 62 | } |
64 | 63 | |
| 64 | + /** |
| 65 | + * Get the displayed file version of this file page |
| 66 | + * @TODO: kind of hacky |
| 67 | + * @return mixed (File/false) |
| 68 | + */ |
| 69 | + public function getDisplayedFile() { |
| 70 | + if ( $this->getTitle()->getNamespace() != NS_FILE ) { |
| 71 | + return false; // not a file page |
| 72 | + } |
| 73 | + if ( is_null( $this->imagePage ) ) { |
| 74 | + $this->imagePage = new ImagePage( $this->getTitle() ); |
| 75 | + } |
| 76 | + return $this->imagePage->getDisplayedFile(); |
| 77 | + } |
| 78 | + |
65 | 79 | /** |
66 | 80 | * Is the stable version shown by default for this page? |
67 | 81 | * @param int $flags, FR_MASTER |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | global $wgUser, $wgSimpleFlaggedRevsUI; |
149 | 149 | return $wgUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) ); |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | /** |
153 | 153 | * Allow auto-review edits directly to the stable version by reviewers? |
154 | 154 | * (1 to allow auto-sighting; 2 for auto-quality; 3 for auto-pristine) |
— | — | @@ -1621,13 +1621,13 @@ |
1622 | 1622 | |
1623 | 1623 | /** |
1624 | 1624 | * Get template and image parameters from parser output |
1625 | | - * @param Article $article |
| 1625 | + * @param FlaggedArticle $article |
1626 | 1626 | * @param array $templateIDs (from ParserOutput/OutputPage->mTemplateIds) |
1627 | 1627 | * @param array $imageSHA1Keys (from ParserOutput/OutputPage->fr_ImageSHA1Keys) |
1628 | 1628 | * @returns array( templateParams, imageParams, fileVersion ) |
1629 | 1629 | */ |
1630 | 1630 | public static function getIncludeParams( |
1631 | | - Article $article, array $templateIDs, array $imageSHA1Keys |
| 1631 | + FlaggedArticle $article, array $templateIDs, array $imageSHA1Keys |
1632 | 1632 | ) { |
1633 | 1633 | $templateParams = $imageParams = $fileVersion = ''; |
1634 | 1634 | # NS -> title -> rev ID mapping |
— | — | @@ -1644,9 +1644,11 @@ |
1645 | 1645 | } |
1646 | 1646 | } |
1647 | 1647 | # For image pages, note the displayed image version |
1648 | | - if ( $article instanceof ImagePage ) { |
1649 | | - $file = $article->getDisplayedFile(); |
1650 | | - $fileVersion = $file->getTimestamp() . "#" . $file->getSha1(); |
| 1648 | + if ( $article->getTitle()->getNamespace() == NS_FILE ) { |
| 1649 | + $file = $article->getDisplayedFile(); // File obj |
| 1650 | + if ( $file ) { |
| 1651 | + $fileVersion = $file->getTimestamp() . "#" . $file->getSha1(); |
| 1652 | + } |
1651 | 1653 | } |
1652 | 1654 | return array( $templateParams, $imageParams, $fileVersion ); |
1653 | 1655 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -891,6 +891,7 @@ |
892 | 892 | * (d) The user can 'review' and the "review pending edits" checkbox was checked |
893 | 893 | * |
894 | 894 | * Note: RC items not inserted yet, RecentChange_save hook does rc_patrolled bit... |
| 895 | + * Note: $article one of Article, ImagePage, Category page as appropriate. |
895 | 896 | */ |
896 | 897 | public static function maybeMakeEditReviewed( |
897 | 898 | Article $article, $rev, $baseRevId = false, $user = null |
Index: trunk/extensions/FlaggedRevs/api/ApiReview.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | if ( $form->isApproval() ) { |
70 | 70 | // Now get the template and image parameters needed |
71 | 71 | // If it is the current revision, try the parser cache first |
72 | | - $article = new Article( $title, $revid ); |
| 72 | + $article = new FlaggedArticle( $title, $revid ); |
73 | 73 | if ( $rev->isCurrent() ) { |
74 | 74 | $parserCache = ParserCache::singleton(); |
75 | 75 | $parserOutput = $parserCache->get( $article, $wgUser ); |