Brian Wolff has submitted this change and it was merged.
Change subject: Redesign and add more information
......................................................................
Redesign and add more information
Now there are screenshots and descriptions! It still looks sorta ugly.
Change-Id: I0d034dbbb5c1d22390a1657cd86bc0e5a8749562
---
M BetaFeatures.i18n.php
M BetaFeatures.php
M BetaFeaturesHooks.php
M SpecialBetaFeatures.php
A css/betafeatures.css
A images/all-beta.png
A images/null-screenshot.png
M includes/HTMLBetaFeatureField.php
8 files changed, 105 insertions(+), 3 deletions(-)
Approvals:
Brian Wolff: Verified; Looks good to me, approved
diff --git a/BetaFeatures.i18n.php b/BetaFeatures.i18n.php
index c386aec..d5cd165 100644
--- a/BetaFeatures.i18n.php
+++ b/BetaFeatures.i18n.php
@@ -28,6 +28,7 @@
'betafetaures-intro' => "On this page you can enable or disable
features on this wiki that are still in beta. These features may not work as
well as you're used to, so enable at your own risk!",
'betafeatures-enable-all' => 'Enable all beta features',
'betafeatures-extension-description' => 'This extension lets you enable
or disable features on the wiki that are still not ready for prime-time. It
adds a hook and a special page to accomplish this.',
+ 'betafeatures-enable-all-desc' => 'If you enable this choice, all of
the preferences on this page, regardless of their actual value, will be set to
true in the database. Use with caution!',
);
/**
@@ -39,4 +40,5 @@
'betafeatures-intro' => 'The text at the top of Special:BetaFeatures
that explains the function of it.',
'betafeatures-enable-all' => 'Label for a checkbox that enables all
beta features on the wiki',
'betafeatures-extension-description' => 'Description of the extension
for Special:Version',
+ 'betafeatures-enable-all-desc' => 'Description for the enable-all beta
preference.',
);
diff --git a/BetaFeatures.php b/BetaFeatures.php
index e40ae39..27b6572 100644
--- a/BetaFeatures.php
+++ b/BetaFeatures.php
@@ -42,3 +42,11 @@
),
'url' => 'https://mediawiki.org/wiki/Extension:BetaFeatures',
);
+
+$wgResourceModules['ext.betaFeatures'] = array(
+ 'styles' => array(
+ 'css/betafeatures.css',
+ ),
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'BetaFeatures',
+);
diff --git a/BetaFeaturesHooks.php b/BetaFeaturesHooks.php
index e088419..57b9347 100644
--- a/BetaFeaturesHooks.php
+++ b/BetaFeaturesHooks.php
@@ -29,8 +29,15 @@
wfRunHooks( 'GetBetaFeaturePreferences', array( $user,
&$betaPrefs ) );
foreach ( $betaPrefs as $key => $info ) {
- $info['type'] = 'hidden';
- $prefs['beta-feature-' . $key] = $info;
+ $opt = array(
+ 'type' => 'hidden',
+ );
+
+ if ( array_key_exists( 'label-message', $info ) ) {
+ $opt['label-message'] = $info['label-message'];
+ }
+
+ $prefs['beta-feature-' . $key] = $opt;
}
return true;
diff --git a/SpecialBetaFeatures.php b/SpecialBetaFeatures.php
index 9b5e107..f513562 100644
--- a/SpecialBetaFeatures.php
+++ b/SpecialBetaFeatures.php
@@ -28,7 +28,7 @@
}
static function getBetaOptions( $context ) {
- global $wgUser;
+ global $wgUser, $wgExtensionAssetsPath;
$betaOpts = array();
@@ -40,6 +40,8 @@
$betaOpts['enable-all-beta'] = array(
'type' => 'checkbox',
+ 'screenshot' => $wgExtensionAssetsPath .
'/BetaFeatures/images/all-beta.png',
+ 'description' => 'betafeatures-enable-all-desc',
'label-message' => 'betafeatures-enable-all',
);
@@ -49,6 +51,9 @@
function execute( $par ) {
$user = $this->getUser();
$out = $this->getOutput();
+
+ $out->addModuleStyles( 'ext.betaFeatures' );
+
$betaOpts = $this->getBetaOptions( $out );
$formFields = array();
@@ -59,6 +64,14 @@
'id' => 'checkbox-for-' . $label,
'default' => $user->getOption( 'beta-feature-'
. $label ),
);
+
+ if ( array_key_exists( 'screenshot', $opt ) ) {
+ $formFields[$label]['screenshot'] =
$opt['screenshot'];
+ }
+
+ if ( array_key_exists( 'description', $opt ) ) {
+ $formFields[$label]['description'] =
$this->msg( $opt['description'] )->escaped();
+ }
}
$this->setHeaders();
diff --git a/css/betafeatures.css b/css/betafeatures.css
new file mode 100644
index 0000000..cc00d8f
--- /dev/null
+++ b/css/betafeatures.css
@@ -0,0 +1,27 @@
+#mw-content-text form table {
+ width: 100%;
+}
+
+.mw-htmlform-field-HTMLBetaFeatureField {
+ width: 100%;
+}
+
+.beta-feature-field {
+ width: 100%;
+}
+
+.beta-feature-screenshot {
+ width: 10%;
+ display: inline-block;
+ float: left;
+}
+
+.beta-feature-screenshot img {
+ width: 100%;
+}
+
+.beta-feature-main {
+ width: 89%;
+ display: inline-block;
+ float: right;
+}
diff --git a/images/all-beta.png b/images/all-beta.png
new file mode 100644
index 0000000..4db8e1c
--- /dev/null
+++ b/images/all-beta.png
Binary files differ
diff --git a/images/null-screenshot.png b/images/null-screenshot.png
new file mode 100644
index 0000000..fa9b1a9
--- /dev/null
+++ b/images/null-screenshot.png
Binary files differ
diff --git a/includes/HTMLBetaFeatureField.php
b/includes/HTMLBetaFeatureField.php
index b1b03de..9873ccb 100644
--- a/includes/HTMLBetaFeatureField.php
+++ b/includes/HTMLBetaFeatureField.php
@@ -21,15 +21,60 @@
class HTMLBetaFeatureField extends HTMLCheckField {
function getInputHTML( $value ) {
+ global $wgExtensionAssetsPath;
+
$htmls = array();
$id = $this->mParams['id'];
+
+ // The first two characters are always "wp" which we don't need
+ $prefName = substr( $this->mName, 2 );
+ $hasImage = false;
$attrs = array(
'id' => $id,
);
+ $htmls[] = Html::openElement( 'div', array(
+ 'class' => 'beta-feature-field',
+ ) );
+
+ $hasImage = array_key_exists( 'screenshot', $this->mParams );
+ $hasDesc = array_key_exists( 'description', $this->mParams );
+
+ $htmls[] = Html::openElement( 'div', array(
+ 'class' => 'beta-feature-screenshot',
+ ) );
+
+ if ( $hasImage ) {
+ $src = $this->mParams['screenshot'];
+ } else {
+ $src = $wgExtensionAssetsPath .
'/BetaFeatures/images/null-screenshot.png';
+ }
+
+ $htmls[] = Html::rawElement( 'img', array(
+ 'src' => $src,
+ ) );
+
+ $htmls[] = Html::closeElement( 'div' );
+
+ $htmls[] = Html::openElement( 'div', array(
+ 'class' => 'beta-feature-main',
+ ) );
+
+ if ( $hasDesc ) {
+ $htmls[] = Html::rawElement( 'p', array(
+ 'class' => 'beta-feature-description',
+ ), $this->mParams['description'] );
+ }
+
+ $htmls[] = Html::openElement( 'p' );
$htmls[] = Xml::check( $this->mName, $value, $attrs );
$htmls[] = Html::rawElement( 'label', array( 'for' => $id ),
$this->mLabel );
+ $htmls[] = Html::closeElement( 'p' );
+
+ $htmls[] = Html::closeElement( 'div' );
+
+ $htmls[] = Html::closeElement( 'div' );
return implode( '', $htmls );
}
--
To view, visit https://gerrit.wikimedia.org/r/73916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0d034dbbb5c1d22390a1657cd86bc0e5a8749562
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits