r39982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39981‎ | r39982 | r39983 >
Date:22:32, 25 August 2008
Author:aaron
Status:old
Tags:
Comment:
* Add sp:LikedPages
* Change vote treshhold a bit
* Update comments
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/LikedPages.i18n.php (added) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/LikedPages_body.php (added) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -44,12 +44,12 @@
4545 define('FR_TEXT',2);
4646
4747 if( !defined('READER_FEEDBACK_SIZE') )
48 - define('READER_FEEDBACK_SIZE',15);
 48+ define('READER_FEEDBACK_SIZE',12);
4949
5050 $wgExtensionCredits['specialpage'][] = array(
5151 'name' => 'Flagged Revisions',
5252 'author' => array( 'Aaron Schulz', 'Joerg Baach' ),
53 - 'version' => '1.2',
 53+ 'version' => '1.21',
5454 'svn-date' => '$LastChangedDate$',
5555 'svn-revision' => '$LastChangedRevision$',
5656 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs',
@@ -270,6 +270,7 @@
271271 $wgAutoloadClasses['FRCacheUpdate'] = $dir.'FRCacheUpdate.php';
272272 $wgAutoloadClasses['FRCacheUpdateJob'] = $dir.'FRCacheUpdate.php';
273273
 274+# Special case cache invalidations
274275 $wgJobClasses['flaggedrevs_CacheUpdate'] = 'FRCacheUpdateJob';
275276
276277 $wgExtensionMessagesFiles['FlaggedRevs'] = $langDir . 'FlaggedRevs.i18n.php';
@@ -316,10 +317,14 @@
317318 $wgAutoloadClasses['QualityOversight'] = $dir . 'specialpages/QualityOversight_body.php';
318319 $wgExtensionMessagesFiles['QualityOversight'] = $langDir . 'QualityOversight.i18n.php';
319320 $wgSpecialPageGroups['QualityOversight'] = 'quality';
320 -# To oversee quality revisions
 321+# To list ill-recieved pages
321322 $wgAutoloadClasses['ProblemPages'] = $dir . 'specialpages/ProblemPages_body.php';
322323 $wgExtensionMessagesFiles['ProblemPages'] = $langDir . 'ProblemPages.i18n.php';
323324 $wgSpecialPageGroups['ProblemPages'] = 'quality';
 325+# To list well-recieved pages
 326+$wgAutoloadClasses['LikedPages'] = $dir . 'specialpages/LikedPages_body.php';
 327+$wgExtensionMessagesFiles['LikedPages'] = $langDir . 'LikedPages.i18n.php';
 328+$wgSpecialPageGroups['LikedPages'] = 'quality';
324329 # Statistics
325330 $wgAutoloadClasses['ValidationStatistics'] = $dir . 'specialpages/ValidationStatistics_body.php';
326331 $wgExtensionMessagesFiles['ValidationStatistics'] = $langDir . 'ValidationStatistics.i18n.php';
@@ -431,6 +436,7 @@
432437 $wgSpecialPages['ReaderFeedback'] = 'ReaderFeedback';
433438 $wgSpecialPages['RatingHistory'] = 'RatingHistory';
434439 $wgSpecialPages['ProblemPages'] = 'ProblemPages';
 440+ $wgSpecialPages['LikedPages'] = 'LikedPages';
435441 }
436442 }
437443
Index: trunk/extensions/FlaggedRevs/language/LikedPages.i18n.php
@@ -0,0 +1,16 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for FlaggedRevs extension, section likedpages
 5+ *
 6+ * @addtogroup Extensions
 7+ */
 8+
 9+$messages = array();
 10+
 11+$messages['en'] = array(
 12+ 'likedpages' => 'Highly rated pages',
 13+ 'likedpages-leg' => 'Find high-rated pages',
 14+ 'likedpages-list' => 'Below is a list of pages sorted by their reader feedback rating.',
 15+ 'likedpages-none' => 'There are no pages in this list',
 16+ 'likedpages-graphs' => 'rating data',
 17+);
