Added Article::newFromWikiPage() function to create an appropriate Article object...
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 15 Nov 2011 19:41:32 +0000 (19:41 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 15 Nov 2011 19:41:32 +0000 (19:41 +0000)
includes/Article.php

index 3b22b86..fe68ddd 100644 (file)
@@ -126,6 +126,19 @@ class Article extends Page {
                return $page;
        }
 
+       /**
+        * Create an Article object of the appropriate class for the given page.
+        *
+        * @param $page WikiPage
+        * @param $context IContextSource
+        * @return Article object
+        */
+       public static function newFromWikiPage( WikiPage $page, IContextSource $context ) {
+               $article = self::newFromTitle( $page->getTitle(), $context );
+               $article->mPage = $page; // override to keep process cached vars
+               return $article;
+       }
+
        /**
         * Tell the page view functions that this view was redirected
         * from another page on the wiki.