jenkins-bot has submitted this change and it was merged.
Change subject: Add support for 'messages' and 'hidden' gadgets
......................................................................
Add support for 'messages' and 'hidden' gadgets
In the backend, allow:
* Adding dependencies on messages
* Marking gadgets as hidden so they don't show in preferences
These cannot be used by MediaWiki:Gadgets-definition gadgets, but will
be used by Gadgets 2.0 gadgets.
Change-Id: I55e97de9d631ae001ccc0164db172ba9c5689a34
---
M GadgetHooks.php
M Gadgets_body.php
M api/ApiQueryGadgets.php
M includes/GadgetResourceLoaderModule.php
4 files changed, 38 insertions(+), 8 deletions(-)
Approvals:
Alex Monk: Looks good to me, approved
jenkins-bot: Verified
diff --git a/GadgetHooks.php b/GadgetHooks.php
index 066e216..8c39394 100644
--- a/GadgetHooks.php
+++ b/GadgetHooks.php
@@ -89,7 +89,7 @@
* @var $gadget Gadget
*/
foreach ( $thisSection as $gadget ) {
- if ( $gadget->isAllowed( $user ) ) {
+ if ( !$gadget->isHidden() &&
$gadget->isAllowed( $user ) ) {
$gname = $gadget->getName();
# bug 30182: dir="auto" because it's
often not translated
$desc = '<span dir="auto">' .
$gadget->getDescription() . '</span>';
diff --git a/Gadgets_body.php b/Gadgets_body.php
index ed861e4..d3483e2 100755
--- a/Gadgets_body.php
+++ b/Gadgets_body.php
@@ -19,13 +19,14 @@
/**
* Increment this when changing class structure
*/
- const GADGET_CLASS_VERSION = 8;
+ const GADGET_CLASS_VERSION = 9;
const CACHE_TTL = 86400;
private $scripts = array(),
$styles = array(),
$dependencies = array(),
+ $messages = array(),
$name,
$definition,
$resourceLoaded = false,
@@ -33,6 +34,7 @@
$requiredSkins = array(),
$targets = array( 'desktop' ),
$onByDefault = false,
+ $hidden = false,
$position = 'bottom',
$category;
@@ -45,6 +47,7 @@
case 'scripts':
case 'styles':
case 'dependencies':
+ case 'messages':
case 'name':
case 'definition':
case 'resourceLoaded':
@@ -53,6 +56,7 @@
case 'targets':
case 'onByDefault':
case 'position':
+ case 'hidden':
case 'category':
$this->{$member} = $option;
break;
@@ -137,6 +141,13 @@
}
/**
+ * @return bool
+ */
+ public function isHidden() {
+ return $this->hidden;
+ }
+
+ /**
* @return Boolean: Whether all of this gadget's JS components support
ResourceLoader
*/
public function supportsResourceLoader() {
@@ -202,7 +213,13 @@
return null;
}
- return new GadgetResourceLoaderModule( $pages,
$this->dependencies, $this->targets, $this->position );
+ return new GadgetResourceLoaderModule(
+ $pages,
+ $this->dependencies,
+ $this->targets,
+ $this->position,
+ $this->messages
+ );
}
/**
@@ -225,6 +242,13 @@
}
/**
+ * @return array
+ */
+ public function getMessages() {
+ return $this->messages;
+ }
+
+ /**
* Returns array of permissions required by this gadget
* @return Array
*/
diff --git a/api/ApiQueryGadgets.php b/api/ApiQueryGadgets.php
index d014fd7..383faf0 100644
--- a/api/ApiQueryGadgets.php
+++ b/api/ApiQueryGadgets.php
@@ -147,8 +147,8 @@
'rights' => $g->getRequiredRights(),
'skins' => $g->getRequiredSkins(),
'default' => $g->isOnByDefault(),
- 'hidden' => false, // Only exists in RL2 branch
- 'shared' => false, // Only exists in RL2 branch
+ 'hidden' => $g->isHidden(),
+ 'shared' => false,
'category' => $g->getCategory(),
'legacyscripts' => (bool)$g->getLegacyScripts(),
),
@@ -156,7 +156,7 @@
'scripts' => $g->getScripts(),
'styles' => $g->getStyles(),
'dependencies' => $g->getDependencies(),
- 'messages' => array(), // Only exists in RL2
branch
+ 'messages' => $g->getMessages(),
)
);
}
diff --git a/includes/GadgetResourceLoaderModule.php
b/includes/GadgetResourceLoaderModule.php
index 471e642..7f00e4c 100644
--- a/includes/GadgetResourceLoaderModule.php
+++ b/includes/GadgetResourceLoaderModule.php
@@ -4,7 +4,7 @@
* Class representing a list of resources for one gadget
*/
class GadgetResourceLoaderModule extends ResourceLoaderWikiModule {
- private $pages, $dependencies;
+ private $pages, $dependencies, $messages;
/**
* Creates an instance of this class
@@ -18,13 +18,15 @@
* @param $dependencies Array: Names of resources this module depends on
* @param $targets Array: List of targets this module support
* @param $position String: 'bottom' or 'top'
+ * @param $messages Array
*/
- public function __construct( $pages, $dependencies, $targets, $position
) {
+ public function __construct( $pages, $dependencies, $targets,
$position, $messages ) {
$this->pages = $pages;
$this->dependencies = $dependencies;
$this->targets = $targets;
$this->position = $position;
$this->isPositionDefined = true;
+ $this->messages = $messages;
}
/**
@@ -52,4 +54,8 @@
public function getPosition() {
return $this->position;
}
+
+ public function getMessages() {
+ return $this->messages;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/228780
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I55e97de9d631ae001ccc0164db172ba9c5689a34
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits