Index: trunk/extensions/GPoC/models/Rating.php |
— | — | @@ -150,11 +150,29 @@ |
151 | 151 | ), |
152 | 152 | __METHOD__ |
153 | 153 | ); |
154 | | - // Article moves not logged |
| 154 | + // Article moves not logged - yet |
155 | 155 | } |
156 | 156 | |
157 | | - public static function getLogs() { |
| 157 | + public static function filterArticles( $filters ) { |
158 | 158 | $dbr = wfGetDB( DB_SLAVE ); |
| 159 | + $clean_filters = array(); |
| 160 | + foreach($filters as $column => $value) { |
| 161 | + if( ! ( !isset($value) or $value == null or $value == "" )) { |
| 162 | + $clean_filters[$column] = $value; |
| 163 | + } |
| 164 | + } |
| 165 | + $query = $dbr->select( |
| 166 | + 'ratings', |
| 167 | + '*', |
| 168 | + $clean_filters, |
| 169 | + __METHOD__ |
| 170 | + ); |
159 | 171 | |
| 172 | + $articles = array(); |
| 173 | + foreach( $query as $article_row ) { |
| 174 | + $article = (array)$article_row; |
| 175 | + array_push( $articles, $article ); |
| 176 | + } |
| 177 | + return $articles; |
160 | 178 | } |
161 | 179 | } |
Index: trunk/extensions/GPoC/SpecialFilterRatings.php |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + */ |
| 5 | + |
| 6 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 7 | + echo( "not a valid entry point.\n" ); |
| 8 | + die( 1 ); |
| 9 | +} |
| 10 | + |
| 11 | +class SpecialFilterRatings extends SpecialPage { |
| 12 | + |
| 13 | + public function __construct() { |
| 14 | + parent::__construct( 'FilterRatings' ); |
| 15 | + } |
| 16 | + |
| 17 | + // prototypey code |
| 18 | + public function execute( $par ) { |
| 19 | + global $wgOut, $wgRequest; |
| 20 | + |
| 21 | + $project = $wgRequest->getVal('project'); |
| 22 | + $importance = $wgRequest->getVal('importance'); |
| 23 | + $quality = $wgRequest->getVal('quality'); |
| 24 | + |
| 25 | + $filters = array( |
| 26 | + 'r_project' => $project, |
| 27 | + 'r_importance' => $importance, |
| 28 | + 'r_quality' => $quality |
| 29 | + ); |
| 30 | + $entries = Rating::filterArticles($filters); |
| 31 | + |
| 32 | + $this->setHeaders(); |
| 33 | + |
| 34 | + $wgOut->setPageTitle("Filter Articles by Ratings"); |
| 35 | + |
| 36 | + $template = new FilterRatingsTemplate(); |
| 37 | + $template->set( 'filters', $filters ); |
| 38 | + $template->set( 'articles', $entries ); |
| 39 | + $wgOut->addTemplate( $template ); |
| 40 | + } |
| 41 | +} |
Property changes on: trunk/extensions/GPoC/SpecialFilterRatings.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 42 | + native |
Index: trunk/extensions/GPoC/GPoC.php |
— | — | @@ -26,7 +26,11 @@ |
27 | 27 | $wgAutoloadClasses['TableDisplay'] = $dir . 'TableDisplay.php'; |
28 | 28 | $wgAutoloadClasses['AssessmentsExtractor'] = $dir . 'AssessmentsExtractor.php'; |
29 | 29 | $wgAutoloadClasses['SpecialAssessmentLog'] = $dir . 'SpecialAssessmentLog.php'; |
| 30 | +$wgAutoloadClasses['SpecialFilterRatings'] = $dir . 'SpecialFilterRatings.php'; |
30 | 31 | |
| 32 | + |
| 33 | +$wgAutoloadClasses['FilterRatingsTemplate'] = $dir . 'templates/FilterRatingsTemplate.php'; |
| 34 | + |
31 | 35 | $wgHooks['ArticleSaveComplete'][] = 'GPoCHooks::ArticleSaveComplete'; |
32 | 36 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'GPoCHooks::SetupSchema'; |
33 | 37 | |
— | — | @@ -36,5 +40,6 @@ |
37 | 41 | $wgHooks['TitleMoveComplete'][] = 'GPoCHooks::TitleMoveComplete'; |
38 | 42 | |
39 | 43 | $wgSpecialPages['AssessmentLog'] = 'SpecialAssessmentLog'; |
| 44 | +$wgSpecialPages['FilterRatings'] = 'SpecialFilterRatings'; |
40 | 45 | |
41 | 46 | // Configuration |
Index: trunk/extensions/GPoC/templates/FilterRatingsTemplate.php |
— | — | @@ -0,0 +1,45 @@ |
| 2 | +<?php |
| 3 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 4 | + die( -1 ); |
| 5 | +} |
| 6 | + |
| 7 | +class FilterRatingsTemplate extends QuickTemplate { |
| 8 | + public function execute() { |
| 9 | + $articles = $this->data['articles']; |
| 10 | + $filters = $this->data['filters']; |
| 11 | +?> |
| 12 | + |
| 13 | +<form method="GET"> |
| 14 | +<p> |
| 15 | +Project Name: <input type="text" name="project" value="<?php echo $filters['r_project']?>" /> |
| 16 | +Importance: <input type="text" name="importance" value="<?php echo $filters['r_importance']?>" /> |
| 17 | +Quality: <input type="text" name="quality" value="<?php echo $filters['r_quality']?>" /> |
| 18 | +<input type="submit" /> |
| 19 | +</p> |
| 20 | +</form> |
| 21 | + |
| 22 | +<div id=""> |
| 23 | +<?php if( count($articles) > 0 ) { ?> |
| 24 | + <table> |
| 25 | + <tr> |
| 26 | + <th>Article</th> |
| 27 | + <th>Importance</th> |
| 28 | + <th>Quality</th> |
| 29 | + </tr> |
| 30 | + <?php foreach( $articles as $article ) { ?> |
| 31 | + <tr> |
| 32 | + <td><?php echo $article['r_article']; ?></td> |
| 33 | + <td><?php echo $article['r_importance']; ?></td> |
| 34 | + <td><?php echo $article['r_quality']; ?></td> |
| 35 | + </tr> |
| 36 | + <?php } ?> |
| 37 | + </table> |
| 38 | +<?php } else { ?> |
| 39 | +<p>No results found</p> |
| 40 | +<?php } ?> |
| 41 | +</div> |
| 42 | + |
| 43 | + |
| 44 | +<?php |
| 45 | + } // execute() |
| 46 | +} // class |
Property changes on: trunk/extensions/GPoC/templates/FilterRatingsTemplate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 47 | + native |