Property changes on: trunk/extensions/FlaggedRevs/language/LikedPages.i18n.php
___________________________________________________________________
Added: svn:eol-style
118 + native
Index: trunk/extensions/FlaggedRevs/specialpages/LikedPages_body.php
@@ -0,0 +1,160 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ echo "FlaggedRevs extension\n";
 5+ exit( 1 );
 6+}
 7+wfLoadExtensionMessages( 'LikedPages' );
 8+wfLoadExtensionMessages( 'FlaggedRevs' );
 9+
 10+class LikedPages extends SpecialPage
 11+{
 12+ function __construct() {
 13+ SpecialPage::SpecialPage( 'LikedPages' );
 14+ }
 15+
 16+ function execute( $par ) {
 17+ global $wgRequest, $wgOut, $wgUser;
 18+ $this->setHeaders();
 19+ if( $wgUser->isAllowed( 'feedback' ) ) {
 20+ if( $wgUser->isBlocked() ) {
 21+ $wgOut->blockedPage();
 22+ return;
 23+ }
 24+ } else {
 25+ $wgOut->permissionRequired( 'feedback' );
 26+ return;
 27+ }
 28+ if( wfReadOnly() ) {
 29+ $wgOut->readOnlyPage();
 30+ return;
 31+ }
 32+ $this->skin = $wgUser->getSkin();
 33+ # Check if there is a featured level
 34+ $this->namespace = $wgRequest->getInt( 'namespace' );
 35+ $this->tag = $wgRequest->getVal( 'ratingtag' );
 36+ $this->showForm();
 37+ $this->showPageList();
 38+ }
 39+
 40+ protected function showForm() {
 41+ global $wgOut, $wgTitle, $wgScript, $wgFlaggedRevsNamespaces;
 42+ $form = Xml::openElement( 'form',
 43+ array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) );
 44+ $form .= "<fieldset><legend>".wfMsg('likedpages-leg')."</legend>\n";
 45+ $form .= Xml::hidden( 'title', $wgTitle->getPrefixedDBKey() );
 46+ if( count($wgFlaggedRevsNamespaces) > 1 ) {
 47+ $form .= FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . '&nbsp;';
 48+ }
 49+ if( count( FlaggedRevs::getFeedbackTags() ) > 0 ) {
 50+ $form .= FlaggedRevsXML::getTagMenu( $this->tag );
 51+ }
 52+ $form .= " ".Xml::submitButton( wfMsg( 'go' ) );
 53+ $form .= "</fieldset></form>\n";
 54+ $wgOut->addHTML( $form );
 55+ }
 56+
 57+ protected function showPageList() {
 58+ global $wgOut;
 59+ $pager = new LikedPagesPager( $this, array(), $this->namespace, $this->tag );
 60+ if( $pager->getNumRows() ) {
 61+ $wgOut->addHTML( wfMsgExt('likedpages-list', array('parse') ) );
 62+ $wgOut->addHTML( $pager->getNavigationBar() );
 63+ $wgOut->addHTML( $pager->getBody() );
 64+ $wgOut->addHTML( $pager->getNavigationBar() );
 65+ } else if( $this->tag ) { // must select first...
 66+ $wgOut->addHTML( wfMsgExt('likedpages-none', array('parse') ) );
 67+ }
 68+ }
 69+
 70+ public function formatRow( $row ) {
 71+ global $wgLang;
 72+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
 73+ $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
 74+ $hist = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('hist'), 'action=history' );
 75+ $stxt = '';
 76+ if( !is_null($size = $row->page_len) ) {
 77+ if($size == 0)
 78+ $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
 79+ else
 80+ $stxt = ' <small>' . wfMsgExt('historysize', array('parsemag'), $wgLang->formatNum( $size ) ) . '</small>';
 81+ }
 82+ $ratinghist = SpecialPage::getTitleFor( 'RatingHistory' );
 83+ $graph = $this->skin->makeKnownLinkObj( $ratinghist, wfMsg('likedpages-graphs'),
 84+ 'target='.$title->getPrefixedUrl() );
 85+ return "<li>$link $stxt ($hist) ($graph)</li>";
 86+ }
 87+}
 88+
 89+/**
 90+ * Query to list out well recieved pages
 91+ */
 92+class LikedPagesPager extends AlphabeticPager {
 93+ public $mForm, $mConds, $namespace, $tag;
 94+
 95+ function __construct( $form, $conds = array(), $namespace=0, $tag ) {
 96+ $this->mForm = $form;
 97+ $this->mConds = $conds;
 98+ # Must be a content page...
 99+ global $wgFlaggedRevsNamespaces;
 100+ if( !is_null($namespace) ) {
 101+ $namespace = intval($namespace);
 102+ }
 103+ if( is_null($namespace) || !in_array($namespace,$wgFlaggedRevsNamespaces) ) {
 104+ $namespace = empty($wgFlaggedRevsNamespaces) ? -1 : $wgFlaggedRevsNamespaces[0];
 105+ }
 106+ $this->namespace = $namespace;
 107+ $this->tag = $tag;
 108+ parent::__construct();
 109+ }
 110+
 111+ function formatRow( $row ) {
 112+ return $this->mForm->formatRow( $row );
 113+ }
 114+
 115+ function getQueryInfo() {
 116+ $conds = $this->mConds;
 117+ $conds[] = 'rfp_page_id = page_id';
 118+ $conds['rfp_tag'] = $this->tag;
 119+ $conds['page_namespace'] = $this->namespace;
 120+ // Has to be good enough
 121+ $x = 3;
 122+ if( $this->tag == 'overall' ) {
 123+ global $wgFlaggedRevsFeedbackTags;
 124+ $s = 3*array_sum($wgFlaggedRevsFeedbackTags);
 125+ $x = intval( floor($s/count($wgFlaggedRevsFeedbackTags)) );
 126+ }
 127+ $conds[] = "rfp_ave_val > $x";
 128+ // Reasonable sample
 129+ $conds[] = 'rfp_count >= '.READER_FEEDBACK_SIZE;
 130+ return array(
 131+ 'tables' => array('reader_feedback_pages','page'),
 132+ 'fields' => 'page_namespace,page_title,page_len,rfp_ave_val',
 133+ 'conds' => $conds,
 134+ 'options' => array( 'USE INDEX' => array('reader_feedback_pages' => 'rfp_tag_val_page') )
 135+ );
 136+ }
 137+
 138+ function getDefaultDirections() {
 139+ return false;
 140+ }
 141+
 142+ function getIndexField() {
 143+ return 'rfp_ave_val';
 144+ }
 145+
 146+ function getStartBody() {
 147+ wfProfileIn( __METHOD__ );
 148+ # Do a link batch query
 149+ $lb = new LinkBatch();
 150+ while( $row = $this->mResult->fetchObject() ) {
 151+ $lb->add( $row->page_namespace, $row->page_title );
 152+ }
 153+ $lb->execute();
 154+ wfProfileOut( __METHOD__ );
 155+ return '<ul>';
 156+ }
 157+
 158+ function getEndBody() {
 159+ return '</ul>';
 160+ }
 161+}
\ No newline at end of file
Property changes on: trunk/extensions/FlaggedRevs/specialpages/LikedPages_body.php
___________________________________________________________________
Added: svn:eol-style
1162 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r40009Per r39982: Add new flagged revs special pageraymond06:30, 26 August 2008
r40011Per r39982: Add new special page to alias file tooraymond07:07, 26 August 2008

Status & tagging log