MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/73916
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures
refs/changes/16/73916/1
diff --git a/BetaFeatures.i18n.php b/BetaFeatures.i18n.php
index 03d94b3..38285cf 100644
--- a/BetaFeatures.i18n.php
+++ b/BetaFeatures.i18n.php
@@ -20,10 +20,12 @@
'betafeatures' => 'Beta Features',
'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-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!',
);
$messages['qqq'] = array(
'betafeatures' => 'Label for the special page where beta features can
be enabled.',
'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-enable-all-desc' => 'Description for the enable-all beta
preference.',
);
diff --git a/BetaFeatures.php b/BetaFeatures.php
index 1daefc2..031af3b 100644
--- a/BetaFeatures.php
+++ b/BetaFeatures.php
@@ -25,3 +25,11 @@
$wgSpecialPages['BetaFeatures'] = 'SpecialBetaFeatures';
$wgHooks['GetPreferences'][] = 'BetaFeaturesHooks::getPreferences';
+
+$wgResourceModules['ext.betaFeatures'] = array(
+ 'styles' => array(
+ 'css/betafeatures.css',
+ ),
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'BetaFeatures',
+);
diff --git a/BetaFeaturesHooks.php b/BetaFeaturesHooks.php
index f7e1459..19553fd 100644
--- a/BetaFeaturesHooks.php
+++ b/BetaFeaturesHooks.php
@@ -24,8 +24,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 e837a75..965721e 100644
--- a/SpecialBetaFeatures.php
+++ b/SpecialBetaFeatures.php
@@ -23,7 +23,7 @@
}
static function getBetaOptions( $context ) {
- global $wgUser;
+ global $wgUser, $wgExtensionAssetsPath;
$betaOpts = array();
@@ -35,6 +35,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',
);
@@ -44,6 +46,9 @@
function execute( $par ) {
global $wgUser;
$out = $this->getOutput();
+
+ $out->addModuleStyles( 'ext.betaFeatures' );
+
$betaOpts = $this->getBetaOptions( $out );
$formFields = array();
@@ -54,6 +59,14 @@
'id' => 'checkbox-for-' . $label,
'default' => $wgUser->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: newchange
Gerrit-Change-Id: I0d034dbbb5c1d22390a1657cd86bc0e5a8749562
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits