Two new functions for Title: isRedirect (maybe should be left Article-only?) and...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 9 Jan 2007 02:45:09 +0000 (02:45 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 9 Jan 2007 02:45:09 +0000 (02:45 +0000)
includes/Title.php

index 171c8b1..fab0654 100644 (file)
@@ -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;