r105128 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105127‎ | r105128 | r105129 >
Date:21:38, 4 December 2011
Author:yuvipanda
Status:resolved (Comments)
Tags:
Comment:
Renamed GPoC to SelectionSifter
Modified paths:
  • /trunk/extensions/GPoC/GPoC.hooks.php (deleted) (history)
  • /trunk/extensions/GPoC/GPoC.php (deleted) (history)
  • /trunk/extensions/GPoC/SelectionSifter.hooks.php (added) (history)
  • /trunk/extensions/GPoC/SelectionSifter.php (added) (history)

Diff [purge]

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
150 + 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
167 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r105165Rename extensions/GPoC to extensions/SelectionSifter . Requested on IRC by yu...catrope11:20, 5 December 2011

Comments

#Comment by Raymond (talk | contribs)   07:37, 5 December 2011

Why not renaiming the extension directory too?

#Comment by YuviPanda (talk | contribs)   08:15, 5 December 2011

Don't have entire extensions folder checked out. And my google-fu wasn't able to find me a way to rename the checked-out folder alone :(

Was planning on asking someone who does have the entire extensions folder checked out to rename it for me :)

#Comment by Hashar (talk | contribs)   14:03, 6 December 2011

Renamed by Roan with r105165

Status & tagging log