Page MenuHomePhabricator

hidden-gadgets.patch

Authored By
bzimport
Nov 21 2014, 11:51 PM
Size
3 KB
Referenced Files
None
Subscribers
None

hidden-gadgets.patch

Index: Gadgets_body.php
===================================================================
--- Gadgets_body.php (wersja 98061)
+++ Gadgets_body.php (kopia robocza)
@@ -65,6 +65,10 @@
$available = array();
foreach ( $thisSection as $gadget ) {
+ if ( $gadget->isHidden() ) {
+ continue;
+ }
+
if ( $gadget->isAllowed( $user ) ) {
$gname = $gadget->getName();
$available[$gadget->getDescription()] = $gname;
@@ -224,7 +228,7 @@
/**
* Increment this when changing class structure
*/
- const GADGET_CLASS_VERSION = 5;
+ const GADGET_CLASS_VERSION = 6;
private $version = self::GADGET_CLASS_VERSION,
$scripts = array(),
@@ -235,6 +239,7 @@
$resourceLoaded = false,
$requiredRights = array(),
$onByDefault = false,
+ $hidden = false,
$category;
/**
@@ -278,6 +283,9 @@
case 'default':
$gadget->onByDefault = true;
break;
+ case 'hidden':
+ $gadget->hidden = true;
+ break;
}
}
@@ -365,6 +373,13 @@
}
/**
+ * @return Boolean: Whether this gadget is hidden in preferences
+ */
+ public function isHidden() {
+ return $this->hidden;
+ }
+
+ /**
* @return Boolean: Whether all of this gadget's JS components support ResourceLoader
*/
public function supportsResourceLoader() {
Index: ApiQueryGadgets.php
===================================================================
--- ApiQueryGadgets.php (wersja 98061)
+++ ApiQueryGadgets.php (kopia robocza)
@@ -120,7 +120,7 @@
'settings' => array(
'rights' => $g->getRequiredRights(),
'default' => $g->isOnByDefault(),
- 'hidden' => false, // Only exists in RL2 branch
+ 'hidden' => $g->isHidden(),
'shared' => false, // Only exists in RL2 branch
'category' => $g->getCategory(),
),
Index: Gadgets_tests.php
===================================================================
--- Gadgets_tests.php (wersja 98061)
+++ Gadgets_tests.php (kopia robocza)
@@ -28,6 +28,7 @@
$this->assertEquals( array( 'Gadget-foo.js' ), $g->getLegacyScripts() );
$this->assertFalse( $g->supportsResourceLoader() );
$this->assertTrue( $g->hasModule() );
+ $this->assertFalse( $g->isHidden() );
}
function testRLtag() {
@@ -35,6 +36,7 @@
$this->assertEquals( 'foo', $g->getName() );
$this->assertTrue( $g->supportsResourceLoader() );
$this->assertEquals( 0, count( $g->getLegacyScripts() ) );
+ $this->assertFalse( $g->isHidden() );
}
function testDependencies() {
@@ -42,8 +44,17 @@
$this->assertEquals( array( 'Gadget-bar.js' ), $g->getScripts() );
$this->assertTrue( $g->supportsResourceLoader() );
$this->assertEquals( array( 'jquery.ui' ), $g->getDependencies() );
+ $this->assertFalse( $g->isHidden() );
}
+ function testHiding() {
+ $g = $this->create( '*foo [ResourceLoader | hidden]|foo.js|foo.css' );
+ $this->assertEquals( 'foo', $g->getName() );
+ $this->assertTrue( $g->supportsResourceLoader() );
+ $this->assertTrue( $g->isHidden() );
+ $this->assertEquals( 0, count( $g->getLegacyScripts() ) );
+ }
+
function testPreferences() {
global $wgUser, $wgOut, $wgTitle;

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7657
Default Alt Text
hidden-gadgets.patch (3 KB)

Event Timeline