http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72071
Revision: 72071
Author: reedy
Date: 2010-09-01 00:06:30 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
Merge hooks. JS is used to add stuff onto pages. Do restriction now in
addResources
As before, only for NS_MAIN, but also, has to be in $wgArticleAssessmentPages
To add stuff... After including the extension in LocalSettings, add
$wgArticleAssessmentPages = array( 1 => 'Main page', 25 => 'Something' );
ie pageid => title
Right hand side of the => doesn't matter hugely, just neededed to force the
pageid to be the key. Some maintainability i suppose also?
Remove some trailing whitespace
Modified Paths:
--------------
trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php
Modified:
trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
===================================================================
--- trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
2010-09-01 00:00:18 UTC (rev 72070)
+++ trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
2010-09-01 00:06:30 UTC (rev 72071)
@@ -46,8 +46,22 @@
}
public static function addResources( $out ) {
+ $title = $out->getTitle();
+
+ // Chances are we only want to be rating Mainspace, right?
+ if ( $title->getNamespace() !== NS_MAIN ) {
+ return true;
+ }
+
+ global $wgArticleAssessmentPages;
+
+ // check if this page should have the form
+ if ( !array_key_exists( $title->getArticleId() ,
$wgArticleAssessmentPages ) ) {
+ return true;
+ }
+
global $wgExtensionAssetsPath;
-
+
foreach ( self::$scriptFiles as $script ) {
$out->addScriptFile( $wgExtensionAssetsPath .
"/ArticleAssessmentPilot/{$script['src']}",
$script['version']
@@ -59,7 +73,7 @@
"/ArticleAssessmentPilot/{$style['src']}?{$style['version']}"
);
}
-
+
// Transforms messages into javascript object members
self::$messages = array(
'articleassessment',
@@ -83,7 +97,7 @@
'articleassessment-results-show',
'articleassessment-results-hide',
);
-
+
foreach ( self::$messages as $i => $message ) {
$escapedMessageValue = Xml::escapeJsString( wfMsg(
$message ) );
$escapedMessageKey = Xml::escapeJsString( $message );
@@ -99,7 +113,7 @@
return true;
}
-
+
/**
* Adds a reference to a javascript file to the head of the document
* @param string $src Path to the file relative to this extension's
folder
@@ -109,7 +123,7 @@
// The key is Andrew's snarky 20-character way of stopping
multiple inclusion of the same file.
self::$scripts["$src?$version"] = array( 'src' => $src,
'version' => $version );
}
-
+
/**
* Adds internationalized message definitions to the document for access
* via javascript using the mw.usability.getMsg() function
@@ -118,26 +132,4 @@
public static function addMessages( $messages ) {
self::$messages = array_merge( self::$messages, $messages );
}
-
- public static function addCode( &$data, $skin ) {
- $title = $skin->getTitle();
-
- // Chances are we only want to be rating Mainspace, right?
- if ( $title->getNamespace() !== NS_MAIN ) {
- return true;
- }
-
- global $wgArticleAssessmentPages;
-
- // check if this page should have the form
- if ( !array_key_exists( $title->getArticleId() ,
$wgArticleAssessmentPages ) ) {
- return true;
- }
-
- // write the form
-
- // if user has no cookie, set cookie
-
- return true;
- }
}
\ No newline at end of file
Modified: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php
===================================================================
--- trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php
2010-09-01 00:00:18 UTC (rev 72070)
+++ trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php
2010-09-01 00:06:30 UTC (rev 72071)
@@ -20,7 +20,6 @@
// Hooks
$wgHooks['BeforePageDisplay'][] = 'ArticleAssessmentPilotHooks::addResources';
-$wgHooks['SkinAfterContent'][] = 'ArticleAssessmentPilotHooks::addCode';
// API modules
$wgAPIListModules['articleassessment'] = 'ApiListArticleAssessment';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs