r114431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114430‎ | r114431 | r114432 >
Date:23:06, 22 March 2012
Author:bsitu
Status:ok (Comments)
Tags:
Comment:
provided metadata to provided page list
Modified paths:
  • /trunk/extensions/PageTriage/SpecialPageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/api/ApiPageTriageList.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/SpecialPageTriage.php
@@ -25,13 +25,14 @@
2626 */
2727 public function execute( $sub ) {
2828 global $wgOut;
29 -
 29+
3030 // Initialize variable to hold list view options
3131 $opts = new FormOptions();
3232
3333 // Set the defaults for the list view options
3434 $opts->add( 'showbots', true );
3535 $opts->add( 'showredirs', false );
 36+ $opts->add( 'showtriaged', false );
3637 $opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
3738 $opts->add( 'offset', '' );
3839 $opts->add( 'namespace', '0' );
@@ -96,9 +97,13 @@
9798 $htmlOut = '';
9899
99100 if ( $pageList ) {
 101+ $articleMetadata = new ArticleMetadata( $pageList );
 102+ $metaData = $articleMetadata->getMetadata();
100103 foreach ( $pageList as $pageId ) {
101 - $formattedRow = $this->buildRow( $pageId );
102 - $htmlOut .= $formattedRow;
 104+ if ( isset( $metaData[$pageId] ) ) {
 105+ $formattedRow = $this->buildRow( $pageId, $metaData[$pageId] );
 106+ $htmlOut .= $formattedRow;
 107+ }
103108 }
104109 } else {
105110 $htmlOut .= wfMessage( 'specialpage-empty' );
@@ -110,14 +115,18 @@
111116 /**
112117 * Builds a single row for the article list.
113118 * @param $pageId integer ID for a single page
 119+ * @param $metaData array the meta data for $pageId
114120 * @return string HTML for the row
115121 */
116 - protected function buildRow( $pageId ) {
 122+ protected function buildRow( $pageId, $metaData ) {
117123
118 - // TODO: get all the metadata for the page
 124+ // TODO: Build the row from metadata provided
 125+ return '<div>'
 126+ . $pageId . ' '
 127+ . htmlspecialchars( $metaData['title'] ) . ' '
 128+ . htmlspecialchars( $metaData['user_name'] ) .
 129+ '</div>';
119130
120 - return '<div>'.$pageId.'</div>';
121 -
122131 }
123132
124133 }
Index: trunk/extensions/PageTriage/api/ApiPageTriageList.php
@@ -27,7 +27,7 @@
2828 * @return an array of ids
2929 */
3030 public static function getPageIds( $opts = array() ) {
31 -
 31+
3232 // Initialize required variables
3333 $pages = array();
3434 $conds = array();
@@ -42,10 +42,32 @@
4343 }
4444
4545 // TODO: Handle filtering options
 46+ $tables = array( 'pagetriage_page', 'page' );
 47+ $conds[] = 'ptrp_page_id = page_id';
 48+
 49+ if ( $opts['namespace'] ) {
 50+ $conds['page_namespace'] = $opts['namespace'];
 51+ }
 52+ if ( $opts['showredirs'] ) {
 53+ $conds['page_is_redirect'] = 1;
 54+ }
 55+ if ( $opts['showbots'] ) {
 56+ $conds[] = 'ptrp_page_id = ptrpt_page_id AND ptrpt_tag_id = ptrt_tag_id';
 57+ $conds['ptrt_tag_name'] = 'user_bot';
 58+ $conds['ptrpt_value'] = '1';
 59+ $tables[] = 'pagetriage_page_tags';
 60+ $tables[] = 'pagetriage_tags';
 61+ }
4662
 63+ if ( $opts['showtriaged'] ) {
 64+ $conds['ptrp_triaged'] = array( 0, 1 );
 65+ } else {
 66+ $conds['ptrp_triaged'] = 0;
 67+ }
 68+
4769 // Pull page IDs from database
4870 $res = $dbr->select(
49 - 'pagetriage_page',
 71+ $tables,
5072 'ptrp_page_id',
5173 $conds,
5274 __METHOD__,
@@ -68,6 +90,9 @@
6991 'showredirs' => array(
7092 ApiBase::PARAM_TYPE => 'boolean',
7193 ),
 94+ 'showtriaged'=> array(
 95+ ApiBase::PARAM_TYPE => 'boolean',
 96+ ),
7297 'limit' => array(
7398 ApiBase::PARAM_DFLT => '5000',
7499 ApiBase::PARAM_TYPE => 'integer',
@@ -83,6 +108,7 @@
84109 return array(
85110 'showbots' => 'Whether to include bot edits or not',
86111 'showredirs' => 'Whether to include redirects or not',
 112+ 'showtriaged' => 'Whether to include triaged or not',
87113 'limit' => 'The maximum number of results to return',
88114 'namespace' => 'What namespace to pull pages from',
89115 );

Comments

#Comment by Kaldari (talk | contribs)   00:01, 14 April 2012
if ( $opts['showtriaged'] ) {
  $conds['ptrp_triaged'] = array( 0, 1 );
} else {
  $conds['ptrp_triaged'] = 0;
}

The first part of this is unnecessary, but it looks like this is already fixed in newer versions of the page.

Status & tagging log