MaxSem has uploaded a new change for review. https://gerrit.wikimedia.org/r/60954
Change subject: Mobile support ...................................................................... Mobile support * Allow other extensions to disallow legacy gadgets * Allow specifying module targets, effectively creating mobile gadgets Change-Id: I9ee852e33412826608b6039fa01a2b0027b35e7b --- M Gadgets_body.php 1 file changed, 23 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gadgets refs/changes/54/60954/1 diff --git a/Gadgets_body.php b/Gadgets_body.php index ab61ad7..fcf2e9a 100644 --- a/Gadgets_body.php +++ b/Gadgets_body.php @@ -182,17 +182,21 @@ } } - $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__ ); @@ -255,6 +259,7 @@ $resourceLoaded = false, $requiredRights = array(), $requiredSkins = array(), + $targets = array( 'desktop' ), $onByDefault = false, $category; @@ -301,6 +306,9 @@ break; case 'default': $gadget->onByDefault = true; + break; + case 'targets': + $gadget->targets = $params; break; } } @@ -455,7 +463,7 @@ return null; } - return new GadgetResourceLoaderModule( $pages, $this->dependencies ); + return new GadgetResourceLoaderModule( $pages, $this->dependencies, $this->targets ); } /** @@ -624,17 +632,20 @@ /** * 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; } /** -- To view, visit https://gerrit.wikimedia.org/r/60954 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9ee852e33412826608b6039fa01a2b0027b35e7b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gadgets Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits