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( LinkCache::getSelectFields(), [ 'page_namespace', 'page_title', 'linter_id', 'linter_params', 'linter_start', 'linter_end', ] ), 'conds' => $conds, 'join_conds' => [ 'page' => [ 'INNER JOIN', 'page_id=linter_page' ] ] ]; } protected function doBatchLookups() { $linkCache = MediaWikiServices::getInstance()->getLinkCache(); foreach ( $this->mResult as $row ) { $titleValue = new TitleValue( (int)$row->page_namespace, $row->page_title ); $linkCache->addGoodLinkObjFromRow( $titleValue, $row ); } } public function isFieldSortable( $field ) { return false; } public function formatValue( $name, $value ) { $row = $this->mCurrentRow; $row->linter_cat = $this->categoryId; $lintError = Database::makeLintError( $row ); switch ( $name ) { case 'title': $title = Title::makeTitle( $row->page_namespace, $row->page_title ); $viewLink = $this->linkRenderer->makeLink( $title ); if ( !$title->quickUserCan( 'edit', $this->getUser() ) ) { return $viewLink; } $editLink = $this->linkRenderer->makeLink( $title, $this->msg( 'linker-page-edit' )->text(), [], [ 'action' => 'edit', 'lintid' => $lintError->lintId, ] ); $historyLink = $this->linkRenderer->makeLink( $title, $this->msg( 'linker-page-history' )->text(), [], [ 'action' => 'history' ] ); $editHistLinks = $this->getLanguage()->pipeList( [ $editLink, $historyLink ] ); return $this->msg( 'linker-page-title-edit' ) ->rawParams( $viewLink, $editHistLinks ) ->escaped(); case 'details': // While deletable-table-tag has params set, it adds no new information // and is not included here since the error category has the tag name. $hasNameCats = [ 'obsolete-tag', 'missing-end-tag', 'self-closed-tag', 'misnested-tag', 'stripped-tag', ]; if ( in_array( $this->category, $hasNameCats ) && isset( $lintError->params['name'] ) ) { return Html::element( 'code', [], $lintError->params['name'] ); } elseif ( $this->category === 'bogus-image-options' && isset( $lintError->params['items'] ) ) { $list = array_map( function ( $in ) { return Html::element( 'code', [], $in ); }, $lintError->params['items'] ); return $this->getLanguage()->commaList( $list ); } elseif ( $this->category === 'pwrap-bug-workaround' && isset( $lintError->params['root'] ) && isset( $lintError->params['child'] ) ) { return Html::element( 'code', [], $lintError->params['root'] . " > " . $lintError->params['child'] ); } return ''; case 'template': if ( !$lintError->templateInfo ) { return '—'; } if ( isset( $lintError->templateInfo['multiPartTemplateBlock'] ) ) { return $this->msg( 'multi-part-template-block' )->escaped(); } else { $templateName = $lintError->templateInfo['name']; $templateTitle = Title::newFromText( $templateName, NS_TEMPLATE ); if ( !$templateTitle ) { // Shouldn't be possible...??? return '—'; } } return $this->linkRenderer->makeLink( $templateTitle ); default: throw new InvalidArgumentException( "Unexpected name: $name" ); } } public function getDefaultSort() { return 'linter_id'; } public function getFieldNames() { $names = [ 'title' => $this->msg( 'linter-pager-title' )->text(), ]; if ( $this->category !== 'fostered' ) { // TODO: don't hardcode list of stuff with no parameters...? $names['details'] = $this->msg( "linter-pager-{$this->category}-details" )->text(); } $names['template'] = $this->msg( "linter-pager-template" )->text(); return $names; } }