MediaWiki REL1_39
ForeignTitle.php
Go to the documentation of this file.
1<?php
33 private $namespaceId;
35 private $namespaceName;
37 private $pageName;
38
47 public function __construct( $namespaceId, $namespaceName, $pageName ) {
48 if ( $namespaceId === null ) {
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 $this->namespaceId !== null;
63 }
64
70 public function getNamespaceId() {
71 if ( $this->namespaceId === null ) {
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() {
80 return $this->namespaceName;
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.
isNamespaceIdKnown()
Do we know the namespace ID of the page on the foreign wiki?
MediaWiki exception.