2016-10-13 08:14:18 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace MediaWiki\Linter;
|
|
|
|
|
2020-01-10 10:06:26 +00:00
|
|
|
use HTMLForm;
|
2024-04-05 02:41:38 +00:00
|
|
|
use MediaWiki\Cache\LinkCache;
|
2023-06-13 22:26:52 +00:00
|
|
|
use MediaWiki\Html\Html;
|
2024-01-06 16:03:30 +00:00
|
|
|
use MediaWiki\Output\OutputPage;
|
2024-04-05 02:41:38 +00:00
|
|
|
use MediaWiki\Permissions\PermissionManager;
|
2024-01-06 16:03:30 +00:00
|
|
|
use MediaWiki\Request\WebRequest;
|
|
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
|
|
|
use MediaWiki\Title\MalformedTitleException;
|
2024-04-04 21:41:29 +00:00
|
|
|
use MediaWiki\Title\NamespaceInfo;
|
|
|
|
use MediaWiki\Title\TitleParser;
|
2016-10-13 08:14:18 +00:00
|
|
|
|
|
|
|
class SpecialLintErrors extends SpecialPage {
|
|
|
|
|
2024-04-04 21:41:29 +00:00
|
|
|
private NamespaceInfo $namespaceInfo;
|
|
|
|
private TitleParser $titleParser;
|
2024-04-05 02:41:38 +00:00
|
|
|
private LinkCache $linkCache;
|
|
|
|
private PermissionManager $permissionManager;
|
2024-04-04 22:55:43 +00:00
|
|
|
private CategoryManager $categoryManager;
|
2024-04-05 02:20:45 +00:00
|
|
|
private TotalsLookup $totalsLookup;
|
2024-04-04 22:55:43 +00:00
|
|
|
private DatabaseFactory $databaseFactory;
|
2024-04-04 21:41:29 +00:00
|
|
|
|
2021-04-06 16:54:41 +00:00
|
|
|
/**
|
2021-09-30 23:20:01 +00:00
|
|
|
* @var string|null
|
2021-04-06 16:54:41 +00:00
|
|
|
*/
|
2016-10-13 08:14:18 +00:00
|
|
|
private $category;
|
|
|
|
|
2024-04-04 21:41:29 +00:00
|
|
|
/**
|
|
|
|
* @param NamespaceInfo $namespaceInfo
|
|
|
|
* @param TitleParser $titleParser
|
2024-04-05 02:41:38 +00:00
|
|
|
* @param LinkCache $linkCache
|
|
|
|
* @param PermissionManager $permissionManager
|
2024-04-04 22:55:43 +00:00
|
|
|
* @param CategoryManager $categoryManager
|
2024-04-05 02:20:45 +00:00
|
|
|
* @param TotalsLookup $totalsLookup
|
2024-04-04 22:55:43 +00:00
|
|
|
* @param DatabaseFactory $databaseFactory
|
2024-04-04 21:41:29 +00:00
|
|
|
*/
|
2024-04-04 22:55:43 +00:00
|
|
|
public function __construct(
|
|
|
|
NamespaceInfo $namespaceInfo,
|
|
|
|
TitleParser $titleParser,
|
2024-04-05 02:41:38 +00:00
|
|
|
LinkCache $linkCache,
|
|
|
|
PermissionManager $permissionManager,
|
2024-04-04 22:55:43 +00:00
|
|
|
CategoryManager $categoryManager,
|
2024-04-05 02:20:45 +00:00
|
|
|
TotalsLookup $totalsLookup,
|
2024-04-04 22:55:43 +00:00
|
|
|
DatabaseFactory $databaseFactory
|
|
|
|
) {
|
2016-10-13 08:14:18 +00:00
|
|
|
parent::__construct( 'LintErrors' );
|
2024-04-04 21:41:29 +00:00
|
|
|
$this->namespaceInfo = $namespaceInfo;
|
|
|
|
$this->titleParser = $titleParser;
|
2024-04-05 02:41:38 +00:00
|
|
|
$this->linkCache = $linkCache;
|
|
|
|
$this->permissionManager = $permissionManager;
|
2024-04-04 22:55:43 +00:00
|
|
|
$this->categoryManager = $categoryManager;
|
2024-04-05 02:20:45 +00:00
|
|
|
$this->totalsLookup = $totalsLookup;
|
2024-04-04 22:55:43 +00:00
|
|
|
$this->databaseFactory = $databaseFactory;
|
2016-10-13 08:14:18 +00:00
|
|
|
}
|
|
|
|
|
2021-04-06 16:54:41 +00:00
|
|
|
/**
|
2022-03-10 19:48:19 +00:00
|
|
|
* @param string $titleLabel
|
2021-04-06 16:54:41 +00:00
|
|
|
*/
|
2023-06-13 22:26:52 +00:00
|
|
|
protected function showFilterForm( $titleLabel ) {
|
2022-03-10 19:48:19 +00:00
|
|
|
$selectOptions = [
|
|
|
|
(string)$this->msg( 'linter-form-exact-match' )->escaped() => true,
|
|
|
|
(string)$this->msg( 'linter-form-prefix-match' )->escaped() => false,
|
|
|
|
];
|
2023-06-13 22:26:52 +00:00
|
|
|
$namespaces = $this->getContext()->getRequest()->getVal( "wpNamespaceRestrictions" );
|
2017-04-14 03:49:21 +00:00
|
|
|
$fields = [
|
2023-06-13 22:26:52 +00:00
|
|
|
'NamespaceRestrictions' => [
|
|
|
|
'type' => 'namespacesmultiselect',
|
|
|
|
'label' => $this->msg( 'linter-form-namespace' )->text(),
|
|
|
|
'exists' => true,
|
|
|
|
'cssclass' => 'mw-block-partial-restriction',
|
|
|
|
'default' => $namespaces,
|
|
|
|
'input' => [ 'autocomplete' => false ]
|
2019-08-25 03:47:40 +00:00
|
|
|
],
|
2022-03-10 19:48:19 +00:00
|
|
|
'titlefield' => [
|
2022-03-28 16:57:36 +00:00
|
|
|
'type' => 'title',
|
2022-03-10 19:48:19 +00:00
|
|
|
'name' => $titleLabel,
|
2022-03-04 20:21:04 +00:00
|
|
|
'label-message' => 'linter-form-title-prefix',
|
2022-03-28 16:57:36 +00:00
|
|
|
'exists' => true,
|
|
|
|
'required' => false
|
2022-03-04 20:21:04 +00:00
|
|
|
],
|
2022-03-10 19:48:19 +00:00
|
|
|
'exactmatchradio' => [
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => 'exactmatch',
|
|
|
|
'options' => $selectOptions,
|
|
|
|
'label-message' => 'linter-form-exact-or-prefix',
|
|
|
|
'default' => true
|
|
|
|
]
|
2017-04-14 03:49:21 +00:00
|
|
|
];
|
2022-08-25 20:15:57 +00:00
|
|
|
|
2024-04-04 21:41:29 +00:00
|
|
|
$enableUserInterfaceTagAndTemplateStage =
|
|
|
|
$this->getConfig()->get( 'LinterUserInterfaceTagAndTemplateStage' );
|
2022-08-25 20:15:57 +00:00
|
|
|
if ( $enableUserInterfaceTagAndTemplateStage ) {
|
|
|
|
$selectTemplateOptions = [
|
|
|
|
(string)$this->msg( 'linter-form-template-option-all' )->escaped() => 'all',
|
|
|
|
(string)$this->msg( 'linter-form-template-option-with' )->escaped() => 'with',
|
|
|
|
(string)$this->msg( 'linter-form-template-option-without' )->escaped() => 'without',
|
|
|
|
];
|
|
|
|
$htmlTags = new HtmlTags( $this );
|
|
|
|
$tagAndTemplateFields = [
|
|
|
|
'tag' => [
|
|
|
|
'type' => 'select',
|
|
|
|
'name' => 'tag',
|
|
|
|
'label-message' => 'linter-form-tag',
|
|
|
|
'options' => $htmlTags->getAllowedHTMLTags()
|
|
|
|
],
|
|
|
|
'template' => [
|
|
|
|
'type' => 'select',
|
|
|
|
'name' => 'template',
|
|
|
|
'label-message' => 'linter-form-template',
|
|
|
|
'options' => $selectTemplateOptions
|
|
|
|
]
|
|
|
|
];
|
|
|
|
$fields = array_merge( $fields, $tagAndTemplateFields );
|
|
|
|
}
|
|
|
|
|
2017-04-14 03:49:21 +00:00
|
|
|
$form = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
|
|
|
|
$form->setWrapperLegend( true );
|
2022-03-10 19:48:19 +00:00
|
|
|
if ( $this->category !== null ) {
|
2022-12-27 11:28:32 +00:00
|
|
|
$form->addHeaderHtml( $this->msg( "linter-category-{$this->category}-desc" )->parse() );
|
2022-03-10 19:48:19 +00:00
|
|
|
}
|
2017-04-14 03:49:21 +00:00
|
|
|
$form->setMethod( 'get' );
|
|
|
|
$form->prepareForm()->displayForm( false );
|
|
|
|
}
|
|
|
|
|
2021-09-30 23:20:01 +00:00
|
|
|
/**
|
2022-03-10 19:48:19 +00:00
|
|
|
* cleanTitle parses a title and handles a malformed titles, namespaces that are mismatched
|
|
|
|
* and exact title searches that find no matching records, and produce appropriate error messages
|
|
|
|
*
|
|
|
|
* @param string $title
|
2023-06-13 22:26:52 +00:00
|
|
|
* @param array $namespaces
|
2022-03-10 19:48:19 +00:00
|
|
|
* @return array
|
2021-09-30 23:20:01 +00:00
|
|
|
*/
|
2023-06-13 22:26:52 +00:00
|
|
|
public function cleanTitle( string $title, $namespaces ): array {
|
2022-03-10 19:48:19 +00:00
|
|
|
// Check all titles for malformation regardless of exact match or prefix match
|
|
|
|
try {
|
2024-04-04 21:41:29 +00:00
|
|
|
$titleElements = $this->titleParser->parseTitle( $title );
|
2022-06-23 00:26:49 +00:00
|
|
|
} catch ( MalformedTitleException $e ) {
|
2022-03-10 19:48:19 +00:00
|
|
|
return [ 'titlefield' => null, 'error' => 'linter-invalid-title' ];
|
|
|
|
}
|
|
|
|
|
|
|
|
// The drop-down namespace defaults to 'all' which is returned as a null, indicating match all namespaces.
|
|
|
|
// If 'main' is selected in the drop-down, int 0 is returned. Other namespaces are returned as int values > 0.
|
|
|
|
//
|
|
|
|
// If the user does not specify a namespace in the title text box, parseTitle sets it to int 0 as the default.
|
|
|
|
// If the user entered ':' (main) namespace as the namespace prefix of a title such as ":MyPageTitle",
|
|
|
|
// parseTitle will also return int 0 as the namespace. Other valid system namespaces entered as prefixes
|
|
|
|
// in the title text box are returned by parseTitle as int values > 0.
|
|
|
|
// To determine if the user entered the ':' (main) namespace when int 0 is returned, a separate check for
|
|
|
|
// the substring ':' at offset 0 must be performed.
|
|
|
|
|
|
|
|
$titleNamespace = $titleElements->getNamespace();
|
|
|
|
// Determine if the user entered ':' (resolves to main) as the namespace part of the title,
|
|
|
|
// or was it was set by default by parseTitle() to 0, but the user intended to search across 'all' namespaces.
|
|
|
|
if ( $titleNamespace === 0 && $title[0] !== ':' ) {
|
|
|
|
$titleNamespace = null;
|
|
|
|
}
|
|
|
|
|
2024-02-10 10:53:17 +00:00
|
|
|
if ( $namespaces && $titleNamespace !== null && !in_array( $titleNamespace, $namespaces ) ) {
|
2022-03-10 19:48:19 +00:00
|
|
|
// Show the namespace mismatch error if the namespaces specified in drop-down and title text do not match.
|
2023-11-26 21:34:22 +00:00
|
|
|
return [ 'titlefield' => null, 'error' => 'linter-namespace-mismatch' ];
|
2022-03-10 19:48:19 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 22:26:52 +00:00
|
|
|
// If no namespaces are selected (null), return the namespace from the title text
|
2024-02-10 10:53:17 +00:00
|
|
|
$namespaces = $namespaces ?: [ $titleNamespace ];
|
2022-03-10 19:48:19 +00:00
|
|
|
|
2023-06-13 22:26:52 +00:00
|
|
|
return [ 'titlefield' => $titleElements->getDBkey(), 'namespace' => $namespaces ];
|
2022-03-10 19:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param OutputPage $out
|
|
|
|
* @param string|null $message
|
|
|
|
*/
|
|
|
|
private function displayError( $out, $message ) {
|
|
|
|
$out->addHTML(
|
|
|
|
Html::element( 'span', [ 'class' => 'error' ],
|
|
|
|
$this->msg( $message )->text() )
|
|
|
|
);
|
2021-09-30 23:20:01 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 22:26:52 +00:00
|
|
|
/**
|
|
|
|
* Extract namespace settings from the request object,
|
|
|
|
* returning an array of namespace id numbers
|
|
|
|
*
|
|
|
|
* @param WebRequest $request
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function findNamespaces( $request ) {
|
|
|
|
$namespaces = [];
|
|
|
|
$activeNamespaces = array_keys(
|
2024-04-04 21:41:29 +00:00
|
|
|
$this->namespaceInfo->getCanonicalNamespaces()
|
|
|
|
);
|
2023-06-13 22:26:52 +00:00
|
|
|
// Remove -2 = "media" and -1 = "Special" namespace elements
|
|
|
|
$activeNamespaces = array_filter( $activeNamespaces,
|
|
|
|
static function ( $x ) {
|
|
|
|
return $x >= 0;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if ( $request->getCheck( 'wpNamespaceRestrictions' ) ) {
|
|
|
|
$namespaceRequestValues = $request->getRawVal( 'wpNamespaceRestrictions' );
|
|
|
|
$namespaceIDs = array_map( 'intval', explode( "\n", $namespaceRequestValues ) );
|
|
|
|
// Security measure: only allow active namespace IDs to reach the query
|
|
|
|
$namespaces = array_values( array_intersect( $activeNamespaces, $namespaceIDs ) );
|
|
|
|
}
|
|
|
|
return $namespaces;
|
|
|
|
}
|
|
|
|
|
2021-04-06 16:54:41 +00:00
|
|
|
/**
|
|
|
|
* @param string|null $par
|
|
|
|
*/
|
2016-10-13 08:14:18 +00:00
|
|
|
public function execute( $par ) {
|
2022-07-02 22:00:46 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$out = $this->getOutput();
|
|
|
|
|
|
|
|
$params = $request->getQueryValues();
|
2022-03-10 19:48:19 +00:00
|
|
|
|
2022-01-10 20:21:20 +00:00
|
|
|
$this->setHeaders();
|
2022-03-10 19:48:19 +00:00
|
|
|
$this->outputHeader( $par || isset( $params[ 'titlesearch' ] ) ? 'disable-summary' : '' );
|
2022-01-10 20:21:20 +00:00
|
|
|
|
2023-06-13 22:26:52 +00:00
|
|
|
$namespaces = $this->findNamespaces( $request );
|
|
|
|
|
2022-07-02 22:00:46 +00:00
|
|
|
$exactMatch = $request->getBool( 'exactmatch', true );
|
2022-08-25 20:15:57 +00:00
|
|
|
$tagName = $this->getRequest()->getText( 'tag' );
|
2023-11-26 21:34:22 +00:00
|
|
|
// map command line tag name through an associative array to protect request from an SQL injection security risk
|
2022-08-25 20:15:57 +00:00
|
|
|
$htmlTags = new HtmlTags( $this );
|
|
|
|
$allowedHtmlTags = $htmlTags->getAllowedHTMLTags();
|
|
|
|
$tag = $allowedHtmlTags[ $tagName ] ?? 'all';
|
|
|
|
$template = $this->getRequest()->getText( 'template' );
|
2022-02-09 15:33:48 +00:00
|
|
|
|
2022-03-10 19:48:19 +00:00
|
|
|
// If the request contains a 'titlesearch' parameter, then the user entered a page title
|
|
|
|
// or just the first few characters of the title. They also may have entered the first few characters
|
2023-11-26 21:34:22 +00:00
|
|
|
// of a custom namespace (just the text before a ':') to search for and pressed the associated Submit button.
|
|
|
|
// Added the pageback parameter to inform the code that the '<- Special:LintErrors' link had been used to allow
|
2022-08-25 20:15:57 +00:00
|
|
|
// the UI to redisplay with previous form values, instead of just resubmitting the query.
|
|
|
|
if ( $par === null && isset( $params[ 'titlesearch' ] ) && !isset( $params[ 'pageback'] ) ) {
|
2023-06-13 22:26:52 +00:00
|
|
|
unset( $params[ 'title' ] );
|
2022-08-25 20:15:57 +00:00
|
|
|
$params = array_merge( [ 'pageback' => true ], $params );
|
|
|
|
$out->addBacklinkSubtitle( $this->getPageTitle(), $params );
|
2022-03-10 19:48:19 +00:00
|
|
|
|
2022-07-02 22:00:46 +00:00
|
|
|
$title = $request->getText( 'titlesearch' );
|
2023-06-13 22:26:52 +00:00
|
|
|
$titleSearch = $this->cleanTitle( $title, $namespaces );
|
2022-03-10 19:48:19 +00:00
|
|
|
|
|
|
|
if ( $titleSearch[ 'titlefield' ] !== null ) {
|
2024-02-17 01:58:49 +00:00
|
|
|
$out->setPageTitleMsg( $this->msg( 'linter-prefix-search-subpage', $titleSearch[ 'titlefield' ] ) );
|
2022-03-10 19:48:19 +00:00
|
|
|
|
|
|
|
$pager = new LintErrorsPager(
|
2024-04-05 02:41:38 +00:00
|
|
|
$this->getContext(),
|
|
|
|
$this->categoryManager,
|
|
|
|
$this->linkCache,
|
|
|
|
$this->getLinkRenderer(),
|
|
|
|
$this->permissionManager,
|
|
|
|
null,
|
2024-04-04 22:55:43 +00:00
|
|
|
$namespaces,
|
2023-06-13 22:26:52 +00:00
|
|
|
$exactMatch, $titleSearch[ 'titlefield' ], $template, $tag
|
2022-03-10 19:48:19 +00:00
|
|
|
);
|
|
|
|
$out->addParserOutput( $pager->getFullOutput() );
|
|
|
|
} else {
|
|
|
|
$this->displayError( $out, $titleSearch[ 'error' ] );
|
|
|
|
}
|
2021-09-30 23:20:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-03 13:56:09 +00:00
|
|
|
if ( in_array( $par, $this->getSubpagesForPrefixSearch() ) ) {
|
2016-10-13 08:14:18 +00:00
|
|
|
$this->category = $par;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !$this->category ) {
|
|
|
|
$this->addHelpLink( 'Help:Extension:Linter' );
|
2024-04-04 22:55:43 +00:00
|
|
|
$this->showCategoryListings();
|
2016-10-13 08:14:18 +00:00
|
|
|
} else {
|
2024-03-22 18:13:25 +00:00
|
|
|
$this->addHelpLink( "Help:Lint_errors/{$this->category}" );
|
2024-02-17 01:58:49 +00:00
|
|
|
$out->setPageTitleMsg(
|
2016-10-13 08:14:18 +00:00
|
|
|
$this->msg( 'linterrors-subpage',
|
|
|
|
$this->msg( "linter-category-{$this->category}" )->text()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$out->addBacklinkSubtitle( $this->getPageTitle() );
|
2022-03-04 20:21:04 +00:00
|
|
|
|
2022-07-02 22:00:46 +00:00
|
|
|
$title = $request->getText( 'titlecategorysearch' );
|
2023-11-26 21:34:22 +00:00
|
|
|
// For category-based searches, allow an undefined title to display all records
|
2022-07-02 21:56:29 +00:00
|
|
|
if ( $title === '' ) {
|
2023-06-13 22:26:52 +00:00
|
|
|
$titleCategorySearch = [ 'titlefield' => '', 'namespace' => $namespaces, 'pageid' => null ];
|
2022-03-10 19:48:19 +00:00
|
|
|
} else {
|
2023-06-13 22:26:52 +00:00
|
|
|
$titleCategorySearch = $this->cleanTitle( $title, $namespaces );
|
2022-03-10 19:48:19 +00:00
|
|
|
}
|
2022-03-04 20:21:04 +00:00
|
|
|
|
2022-03-10 19:48:19 +00:00
|
|
|
if ( $titleCategorySearch[ 'titlefield' ] !== null ) {
|
2023-06-13 22:26:52 +00:00
|
|
|
$this->showFilterForm( 'titlecategorysearch' );
|
2022-03-10 19:48:19 +00:00
|
|
|
$pager = new LintErrorsPager(
|
2024-04-05 02:41:38 +00:00
|
|
|
$this->getContext(),
|
|
|
|
$this->categoryManager,
|
|
|
|
$this->linkCache,
|
|
|
|
$this->getLinkRenderer(),
|
|
|
|
$this->permissionManager,
|
|
|
|
$this->category,
|
2024-04-04 22:55:43 +00:00
|
|
|
$namespaces,
|
2023-06-13 22:26:52 +00:00
|
|
|
$exactMatch, $titleCategorySearch[ 'titlefield' ], $template, $tag
|
2022-03-10 19:48:19 +00:00
|
|
|
);
|
|
|
|
$out->addParserOutput( $pager->getFullOutput() );
|
|
|
|
} else {
|
|
|
|
$this->displayError( $out, $titleCategorySearch[ 'error' ] );
|
|
|
|
}
|
2016-10-13 08:14:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 22:11:23 +00:00
|
|
|
/**
|
|
|
|
* @param string $priority
|
|
|
|
* @param int[] $totals name => count
|
|
|
|
* @param string[] $categories
|
|
|
|
*/
|
|
|
|
private function displayList( $priority, $totals, array $categories ) {
|
|
|
|
$out = $this->getOutput();
|
|
|
|
$msgName = 'linter-heading-' . $priority . '-priority';
|
|
|
|
$out->addHTML( Html::element( 'h2', [], $this->msg( $msgName )->text() ) );
|
|
|
|
$out->addHTML( $this->buildCategoryList( $categories, $totals ) );
|
|
|
|
}
|
|
|
|
|
2021-09-30 23:20:01 +00:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
private function displaySearchPage() {
|
|
|
|
$out = $this->getOutput();
|
|
|
|
$out->addHTML( Html::element( 'h2', [],
|
2022-03-10 19:48:19 +00:00
|
|
|
$this->msg( "linter-lints-prefix-search-page-desc" )->text() ) );
|
2023-06-13 22:26:52 +00:00
|
|
|
$this->showFilterForm( 'titlesearch' );
|
2021-09-30 23:20:01 +00:00
|
|
|
}
|
|
|
|
|
2024-04-04 22:55:43 +00:00
|
|
|
private function showCategoryListings() {
|
2024-04-05 02:20:45 +00:00
|
|
|
$totals = $this->totalsLookup->getTotals( $this->databaseFactory->newDatabase( 0 ) );
|
2016-12-15 01:07:40 +00:00
|
|
|
|
2017-04-26 22:11:23 +00:00
|
|
|
// Display lint issues by priority
|
2024-04-04 22:55:43 +00:00
|
|
|
$this->displayList( 'high', $totals, $this->categoryManager->getHighPriority() );
|
|
|
|
$this->displayList( 'medium', $totals, $this->categoryManager->getMediumPriority() );
|
|
|
|
$this->displayList( 'low', $totals, $this->categoryManager->getLowPriority() );
|
2021-09-30 23:20:01 +00:00
|
|
|
|
|
|
|
$this->displaySearchPage();
|
2016-12-15 01:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string[] $cats
|
|
|
|
* @param int[] $totals name => count
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function buildCategoryList( array $cats, array $totals ) {
|
2016-10-13 08:14:18 +00:00
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
|
|
|
$html = Html::openElement( 'ul' ) . "\n";
|
|
|
|
foreach ( $cats as $cat ) {
|
|
|
|
$html .= Html::rawElement( 'li', [], $linkRenderer->makeKnownLink(
|
|
|
|
$this->getPageTitle( $cat ),
|
|
|
|
$this->msg( "linter-category-$cat" )->text()
|
2017-04-14 08:43:37 +00:00
|
|
|
) . ' ' . Html::element( 'bdi', [],
|
|
|
|
$this->msg( "linter-numerrors" )->numParams( $totals[$cat] )->text()
|
|
|
|
) ) . "\n";
|
2016-10-13 08:14:18 +00:00
|
|
|
}
|
|
|
|
$html .= Html::closeElement( 'ul' );
|
2016-12-15 01:07:40 +00:00
|
|
|
|
|
|
|
return $html;
|
2016-10-13 08:14:18 +00:00
|
|
|
}
|
|
|
|
|
2021-04-06 16:54:41 +00:00
|
|
|
/** @inheritDoc */
|
2016-10-13 08:14:18 +00:00
|
|
|
public function getGroupName() {
|
|
|
|
return 'maintenance';
|
|
|
|
}
|
|
|
|
|
2021-04-06 16:54:41 +00:00
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
2016-11-22 09:16:28 +00:00
|
|
|
protected function getSubpagesForPrefixSearch() {
|
2024-04-04 22:55:43 +00:00
|
|
|
return array_merge(
|
|
|
|
$this->categoryManager->getVisibleCategories(),
|
|
|
|
$this->categoryManager->getInvisibleCategories()
|
|
|
|
);
|
2016-11-22 09:16:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 08:14:18 +00:00
|
|
|
}
|