MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/74307
Change subject: Add user count, play with layout a bit
......................................................................
Add user count, play with layout a bit
Change-Id: I24dab7b1034f2efcd1959d6c69858f3ec37a06bd
---
M BetaFeatures.i18n.php
M SpecialBetaFeatures.php
M css/betafeatures.css
M includes/HTMLBetaFeatureField.php
4 files changed, 87 insertions(+), 23 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures
refs/changes/07/74307/1
diff --git a/BetaFeatures.i18n.php b/BetaFeatures.i18n.php
index d5cd165..3cd9136 100644
--- a/BetaFeatures.i18n.php
+++ b/BetaFeatures.i18n.php
@@ -27,8 +27,10 @@
'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-title' => 'Enable All',
'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!',
+ 'betafeatures-enable-all-desc' => 'If you enable this feature, you will
be automatically given all of the latest beta features.',
+ 'betafeatures-user-count' => '{{PLURAL:$1|One user has|$2 users have}}
enabled this feature.',
);
/**
@@ -39,6 +41,8 @@
'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-title' => 'Title for the field 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.',
+ 'betafeatures-user-count' => 'Displays how many users on the wiki have
the preference enabled. First parameter is the number of users, second
parameter is the commafied version (e.g. 1002 vs. 1,002).',
);
diff --git a/SpecialBetaFeatures.php b/SpecialBetaFeatures.php
index 2e9d81e..47cd503 100644
--- a/SpecialBetaFeatures.php
+++ b/SpecialBetaFeatures.php
@@ -36,6 +36,7 @@
'screenshot' => $wgExtensionAssetsPath .
'/BetaFeatures/images/all-beta.png',
'description' => 'betafeatures-enable-all-desc',
'label-message' => 'betafeatures-enable-all',
+ 'title-message' =>
'betafeatures-enable-all-title',
),
);
@@ -48,9 +49,29 @@
return $betaOpts;
}
+ static function getUserCounts() {
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select(
+ 'user_properties',
+ array( 'up_property', 'count(up_user) AS number' ),
+ "up_value = 1 AND up_property REGEXP '^beta-feature-'",
+ __METHOD__,
+ array()
+ );
+
+ $counts = array();
+
+ foreach ( $res as $row ) {
+ $counts[$row->up_property] = $row->number;
+ }
+
+ return $counts;
+ }
+
function execute( $par ) {
$user = $this->getUser();
$out = $this->getOutput();
+ $lang = $this->getLang();
$out->addModuleStyles( 'ext.betaFeatures' );
@@ -59,12 +80,21 @@
$allEnabled = $user->getOption( 'enable-all-beta' );
+ $userCount = self::getUserCounts();
+
foreach ( $betaOpts as $label => $opt ) {
+ $prefname = $label;
+
+ if ( $label !== 'enable-all-beta' ) {
+ $prefname = 'beta-feature-' . $label;
+ }
+
$formFields[$label] = array(
'label' => $this->msg( $opt['label-message']
)->escaped(),
+ 'title' => $this->msg( $opt['title-message']
)->escaped(),
'class' => 'HTMLBetaFeatureField',
'id' => 'checkbox-for-' . $label,
- 'default' => $user->getOption( 'beta-feature-'
. $label ),
+ 'default' => $user->getOption( $prefname ),
);
if ( array_key_exists( 'screenshot', $opt ) ) {
@@ -79,6 +109,13 @@
$formFields[$label]['htmlclass'] =
'all-enabled';
$formFields[$label]['disabled'] = true;
}
+
+ if ( array_key_exists( $prefname, $userCount ) ) {
+ $formFields[$label]['userCount'] = $this->msg(
+ 'betafeatures-user-count',
+ $userCount[$prefname],
+ $lang->commafy( $userCount[$prefname] )
)->escaped();
+ }
}
$formFields['enable-all-beta']['default'] = $allEnabled;
diff --git a/css/betafeatures.css b/css/betafeatures.css
index 8618101..4443da5 100644
--- a/css/betafeatures.css
+++ b/css/betafeatures.css
@@ -1,5 +1,5 @@
#mw-content-text form table {
- width: 100%;
+ width: 70%;
}
.mw-htmlform-field-HTMLBetaFeatureField {
@@ -10,9 +10,16 @@
width: 100%;
}
+.beta-feature-contain {
+ position: relative;
+}
+
.beta-feature-screenshot {
- width: 10%;
+ position: absolute;
+ width: 12%;
display: inline-block;
+ top: 0px;
+ right: 0px;
}
.beta-feature-screenshot img {
@@ -20,11 +27,14 @@
}
.beta-feature-main {
- margin-left: 1%;
- width: 89%;
+ width: 80%;
display: inline-block;
}
.beta-feature-field.all-enabled {
opacity: 0.3;
}
+
+.beta-feature-user-count {
+ color: #00b08a;
+}
diff --git a/includes/HTMLBetaFeatureField.php
b/includes/HTMLBetaFeatureField.php
index 4b4a9c2..4f5da86 100644
--- a/includes/HTMLBetaFeatureField.php
+++ b/includes/HTMLBetaFeatureField.php
@@ -54,6 +54,35 @@
$hasImage = array_key_exists( 'screenshot', $this->mParams );
$hasDesc = array_key_exists( 'description', $this->mParams );
+ $htmls[] = Html::rawElement( 'h2', array(),
$this->mParams['title'] );
+
+ $htmls[] = Html::openElement( 'div', array(
+ 'class' => 'beta-feature-contain',
+ ) );
+
+ $htmls[] = Html::openElement( 'div', array(
+ 'class' => 'beta-feature-main',
+ ) );
+
+ if ( array_key_exists( 'userCount', $this->mParams ) ) {
+ $htmls[] = Html::rawElement(
+ 'p',
+ array( 'class' => 'beta-feature-user-count' ),
+ $this->mParams['userCount']
+ );
+ }
+
+ 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::openElement( 'div', array(
'class' => 'beta-feature-screenshot',
) );
@@ -69,24 +98,8 @@
) );
$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' );
$htmls[] = Html::closeElement( 'div' );
return implode( '', $htmls );
--
To view, visit https://gerrit.wikimedia.org/r/74307
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I24dab7b1034f2efcd1959d6c69858f3ec37a06bd
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