r60307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60306‎ | r60307 | r60308 >
Date:05:55, 23 December 2009
Author:aaron
Status:ok
Tags:
Comment:
* Added pending edit notice to history
* Refactored out code into pendingEditBox() and lockStatusIcon()
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsXML.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -427,8 +427,10 @@
428428 $wgHooks['SkinTemplateTabs'][] = 'FlaggedRevsHooks::setActionTabs';
429429 # Set navigation
430430 $wgHooks['SkinTemplateNavigation'][] = 'FlaggedRevsHooks::setNavigation';
431 -# Add tags to edit view
 431+# Add notice tags to edit view
432432 $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsHooks::addToEditView';
 433+# Add notice tags to history
 434+$wgHooks['PageHistoryBeforeList'][] = 'FlaggedRevsHooks::addToHistView';
433435 # Add review form and visiblity settings link
434436 $wgHooks['SkinAfterContent'][] = 'FlaggedRevsHooks::onSkinAfterContent';
435437 # Add protection form field
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php
@@ -323,4 +323,60 @@
324324 }
325325 return $form;
326326 }
 327+
 328+ /*
 329+ * @param FlaggedArticle $flaggedArticle
 330+ * @returns string
 331+ * Creates CSS lock icon if page is locked/unlocked
 332+ */
 333+ public static function lockStatusIcon( $flaggedArticle ) {
 334+ if( $flaggedArticle->isPageLocked() ) {
 335+ return "<span class='fr-icon-locked' title=\"".
 336+ wfMsgHtml('revreview-locked-title')."\"></span>";
 337+ } elseif( $flaggedArticle->isPageUnlocked() ) {
 338+ return "<span class='fr-icon-unlocked' title=\"".
 339+ wfMsgHtml('revreview-unlocked-title')."\"></span>";
 340+ }
 341+ }
 342+
 343+ /*
 344+ * @param FlaggedArticle $flaggedArticle
 345+ * @param FlaggedRevision $frev
 346+ * @param int $revsSince
 347+ * @returns string
 348+ * Creates "there are x pending edits" message in a div
 349+ */
 350+ public static function pendingEditBox( $flaggedArticle, $frev, $revsSince ) {
 351+ global $wgLang;
 352+ $flags = $frev->getTags();
 353+ $quality = FlaggedRevs::isQuality( $flags );
 354+ $time = $wgLang->date( $frev->getTimestamp(), true );
 355+ // Is the page config altered?
 356+ $prot = self::lockStatusIcon( $flaggedArticle );
 357+ # Streamlined UI
 358+ if( FlaggedRevs::useSimpleUI() ) {
 359+ $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
 360+ $msg .= ($revsSince == 0) ? '-i' : '';
 361+ $tag = "{$prot}<span class='fr-checkbox'></span>" .
 362+ wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
 363+ $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>" .
 364+ "$tag</div>";
 365+ # Standard UI
 366+ } else {
 367+ $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
 368+ $msg .= ($revsSince == 0) ? '-i' : '';
 369+ $tag = "{$prot}<span class='fr-checkbox'></span>" .
 370+ wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
 371+ # Hide clutter
 372+ if( !empty($flags) ) {
 373+ $tag .= " " . FlaggedRevsXML::ratingToggle();
 374+ $tag .= '<span id="mw-revisionratings" style="display:block;"><br />' .
 375+ wfMsg('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) .
 376+ '</span>';
 377+ }
 378+ $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>" .
 379+ "$tag</div>";
 380+ }
 381+ return $tag;
 382+ }
327383 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1576,6 +1576,12 @@
15771577 return true;
15781578 }
15791579
 1580+ public static function addToHistView( &$article ) {
 1581+ $view = FlaggedArticleView::singleton();
 1582+ $view->addToHistView();
 1583+ return true;
 1584+ }
 1585+
15801586 public static function onCategoryPageView( &$category ) {
15811587 $view = FlaggedArticleView::singleton();
15821588 $view->addToCategoryView();
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -226,13 +226,7 @@
227227 return true;
228228 }
229229 // Is the page config altered?
230 - if( $this->article->isPageLocked() ) {
231 - $prot = "<span class='fr-icon-locked' title=\"".
232 - wfMsgHtml('revreview-locked-title')."\"></span>";
233 - } elseif( $this->article->isPageUnlocked() ) {
234 - $prot = "<span class='fr-icon-unlocked' title=\"".
235 - wfMsgHtml('revreview-unlocked-title')."\"></span>";
236 - }
 230+ $prot = FlaggedRevsXML::lockStatusIcon( $this->article );
237231 // Is there no stable version?
238232 if( is_null($frev) ) {
239233 # Add "no reviewed version" tag, but not for printable output
@@ -648,8 +642,27 @@
649643 }
650644
651645 /**
652 - * Adds latest stable version tag to page when editing
 646+ * Adds stable version tags to page when viewing history
653647 */
 648+ public function addToHistView() {
 649+ global $wgOut, $wgLang;
 650+ $this->load();
 651+ # Must be reviewable. UI may be limited to unobtrusive patrolling system.
 652+ if( !$this->article->isReviewable() || $this->article->limitedUI() )
 653+ return true;
 654+ # Add a notice if there are pending edits...
 655+ $frev = $this->article->getStableRev();
 656+ if( $frev && $frev->getRevId() < $this->article->getLatest() ) {
 657+ $revsSince = FlaggedRevs::getRevCountSince( $this->article, $frev->getRevId() );
 658+ $tag = FlaggedRevsXML::pendingEditBox( $this->article, $frev, $revsSince );
 659+ $wgOut->addHTML( $tag );
 660+ }
 661+ return true;
 662+ }
 663+
 664+ /**
 665+ * Adds stable version tags to page when editing
 666+ */
654667 public function addToEditView( $editPage ) {
655668 global $wgRequest, $wgOut;
656669 $this->load();
@@ -658,11 +671,11 @@
659672 return true;
660673 # Show stabilization log
661674 $this->showStabilityLog();
662 - # Set new body html text as that of now
663675 $tag = $warning = $prot = '';
664676 # Check the newest stable version
665677 $quality = 0;
666 - if( $frev = $this->article->getStableRev() ) {
 678+ $frev = $this->article->getStableRev();
 679+ if( $frev ) {
667680 global $wgLang, $wgUser;
668681 # Find out revision id
669682 $revId = $editPage->oldid ?
@@ -684,42 +697,10 @@
685698 $warning = "<div id='mw-editwarningtag' class='flaggedrevs_editnotice plainlinks'>" .
686699 wfMsgExt('revreview-editnotice',array('parseinline')) . "</div>";
687700 }
 701+ # Add a notice if there are pending edits...
688702 if( $frev->getRevId() != $revId ) {
689 - $time = $wgLang->date( $frev->getTimestamp(), true );
690 - $flags = $frev->getTags();
691 - if( FlaggedRevs::isQuality($flags) ) {
692 - $quality = FlaggedRevs::isPristine($flags) ? 2 : 1;
693 - }
694703 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $frev->getRevId() );
695 - // Is the page config altered?
696 - if( $this->article->isPageLocked() ) {
697 - $prot = "<span class='fr-icon-locked' title=\"".
698 - wfMsgHtml('revreview-locked-title')."\"></span>";
699 - } elseif( $this->article->isPageUnlocked() ) {
700 - $prot = "<span class='fr-icon-unlocked' title=\"".
701 - wfMsgHtml('revreview-unlocked-title')."\"></span>";
702 - }
703 - # Streamlined UI
704 - if( FlaggedRevs::useSimpleUI() ) {
705 - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
706 - $msg .= ($revsSince == 0) ? '-i' : '';
707 - $tag = "{$prot}<span class='fr-checkbox'></span>" .
708 - wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
709 - $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>";
710 - # Standard UI
711 - } else {
712 - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
713 - $msg .= ($revsSince == 0) ? '-i' : '';
714 - $tag = "{$prot}<span class='fr-checkbox'></span>" .
715 - wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
716 - # Hide clutter
717 - if( !empty($flags) ) {
718 - $tag .= " " . FlaggedRevsXML::ratingToggle();
719 - $tag .= '<span id="mw-revisionratings" style="display:block;"><br />' .
720 - wfMsg('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
721 - }
722 - $tag = "<div id='mw-revisiontag-edit' class='flaggedrevs_editnotice plainlinks'>$tag</div>";
723 - }
 704+ $tag = FlaggedRevsXML::pendingEditBox( $this->article, $frev, $revsSince );
724705 }
725706 # Output notice and warning for editors
726707 if( $tag || $warning ) {

Status & tagging log