Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -1,13 +1,23 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * MediaWiki is the to-be base class for this whole project |
| 5 | +*/ |
3 | 6 | |
| 7 | + |
4 | 8 | class MediaWiki { |
5 | 9 | |
6 | 10 | var $params = array(); |
7 | | - |
| 11 | + |
| 12 | + /** |
| 13 | + * Stores parameters (to avoid using globals) |
| 14 | + */ |
8 | 15 | function setVal( $key, &$value ) { |
9 | 16 | $this->param[strtolower( $key )] = $value; |
10 | 17 | } |
11 | | - |
| 18 | + |
| 19 | + /** |
| 20 | + * Retrieves parameters |
| 21 | + */ |
12 | 22 | function getVal( $key, $default = "" ) { |
13 | 23 | $key = strtolower( $key ); |
14 | 24 | if( isset( $this->params[$key] ) ) { |
— | — | @@ -16,7 +26,11 @@ |
17 | 27 | return $default; |
18 | 28 | } |
19 | 29 | |
20 | | - function initializeArticle( &$title, $request, $action ) { |
| 30 | + /** |
| 31 | + * Creates the article to be known as $wgArticle |
| 32 | + */ |
| 33 | + function initializeArticle( &$title, &$request, $action ) { |
| 34 | + // Fix Media namespace |
21 | 35 | if( NS_MEDIA == $title->getNamespace() ) { |
22 | 36 | $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() ); |
23 | 37 | } |
— | — | @@ -31,22 +45,31 @@ |
32 | 46 | # Reload from the page pointed to later |
33 | 47 | $article->mContentLoaded = false; |
34 | 48 | $ns = $rTitle->getNamespace(); |
| 49 | + $wasRedirected = true; |
35 | 50 | } |
36 | 51 | } |
37 | 52 | |
38 | 53 | // Categories and images are handled by a different class |
39 | 54 | if( $ns == NS_IMAGE ) { |
| 55 | + $b4 = $title->getPrefixedText(); |
40 | 56 | unset($article); |
41 | 57 | require_once( 'includes/ImagePage.php' ); |
42 | | - return new ImagePage( $title ); |
| 58 | + $article = new ImagePage( $title ); |
| 59 | + if( isset( $wasRedirected ) ) { |
| 60 | + $article->mTitle = $rTitle; |
| 61 | + $article->mRedirectedFrom = $b4; |
| 62 | + } |
43 | 63 | } elseif( $ns == NS_CATEGORY ) { |
44 | 64 | unset($article); |
45 | 65 | require_once( 'includes/CategoryPage.php' ); |
46 | | - return new CategoryPage( $title ); |
| 66 | + $article = new CategoryPage( $title ); |
47 | 67 | } |
48 | 68 | return $article; |
49 | 69 | } |
50 | 70 | |
| 71 | + /** |
| 72 | + * Performs any of a wide range of passed actions |
| 73 | + */ |
51 | 74 | function performAction( $action, &$output, &$article, &$title, &$user, &$request ) { |
52 | 75 | switch( $action ) { |
53 | 76 | case 'view': |