+
+ /**
+ * Get the language in which the content of this page is written.
+ * Defaults to $wgContLang, but in certain cases it can be e.g.
+ * $wgLang (such as special pages, which are in the user language).
+ *
+ * @return object Language
+ */
+ public function getPageLanguage() {
+ global $wgLang;
+ if ( $this->getNamespace() == NS_SPECIAL ) {
+ // special pages are in the user language
+ return $wgLang;
+ } elseif ( $this->isRedirect() ) {
+ // the arrow on a redirect page is aligned according to the user language
+ return $wgLang;
+ } elseif ( $this->isCssOrJsPage() ) {
+ // css/js should always be LTR and is, in fact, English
+ return wfGetLangObj( 'en' );
+ } elseif ( $this->getNamespace() == NS_MEDIAWIKI ) {
+ // Parse mediawiki messages with correct target language
+ list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->getText() );
+ return wfGetLangObj( $lang );
+ }
+ global $wgContLang;
+ // If nothing special, it should be in the wiki content language
+ $pageLang = $wgContLang;
+ // Hook at the end because we don't want to override the above stuff
+ wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang, $wgLang ) );
+ return wfGetLangObj( $pageLang );
+ }
+}
+
+/**
+ * A BadTitle is generated in MediaWiki::parseTitle() if the title is invalid; the
+ * software uses this to display an error page. Internally it's basically a Title
+ * for an empty special page
+ */
+class BadTitle extends Title {
+ public function __construct(){
+ $this->mTextform = '';
+ $this->mUrlform = '';
+ $this->mDbkeyform = '';
+ $this->mNamespace = NS_SPECIAL; // Stops talk page link, etc, being shown
+ }
+
+ public function exists(){
+ return false;
+ }
+
+ public function getPrefixedText(){
+ return '';
+ }
+
+ public function getText(){
+ return '';
+ }
+
+ public function getPrefixedURL(){
+ return '';
+ }
+
+ public function getPrefixedDBKey(){
+ return '';
+ }