http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88594
Revision: 88594
Author: ialex
Date: 2011-05-22 18:38:04 +0000 (Sun, 22 May 2011)
Log Message:
-----------
Moved MediaWiki::articleFromTitle() to Article::newFromTitle(), this has
nothing to do in the MediaWiki class
Modified Paths:
--------------
trunk/phase3/includes/Article.php
trunk/phase3/includes/Wiki.php
trunk/phase3/includes/api/ApiPurge.php
trunk/phase3/includes/search/SearchEngine.php
trunk/phase3/index.php
Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php 2011-05-22 18:14:23 UTC (rev 88593)
+++ trunk/phase3/includes/Article.php 2011-05-22 18:38:04 UTC (rev 88594)
@@ -86,6 +86,40 @@
}
/**
+ * Create an Article object of the appropriate class for the given page.
+ *
+ * @param $title Title
+ * @param $context RequestContext
+ * @return Article object
+ */
+ public static function newFromTitle( $title, RequestContext $context ) {
+ if ( NS_MEDIA == $title->getNamespace() ) {
+ // FIXME: where should this go?
+ $title = Title::makeTitle( NS_FILE, $title->getDBkey()
);
+ }
+
+ $article = null;
+ wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) );
+ if ( $article ) {
+ $article->setContext( $context );
+ return $article;
+ }
+
+ switch( $title->getNamespace() ) {
+ case NS_FILE:
+ $page = new ImagePage( $title );
+ break;
+ case NS_CATEGORY:
+ $page = new CategoryPage( $title );
+ break;
+ default:
+ $page = new Article( $title );
+ }
+ $page->setContext( $context );
+ return $page;
+ }
+
+ /**
* Constructor from an page id
* @param $id Int article ID to load
*/
Modified: trunk/phase3/includes/Wiki.php
===================================================================
--- trunk/phase3/includes/Wiki.php 2011-05-22 18:14:23 UTC (rev 88593)
+++ trunk/phase3/includes/Wiki.php 2011-05-22 18:38:04 UTC (rev 88594)
@@ -228,34 +228,13 @@
/**
* Create an Article object of the appropriate class for the given page.
*
+ * @deprecated in 1.19; use Article::newFromTitle() instead
* @param $title Title
* @param $context RequestContext
* @return Article object
*/
public static function articleFromTitle( $title, RequestContext
$context ) {
- if ( NS_MEDIA == $title->getNamespace() ) {
- // @todo FIXME: Where should this go?
- $title = Title::makeTitle( NS_FILE, $title->getDBkey()
);
- }
-
- $article = null;
- wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) );
- if ( $article ) {
- return $article;
- }
-
- switch( $title->getNamespace() ) {
- case NS_FILE:
- $page = new ImagePage( $title );
- break;
- case NS_CATEGORY:
- $page = new CategoryPage( $title );
- break;
- default:
- $page = new Article( $title );
- }
- $page->setContext( $context );
- return $page;
+ return Article::newFromTitle( $title, $context );
}
/**
@@ -302,7 +281,7 @@
wfProfileIn( __METHOD__ );
$action = $this->context->request->getVal( 'action', 'view' );
- $article = self::articleFromTitle( $this->context->title,
$this->context );
+ $article = Article::newFromTitle( $this->context->title,
$this->context );
// NS_MEDIAWIKI has no redirects.
// It is also used for CSS/JS, so performance matters here...
if ( $this->context->title->getNamespace() == NS_MEDIAWIKI ) {
@@ -339,7 +318,7 @@
}
if ( is_object( $target ) ) {
// Rewrite environment to redirected
article
- $rarticle = self::articleFromTitle(
$target, $this->context );
+ $rarticle = Article::newFromTitle(
$target, $this->context );
$rarticle->loadPageData();
if ( $rarticle->exists() || (
is_object( $file ) && !$file->isLocal() ) ) {
$rarticle->setRedirectedFrom(
$this->context->title );
Modified: trunk/phase3/includes/api/ApiPurge.php
===================================================================
--- trunk/phase3/includes/api/ApiPurge.php 2011-05-22 18:14:23 UTC (rev
88593)
+++ trunk/phase3/includes/api/ApiPurge.php 2011-05-22 18:38:04 UTC (rev
88594)
@@ -69,7 +69,7 @@
continue;
}
$context = RequestContext::getMain();
- $article = MediaWiki::articleFromTitle( $title,
$context );
+ $article = Article::newFromTitle( $title, $context );
$article->doPurge(); // Directly purge and skip the UI
part of purge().
$r['purged'] = '';
Modified: trunk/phase3/includes/search/SearchEngine.php
===================================================================
--- trunk/phase3/includes/search/SearchEngine.php 2011-05-22 18:14:23 UTC
(rev 88593)
+++ trunk/phase3/includes/search/SearchEngine.php 2011-05-22 18:38:04 UTC
(rev 88594)
@@ -177,7 +177,7 @@
# See if it still otherwise has content is some sane
sense
$context->setTitle( $title );
- $article = MediaWiki::articleFromTitle( $title,
$context );
+ $article = Article::newFromTitle( $title, $context );
if ( $article->hasViewableContent() ) {
return $title;
}
Modified: trunk/phase3/index.php
===================================================================
--- trunk/phase3/index.php 2011-05-22 18:14:23 UTC (rev 88593)
+++ trunk/phase3/index.php 2011-05-22 18:38:04 UTC (rev 88594)
@@ -124,7 +124,7 @@
$cache->loadFromFileCache();
}
# Do any stats increment/watchlist stuff
- $article = MediaWiki::articleFromTitle(
$wgTitle, $context );
+ $article = Article::newFromTitle( $wgTitle,
$context );
$article->viewUpdates();
# Tell OutputPage that output is taken care of
$context->output->disable();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs