summaryrefslogtreecommitdiff
path: root/extensions/Gadgets/Gadgets_body.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
commit08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch)
tree577a29fb579188d16003a209ce2a2e9c5b0aa2bd /extensions/Gadgets/Gadgets_body.php
parentcacc939b34e315b85e2d72997811eb6677996cc1 (diff)
Update to MediaWiki 1.21.1
Diffstat (limited to 'extensions/Gadgets/Gadgets_body.php')
-rw-r--r--extensions/Gadgets/Gadgets_body.php51
1 files changed, 31 insertions, 20 deletions
diff --git a/extensions/Gadgets/Gadgets_body.php b/extensions/Gadgets/Gadgets_body.php
index 330a1541..e787062a 100644
--- a/extensions/Gadgets/Gadgets_body.php
+++ b/extensions/Gadgets/Gadgets_body.php
@@ -182,17 +182,21 @@ class GadgetHooks {
}
}
- $lb->execute( __METHOD__ );
- $done = array();
+ // Allow other extensions, e.g. MobileFrontend, to disallow legacy gadgets
+ if ( wfRunHooks( 'Gadgets::allowLegacy', array( $out->getContext() ) ) ) {
+ $lb->execute( __METHOD__ );
- foreach ( $pages as $page ) {
- if ( isset( $done[$page] ) ) {
- continue;
- }
+ $done = array();
+
+ foreach ( $pages as $page ) {
+ if ( isset( $done[$page] ) ) {
+ continue;
+ }
- $done[$page] = true;
- self::applyScript( $page, $out );
+ $done[$page] = true;
+ self::applyScript( $page, $out );
+ }
}
wfProfileOut( __METHOD__ );
@@ -202,8 +206,8 @@ class GadgetHooks {
/**
* Adds one legacy script to output.
*
- * @param $page String: Unprefixed page title
- * @param $out OutputPage
+ * @param string $page Unprefixed page title
+ * @param OutputPage $out
*/
private static function applyScript( $page, $out ) {
global $wgJsMimeType;
@@ -227,12 +231,12 @@ class GadgetHooks {
/**
* UnitTestsList hook handler
- * @param $files Array: List of extension test files
+ * @param array $files
* @return bool
*/
- public static function unitTestsList( $files ) {
- $files[] = dirname( __FILE__ ) . '/Gadgets_tests.php';
-
+ public static function onUnitTestsList( array &$files ) {
+ $testDir = __DIR__ . '/tests/';
+ $files = array_merge( $files, glob( "$testDir/*Test.php" ) );
return true;
}
}
@@ -255,6 +259,7 @@ class Gadget {
$resourceLoaded = false,
$requiredRights = array(),
$requiredSkins = array(),
+ $targets = array( 'desktop' ),
$onByDefault = false,
$category;
@@ -302,6 +307,9 @@ class Gadget {
case 'default':
$gadget->onByDefault = true;
break;
+ case 'targets':
+ $gadget->targets = $params;
+ break;
}
}
@@ -455,7 +463,7 @@ class Gadget {
return null;
}
- return new GadgetResourceLoaderModule( $pages, $this->dependencies );
+ return new GadgetResourceLoaderModule( $pages, $this->dependencies, $this->targets );
}
/**
@@ -553,7 +561,7 @@ class Gadget {
* Loads list of gadgets and returns it as associative array of sections with gadgets
* e.g. array( 'sectionnname1' => array( $gadget1, $gadget2),
* 'sectionnname2' => array( $gadget3 ) );
- * @param $forceNewText String: New text of MediaWiki:gadgets-sdefinition. If specified, will
+ * @param $forceNewText String: New text of MediaWiki:gadgets-definition. If specified, will
* force a purge of cache and recreation of the gadget list.
* @return Mixed: Array or false
*/
@@ -587,7 +595,7 @@ class Gadget {
$g = $forceNewText;
}
- $g = preg_replace( '/<!--.*-->/s', '', $g );
+ $g = preg_replace( '/<!--.*?-->/s', '', $g );
$g = preg_split( '/(\r\n|\r|\n)+/', $g );
$gadgets = array();
@@ -624,17 +632,20 @@ class GadgetResourceLoaderModule extends ResourceLoaderWikiModule {
/**
* Creates an instance of this class
+ *
* @param $pages Array: Associative array of pages in ResourceLoaderWikiModule-compatible
* format, for example:
* array(
- * 'MediaWiki:Gadget-foo.js' => array( 'type' => 'script' ),
- * 'MediaWiki:Gadget-foo.css' => array( 'type' => 'style' ),
+ * 'MediaWiki:Gadget-foo.js' => array( 'type' => 'script' ),
+ * 'MediaWiki:Gadget-foo.css' => array( 'type' => 'style' ),
* )
* @param $dependencies Array: Names of resources this module depends on
+ * @param $targets Array: List of targets this module support
*/
- public function __construct( $pages, $dependencies ) {
+ public function __construct( $pages, $dependencies, $targets ) {
$this->pages = $pages;
$this->dependencies = $dependencies;
+ $this->targets = $targets;
}
/**