r23406 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23405‎ | r23406 | r23407 >
Date:22:57, 25 June 2007
Author:aaron
Status:old
Tags:
Comment:
*Code and UI cleanup
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/flaggedrevs.css (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -93,9 +93,12 @@
9494 'style' => array('review' => 3),
9595 );
9696
97 -// For users of the monobook skin, a simplified UI will be used.
98 -// Ratings will go by the toolbox. The standard UI still shows
99 -// in edit mode and at stable versions.
 97+# Use RC Patrolling to check for vandalism
 98+# When revisions are flagged, they count as patrolled
 99+$wgUseRCPatrol = true;
 100+
 101+# This will only distinguish "sigted", "quality", and unreviewed
 102+# A small icon will show in the upper right hand corner
100103 $wgSimpleFlaggedRevsUI = false;
101104
102105 # Lets some users access the review UI and set some flags
@@ -182,7 +185,7 @@
183186 $options->setEditSection(false);
184187 # Parse the new body, wikitext -> html
185188 $parserOut = $wgParser->parse( $text, $title, $options, true, true, $id );
186 -
 189+ # Reset $wgParser
187190 $wgParser->isStable = false; // Done!
188191
189192 return $parserOut;
@@ -244,8 +247,7 @@
245248 wfProfileIn( __METHOD__ );
246249 $db = wfGetDB( DB_SLAVE );
247250
248 - $result = $db->select(
249 - array('flaggedrevs'),
 251+ $result = $db->select('flaggedrevs',
250252 array('fr_rev_id','fr_quality'),
251253 array('fr_namespace' => $page->getNamespace(), 'fr_title' => $page->getDBkey() ),
252254 __METHOD__ ,
@@ -278,7 +280,8 @@
279281 * static counterpart for getOverridingRev()
280282 */
281283 public static function getOverridingPageRev( $title=NULL ) {
282 - if( !$title ) return null;
 284+ if( is_null($title) )
 285+ return null;
283286
284287 $dbr = wfGetDB( DB_SLAVE );
285288 // Skip deleted revisions
@@ -309,7 +312,6 @@
310313 */
311314 public static function getFlagsForPageRev( $rev_id ) {
312315 global $wgFlaggedRevTags;
313 -
314316 // Set all flags to zero
315317 $flags = array();
316318 foreach( array_keys($wgFlaggedRevTags) as $tag ) {
@@ -319,8 +321,7 @@
320322 wfProfileIn( __METHOD__ );
321323 $db = wfGetDB( DB_SLAVE );
322324 // Grab all the tags for this revision
323 - $result = $db->select(
324 - array('flaggedrevtags'),
 325+ $result = $db->select('flaggedrevtags',
325326 array('frt_dimension', 'frt_value'),
326327 array('frt_rev_id' => $rev_id),
327328 __METHOD__ );
@@ -333,11 +334,11 @@
334335 return $flags;
335336 }
336337
337 - public function addTagRatings( $flags, $box=false, $css='' ) {
 338+ public function addTagRatings( $flags, $prettyBox = false, $css='' ) {
338339 global $wgFlaggedRevTags;
339340
340341 $tag = '';
341 - if( $box )
 342+ if( $prettyBox )
342343 $tag .= "<table align='center' class='$css' cellpading='0'>";
343344
344345 foreach( $this->dimensions as $quality => $value ) {
@@ -352,7 +353,7 @@
353354 $classmarker = 0;
354355
355356 $levelmarker = $level * 20 + 20; //XXX do this better
356 - if( $box ) {
 357+ if( $prettyBox ) {
357358 $tag .= "<tr><td><span class='fr-group'><span class='fr-text'>" . wfMsgHtml("revreview-$quality") .
358359 "</span></tr><tr><td><span class='fr-marker fr_value$levelmarker'>$valuetext</span></span></td></tr>\n";
359360 } else {
@@ -362,20 +363,50 @@
363364 "</span>\n";
364365 }
365366 }
366 - if( $box )
 367+ if( $prettyBox )
367368 $tag .= '</table>';
368369
369370 return $tag;
370371 }
371372
 373+ function prettyRatingBox( $tfrev, $flags, $revs_since, $simpleTag=false ) {
 374+ global $wgLang, $wgUser;
 375+
 376+ $box = '';
 377+ # Get quality level
 378+ $quality = self::isQuality( $flags );
 379+ $pristine = self::isPristine( $flags );
 380+ $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $tfrev->fr_timestamp), true );
 381+
 382+ $skin = $wgUser->getSkin();
 383+ // Some checks for which tag CSS to use
 384+ if( $simpleTag )
 385+ $tagClass = 'flaggedrevs_box0';
 386+ else if( $pristine )
 387+ $tagClass = 'flaggedrevs_box3';
 388+ else if( $quality )
 389+ $tagClass = 'flaggedrevs_box2';
 390+ else
 391+ $tagClass = 'flaggedrevs_box1';
 392+ // Construct some tagging
 393+ $msg = $quality ? 'revreview-quality' : 'revreview-basic';
 394+ $box = self::addTagRatings( $flags, true, "{$tagClass}a" );
 395+ $box .= '<p><a id="mwrevisiontoggle" style="display:none;" href="javascript:toggleRevRatings()">' .
 396+ wfMsg('revreview-toggle') . '</a></p>';
 397+ $box .= '<span id="mwrevisionratings">' .
 398+ wfMsgExt($msg, array('parseinline'), $tfrev->fr_rev_id, $time, $revs_since) .
 399+ '</span>';
 400+
 401+ return $box;
 402+ }
 403+
372404 public static function ReviewNotes( $row ) {
373405 global $wgUser, $wgFlaggedRevComments;
374406 $notes = '';
375407 if( !$row || !$wgFlaggedRevComments) return $notes;
376408
377 - $skin = $wgUser->getSkin();
378 -
379409 if( $row->fr_comment ) {
 410+ $skin = $wgUser->getSkin();
380411 $notes .= '<p><div class="flaggedrevs_notes plainlinks">';
381412 $notes .= wfMsgExt('revreview-note', array('parse'), User::whoIs( $row->fr_user ) );
382413 $notes .= '<i>' . $skin->formatComment( $row->fr_comment ) . '</i></div></p><br/>';
@@ -726,6 +757,7 @@
727758
728759 static function outputInjectImageTimestamps( &$out, &$parserOutput ) {
729760 $out->mImageTimestamps = $parserOutput->mImageTimestamps;
 761+
730762 return true;
731763 }
732764
@@ -803,64 +835,6 @@
804836
805837 return( $wgSimpleFlaggedRevsUI && $userSkin=='monobook' );
806838 }
807 -
808 - function addPrettyRatingBox( &$tmpl ) {
809 - global $wgUser, $wgArticle, $wgOut, $wgRequest, $action, $wgSimpleFlaggedRevsUI;
810 -
811 - if( !$this->useSimpleUI() )
812 - return true;
813 - // Only trigger on article view for content pages, not for protect/delete/hist
814 - if( !$wgArticle || !$wgArticle->exists() || !$wgArticle->mTitle->isContentPage() || $action !='view' )
815 - return true;
816 - // Check the newest stable version...
817 - if( !$this->pageOverride() )
818 - return true;
819 -
820 - $box = '';
821 - $tfrev = $this->getOverridingRev();
822 - if( is_null($tfrev) )
823 - return true;
824 - $simpleTag = false;
825 -
826 - global $wgLang;
827 - # Get flags and date
828 - $flags = $this->getFlagsForRevision( $tfrev->fr_rev_id );
829 - # Get quality level
830 - $quality = $this->isQuality( $flags );
831 - $pristine = $this->isPristine( $flags );
832 - $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $tfrev->fr_timestamp), true );
833 -
834 - $skin = $wgUser->getSkin();
835 - # We will be looking at the reviewed revision...
836 - $vis_id = $tfrev->fr_rev_id;
837 - $revs_since = parent::getRevCountSince( $pageid, $vis_id );
838 - // Some checks for which tag CSS to use
839 - if( $simpleTag )
840 - $tagClass = 'flaggedrevs_box0';
841 - else if( $pristine )
842 - $tagClass = 'flaggedrevs_box3';
843 - else if( $quality )
844 - $tagClass = 'flaggedrevs_box2';
845 - else
846 - $tagClass = 'flaggedrevs_box1';
847 - // Construct some tagging
848 - if( !$wgOut->isPrintable() ) {
849 - $msg = $quality ? 'revreview-quality' : 'revreview-basic';
850 - $box = parent::addTagRatings( $flags, true, "{$tagClass}a" );
851 - $box .= '<h5><a id="mwrevisiontoggle" style="display:none;" href="javascript:toggleRevRatings()">' . wfMsg('revreview-toggle') . '</a></h5>';
852 - $box .= '<span id="mwrevisionratings">' .
853 - wfMsgExt($msg, array('parseinline'), $vis_id, $time, $revs_since) .
854 - '</span>';
855 - }
856 - // Ugh...
857 - print('</ul></div>');
858 - print('<h5>' . wfMsgExt('revreview-rating', array('parseinline') ) . '</h5>');
859 - print("<div class='$tagClass'>");
860 - print($box);
861 - print("</div><div class='pBody'><ul>");
862 -
863 - return true;
864 - }
865839
866840 /**
867841 * Replaces a page with the last stable version if possible
@@ -892,8 +866,8 @@
893867 # Get flags and date
894868 $flags = $this->getFlagsForRevision( $tfrev->fr_rev_id );
895869 # Get quality level
896 - $quality = $this->isQuality( $flags );
897 - $pristine = $this->isPristine( $flags );
 870+ $quality = parent::isQuality( $flags );
 871+ $pristine = parent::isPristine( $flags );
898872 $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $tfrev->fr_timestamp), true );
899873 # Looking at some specific old rev or if flagged revs override only for anons
900874 if( !$this->pageOverride() ) {
@@ -902,9 +876,8 @@
903877 # Construct some tagging
904878 if( !$wgOut->isPrintable() ) {
905879 if( $this->useSimpleUI() ) {
906 - $msg = $quality ? 'revreview-quick-quality' : 'revreview-quick-basic';
907 - $css = $quality ? 'fr_tab_quality' : 'fr_tab_stable';
908 - $tag .= "<span class='$css plainlinks'></span>" . wfMsgExt($msg,array('parseinline'));
 880+ $msg = $quality ? 'revreview-quick-see-quality' : 'revreview-quick-see-basic';
 881+ $tag .= "<span class='fr_tab_current plainlinks'></span>" . wfMsgExt($msg,array('parseinline'));
909882 } else {
910883 $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
911884 $tag .= wfMsgExt($msg, array('parseinline'), $tfrev->fr_rev_id, $time, $revs_since);
@@ -923,8 +896,9 @@
924897 // Construct some tagging
925898 if( !$wgOut->isPrintable() ) {
926899 if( $this->useSimpleUI() ) {
927 - $msg = 'revreview-quick-current';
928 - $tag .= "<span class='fr_tab_current plainlinks'></span>" .
 900+ $msg = $quality ? 'revreview-quick-quality' : 'revreview-quick-basic';
 901+ $css = $quality ? 'fr_tab_quality' : 'fr_tab_stable';
 902+ $tag .= "<span class='$css plainlinks'></span>" .
929903 wfMsgExt($msg,array('parseinline'),$tfrev->fr_rev_id,$revs_since);
930904 } else {
931905 $msg = $quality ? 'revreview-quality' : 'revreview-basic';
@@ -973,7 +947,14 @@
974948 // Set the new body HTML, place a tag on top
975949 $wgOut->mBodytext = $tag . $wgOut->mBodytext . $notes;
976950 } else {
977 - $tag = '<div id="mwrevisiontag" class="mw-warning plainlinks">'.wfMsgExt('revreview-noflagged', array('parseinline')).'</div>';
 951+ if( $this->useSimpleUI() ) {
 952+ $tag .= "<span class='fr_tab_current plainlinks'></span>" .
 953+ wfMsgExt('revreview-quick-none',array('parseinline'));
 954+ $tag = '<div id="mwrevisiontag" class="flaggedrevs_short plainlinks">'.$tag.'</div>';
 955+ } else {
 956+ $tag = '<div id="mwrevisiontag" class="mw-warning plainlinks">' .
 957+ wfMsgExt('revreview-noflagged', array('parseinline')) . '</div>';
 958+ }
978959 $wgOut->addHTML( $tag );
979960 }
980961 return true;
@@ -1003,7 +984,7 @@
1004985 $flags = $this->getFlagsForRevision( $tfrev->fr_rev_id );
1005986 $revs_since = parent::getRevCountSince( $editform->mArticle->getID(), $tfrev->fr_rev_id );
1006987 # Construct some tagging
1007 - $msg = $this->isQuality( $flags ) ? 'revreview-newest-quality' : 'revreview-newest-basic';
 988+ $msg = parent::isQuality( $flags ) ? 'revreview-newest-quality' : 'revreview-newest-basic';
1008989 $tag = wfMsgExt($msg, array('parseinline'), $tfrev->fr_rev_id, $time, $revs_since );
1009990 # Hide clutter
1010991 $tag .= ' <a id="mwrevisiontoggle" style="display:none;" href="javascript:toggleRevRatings()">' . wfMsg('revreview-toggle') . '</a>';
@@ -1179,14 +1160,12 @@
11801161
11811162 $this->pageFlaggedRevs = array();
11821163 $rows = $this->getReviewedRevs( $article->getTitle() );
1183 -
 1164+ if( !$rows )
 1165+ return true;
11841166 // Try to keep the skin readily accesible,
11851167 // addToHistLine() will use it
11861168 $this->skin = $wgUser->getSkin();
11871169
1188 - if( !$rows )
1189 - return true;
1190 -
11911170 foreach( $rows as $rev => $quality )
11921171 $this->pageFlaggedRevs[$rev] = $quality;
11931172
@@ -1390,8 +1369,7 @@
13911370 wfProfileIn( __METHOD__ );
13921371 $db = wfGetDB( DB_SLAVE );
13931372 // Grab all the tags for this revision
1394 - $result = $db->select(
1395 - array('flaggedrevtags'),
 1373+ $result = $db->select('flaggedrevtags',
13961374 array('frt_dimension', 'frt_value'),
13971375 array('frt_rev_id' => $rev_id),
13981376 __METHOD__ );
@@ -1441,6 +1419,4 @@
14421420 // Additional parser versioning
14431421 $wgHooks['ParserAfterTidy'][] = array( $flaggedRevsModifier, 'parserInjectImageTimestamps');
14441422 $wgHooks['OutputPageParserOutput'][] = array( $flaggedRevsModifier, 'outputInjectImageTimestamps');
1445 -// Fany monobook UI only
1446 -$wgHooks['MonoBookTemplateToolboxEnd'][] = array( $flaggedRevsModifier, 'addPrettyRatingBox');
14471423 ?>
Index: trunk/extensions/FlaggedRevs/flaggedrevs.css
@@ -51,12 +51,12 @@
5252 .flaggedrevs_short {
5353 border: 1px solid #aaa;
5454 background-color: #f9f9f9;
55 - padding: 5px;
 55+ padding: 4px;
5656 position: relative;
5757 float: right;
5858 font-size: 80%;
59 - margin-left: 50px;
60 - margin-right: 50px;
 59+ margin-left: 25px;
 60+ margin-right: 25px;
6161 text-align: left;
6262 }
6363
@@ -72,10 +72,8 @@
7373 }
7474
7575 .fr-text-value {
76 - /*font-size:0px; */
7776 min-width:100px;
7877 width: 100px;
79 -
8078 }
8179
8280 .fr-marker-20 {
@@ -90,7 +88,6 @@
9189 background-repeat: no-repeat;
9290 padding-bottom: 3px;
9391 }
94 -
9592 .fr-marker-60 {
9693 background-image: url(../FlaggedRevs/img/bar_60.png);
9794 background-position: bottom left;
@@ -98,14 +95,12 @@
9996 padding-bottom: 3px;
10097
10198 }
102 -
10399 .fr-marker-80 {
104100 background-image: url(../FlaggedRevs/img/bar_80.png);
105101 background-position: bottom left;
106102 background-repeat: no-repeat;
107103 padding-bottom: 3px;
108104 }
109 -
110105 .fr-marker-100 {
111106 background-image: url(../FlaggedRevs/img/bar_100.png);
112107 background-position: bottom left;
@@ -123,40 +118,40 @@
124119 padding: 0px;
125120 margin: 0px;
126121 width: 27px;
 122+ height: 27px;
127123 position: relative;
128124 float: left;
129 - top: -3px;
 125+ top: -1px;
130126 right: 0px;
131127 background-image: url(../FlaggedRevs/img/1.png);
132128 background-repeat: no-repeat;
133129 background-position: 0px 0px;
134 - height: 27px;
135130 }
136131 .fr_tab_stable {
137132 padding: 0px;
138133 margin: 0px;
139134 width: 27px;
 135+ height: 27px;
140136 position: relative;
141137 float: left;
142 - top: -3px;
 138+ top: -1px;
143139 right: 0px;
144140 background-image: url(../FlaggedRevs/img/2.png);
145141 background-repeat: no-repeat;
146142 background-position: 0px 0px;
147 - height: 27px;
148143 }
149144 .fr_tab_quality {
150145 padding: 0px;
151146 margin: 0px;
152147 width: 27px;
 148+ height: 27px;
153149 position: relative;
154150 float: left;
155 - top: -3px;
 151+ top: -1px;
156152 right: 0px;
157153 background-image: url(../FlaggedRevs/img/3.png);
158154 background-repeat: no-repeat;
159155 background-position: 0px 0px;
160 - height: 27px;
161156 }
162157
163158 .fr-text {
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php
@@ -370,6 +370,13 @@
371371 $dbw->replace( 'flaggedrevs', array( array('fr_rev_id','fr_namespace','fr_title') ), $revset, __METHOD__ );
372372 // Set all of our flags
373373 $dbw->replace( 'flaggedrevtags', array( array('frt_rev_id','frt_dimension') ), $flagset, __METHOD__ );
 374+
 375+ // Mark as patrolled
 376+ $dbw->update( 'recentchanges',
 377+ array( 'rc_patrolled' => 1 ),
 378+ array( 'rc_this_oldid' => $rev->getId() ), __METHOD__
 379+ );
 380+
374381 // Update the article review log
375382 $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, true );
376383
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -16,14 +16,16 @@
1717 'revreview-current' => 'Current revision',
1818 'revreview-stable' => 'Stable version',
1919 'revreview-oldrating' => 'It was rated as:',
20 - 'revreview-rating' => 'Revision rating:',
2120 'revreview-noflagged' => 'There are no reviewed revisions of this page, so it may \'\'\'not\'\'\' have been
2221 [[Help:Article validation|checked]] for quality.',
2322
24 - 'revreview-quick-basic' => '[{{fullurl:{{FULLPAGENAMEE}}|stable=1}} See latest sighted revision]',
25 - 'revreview-quick-quality' => '[{{fullurl:{{FULLPAGENAMEE}}|stable=1}} See latest quality revision]',
26 - 'revreview-quick-current' => '[{{fullurl:{{FULLPAGENAMEE}}|stable=0}} See current revision]
 23+ 'revreview-quick-see-quality' => '\'\'\'Current\'\'\'. [{{fullurl:{{FULLPAGENAMEE}}|stable=1}} See latest quality revision]',
 24+ 'revreview-quick-see-basic' => '\'\'\'Current\'\'\'. [{{fullurl:{{FULLPAGENAMEE}}|stable=1}} See latest sighted revision]',
 25+ 'revreview-quick-basic' => '\'\'\'Sighted\'\'\'. [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} See current revision]
2726 ($2 [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} {{plural:$2|change|changes}}])',
 27+ 'revreview-quick-quality' => '\'\'\'Quality\'\'\'. [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} See current revision]
 28+ ($2 [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} {{plural:$2|change|changes}}])',
 29+ 'revreview-quick-none' => '\'\'\'Current\'\'\'. Revision not reviewed.',
2830 'revreview-newest-basic' => 'The [{{fullurl:{{FULLPAGENAMEE}}|stable=1}} latest sighted revision]
2931 ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} see all]) of this page was [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved]
3032 on <i>$2</i>. <br/> There {{plural:$3|is $3 revision|are $3 revisions}} ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} changes]) awaiting review.',

Status & tagging log