r44861 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44860‎ | r44861 | r44862 >
Date:23:48, 20 December 2008
Author:aaron
Status:deferred
Tags:
Comment:
Refactoring for bug 16278
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -1425,24 +1425,8 @@
14261426 $templateIDs = $wgOut->mTemplateIds;
14271427 $imageSHA1Keys = $wgOut->fr_ImageSHA1Keys;
14281428 }
1429 - # NS -> title -> rev ID mapping
1430 - foreach( $templateIDs as $namespace => $title ) {
1431 - foreach( $title as $dbKey => $revId ) {
1432 - $title = Title::makeTitle( $namespace, $dbKey );
1433 - $templateParams .= $title->getPrefixedDBKey() . "|" . $revId . "#";
1434 - }
1435 - }
1436 - # Image -> timestamp -> sha1 mapping
1437 - foreach( $imageSHA1Keys as $dbKey => $timeAndSHA1 ) {
1438 - foreach( $timeAndSHA1 as $time => $sha1 ) {
1439 - $imageParams .= $dbKey . "|" . $time . "|" . $sha1 . "#";
1440 - }
1441 - }
1442 - # For image pages, note the displayed image version
1443 - if( $this->parent instanceof ImagePage ) {
1444 - $file = $this->parent->getDisplayedFile();
1445 - $fileVersion = $file->getTimestamp() . "#" . $file->getSha1();
1446 - }
 1429+ list($templateParams,$imageParams,$fileVersion) =
 1430+ FlaggedRevs::getIncludeParams( $this->parent, $templateIDs, $imageSHA1Keys );
14471431
14481432 $form .= Xml::openElement( 'span', array('style' => 'white-space: nowrap;') );
14491433 # Hide comment if needed
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1151,4 +1151,34 @@
11521152 $params = array( 'tags' => (object)$wgFlaggedRevsFeedbackTags );
11531153 return Xml::encodeJsVar( (object)$params );
11541154 }
 1155+
 1156+ /**
 1157+ * Get template and image parameters from parser output
 1158+ * @param Article $article
 1159+ * @param array $templateIDs (from ParserOutput/OutputPage->mTemplateIds)
 1160+ * @param array $imageSHA1Keys (from ParserOutput/OutputPage->fr_ImageSHA1Keys)
 1161+ * @returns array( templateParams, imageParams, fileVersion )
 1162+ */
 1163+ public static function getIncludeParams( $article, $templateIDs, $imageSHA1Keys ) {
 1164+ $templateParams = $imageParams = $fileVersion = '';
 1165+ # NS -> title -> rev ID mapping
 1166+ foreach( $templateIDs as $namespace => $t ) {
 1167+ foreach( $t as $dbKey => $revId ) {
 1168+ $temptitle = Title::makeTitle( $namespace, $dbKey );
 1169+ $templateParams .= $temptitle->getPrefixedDBKey() . "|" . $revId . "#";
 1170+ }
 1171+ }
 1172+ # Image -> timestamp -> sha1 mapping
 1173+ foreach( $imageSHA1Keys as $dbKey => $timeAndSHA1 ) {
 1174+ foreach( $timeAndSHA1 as $time => $sha1 ) {
 1175+ $imageParams .= $dbKey . "|" . $time . "|" . $sha1 . "#";
 1176+ }
 1177+ }
 1178+ # For image pages, note the displayed image version
 1179+ if( $article instanceof ImagePage ) {
 1180+ $file = $article->getDisplayedFile();
 1181+ $fileVersion = $file->getTimestamp() . "#" . $file->getSha1();
 1182+ }
 1183+ return array( $templateParams, $imageParams, $fileVersion );
 1184+ }
11551185 }
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -366,7 +366,7 @@
367367 return "<li> $difflink $revlink " . $this->skin->revUserLink($rev) . " " . $this->skin->revComment($rev) . "</li>";
368368 }
369369
370 - private function submit() {
 370+ public function submit() {
371371 global $wgUser;
372372 # If all values are set to zero, this has been unapproved
373373 $approved = !count( FlaggedRevs::getDimensions() ) && $this->approve;

Follow-up revisions

RevisionCommit summaryAuthorDate
r44880(bug 16278) FlaggedRevisions extension: API "sighting" of revisions (patch by...aaron21:02, 21 December 2008

Status & tagging log