jenkins-bot has submitted this change and it was merged.
Change subject: Add a special page to show number of users for each gadget on
the wiki
......................................................................
Add a special page to show number of users for each gadget on the wiki
Bug: T115152
Change-Id: Id1e245f8fdb2fc6a764682ae34937f35af24bd7c
---
M Gadgets.alias.php
A SpecialGadgetUsage.php
M extension.json
M i18n/en.json
M i18n/qqq.json
5 files changed, 146 insertions(+), 2 deletions(-)
Approvals:
Siebrand: Looks good to me, but someone else must approve
Kaldari: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Gadgets.alias.php b/Gadgets.alias.php
index e8f32cf..c63de80 100644
--- a/Gadgets.alias.php
+++ b/Gadgets.alias.php
@@ -12,6 +12,7 @@
/** English (English) */
$specialPageAliases['en'] = array(
'Gadgets' => array( 'Gadgets' ),
+ 'GadgetUsage' => array( 'GadgetUsage' ),
);
/** Afrikaans (Afrikaans) */
@@ -377,4 +378,4 @@
/** Traditional Chinese (中文(繁體)) */
$specialPageAliases['zh-hant'] = array(
'Gadgets' => array( '小工具' ),
-);
\ No newline at end of file
+);
diff --git a/SpecialGadgetUsage.php b/SpecialGadgetUsage.php
new file mode 100644
index 0000000..96cb5b5
--- /dev/null
+++ b/SpecialGadgetUsage.php
@@ -0,0 +1,131 @@
+<?php
+/**
+ * Implements Special:GadgetUsage
+ *
+ * Copyright © 2015 Niharika Kohli
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ * @author Niharika Kohli <[email protected]>
+ */
+
+/**
+ * Special:GadgetUsage - Lists all the gadgets on the wiki along with number
of users.
+ * @ingroup SpecialPage
+ */
+class SpecialGadgetUsage extends QueryPage {
+ function __construct( $name = 'GadgetUsage' ) {
+ parent::__construct( $name );
+ $this->limit = 1000; // Show all gadgets
+ $this->shownavigation = false;
+ }
+
+ public function isExpensive() {
+ return true;
+ }
+
+ public function getQueryInfo() {
+ $dbr = wfGetDB( DB_SLAVE );
+ return array(
+ 'tables' => array( 'user_properties' ),
+ 'fields' => array(
+ 'title' => 'up_property',
+ 'value' => 'SUM( up_value )',
+ 'namespace' => NS_GADGET
+ ),
+ 'conds' => array(
+ 'up_property' . $dbr->buildLike( 'gadget-',
$dbr->anyString() )
+ ),
+ 'options' => array(
+ 'GROUP BY' => array( 'up_property' )
+ )
+ );
+ }
+
+ public function getOrderFields() {
+ return array( 'up_property' );
+ }
+
+ /**
+ * Output the start of the table
+ * Including opening <table>, and first <tr> with column headers.
+ */
+ protected function outputTableStart() {
+ $html = Html::openElement( 'table', array( 'class' => array(
'sortable', 'wikitable' ) ) );
+ $html .= Html::openElement( 'tr', array() );
+
+ $headers = array( 'gadgetusage-gadget', 'gadgetusage-usercount'
);
+ foreach( $headers as $h ) {
+ $html .= Html::rawElement( 'th', array(), $this->msg(
$h )->escaped() );
+ }
+ $html .= Html::closeElement( 'tr' );
+ $this->getOutput()->addHTML( $html );
+ }
+
+ /**
+ * @param Skin $skin
+ * @param object $result Result row
+ * @return string bool
+ */
+ public function formatResult( $skin, $result ) {
+ $gadgetTitle = wfEscapeWikiText( substr( $result->title, 7 ) );
+ $gadgetUserCount = $this->getLanguage()->formatNum(
$result->value );
+ if ( $gadgetTitle ) {
+ $html = Html::openElement( 'tr', array() );
+ $html .= Html::rawElement( 'td', array(), $gadgetTitle
);
+ $html .= Html::rawElement( 'td', array(),
$gadgetUserCount );
+ $html .= Html::closeElement( 'tr' );
+ return $html;
+ }
+ return false;
+ }
+
+ /**
+ * Format and output report results using the given information plus
+ * OutputPage
+ *
+ * @param OutputPage $out OutputPage to print to
+ * @param Skin $skin User skin to use
+ * @param IDatabase $dbr Database (read) connection to use
+ * @param ResultWrapper $res Result pointer
+ * @param int $num Number of available result rows
+ * @param int $offset Paging offset
+ */
+ protected function outputResults( $out, $skin, $dbr, $res, $num,
$offset ) {
+ if ( $num > 0 ) {
+ $this->outputTableStart();
+
+ foreach ( $res as $row ) {
+ $line = $this->formatResult( $skin, $row );
+ if ( $line ) {
+ $out->addHTML( $line );
+ }
+ }
+ // Close table element
+ $out->addHtml( Html::closeElement( 'table' ) );
+ } else {
+ $out->addHtml(
+ $this->msg( 'gadgetusage-noresults'
)->parseAsBlock()
+ );
+ }
+ }
+
+ protected function getGroupName() {
+ return 'wiki';
+ }
+}
diff --git a/extension.json b/extension.json
index 423861d..6b330d7 100644
--- a/extension.json
+++ b/extension.json
@@ -38,7 +38,8 @@
"gadgets-definition-edit"
],
"SpecialPages": {
- "Gadgets": "SpecialGadgets"
+ "Gadgets": "SpecialGadgets",
+ "GadgetUsage": "SpecialGadgetUsage"
},
"APIListModules": {
"gadgetcategories": "ApiQueryGadgetCategories",
@@ -60,6 +61,7 @@
"GadgetHooks": "GadgetHooks.php",
"GadgetResourceLoaderModule":
"includes/GadgetResourceLoaderModule.php",
"SpecialGadgets": "SpecialGadgets.php",
+ "SpecialGadgetUsage": "SpecialGadgetUsage.php",
"GadgetRepo": "includes/GadgetRepo.php",
"MediaWikiGadgetsDefinitionRepo":
"includes/MediaWikiGadgetsDefinitionRepo.php"
},
diff --git a/i18n/en.json b/i18n/en.json
index 7b8170b..4d2a164 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,6 +8,11 @@
"prefs-gadgets": "Gadgets",
"gadgets-prefstext": "Below is a list of special gadgets you can enable
for your account.\nThese gadgets are mostly based on JavaScript, so JavaScript
has to be enabled in your browser for them to work.\nNote that these gadgets
will have no effect on this preferences page.\n\nAlso note that these special
gadgets are not part of the MediaWiki software, and are usually developed and
maintained by users on your local wiki.\nLocal administrators can edit the
[[MediaWiki:Gadgets-definition|definitions]] and
[[Special:Gadgets|descriptions]] of available gadgets.",
"gadgets": "Gadgets",
+ "gadgetusage": "Gadget usage statistics",
+ "gadgetusage-gadget": "Gadget",
+ "gadgetusage-usercount": "Number of users",
+ "gadgetusage-noresults": "No gadgets found.",
+ "gadgetusage-summary": "This table indicates the number of users who
have enabled each gadget on this wiki. It may include gadgets that are no
longer available.",
"gadgets-definition": "",
"gadgets-title": "Gadgets",
"gadgets-pagetext": "Below is a list of special gadgets users can
enable on their [[Special:Preferences#mw-prefsection-gadgets|preferences
page]], as defined by the [[MediaWiki:Gadgets-definition|definitions]].\nThis
overview provides easy access to the system message pages that define each
gadget's description and code.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 011bba6..1b75e29 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -19,6 +19,11 @@
"prefs-gadgets": "In Gadgets extension. The name of a tab in
[[Special:Preferences#mw-prefsection-gadgets|Special:Preferences]] where user
set their preferences for the extension.\n\n{{Identical|Gadgets}}",
"gadgets-prefstext": "In Gadgets extension. This is the explanation
text displayed under the Gadgets tab in
[[Special:Preferences#mw-prefsection-gadgets|Special:Preferences]].",
"gadgets": "{{doc-special|Gadgets}}\n{{Identical|Gadgets}}",
+ "gadgetusage": "{{doc-special|Gadget usage statistics}}",
+ "gadgetusage-gadget": "Table column header on [[Special:GadgetUsage]]",
+ "gadgetusage-usercount": "Table column header on
[[Special:GadgetUsage]]",
+ "gadgetusage-noresults": "Message shown to user when no gadgets found
installed on the wiki. Used on [[Special:GadgetUsage]]",
+ "gadgetusage-summary": "Intro text on [[Special:GadgetUsage]]",
"gadgets-definition": "{{notranslate}}",
"gadgets-title": "{{Identical|Gadgets}}",
"gadgets-pagetext": "Used as intro text in [[Special:Gadgets]].",
--
To view, visit https://gerrit.wikimedia.org/r/247559
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id1e245f8fdb2fc6a764682ae34937f35af24bd7c
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Glaisher <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Niharika29 <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits