Index: trunk/extensions/GPoC/GPoC.hooks.php |
— | — | @@ -1,65 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * |
5 | | - * @file |
6 | | - * @ingroup Extensions |
7 | | - * @author Yuvi Panda, http://yuvi.in |
8 | | - * @copyright © 2011 Yuvaraj Pandian (yuvipanda@yuvi.in) |
9 | | - * @licence Modified BSD License |
10 | | - */ |
11 | | - |
12 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
13 | | - exit( 1 ); |
14 | | -} |
15 | | - |
16 | | -class GPoCHooks { |
17 | | - |
18 | | - private static function updateDatabase( $title, $assessments, $timestamp ) { |
19 | | - $main_title = Title::makeTitle( NS_MAIN, $title->getText() ); |
20 | | - $ratings = Rating::forTitle( $main_title ); |
21 | | - foreach ( $assessments as $project => $assessment ) { |
22 | | - $curRating = $ratings[$project]; |
23 | | - if( $curRating ) { |
24 | | - $curRating->update( $assessment['importance'], $assessment['quality'], 0 ); |
25 | | - } else { |
26 | | - $rating = new Rating( |
27 | | - $project, |
28 | | - $main_title->getNamespace(), |
29 | | - $main_title->getText(), |
30 | | - $assessment['quality'], |
31 | | - 0, |
32 | | - $assessment['importance'], |
33 | | - 0 |
34 | | - ); |
35 | | - $rating->saveAll(); |
36 | | - } |
37 | | - } |
38 | | - } |
39 | | - |
40 | | - public static function TitleMoveComplete( &$title, &$newtitle, &$user, $oldid, $newid ) { |
41 | | - Rating::moveArticle( $title, $newtitle ); |
42 | | - return true; |
43 | | - } |
44 | | - |
45 | | - public static function ArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) { |
46 | | - global $wgParser; |
47 | | - $title = $article->getTitle(); |
48 | | - if( $title->getNamespace() == NS_TALK && $revision ) { |
49 | | - // All conditions to minimize the situations we've to run the job to update the data |
50 | | - $preparedText = $article->prepareTextForEdit( $text )->output->getText(); |
51 | | - $extractor = new AssessmentsExtractor( $preparedText ); |
52 | | - $assessments = $extractor->extractAssessments(); |
53 | | - GPoCHooks::updateDatabase( $title, $assessments, $revision ); |
54 | | - } |
55 | | - return true; |
56 | | - } |
57 | | - |
58 | | - public static function SetupSchema( DatabaseUpdater $du ) { |
59 | | - $base = dirname( __FILE__ ) . '/schema'; |
60 | | - $du->addExtensionTable( "ratings", "$base/ratings.sql"); |
61 | | - $du->addExtensionTable( "project_stats", "$base/project_stats.sql" ); |
62 | | - $du->addExtensionTable( "assessment_changelog", "$base/log.sql" ); |
63 | | - $du->addExtensionTable( "selections", "$base/selections.sql" ); |
64 | | - return true; |
65 | | - } |
66 | | -} |
Index: trunk/extensions/GPoC/GPoC.php |
— | — | @@ -1,48 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Proof of Concept for Yuvi Panda's 2011 GSoC |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Extensions |
8 | | - * @author Yuvi Panda, http://yuvi.in |
9 | | - * @copyright © 2011 Yuvaraj Pandian (yuvipanda@yuvi.in) |
10 | | - * @licence Modified BSD License |
11 | | - */ |
12 | | - |
13 | | -if( !defined( 'MEDIAWIKI' ) ) { |
14 | | - echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
15 | | - die( 1 ); |
16 | | -} |
17 | | - |
18 | | -// Extension credits that will show up on Special:Version |
19 | | - |
20 | | -// Set up the new special page |
21 | | -$dir = dirname( __FILE__ ) . '/'; |
22 | | - |
23 | | -$wgAutoloadClasses['GPoCHooks'] = $dir . 'GPoC.hooks.php'; |
24 | | -$wgAutoloadClasses['Statistics'] = $dir . 'models/Statistics.php'; |
25 | | -$wgAutoloadClasses['Rating'] = $dir . 'models/Rating.php'; |
26 | | -$wgAutoloadClasses['AssessmentChangeLog'] = $dir . 'models/Log.php'; |
27 | | -$wgAutoloadClasses['Selection'] = $dir . 'models/Selection.php'; |
28 | | -$wgAutoloadClasses['TableDisplay'] = $dir . 'TableDisplay.php'; |
29 | | -$wgAutoloadClasses['AssessmentsExtractor'] = $dir . 'AssessmentsExtractor.php'; |
30 | | -$wgAutoloadClasses['SpecialAssessmentLog'] = $dir . 'SpecialAssessmentLog.php'; |
31 | | -$wgAutoloadClasses['SpecialFilterRatings'] = $dir . 'SpecialFilterRatings.php'; |
32 | | -$wgAutoloadClasses['SpecialSelection'] = $dir . 'SpecialSelection.php'; |
33 | | - |
34 | | -$wgAutoloadClasses['FilterRatingsTemplate'] = $dir . 'templates/FilterRatingsTemplate.php'; |
35 | | -$wgAutoloadClasses['SelectionTemplate'] = $dir . 'templates/SelectionTemplate.php'; |
36 | | - |
37 | | -$wgHooks['ArticleSaveComplete'][] = 'GPoCHooks::ArticleSaveComplete'; |
38 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'GPoCHooks::SetupSchema'; |
39 | | - |
40 | | -$wgHooks['ParserFirstCallInit'][] = 'TableDisplay::ParserFunctionInit'; |
41 | | -$wgHooks['LanguageGetMagic'][] = 'TableDisplay::LanguageGetMagic'; |
42 | | - |
43 | | -$wgHooks['TitleMoveComplete'][] = 'GPoCHooks::TitleMoveComplete'; |
44 | | - |
45 | | -$wgSpecialPages['AssessmentLog'] = 'SpecialAssessmentLog'; |
46 | | -$wgSpecialPages['FilterRatings'] = 'SpecialFilterRatings'; |
47 | | -$wgSpecialPages['Selection'] = 'SpecialSelection'; |
48 | | - |
49 | | -// Configuration |
Index: trunk/extensions/GPoC/SelectionSifter.php |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Proof of Concept for Yuvi Panda's 2011 GSoC |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Yuvi Panda, http://yuvi.in |
| 9 | + * @copyright © 2011 Yuvaraj Pandian (yuvipanda@yuvi.in) |
| 10 | + * @licence Modified BSD License |
| 11 | + */ |
| 12 | + |
| 13 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
| 15 | + die( 1 ); |
| 16 | +} |
| 17 | + |
| 18 | +// Extension credits that will show up on Special:Version |
| 19 | + |
| 20 | +// Set up the new special page |
| 21 | +$dir = dirname( __FILE__ ) . '/'; |
| 22 | + |
| 23 | +$wgAutoloadClasses['SelectionSifterHooks'] = $dir . 'SelectionSifter.hooks.php'; |
| 24 | +$wgAutoloadClasses['Statistics'] = $dir . 'models/Statistics.php'; |
| 25 | +$wgAutoloadClasses['Rating'] = $dir . 'models/Rating.php'; |
| 26 | +$wgAutoloadClasses['AssessmentChangeLog'] = $dir . 'models/Log.php'; |
| 27 | +$wgAutoloadClasses['Selection'] = $dir . 'models/Selection.php'; |
| 28 | +$wgAutoloadClasses['TableDisplay'] = $dir . 'TableDisplay.php'; |
| 29 | +$wgAutoloadClasses['AssessmentsExtractor'] = $dir . 'AssessmentsExtractor.php'; |
| 30 | +$wgAutoloadClasses['SpecialAssessmentLog'] = $dir . 'SpecialAssessmentLog.php'; |
| 31 | +$wgAutoloadClasses['SpecialFilterRatings'] = $dir . 'SpecialFilterRatings.php'; |
| 32 | +$wgAutoloadClasses['SpecialSelection'] = $dir . 'SpecialSelection.php'; |
| 33 | + |
| 34 | +$wgAutoloadClasses['FilterRatingsTemplate'] = $dir . 'templates/FilterRatingsTemplate.php'; |
| 35 | +$wgAutoloadClasses['SelectionTemplate'] = $dir . 'templates/SelectionTemplate.php'; |
| 36 | + |
| 37 | +$wgHooks['ArticleSaveComplete'][] = 'SelectionSifterHooks::ArticleSaveComplete'; |
| 38 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'SelectionSifterHooks::SetupSchema'; |
| 39 | + |
| 40 | +$wgHooks['ParserFirstCallInit'][] = 'TableDisplay::ParserFunctionInit'; |
| 41 | +$wgHooks['LanguageGetMagic'][] = 'TableDisplay::LanguageGetMagic'; |
| 42 | + |
| 43 | +$wgHooks['TitleMoveComplete'][] = 'SelectionSifterHooks::TitleMoveComplete'; |
| 44 | + |
| 45 | +$wgSpecialPages['AssessmentLog'] = 'SpecialAssessmentLog'; |
| 46 | +$wgSpecialPages['FilterRatings'] = 'SpecialFilterRatings'; |
| 47 | +$wgSpecialPages['Selection'] = 'SpecialSelection'; |
| 48 | + |
| 49 | +// Configuration |
Property changes on: trunk/extensions/GPoC/SelectionSifter.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 50 | + native |
Index: trunk/extensions/GPoC/SelectionSifter.hooks.php |
— | — | @@ -0,0 +1,65 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * |
| 5 | + * @file |
| 6 | + * @ingroup Extensions |
| 7 | + * @author Yuvi Panda, http://yuvi.in |
| 8 | + * @copyright © 2011 Yuvaraj Pandian (yuvipanda@yuvi.in) |
| 9 | + * @licence Modified BSD License |
| 10 | + */ |
| 11 | + |
| 12 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 13 | + exit( 1 ); |
| 14 | +} |
| 15 | + |
| 16 | +class SelectionSifterHooks { |
| 17 | + |
| 18 | + private static function updateDatabase( $title, $assessments, $timestamp ) { |
| 19 | + $main_title = Title::makeTitle( NS_MAIN, $title->getText() ); |
| 20 | + $ratings = Rating::forTitle( $main_title ); |
| 21 | + foreach ( $assessments as $project => $assessment ) { |
| 22 | + $curRating = $ratings[$project]; |
| 23 | + if( $curRating ) { |
| 24 | + $curRating->update( $assessment['importance'], $assessment['quality'], 0 ); |
| 25 | + } else { |
| 26 | + $rating = new Rating( |
| 27 | + $project, |
| 28 | + $main_title->getNamespace(), |
| 29 | + $main_title->getText(), |
| 30 | + $assessment['quality'], |
| 31 | + 0, |
| 32 | + $assessment['importance'], |
| 33 | + 0 |
| 34 | + ); |
| 35 | + $rating->saveAll(); |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + public static function TitleMoveComplete( &$title, &$newtitle, &$user, $oldid, $newid ) { |
| 41 | + Rating::moveArticle( $title, $newtitle ); |
| 42 | + return true; |
| 43 | + } |
| 44 | + |
| 45 | + public static function ArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) { |
| 46 | + global $wgParser; |
| 47 | + $title = $article->getTitle(); |
| 48 | + if( $title->getNamespace() == NS_TALK && $revision ) { |
| 49 | + // All conditions to minimize the situations we've to run the job to update the data |
| 50 | + $preparedText = $article->prepareTextForEdit( $text )->output->getText(); |
| 51 | + $extractor = new AssessmentsExtractor( $preparedText ); |
| 52 | + $assessments = $extractor->extractAssessments(); |
| 53 | + SelectionSifterHooks::updateDatabase( $title, $assessments, $revision ); |
| 54 | + } |
| 55 | + return true; |
| 56 | + } |
| 57 | + |
| 58 | + public static function SetupSchema( DatabaseUpdater $du ) { |
| 59 | + $base = dirname( __FILE__ ) . '/schema'; |
| 60 | + $du->addExtensionTable( "ratings", "$base/ratings.sql"); |
| 61 | + $du->addExtensionTable( "project_stats", "$base/project_stats.sql" ); |
| 62 | + $du->addExtensionTable( "assessment_changelog", "$base/log.sql" ); |
| 63 | + $du->addExtensionTable( "selections", "$base/selections.sql" ); |
| 64 | + return true; |
| 65 | + } |
| 66 | +} |
Property changes on: trunk/extensions/GPoC/SelectionSifter.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 67 | + native |