12use InvalidArgumentException;
16use Wikimedia\Parsoid\Core\LinkTarget;
68 public function formatTitle( $namespace, $text, $fragment =
'', $interwiki =
'' ) {
70 if ( $interwiki !==
'' ) {
71 $out = $interwiki .
':';
74 if ( $namespace != 0 ) {
77 }
catch ( InvalidArgumentException ) {
79 $nsName = $this->language->getNsText(
NS_SPECIAL ) .
":Badtitle/NS{$namespace}";
82 $out .= $nsName .
':';
86 if ( $fragment !==
'' ) {
87 $out .=
'#' . $fragment;
90 $out = str_replace(
'_',
' ', $out );
104 return $title->getText();
106 return strtr( $title->getDBKey(),
'_',
' ' );
108 throw new InvalidArgumentException(
'$title has invalid type: ' . get_class( $title ) );
122 if ( !isset( $title->prefixedText ) ) {
124 $title->getNamespace(),
127 $title->getInterwiki()
130 return $title->prefixedText;
132 $title->assertWiki( PageReference::LOCAL );
134 $title->getNamespace(),
135 $this->getText( $title )
138 throw new InvalidArgumentException(
'$title has invalid type: ' . get_class( $title ) );
154 $target->getNamespace(),
157 $target->getInterwiki()
160 $target->assertWiki( PageReference::LOCAL );
162 $target->getNamespace(),
166 throw new InvalidArgumentException(
'$title has invalid type: ' . get_class( $target ) );
192 $title->getNamespace(),
194 $title->getFragment(),
195 $title->getInterwiki()
198 $title->assertWiki( PageReference::LOCAL );
200 $title->getNamespace(),
201 $this->getText( $title )
204 throw new InvalidArgumentException(
'$title has invalid type: ' . get_class( $title ) );
220 if ( $this->language->needsGenderDistinction() &&
221 $this->nsInfo->hasGenderDistinction( $namespace )
224 $gender = $this->genderCache->getGenderOf( $text, __METHOD__ );
225 $name = $this->language->getGenderNsText( $namespace, $gender );
227 $name = $this->language->getNsText( $namespace );
230 if ( $name ===
false ) {
231 throw new InvalidArgumentException(
'Unknown namespace ID: ' . $namespace );
240class_alias( TitleFormatter::class,
'TitleFormatter' );
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...