r93835 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93834‎ | r93835 | r93836 >
Date:17:10, 3 August 2011
Author:yuvipanda
Status:deferred
Tags:
Comment:
Added Special Page to view selections
Modified paths:
  • /trunk/extensions/GPoC/GPoC.php (modified) (history)
  • /trunk/extensions/GPoC/SpecialFilterRatings.php (modified) (history)
  • /trunk/extensions/GPoC/SpecialSelection.php (added) (history)
  • /trunk/extensions/GPoC/models/Selection.php (modified) (history)
  • /trunk/extensions/GPoC/templates/SelectionTemplate.php (added) (history)

Diff [purge]

Index: trunk/extensions/GPoC/models/Selection.php
@@ -21,4 +21,24 @@
2222 );
2323 }
2424 }
 25+
 26+ public static function getSelection( $name ) {
 27+ $dbr = wfGetDB( DB_SLAVE );
 28+
 29+ $query = $dbr->select(
 30+ 'selections',
 31+ '*',
 32+ array('s_selection_name' => $name),
 33+ __METHOD__
 34+ );
 35+
 36+ $articles = array();
 37+ foreach( $query as $article_row ) {
 38+ $article = (array)$article_row;
 39+ $title = Title::makeTitle( $article['s_namespace'], $article['s_article'] );
 40+ $article['title'] = $title;
 41+ array_push( $articles, $article );
 42+ }
 43+ return $articles;
 44+ }
2545 }
Index: trunk/extensions/GPoC/SpecialFilterRatings.php
@@ -49,7 +49,7 @@
5050 $template->set( 'filters', $filters );
5151 $template->set( 'articles', $entries );
5252 $template->set( 'action', $action );
53 - $template->set( 'selection', $selection );
 53+ $template->set( 'selection', $selection_name );
5454
5555 $wgOut->addTemplate( $template );
5656 }
Index: trunk/extensions/GPoC/SpecialSelection.php
@@ -0,0 +1,32 @@
 2+<?php
 3+/**
 4+ */
 5+
 6+if ( !defined( 'MEDIAWIKI' ) ) {
 7+ echo( "not a valid entry point.\n" );
 8+ die( 1 );
 9+}
 10+
 11+class SpecialSelection extends SpecialPage {
 12+
 13+ public function __construct() {
 14+ parent::__construct( 'Selection' );
 15+ }
 16+
 17+ public function execute( $par ) {
 18+ global $wgOut, $wgRequest;
 19+
 20+ $name = $par;
 21+
 22+ $entries = Selection::getSelection( $name );
 23+ $this->setHeaders();
 24+
 25+ $wgOut->setPageTitle("Selection");
 26+
 27+ $template = new SelectionTemplate();
 28+ $template->set( 'articles', $entries );
 29+
 30+ $wgOut->addTemplate( $template );
 31+
 32+ }
 33+}
Property changes on: trunk/extensions/GPoC/SpecialSelection.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/GPoC/GPoC.php
@@ -28,8 +28,10 @@
2929 $wgAutoloadClasses['AssessmentsExtractor'] = $dir . 'AssessmentsExtractor.php';
3030 $wgAutoloadClasses['SpecialAssessmentLog'] = $dir . 'SpecialAssessmentLog.php';
3131 $wgAutoloadClasses['SpecialFilterRatings'] = $dir . 'SpecialFilterRatings.php';
 32+$wgAutoloadClasses['SpecialSelection'] = $dir . 'SpecialSelection.php';
3233
3334 $wgAutoloadClasses['FilterRatingsTemplate'] = $dir . 'templates/FilterRatingsTemplate.php';
 35+$wgAutoloadClasses['SelectionTemplate'] = $dir . 'templates/SelectionTemplate.php';
3436
3537 $wgHooks['ArticleSaveComplete'][] = 'GPoCHooks::ArticleSaveComplete';
3638 $wgHooks['LoadExtensionSchemaUpdates'][] = 'GPoCHooks::SetupSchema';
@@ -41,5 +43,6 @@
4244
4345 $wgSpecialPages['AssessmentLog'] = 'SpecialAssessmentLog';
4446 $wgSpecialPages['FilterRatings'] = 'SpecialFilterRatings';
 47+$wgSpecialPages['Selection'] = 'SpecialSelection';
4548
4649 // Configuration
Index: trunk/extensions/GPoC/templates/SelectionTemplate.php
@@ -0,0 +1,35 @@
 2+<?php
 3+if( !defined( 'MEDIAWIKI' ) ) {
 4+ die( -1 );
 5+}
 6+
 7+class SelectionTemplate extends QuickTemplate {
 8+ public function execute() {
 9+ $articles = $this->data['articles'];
 10+?>
 11+
 12+<div id="">
 13+<?php if( count($articles) > 0 ) { ?>
 14+<h3>Results</h3>
 15+ <table>
 16+ <tr>
 17+ <th>Article</th>
 18+ <th>Added on</th>
 19+ <th>Revision</th>
 20+ </tr>
 21+ <?php foreach( $articles as $article ) { ?>
 22+ <tr>
 23+ <td><a href="<?php echo $article['title']->getLinkURL(); ?>"><?php echo $article['s_article']; ?></a></td>
 24+ <td><?php echo wfTimeStamp( TS_ISO_8601, $article['s_timestamp'] ); ?></td>
 25+ </tr>
 26+ <?php } ?>
 27+ </table>
 28+<?php } else { ?>
 29+<p>No results found</p>
 30+<?php } ?>
 31+</div>
 32+
 33+
 34+<?php
 35+ } // execute()
 36+} // class
Property changes on: trunk/extensions/GPoC/templates/SelectionTemplate.php
___________________________________________________________________
Added: svn:eol-style
137 + native

Status & tagging log