27 private readonly
Language $contentLanguage
29 parent::__construct(
'NamespaceInfo' );
44 $this->
msg(
'namespaceinfo-heading-id' )->text()
49 $this->
msg(
'namespaceinfo-heading-canonical' )->text()
54 $this->
msg(
'namespaceinfo-heading-local' )->text()
59 $this->
msg(
'namespaceinfo-heading-aliases' )->text()
64 $this->
msg(
'namespaceinfo-heading-info' )->text()
66 $tableHeadingRow = Html::rawElement(
69 $idHeading . $canonicalHeading . $localHeading . $aliasHeading . $infoHeading
72 $allAliases = $this->contentLanguage->getNamespaceAliases();
75 foreach ( $allAliases as $alias => $ns ) {
76 $aliases[$ns][] = $alias;
80 foreach ( $this->
getContentLanguage()->getFormattedNamespaces() as $ns => $localName ) {
85 $table = Html::rawElement(
87 [
'class' =>
'wikitable' ],
88 $tableHeadingRow . $tableBodyRows
91 $out->addHtml( $table );
101 private function makeNamespaceRow(
int $ns,
string $localName, array $aliases = [] ): string {
102 $canonicalName = $this->namespaceInfo->getCanonicalName( $ns );
103 if ( $canonicalName ) {
104 $canonicalName = strtr( $canonicalName,
'_',
' ' );
111 $localName = $this->
msg(
'blanknamespace' )->escaped();
112 $canonicalName = $this->
msg(
'blanknamespace' )->inLanguage(
'en' )->escaped();
115 $description = $this->
msg(
'namespaceinfo-description-ns' . $ns );
116 if ( $description->isDisabled() ) {
119 if ( $this->namespaceInfo->isTalk( $ns ) ) {
120 $subjectNs = $this->namespaceInfo->getSubject( $ns );
121 $subjectName = strtr(
122 $this->namespaceInfo->getCanonicalName( $subjectNs ),
126 $description = $this->
msg(
'namespaceinfo-description-custom-talk',
131 $description = $this->
msg(
'namespaceinfo-description-custom', $localName );
134 $descriptionText = $description->parse();
139 $namespaceProtection = $this->
getConfig()->get(
'NamespaceProtection' );
140 if ( isset( $namespaceProtection[$ns] ) ) {
141 $rightsNeeded = $namespaceProtection[$ns];
142 if ( !is_array( $rightsNeeded ) ) {
143 $rightsNeeded = [ $rightsNeeded ];
145 foreach ( $rightsNeeded as $right ) {
146 $properties[] = $this->
msg(
'namespaceinfo-namespace-protection-right', $right )
151 if ( !$this->namespaceInfo->isMovable( $ns ) ) {
152 $properties[] = $this->
msg(
'namespaceinfo-namespace-immovable' )->parse();
154 if ( $this->namespaceInfo->isContent( $ns ) ) {
155 $properties[] = $this->
msg(
'namespaceinfo-namespace-iscontent' )->parse();
157 if ( $this->namespaceInfo->hasSubpages( $ns ) ) {
158 $properties[] = $this->
msg(
'namespaceinfo-namespace-subpages' )->parse();
160 if ( $this->namespaceInfo->isNonincludable( $ns ) ) {
161 $properties[] = $this->
msg(
'namespaceinfo-namespace-nonincludable' )->parse();
163 $contentModel = $this->namespaceInfo->getNamespaceContentModel( $ns );
164 if ( $contentModel !==
null ) {
165 $properties[] = $this->
msg(
'namespaceinfo-namespace-default-contentmodel' )
166 ->params( $contentModel )
172 $namespaceProperties =
'';
173 if ( $properties !== [] ) {
174 $namespaceProperties = Html::openElement(
'ul' );
175 foreach ( $properties as $propertyText ) {
176 $namespaceProperties .= Html::rawElement(
182 $namespaceProperties .= Html::closeElement(
'ul' );
186 if ( $aliases !== [] ) {
187 if ( count( $aliases ) === 1 ) {
191 foreach ( $aliases as $alias ) {
193 $alias = str_replace(
"_",
" ", $alias );
205 $idField = Html::rawElement(
'td', [], (
string)$ns );
206 $canonicalField = Html::rawElement(
'td', [], $canonicalName );
207 $localField = Html::rawElement(
'td', [], $localName );
209 $infoField = Html::rawElement(
'td', [], $descriptionText . $namespaceProperties );
211 return Html::rawElement(
214 $idField . $canonicalField . $localField . $aliasesField . $infoField