Legoktm has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/348198 )
Change subject: Add namespace filter to Special:LintErrors
......................................................................
Add namespace filter to Special:LintErrors
Bug: T162918
Change-Id: Id41faeafb9af161d32d5c273094fb2e6d8a8a64b
---
M i18n/en.json
M i18n/qqq.json
M includes/LintErrorsPager.php
M includes/SpecialLintErrors.php
4 files changed, 37 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter
refs/changes/98/348198/1
diff --git a/i18n/en.json b/i18n/en.json
index 9d904d8..bed97b6 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -7,6 +7,7 @@
"linterrors": "Lint errors",
"linterrors-subpage": "Lint errors: $1",
"linter-desc": "Track lint errors from an external service and show
them to users",
+ "linter-form-namespace": "Namespace:",
"linter-pager-title": "Page title",
"linter-pager-template": "Through a template?",
"linter-pager-obsolete-tag-details": "Obsolete HTML tag",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 93c4291..5dd3129 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -9,6 +9,7 @@
"linterrors": "{{doc-special|LintErrors}}",
"linterrors-subpage": "Page title for Special:LintErrors, $1 is the
localized category description",
"linter-desc":
"{{desc|name=Linter|url=https://www.mediawiki.org/wiki/Extension:Linter}}",
+ "linter-form-namespace": "Label for select field on Special:LintErrors",
"linter-pager-title": "Table column heading for the column with page
titles in it\n{{Identical|Page title}}",
"linter-pager-template": "Table column heading for column with template
title in it or an em dash if lint error is not inside a template",
"linter-pager-obsolete-tag-details": "Table column heading",
diff --git a/includes/LintErrorsPager.php b/includes/LintErrorsPager.php
index 81d9b3a..fac9107 100644
--- a/includes/LintErrorsPager.php
+++ b/includes/LintErrorsPager.php
@@ -41,16 +41,26 @@
*/
private $linkRenderer;
+ /**
+ * @var int|null
+ */
+ private $namespace;
+
public function __construct( IContextSource $context, $category,
LinkRenderer $linkRenderer,
- CategoryManager $catManager
+ CategoryManager $catManager, $namespace
) {
$this->category = $category;
$this->categoryId = $catManager->getCategoryId( $this->category
);
$this->linkRenderer = $linkRenderer;
+ $this->namespace = $namespace;
parent::__construct( $context );
}
public function getQueryInfo() {
+ $conds = [ 'linter_cat' => $this->categoryId ];
+ if ( $this->namespace !== null ) {
+ $conds['page_namespace'] = $this->namespace;
+ }
return [
'tables' => [ 'page', 'linter' ],
'fields' => array_merge(
@@ -61,7 +71,7 @@
'linter_start', 'linter_end',
]
),
- 'conds' => [ 'linter_cat' => $this->categoryId ],
+ 'conds' => $conds,
'join_conds' => [ 'page' => [ 'INNER JOIN',
'page_id=linter_page' ] ]
];
}
diff --git a/includes/SpecialLintErrors.php b/includes/SpecialLintErrors.php
index f13e765..ed100f3 100644
--- a/includes/SpecialLintErrors.php
+++ b/includes/SpecialLintErrors.php
@@ -20,6 +20,7 @@
namespace MediaWiki\Linter;
+use HTMLForm;
use Html;
use SpecialPage;
@@ -29,6 +30,25 @@
public function __construct() {
parent::__construct( 'LintErrors' );
+ }
+
+ protected function showNamespaceFilterForm( $ns ) {
+ $fields = [
+ 'namespace' => [
+ 'type' => 'namespaceselect',
+ 'name' => 'namespace',
+ 'label-message' => 'linter-form-namespace',
+ 'default' => $ns,
+ 'id' => 'namespace',
+ 'all' => '',
+ 'cssclass' => 'namespaceselector',
+ ],
+ ];
+ $form = HTMLForm::factory( 'ooui', $fields, $this->getContext()
);
+ $form->setWrapperLegend( true );
+ $form->addHeaderText( $this->msg(
"linter-category-{$this->category}-desc" )->escaped() );
+ $form->setMethod( 'get' );
+ $form->prepareForm()->displayForm( false );
}
public function execute( $par ) {
@@ -51,10 +71,11 @@
)
);
$out->addBacklinkSubtitle( $this->getPageTitle() );
- $out->addWikiMsg(
"linter-category-{$this->category}-desc" );
+ $ns = $this->getRequest()->getIntOrNull( 'namespace' );
+ $this->showNamespaceFilterForm( $ns );
$pager = new LintErrorsPager(
$this->getContext(), $this->category,
$this->getLinkRenderer(),
- $catManager
+ $catManager, $ns
);
$out->addParserOutput( $pager->getFullOutput() );
}
--
To view, visit https://gerrit.wikimedia.org/r/348198
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id41faeafb9af161d32d5c273094fb2e6d8a8a64b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits