MediaWiki REL1_34
ForeignTitle.php
Go to the documentation of this file.
1<?php
33 private $namespaceId;
37 private $pageName;
38
48 if ( is_null( $namespaceId ) ) {
49 $this->namespaceId = null;
50 } else {
51 $this->namespaceId = intval( $namespaceId );
52 }
53 $this->namespaceName = str_replace( ' ', '_', $namespaceName );
54 $this->pageName = str_replace( ' ', '_', $pageName );
55 }
56
61 public function isNamespaceIdKnown() {
62 return !is_null( $this->namespaceId );
63 }
64
70 public function getNamespaceId() {
71 if ( is_null( $this->namespaceId ) ) {
72 throw new MWException(
73 "Attempted to call getNamespaceId when the namespace ID is not known" );
74 }
75 return $this->namespaceId;
76 }
77
79 public function getNamespaceName() {
81 }
82
84 public function getText() {
85 return $this->pageName;
86 }
87
89 public function getFullText() {
90 $result = '';
91 if ( $this->namespaceName ) {
92 $result .= $this->namespaceName . ':';
93 }
94 $result .= $this->pageName;
95 return $result;
96 }
97
106 public function __toString() {
107 $name = '';
108 if ( $this->isNamespaceIdKnown() ) {
109 $name .= '{ns' . $this->namespaceId . '}';
110 } else {
111 $name .= '{ns??}';
112 }
113 $name .= $this->namespaceName . ':' . $this->pageName;
114
115 return $name;
116 }
117}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
__toString()
Returns a string representation of the title, for logging.
__construct( $namespaceId, $namespaceName, $pageName)
Creates a new ForeignTitle object.
int null $namespaceId
Null if we don't know the namespace ID (e.g.
isNamespaceIdKnown()
Do we know the namespace ID of the page on the foreign wiki?
string $namespaceName
MediaWiki exception.