0224853b51efba21a264d37ee4ae949a0acafb97
3 * MediaWiki is the to-be base class for this whole project
8 var $GET ; # Stores the $_GET variables at time of creation, can be changed
14 function MediaWiki () {
18 function setVal( $key, &$value ) {
19 $this->param
[strtolower( $key )] = $value;
22 function getVal( $key, $default = "" ) {
23 $key = strtolower( $key );
24 if( isset( $this->params
[$key] ) ) {
25 return $this->params
[$key];
31 * Initialize the object to be known as $wgArticle for special cases
33 function initializeSpecialCases ( &$title , &$output , $request , $action ) {
34 if ( $title->getInterwiki() != '' ) {
35 if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
36 $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
38 $url = $title->getFullURL();
40 # Check for a redirect loop
41 if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
42 $output->redirect( $url );
44 $title = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
45 $output->errorpage( 'badtitle', 'badtitletext' );
47 } else if ( ( $action == 'view' ) &&
48 (!isset( $this->GET
['title'] ) ||
$title->getPrefixedDBKey() != $this->GET
['title'] ) &&
49 !count( array_diff( array_keys( $this->GET
), array( 'action', 'title' ) ) ) )
51 /* Redirect to canonical url, make it a 301 to allow caching */
52 $output->setSquidMaxage( 1200 );
53 $output->redirect( $title->getFullURL(), '301');
54 } else if ( NS_SPECIAL
== $title->getNamespace() ) {
55 # actions that need to be made when we have a special pages
56 SpecialPage
::executePath( $title );
58 /* No match to special cases */
61 /* Did match a special case */
66 * Initialize the object to be known as $wgArticle for "standard" actions
68 function initializeArticle( &$title, $request, $action ) {
69 if( NS_MEDIA
== $title->getNamespace() ) {
70 $title = Title
::makeTitle( NS_IMAGE
, $title->getDBkey() );
73 $ns = $title->getNamespace();
75 /* Namespace might change when using redirects */
76 $article = new Article( $title );
77 if( $action == 'view' && !$request->getVal( 'oldid' ) ) {
78 $rTitle = Title
::newFromRedirect( $article->fetchContent() );
80 # Reload from the page pointed to later
81 $article->mContentLoaded
= false;
82 $ns = $rTitle->getNamespace();
83 $wasRedirected = true;
87 /* Categories and images are handled by a different class */
88 if( $ns == NS_IMAGE
) {
89 $b4 = $title->getPrefixedText();
91 require_once( 'includes/ImagePage.php' );
92 $article = new ImagePage( $title );
93 if( isset( $wasRedirected ) && $request->getVal( 'redirect' ) != 'no' ) {
94 $article->mTitle
= $rTitle;
95 $article->mRedirectedFrom
= $b4;
97 } elseif( $ns == NS_CATEGORY
) {
99 require_once( 'includes/CategoryPage.php' );
100 $article = new CategoryPage( $title );
106 * Perform one of the "standard" actions
108 function performAction( $action, &$output, &$article, &$title, &$user, &$request ) {
111 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
122 case 'markpatrolled':
125 case 'deletetrackback':
133 if( !$this->getVal( 'EnableDublinCoreRdf' ) ) {
134 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
136 require_once( 'includes/Metadata.php' );
137 wfDublinCoreRdf( $article );
140 case 'creativecommons':
141 if( !$this->getVal( 'EnableCreativeCommonsRdf' ) ) {
142 wfHttpError( 403, 'Forbidden', wfMsg( 'nocreativecommons' ) );
144 require_once( 'includes/Metadata.php' );
145 wfCreativeCommonsRdf( $article );
149 require_once( 'includes/Credits.php' );
150 showCreditsPage( $article );
153 if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) {
154 # Send a cookie so anons get talk message notifications
155 User
::SetupSession();
159 $internal = $request->getVal( 'internaledit' );
160 $external = $request->getVal( 'externaledit' );
161 $section = $request->getVal( 'section' );
162 $oldid = $request->getVal( 'oldid' );
163 if( !$this->getVal( 'UseExternalEditor' ) ||
$action=='submit' ||
$internal ||
164 $section ||
$oldid ||
( !$user->getOption( 'externaleditor' ) && !$external ) ) {
165 require_once( 'includes/EditPage.php' );
166 $editor = new EditPage( $article );
168 } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external ||
$user->getOption( 'externaleditor' ) ) ) {
169 require_once( 'includes/ExternalEdit.php' );
170 $mode = $request->getVal( 'mode' );
171 $extedit = new ExternalEdit( $article, $mode );
176 if( $_SERVER['REQUEST_URI'] == $title->getInternalURL( 'action=history' ) ) {
177 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
179 require_once( 'includes/PageHistory.php' );
180 $history = new PageHistory( $article );
184 require_once( 'includes/RawPage.php' );
185 $raw = new RawPage( $article );
189 if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
190 $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
195 }; # End of class MediaWiki