Index: trunk/phase3/tests/phpunit/includes/ArticleTest.php |
— | — | @@ -65,15 +65,15 @@ |
66 | 66 | |
67 | 67 | function testWikiPageFactory() { |
68 | 68 | $title = Title::makeTitle( NS_FILE, 'Someimage.png' ); |
69 | | - $page = WikiPageFactory::newFromTitle( $title ); |
| 69 | + $page = WikiPage::factory( $title ); |
70 | 70 | $this->assertEquals( 'WikiFilePage', get_class( $page ) ); |
71 | 71 | |
72 | 72 | $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' ); |
73 | | - $page = WikiPageFactory::newFromTitle( $title ); |
| 73 | + $page = WikiPage::factory( $title ); |
74 | 74 | $this->assertEquals( 'WikiCategoryPage', get_class( $page ) ); |
75 | 75 | |
76 | 76 | $title = Title::makeTitle( NS_MAIN, 'SomePage' ); |
77 | | - $page = WikiPageFactory::newFromTitle( $title ); |
| 77 | + $page = WikiPage::factory( $title ); |
78 | 78 | $this->assertEquals( 'WikiPage', get_class( $page ) ); |
79 | 79 | } |
80 | 80 | } |
Index: trunk/phase3/includes/WikiPageFactory.php |
— | — | @@ -1,28 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Factory class for classes representing a MediaWiki article and history. |
5 | | - */ |
6 | | -class WikiPageFactory { |
7 | | - /** |
8 | | - * Create an WikiPage object of the appropriate class for the given title. |
9 | | - * |
10 | | - * @param $title Title |
11 | | - * @return WikiPage object |
12 | | - */ |
13 | | - public static function newFromTitle( Title $title ) { |
14 | | - switch( $title->getNamespace() ) { |
15 | | - case NS_MEDIA: |
16 | | - throw new MWException( "NS_MEDIA is a virtual namespace" ); |
17 | | - case NS_FILE: |
18 | | - $page = new WikiFilePage( $title ); |
19 | | - break; |
20 | | - case NS_CATEGORY: |
21 | | - $page = new WikiCategoryPage( $title ); |
22 | | - break; |
23 | | - default: |
24 | | - $page = new WikiPage( $title ); |
25 | | - } |
26 | | - |
27 | | - return $page; |
28 | | - } |
29 | | -} |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -243,7 +243,6 @@ |
244 | 244 | 'WikiFilePage' => 'includes/WikiFilePage.php', |
245 | 245 | 'WikiImporter' => 'includes/Import.php', |
246 | 246 | 'WikiPage' => 'includes/WikiPage.php', |
247 | | - 'WikiPageFactory' => 'includes/WikiPageFactory.php', |
248 | 247 | 'WikiRevision' => 'includes/Import.php', |
249 | 248 | 'WikiMap' => 'includes/WikiMap.php', |
250 | 249 | 'WikiReference' => 'includes/WikiMap.php', |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -48,6 +48,29 @@ |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
| 52 | + * Create a WikiPage object of the appropriate class for the given title. |
| 53 | + * |
| 54 | + * @param $title Title |
| 55 | + * @return WikiPage object of the appropriate type |
| 56 | + */ |
| 57 | + public static function factory( Title $title ) { |
| 58 | + switch( $title->getNamespace() ) { |
| 59 | + case NS_MEDIA: |
| 60 | + throw new MWException( "NS_MEDIA is a virtual namespace" ); |
| 61 | + case NS_FILE: |
| 62 | + $page = new WikiFilePage( $title ); |
| 63 | + break; |
| 64 | + case NS_CATEGORY: |
| 65 | + $page = new WikiCategoryPage( $title ); |
| 66 | + break; |
| 67 | + default: |
| 68 | + $page = new WikiPage( $title ); |
| 69 | + } |
| 70 | + |
| 71 | + return $page; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
52 | 75 | * Constructor from a page id |
53 | 76 | * |
54 | 77 | * Always override this for all subclasses (until we use PHP with LSB) |