r75949 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75948‎ | r75949 | r75950 >
Date:18:20, 3 November 2010
Author:yaron
Status:deferred
Tags:
Comment:
Turned into a multi-purpose page that includes three lists: all approved pages, pages whose approved rev is not their latest rev, and unapproved pages.
Modified paths:
  • /trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php
@@ -1,33 +1,44 @@
22 <?php
33 /**
4 - * Special page that lists all pages that have an approved revision.
 4+ * Special page that displays various lists of pages that either do or do
 5+ * not have an approved revision.
56 *
67 * @author Yaron Koren
78 */
89
910 if ( !defined( 'MEDIAWIKI' ) ) die();
1011
11 -class ARApprovedPages extends SpecialPage {
 12+class SpecialApprovedRevs extends SpecialPage {
1213
1314 /**
1415 * Constructor
1516 */
1617 function __construct() {
17 - parent::__construct( 'ApprovedPages' );
 18+ parent::__construct( 'ApprovedRevs' );
1819 wfLoadExtensionMessages( 'ApprovedRevs' );
1920 }
2021
2122 function execute( $query ) {
 23+ global $wgRequest;
 24+
 25+ ApprovedRevs::addCSS();
2226 $this->setHeaders();
2327 list( $limit, $offset ) = wfCheckLimits();
24 - $rep = new ARApprovedPagesPage();
 28+ $mode = $wgRequest->getVal( 'show' );
 29+ $rep = new SpecialApprovedRevsPage( $mode );
2530 return $rep->doQuery( $offset, $limit );
2631 }
2732 }
2833
29 -class ARApprovedPagesPage extends QueryPage {
 34+class SpecialApprovedRevsPage extends QueryPage {
 35+ private $mMode;
 36+
 37+ public function __construct( $mode ) {
 38+ $this->mMode = $mode;
 39+ }
 40+
3041 function getName() {
31 - return "ApprovedPages";
 42+ return "ApprovedRevs";
3243 }
3344
3445 function isExpensive() { return false; }
@@ -35,10 +46,64 @@
3647 function isSyndicated() { return false; }
3748
3849 function getPageHeader() {
39 - $header = Xml::element( 'p', null, wfMsg( 'approvedrevs-approvedpages-docu' ) ) . "<br />\n";
 50+ // show the names of the three lists of pages, with the one
 51+ // corresponding to the current "mode" not being linked
 52+ $approvedPagesPage = SpecialPage::getPage( 'ApprovedRevs' );
 53+ $approvedPagesTitle = SpecialPage::getPage( 'ApprovedRevs' )->getTitle();
 54+ $navLine = wfMsg( 'approvedrevs-view' ) . ' ';
 55+ if ( $this->mMode == '' ) {
 56+ $navLine .= Xml::element( 'strong',
 57+ null,
 58+ wfMsg( 'approvedrevs-approvedpages' )
 59+ );
 60+ } else {
 61+ $navLine .= Xml::element( 'a',
 62+ array( 'href' => $approvedPagesTitle->getLocalURL() ),
 63+ wfMsg( 'approvedrevs-approvedpages' )
 64+ );
 65+ }
 66+ $navLine .= " | ";
 67+ if ( $this->mMode == 'notlatest' ) {
 68+ $navLine .= Xml::element( 'strong',
 69+ null,
 70+ wfMsg( 'approvedrevs-notlatest' )
 71+ );
 72+ } else {
 73+ $navLine .= Xml::element( 'a',
 74+ array( 'href' => $approvedPagesTitle->getLocalURL( array( 'show' => 'notlatest' ) ) ),
 75+ wfMsg( 'approvedrevs-notlatest' )
 76+ );
 77+ }
 78+ $navLine .= " | ";
 79+ if ( $this->mMode == 'unapproved' ) {
 80+ $navLine .= Xml::element( 'strong',
 81+ null,
 82+ wfMsg( 'approvedrevs-unapprovedpages' )
 83+ );
 84+ } else {
 85+ $navLine .= Xml::element( 'a',
 86+ array( 'href' => $approvedPagesTitle->getLocalURL( array( 'show' => 'unapproved' ) ) ),
 87+ wfMsg( 'approvedrevs-unapprovedpages' )
 88+ );
 89+ }
 90+ $header = Xml::tags( 'p', null, $navLine ) . "\n";
4091 return $header;
4192 }
4293
 94+ /**
 95+ * Set parameters for standard navigation links.
 96+ */
 97+ function linkParameters() {
 98+ $params = array();
 99+ if ( $this->mMode == 'notlatest' ) {
 100+ $params['show'] = 'notlatest';
 101+ } elseif ( $this->mMode == 'unapproved' ) {
 102+ $params['show'] = 'unapproved';
 103+ } else { // all approved pages
 104+ }
 105+ return $params;
 106+ }
 107+
43108 function getPageFooter() {
44109 }
45110
@@ -46,10 +111,28 @@
47112 $dbr = wfGetDB( DB_SLAVE );
48113 $approved_revs = $dbr->tableName( 'approved_revs' );
49114 $page = $dbr->tableName( 'page' );
50 - return "SELECT 'Page' AS type,
51 - p.page_id AS id
52 - FROM $approved_revs ar JOIN $page p
53 - ON ar.page_id = p.page_id";
 115+ if ( $this->mMode == 'notlatest' ) {
 116+ return "SELECT 'Page' AS type,
 117+ p.page_id AS id,
 118+ ar.rev_id AS rev_id,
 119+ p.page_latest AS latest_id
 120+ FROM $approved_revs ar JOIN $page p
 121+ ON ar.page_id = p.page_id
 122+ WHERE p.page_latest != ar.rev_id";
 123+ } elseif ( $this->mMode == 'unapproved' ) {
 124+ return "SELECT 'Page' AS type,
 125+ p.page_id AS id
 126+ FROM $approved_revs ar RIGHT OUTER JOIN $page p
 127+ ON ar.page_id = p.page_id
 128+ WHERE ar.page_id IS NULL";
 129+ } else { // all approved pages
 130+ return "SELECT 'Page' AS type,
 131+ p.page_id AS id,
 132+ ar.rev_id AS rev_id,
 133+ p.page_latest AS latest_id
 134+ FROM $approved_revs ar JOIN $page p
 135+ ON ar.page_id = p.page_id";
 136+ }
54137 }
55138
56139 function getOrder() {
@@ -58,6 +141,21 @@
59142
60143 function formatResult( $skin, $result ) {
61144 $title = Title::newFromId( $result->id );
62 - return $skin->makeLinkObj( $title );
 145+ $pageLink = $skin->makeLinkObj( $title );
 146+ if ( $this->mMode == 'unapproved' ) {
 147+ return $pageLink;
 148+ } else {
 149+ if ( $result->rev_id == $result->latest_id ) {
 150+ $class = "approvedRevIsLatest";
 151+ } else {
 152+ $class = "approvedRevNotLatest";
 153+ }
 154+ return $pageLink . ' (' .
 155+ Xml::element( 'span',
 156+ array ( 'class' => $class ),
 157+ wfMsg( 'approvedrevs-revisionnumber', $result->rev_id )
 158+ ) .
 159+ ')';
 160+ }
63161 }
64162 }

Status & tagging log