Index: trunk/phase3/includes/search/SearchEngine.php |
— | — | @@ -177,7 +177,7 @@ |
178 | 178 | |
179 | 179 | # See if it still otherwise has content is some sane sense |
180 | 180 | $context->setTitle( $title ); |
181 | | - $article = MediaWiki::articleFromTitle( $title, $context ); |
| 181 | + $article = Article::newFromTitle( $title, $context ); |
182 | 182 | if ( $article->hasViewableContent() ) { |
183 | 183 | return $title; |
184 | 184 | } |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -86,6 +86,40 @@ |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
| 90 | + * Create an Article object of the appropriate class for the given page. |
| 91 | + * |
| 92 | + * @param $title Title |
| 93 | + * @param $context RequestContext |
| 94 | + * @return Article object |
| 95 | + */ |
| 96 | + public static function newFromTitle( $title, RequestContext $context ) { |
| 97 | + if ( NS_MEDIA == $title->getNamespace() ) { |
| 98 | + // FIXME: where should this go? |
| 99 | + $title = Title::makeTitle( NS_FILE, $title->getDBkey() ); |
| 100 | + } |
| 101 | + |
| 102 | + $article = null; |
| 103 | + wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) ); |
| 104 | + if ( $article ) { |
| 105 | + $article->setContext( $context ); |
| 106 | + return $article; |
| 107 | + } |
| 108 | + |
| 109 | + switch( $title->getNamespace() ) { |
| 110 | + case NS_FILE: |
| 111 | + $page = new ImagePage( $title ); |
| 112 | + break; |
| 113 | + case NS_CATEGORY: |
| 114 | + $page = new CategoryPage( $title ); |
| 115 | + break; |
| 116 | + default: |
| 117 | + $page = new Article( $title ); |
| 118 | + } |
| 119 | + $page->setContext( $context ); |
| 120 | + return $page; |
| 121 | + } |
| 122 | + |
| 123 | + /** |
90 | 124 | * Constructor from an page id |
91 | 125 | * @param $id Int article ID to load |
92 | 126 | */ |
Index: trunk/phase3/includes/api/ApiPurge.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | $context = RequestContext::getMain(); |
73 | | - $article = MediaWiki::articleFromTitle( $title, $context ); |
| 73 | + $article = Article::newFromTitle( $title, $context ); |
74 | 74 | $article->doPurge(); // Directly purge and skip the UI part of purge(). |
75 | 75 | $r['purged'] = ''; |
76 | 76 | |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -228,34 +228,13 @@ |
229 | 229 | /** |
230 | 230 | * Create an Article object of the appropriate class for the given page. |
231 | 231 | * |
| 232 | + * @deprecated in 1.19; use Article::newFromTitle() instead |
232 | 233 | * @param $title Title |
233 | 234 | * @param $context RequestContext |
234 | 235 | * @return Article object |
235 | 236 | */ |
236 | 237 | public static function articleFromTitle( $title, RequestContext $context ) { |
237 | | - if ( NS_MEDIA == $title->getNamespace() ) { |
238 | | - // @todo FIXME: Where should this go? |
239 | | - $title = Title::makeTitle( NS_FILE, $title->getDBkey() ); |
240 | | - } |
241 | | - |
242 | | - $article = null; |
243 | | - wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) ); |
244 | | - if ( $article ) { |
245 | | - return $article; |
246 | | - } |
247 | | - |
248 | | - switch( $title->getNamespace() ) { |
249 | | - case NS_FILE: |
250 | | - $page = new ImagePage( $title ); |
251 | | - break; |
252 | | - case NS_CATEGORY: |
253 | | - $page = new CategoryPage( $title ); |
254 | | - break; |
255 | | - default: |
256 | | - $page = new Article( $title ); |
257 | | - } |
258 | | - $page->setContext( $context ); |
259 | | - return $page; |
| 238 | + return Article::newFromTitle( $title, $context ); |
260 | 239 | } |
261 | 240 | |
262 | 241 | /** |
— | — | @@ -302,7 +281,7 @@ |
303 | 282 | wfProfileIn( __METHOD__ ); |
304 | 283 | |
305 | 284 | $action = $this->context->request->getVal( 'action', 'view' ); |
306 | | - $article = self::articleFromTitle( $this->context->title, $this->context ); |
| 285 | + $article = Article::newFromTitle( $this->context->title, $this->context ); |
307 | 286 | // NS_MEDIAWIKI has no redirects. |
308 | 287 | // It is also used for CSS/JS, so performance matters here... |
309 | 288 | if ( $this->context->title->getNamespace() == NS_MEDIAWIKI ) { |
— | — | @@ -339,7 +318,7 @@ |
340 | 319 | } |
341 | 320 | if ( is_object( $target ) ) { |
342 | 321 | // Rewrite environment to redirected article |
343 | | - $rarticle = self::articleFromTitle( $target, $this->context ); |
| 322 | + $rarticle = Article::newFromTitle( $target, $this->context ); |
344 | 323 | $rarticle->loadPageData(); |
345 | 324 | if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
346 | 325 | $rarticle->setRedirectedFrom( $this->context->title ); |
Index: trunk/phase3/index.php |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | $cache->loadFromFileCache(); |
126 | 126 | } |
127 | 127 | # Do any stats increment/watchlist stuff |
128 | | - $article = MediaWiki::articleFromTitle( $wgTitle, $context ); |
| 128 | + $article = Article::newFromTitle( $wgTitle, $context ); |
129 | 129 | $article->viewUpdates(); |
130 | 130 | # Tell OutputPage that output is taken care of |
131 | 131 | $context->output->disable(); |