Index: trunk/extensions/GPoC/models/Selection.php |
— | — | @@ -21,4 +21,24 @@ |
22 | 22 | ); |
23 | 23 | } |
24 | 24 | } |
| 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 | + } |
25 | 45 | } |
Index: trunk/extensions/GPoC/SpecialFilterRatings.php |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | $template->set( 'filters', $filters ); |
51 | 51 | $template->set( 'articles', $entries ); |
52 | 52 | $template->set( 'action', $action ); |
53 | | - $template->set( 'selection', $selection ); |
| 53 | + $template->set( 'selection', $selection_name ); |
54 | 54 | |
55 | 55 | $wgOut->addTemplate( $template ); |
56 | 56 | } |
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 |
1 | 34 | + native |
Index: trunk/extensions/GPoC/GPoC.php |
— | — | @@ -28,8 +28,10 @@ |
29 | 29 | $wgAutoloadClasses['AssessmentsExtractor'] = $dir . 'AssessmentsExtractor.php'; |
30 | 30 | $wgAutoloadClasses['SpecialAssessmentLog'] = $dir . 'SpecialAssessmentLog.php'; |
31 | 31 | $wgAutoloadClasses['SpecialFilterRatings'] = $dir . 'SpecialFilterRatings.php'; |
| 32 | +$wgAutoloadClasses['SpecialSelection'] = $dir . 'SpecialSelection.php'; |
32 | 33 | |
33 | 34 | $wgAutoloadClasses['FilterRatingsTemplate'] = $dir . 'templates/FilterRatingsTemplate.php'; |
| 35 | +$wgAutoloadClasses['SelectionTemplate'] = $dir . 'templates/SelectionTemplate.php'; |
34 | 36 | |
35 | 37 | $wgHooks['ArticleSaveComplete'][] = 'GPoCHooks::ArticleSaveComplete'; |
36 | 38 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'GPoCHooks::SetupSchema'; |
— | — | @@ -41,5 +43,6 @@ |
42 | 44 | |
43 | 45 | $wgSpecialPages['AssessmentLog'] = 'SpecialAssessmentLog'; |
44 | 46 | $wgSpecialPages['FilterRatings'] = 'SpecialFilterRatings'; |
| 47 | +$wgSpecialPages['Selection'] = 'SpecialSelection'; |
45 | 48 | |
46 | 49 | // 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 |
1 | 37 | + native |