59 if ( $pstSignature ===
false ) {
63 if ( $this->localizer ) {
64 return [ $this->localizer->msg(
'badsigsubst' )->parse() ];
69 $pstWasApplied =
false;
70 if ( $pstSignature !== $signature ) {
71 $pstWasApplied =
true;
72 $signature = $pstSignature;
75 $errors = $this->localizer ? [] :
false;
80 $allowedLintErrors =
$config->
get(
'SignatureAllowedLintErrors' );
83 foreach ( $lintErrors as $error ) {
84 if ( $error[
'type'] ===
'multiple-unclosed-formatting-tags' ) {
88 if ( in_array( $error[
'type'], $allowedLintErrors,
true ) ) {
91 if ( !$this->localizer ) {
115 $label = $this->localizer->msg(
"linter-pager-{$error['type']}-details" )->parse();
116 $docsLink = new \OOUI\ButtonWidget( [
118 "https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Lint_errors/{$error['type']}",
119 'target' =>
'_blank',
120 'label' => $this->localizer->msg(
'prefs-signature-error-details' )->text(),
126 $encLocation = $pstWasApplied ? null : json_encode( $location );
130 [
'data-mw-lint-error-location' => $encLocation ],
131 $label . $this->localizer->msg(
'colon-separator' )->escaped() .
132 $details .
' ' . $docsLink
136 if ( $messages && $this->localizer ) {
137 $errors[] = $this->localizer->msg(
'badsightml' )->parse() .
143 if ( $this->localizer ) {
145 $linkWikitext = $this->localizer->msg(
'signature', $userText, $userText )->inContentLanguage()->text();
146 $errors[] = $this->localizer->msg(
'badsiglinks',
wfEscapeWikiText( $linkWikitext ) )->parse();
164 $pstSignature = $parser->preSaveTransform(
172 if ( $parser->getOutput()->getFlag(
'user-signature' ) ) {
177 $pstPstSignature = $parser->preSaveTransform(
183 if ( $pstPstSignature !== $pstSignature ) {
187 return $pstSignature;
203 $vrsConfig =
$config->
get(
'VirtualRestConfig' );
204 if ( isset( $vrsConfig[
'modules'][
'parsoid'] ) ) {
205 $params = $vrsConfig[
'modules'][
'parsoid'];
206 if ( isset( $vrsConfig[
'global'] ) ) {
207 $params = array_merge( $vrsConfig[
'global'], $params );
212 $vrsClient->mount(
'/parsoid/', $parsoidVrs );
216 'url' =>
'/parsoid/local/v3/transform/wikitext/to/lint',
218 'wikitext' => $signature,
223 'Api-User-Agent' =>
'MediaWiki/' .
MW_VERSION,
227 $response = $vrsClient->run( $request );
228 if ( $response[
'code'] === 200 ) {
229 $json = json_decode( $response[
'body'],
true );
249 $pout = $parser->parse(
256 $links = $pout->getLinks();
257 $username = $this->user->getName();
259 isset( $links[
NS_USER ][ strtr( $username,
' ',
'_' ) ] ) ||
260 isset( $links[
NS_USER_TALK ][ strtr( $username,
' ',
'_' ) ] )
267 $splinks = $pout->getLinksSpecial();
269 foreach ( $splinks as $dbkey => $unused ) {
270 list( $name, $subpage ) = $specialPageFactory->resolveAlias( $dbkey );
271 if ( $name ===
'Contributions' && $subpage ) {
273 if ( $userTitle && $userTitle->getText() === $username ) {
284 return array_slice( $lintError[
'dsr'], 0, 2 );
289 [
'type' =>
$type,
'params' => $params ] = $lintError;
291 if (
$type ===
'bogus-image-options' && isset( $params[
'items'] ) ) {
292 $list = array_map(
function ( $in ) {
294 }, $params[
'items'] );
296 $this->localizer->msg(
'comma-separator' )->escaped(),
299 } elseif (
$type ===
'pwrap-bug-workaround' &&
300 isset( $params[
'root'] ) &&
301 isset( $params[
'child'] ) ) {
303 $params[
'root'] .
" > " . $params[
'child'] );
304 } elseif (
$type ===
'tidy-whitespace-bug' &&
305 isset( $params[
'node'] ) &&
306 isset( $params[
'sibling'] ) ) {
308 $params[
'node'] .
" + " . $params[
'sibling'] );
309 } elseif (
$type ===
'multi-colon-escape' &&
310 isset( $params[
'href'] ) ) {
312 } elseif (
$type ===
'multiline-html-table-in-list' ) {
315 $params[
'ancestorName'] .
" > " . $params[
'name'] );
316 } elseif (
$type ===
'misc-tidy-replacement-issues' ) {
319 } elseif (
$type ===
'missing-end-tag' ) {
320 return Html::element(
'code', [],
'</' . $params[
'name'] .
'>' );
321 } elseif ( isset( $params[
'name'] ) ) {