}
try {
- return Title::newFromTextThrow( strval( $text ), $defaultNamespace );
+ return self::newFromTextThrow( strval( $text ), $defaultNamespace );
} catch ( MalformedTitleException $ex ) {
return null;
}
__METHOD__
);
if ( $row !== false ) {
- $title = Title::newFromRow( $row );
+ $title = self::newFromRow( $row );
} else {
$title = null;
}
$titles = [];
foreach ( $res as $row ) {
- $titles[] = Title::newFromRow( $row );
+ $titles[] = self::newFromRow( $row );
}
return $titles;
}
}
$t = new Title();
- $t->mDbkeyform = Title::makeName( $ns, $title, $fragment, $interwiki, true );
+ $t->mDbkeyform = self::makeName( $ns, $title, $fragment, $interwiki, true );
try {
$t->secureAndSplit();
* @return Title The new object
*/
public static function newMainPage() {
- $title = Title::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() );
+ $title = self::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() );
// Don't give fatal errors if the message is broken
if ( !$title ) {
- $title = Title::newFromText( 'Main Page' );
+ $title = self::newFromText( 'Main Page' );
}
return $title;
}
*/
public function getContentModel( $flags = 0 ) {
if ( !$this->mForcedContentModel
- && ( !$this->mContentModel || $flags === Title::GAID_FOR_UPDATE )
+ && ( !$this->mContentModel || $flags === self::GAID_FOR_UPDATE )
&& $this->getArticleID( $flags )
) {
$linkCache = LinkCache::singleton();
}
/**
- * Could this title have a corresponding talk page?
+ * Can this title have a corresponding talk page?
*
- * @return bool
+ * @deprecated since 1.30, use canHaveTalkPage() instead.
+ *
+ * @return bool True if this title either is a talk page or can have a talk page associated.
*/
public function canTalk() {
- return MWNamespace::canTalk( $this->mNamespace );
+ return $this->canHaveTalkPage();
+ }
+
+ /**
+ * Can this title have a corresponding talk page?
+ *
+ * @see MWNamespace::hasTalkNamespace
+ *
+ * @return bool True if this title either is a talk page or can have a talk page associated.
+ */
+ public function canHaveTalkPage() {
+ return MWNamespace::hasTalkNamespace( $this->mNamespace );
}
/**
if ( $canonicalName ) {
$localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par );
if ( $localName != $this->mDbkeyform ) {
- return Title::makeTitle( NS_SPECIAL, $localName );
+ return self::makeTitle( NS_SPECIAL, $localName );
}
}
}
* @return bool
*/
public function isMainPage() {
- return $this->equals( Title::newMainPage() );
+ return $this->equals( self::newMainPage() );
}
/**
* @return Title The object for the talk page
*/
public function getTalkPage() {
- return Title::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
+ return self::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
}
/**
if ( $this->getNamespace() == $subjectNS ) {
return $this;
}
- return Title::makeTitle( $subjectNS, $this->getDBkey() );
+ return self::makeTitle( $subjectNS, $this->getDBkey() );
}
/**
if ( !$this->hasFragment() ) {
return '';
} else {
- return '#' . Title::escapeFragmentForURL( $this->getFragment() );
+ return '#' . self::escapeFragmentForURL( $this->getFragment() );
}
}
* @since 1.20
*/
public function getRootTitle() {
- return Title::makeTitle( $this->getNamespace(), $this->getRootText() );
+ return self::makeTitle( $this->getNamespace(), $this->getRootText() );
}
/**
* @since 1.20
*/
public function getBaseTitle() {
- return Title::makeTitle( $this->getNamespace(), $this->getBaseText() );
+ return self::makeTitle( $this->getNamespace(), $this->getBaseText() );
}
/**
* @since 1.20
*/
public function getSubpage( $text ) {
- return Title::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text );
+ return self::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text );
}
/**
$page_id = $row->pr_page;
$page_ns = $row->page_namespace;
$page_title = $row->page_title;
- $sources[$page_id] = Title::makeTitle( $page_ns, $page_title );
+ $sources[$page_id] = self::makeTitle( $page_ns, $page_title );
# Add groups needed for each restriction type if its not already there
# Make sure this restriction type still exists
* @return int Int or 0 if the page doesn't exist
*/
public function getLatestRevID( $flags = 0 ) {
- if ( !( $flags & Title::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) {
+ if ( !( $flags & self::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) {
return intval( $this->mLatestID );
}
if ( !$this->getArticleID( $flags ) ) {
if ( $res->numRows() ) {
$linkCache = LinkCache::singleton();
foreach ( $res as $row ) {
- $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title );
+ $titleObj = self::makeTitle( $row->page_namespace, $row->page_title );
if ( $titleObj ) {
$linkCache->addGoodLinkObjFromRow( $titleObj, $row );
$retVal[] = $titleObj;
$linkCache = LinkCache::singleton();
foreach ( $res as $row ) {
if ( $row->page_id ) {
- $titleObj = Title::newFromRow( $row );
+ $titleObj = self::newFromRow( $row );
} else {
- $titleObj = Title::makeTitle( $row->$blNamespace, $row->$blTitle );
+ $titleObj = self::makeTitle( $row->$blNamespace, $row->$blTitle );
$linkCache->addBadLinkObj( $titleObj );
}
$retVal[] = $titleObj;
$retVal = [];
foreach ( $res as $row ) {
- $retVal[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );
+ $retVal[] = self::makeTitle( $row->pl_namespace, $row->pl_title );
}
return $retVal;
}
* @return array|bool True on success, getUserPermissionsErrors()-like array on failure
*/
public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true,
- array $changeTags = [] ) {
-
+ array $changeTags = []
+ ) {
global $wgUser;
$err = $this->isValidMoveOperation( $nt, $auth, $reason );
if ( is_array( $err ) ) {
* no pages were moved
*/
public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true,
- array $changeTags = [] ) {
-
+ array $changeTags = []
+ ) {
global $wgMaximumMovedPages;
// Check permissions
if ( !$this->userCan( 'move-subpages' ) ) {
}
# T16385: we need makeTitleSafe because the new page names may
# be longer than 255 characters.
- $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
+ $newSubpage = self::makeTitleSafe( $newNs, $newPageName );
$success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags );
if ( $success === true ) {
# Circular reference
$stack[$parent] = [];
} else {
- $nt = Title::newFromText( $parent );
+ $nt = self::newFromText( $parent );
if ( $nt ) {
$stack[$parent] = $nt->getParentCategoryTree( $children + [ $parent => 1 ] );
}