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 , &$search ) {
34 wfProfileIn( 'MediaWiki::initializeSpecialCases' );
35 if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) {
36 require_once( 'includes/SpecialSearch.php' );
37 $title = Title
::makeTitle( NS_SPECIAL
, 'Search' );
39 } else if( !$title or $title->getDBkey() == '' ) {
40 $title = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
41 $output->errorpage( 'badtitle', 'badtitletext' );
42 } else if ( $title->getInterwiki() != '' ) {
43 if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
44 $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
46 $url = $title->getFullURL();
48 /* Check for a redirect loop */
49 if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
50 $output->redirect( $url );
52 $title = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
53 $output->errorpage( 'badtitle', 'badtitletext' );
55 } else if ( ( $action == 'view' ) &&
56 (!isset( $this->GET
['title'] ) ||
$title->getPrefixedDBKey() != $this->GET
['title'] ) &&
57 !count( array_diff( array_keys( $this->GET
), array( 'action', 'title' ) ) ) )
59 /* Redirect to canonical url, make it a 301 to allow caching */
60 $output->setSquidMaxage( 1200 );
61 $output->redirect( $title->getFullURL(), '301');
62 } else if ( NS_SPECIAL
== $title->getNamespace() ) {
63 /* actions that need to be made when we have a special pages */
64 SpecialPage
::executePath( $title );
66 /* No match to special cases */
67 wfProfileOut( 'MediaWiki::initializeSpecialCases' );
70 /* Did match a special case */
71 wfProfileOut( 'MediaWiki::initializeSpecialCases' );
76 * Initialize the object to be known as $wgArticle for "standard" actions
78 function initializeArticle( &$title, $request, $action ) {
80 wfProfileIn( 'MediaWiki::initializeArticle' );
82 if( NS_MEDIA
== $title->getNamespace() ) {
83 $title = Title
::makeTitle( NS_IMAGE
, $title->getDBkey() );
86 $ns = $title->getNamespace();
88 /* Namespace might change when using redirects */
89 $article = new Article( $title );
90 if( $action == 'view' && !$request->getVal( 'oldid' ) ) {
91 $rTitle = Title
::newFromRedirect( $article->fetchContent() );
93 /* Reload from the page pointed to later */
94 $article->mContentLoaded
= false;
95 $ns = $rTitle->getNamespace();
96 $wasRedirected = true;
100 /* Categories and images are handled by a different class */
101 if( $ns == NS_IMAGE
) {
102 $b4 = $title->getPrefixedText();
104 require_once( 'includes/ImagePage.php' );
105 $article = new ImagePage( $title );
106 if( isset( $wasRedirected ) && $request->getVal( 'redirect' ) != 'no' ) {
107 $article->mTitle
= $rTitle;
108 $article->mRedirectedFrom
= $b4;
110 } elseif( $ns == NS_CATEGORY
) {
112 require_once( 'includes/CategoryPage.php' );
113 $article = new CategoryPage( $title );
115 wfProfileOut( 'MediaWiki::initializeArticle' );
120 * Perform one of the "standard" actions
122 function performAction( $action, &$output, &$article, &$title, &$user, &$request ) {
124 wfProfileIn( 'MediaWiki::performAction' );
128 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
139 case 'markpatrolled':
142 case 'deletetrackback':
150 if( !$this->getVal( 'EnableDublinCoreRdf' ) ) {
151 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
153 require_once( 'includes/Metadata.php' );
154 wfDublinCoreRdf( $article );
157 case 'creativecommons':
158 if( !$this->getVal( 'EnableCreativeCommonsRdf' ) ) {
159 wfHttpError( 403, 'Forbidden', wfMsg( 'nocreativecommons' ) );
161 require_once( 'includes/Metadata.php' );
162 wfCreativeCommonsRdf( $article );
166 require_once( 'includes/Credits.php' );
167 showCreditsPage( $article );
170 if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) {
171 /* Send a cookie so anons get talk message notifications */
172 User
::SetupSession();
176 $internal = $request->getVal( 'internaledit' );
177 $external = $request->getVal( 'externaledit' );
178 $section = $request->getVal( 'section' );
179 $oldid = $request->getVal( 'oldid' );
180 if( !$this->getVal( 'UseExternalEditor' ) ||
$action=='submit' ||
$internal ||
181 $section ||
$oldid ||
( !$user->getOption( 'externaleditor' ) && !$external ) ) {
182 require_once( 'includes/EditPage.php' );
183 $editor = new EditPage( $article );
185 } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external ||
$user->getOption( 'externaleditor' ) ) ) {
186 require_once( 'includes/ExternalEdit.php' );
187 $mode = $request->getVal( 'mode' );
188 $extedit = new ExternalEdit( $article, $mode );
193 if( $_SERVER['REQUEST_URI'] == $title->getInternalURL( 'action=history' ) ) {
194 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
196 require_once( 'includes/PageHistory.php' );
197 $history = new PageHistory( $article );
201 require_once( 'includes/RawPage.php' );
202 $raw = new RawPage( $article );
206 if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
207 $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
209 wfProfileOut( 'MediaWiki::performAction' );
214 }; /* End of class MediaWiki */