r91392 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91391‎ | r91392 | r91393 >
Date:06:48, 4 July 2011
Author:yuvipanda
Status:resolved
Tags:
Comment:
ParserFunction to display the project statistics

Needs formatting work
Modified paths:
  • /trunk/extensions/GPoC/GPoC.php (modified) (history)
  • /trunk/extensions/GPoC/TableDisplay.php (added) (history)

Diff [purge]

Index: trunk/extensions/GPoC/TableDisplay.php
@@ -0,0 +1,22 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ exit( 1 );
 5+}
 6+
 7+class TableDisplay {
 8+ public static function ParserFunctionInit( &$parser ) {
 9+ $parser->setFunctionHook( 'AssessmentStats', 'TableDisplay::AssessmentStatsRender' );
 10+ return true;
 11+ }
 12+
 13+ public static function LanguageGetMagic( &$magicWords, $langCode ) {
 14+ $magicWords['AssessmentStats'] = array( 0, 'AssessmentStats' );
 15+ return true;
 16+ }
 17+
 18+ public static function AssessmentStatsRender( $parser, $project ) {
 19+ $projectStats = Statistics::getProjectStats( $project );
 20+ $output = print_r( $projectStats, true );
 21+ return $output;
 22+ }
 23+}
Index: trunk/extensions/GPoC/GPoC.php
@@ -20,8 +20,13 @@
2121 $dir = dirname( __FILE__ ) . '/';
2222
2323 $wgAutoloadClasses['GPoCHooks'] = $dir . 'GPoC.hooks.php';
 24+$wgAutoloadClasses['Statistics'] = $dir . 'models/Statistics.php';
 25+$wgAutoloadClasses['TableDisplay'] = $dir . 'TableDisplay.php';
2426
2527 $wgHooks['ArticleSaveComplete'][] = 'GPoCHooks::ArticleSaveComplete';
2628 $wgHooks['LoadExtensionSchemaUpdates'][] = 'GPoCHooks::SetupSchema';
2729
 30+$wgHooks['ParserFirstCallInit'][] = 'TableDisplay::ParserFunctionInit';
 31+$wgHooks['LanguageGetMagic'][] = 'TableDisplay::LanguageGetMagic';
 32+
2833 // Configuration

Status & tagging log