Файловый менеджер - Редактировать - /var/www/html/mediawiki-1.43.1/extensions/FileImporter/src/Services/Wikitext/NamespaceUnlocalizer.php
Ðазад
<?php namespace FileImporter\Services\Wikitext; use MediaWiki\Title\NamespaceInfo; /** * A small parser for wiki links that is able to understand namespace prefixes in a specific * language, e.g. [[Kategorie:…]] from a German wiki, and unlocalize them to their canonical English * form, e.g. [[Category:…]]. * * As of now, we intentionally do not use MediaWiki's TitleParser infrastructure for a few reasons: * - It does to many things (most notably extracting known interwiki prefixes) we really don't care * about here. * - We don't want to do any normalization on link elements we don't care about (basicaly everything * except the namespace) as these would show up as unrelated changes in the diff. * * @license GPL-2.0-or-later */ class NamespaceUnlocalizer implements WikiLinkCleaner { private NamespaceNameLookup $namespaceNameLookup; private NamespaceInfo $namespaceInfo; public function __construct( NamespaceNameLookup $namespaceNameLookup, NamespaceInfo $namespaceInfo ) { $this->namespaceNameLookup = $namespaceNameLookup; $this->namespaceInfo = $namespaceInfo; } public function process( string $link ): string { return preg_replace_callback( '/^ # Group 1 captures an optional leading colon, the extra + avoid backtracking (\h*+:?\h*+) # Ungreedy group 2 captures the first prefix ([^\v:]+?) # Must be followed by a colon and something plausible (?=\h*+:[^\v:][^\v]*$) /xu', function ( array $matches ): string { [ $unchanged, $colon, $name ] = $matches; // Normalize to use underscores, as this is what the services require $name = trim( preg_replace( '/[\s\xA0_]+/u', '_', $name ), '_' ); $namespaceId = $this->namespaceNameLookup->getIndex( $name ); if ( !is_int( $namespaceId ) || $namespaceId === NS_MAIN // The Project namespace shouldn't be "unlocalized" because it is not localized, // but configured via $wgMetaNamespace or $wgSitename. || $namespaceId === NS_PROJECT ) { return $unchanged; } $canonicalName = $this->namespaceInfo->getCanonicalName( $namespaceId ); if ( !is_string( $canonicalName ) || $canonicalName === $name ) { return $unchanged; } return $colon . str_replace( '_', ' ', $canonicalName ); }, $link, 1 ); } }
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка