From 0bcc2bb2e20fd6e651aa09c0e00bf15cb5e09c8c Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 9 Jan 2007 02:45:09 +0000 Subject: [PATCH] Two new functions for Title: isRedirect (maybe should be left Article-only?) and getArticle --- includes/Title.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 171c8b1080..fab065473e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -280,8 +280,6 @@ class Title { * @param string $text the redirect title text * @return Title the new object, or NULL if the text is not a * valid redirect - * @static - * @access public */ public static function newFromRedirect( $text ) { $mwRedir = MagicWord::get( 'redirect' ); @@ -513,6 +511,16 @@ class Title { return (bool)(Title::$interwikiCache[$k]->iw_trans); } + /** + * Determine whether a Title is a redirect + * + * @return bool + */ + public function isRedirect() { + $article = new Article( $this ); + return $article->isRedirect(); + } + /** * Update the page_touched field for an array of title objects * @todo Inefficient unless the IDs are already loaded into the @@ -1386,9 +1394,8 @@ class Title { * @param int $flags a bit field; may be GAID_FOR_UPDATE to select * for update * @return int the ID - * @access public */ - function getArticleID( $flags = 0 ) { + public function getArticleID( $flags = 0 ) { $linkCache =& LinkCache::singleton(); if ( $flags & GAID_FOR_UPDATE ) { $oldUpdate = $linkCache->forUpdate( true ); @@ -1402,6 +1409,15 @@ class Title { return $this->mArticleID; } + /** + * Return the associated Article object. + * + * @return Article + */ + public function getArticle() { + return new Article( $this ); + } + function getLatestRevID() { if ($this->mLatestID !== false) return $this->mLatestID; -- 2.20.1