3 #__________________________
8 function main_action () {
9 global $wgTitle , $wgArticle , $wgRequest , $wgOut , $wgServer ;
10 global $wgDisableInternalSearch , $wgUseCategoryMagic , $wgDisabledActions , $action ;
11 wfProfileIn( 'main-action' );
13 if( !$wgDisableInternalSearch && !is_null( $this->mSearch
) && $this->mSearch
!== '' ) {
14 require_once( 'includes/SpecialSearch.php' );
15 $wgTitle = Title
::makeTitle( NS_SPECIAL
, 'Search' );
17 } else if( !$wgTitle or $wgTitle->getDBkey() == '' ) {
18 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
19 $wgOut->errorpage( 'badtitle', 'badtitletext' );
20 } else if ( $wgTitle->getInterwiki() != '' ) {
21 if( $rdfrom = $wgRequest->getVal( 'rdfrom' ) ) {
22 $url = $wgTitle->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
24 $url = $wgTitle->getFullURL();
26 # Check for a redirect loop
27 if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $wgTitle->isLocal() ) {
28 $wgOut->redirect( $url );
30 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
31 $wgOut->errorpage( 'badtitle', 'badtitletext' );
33 } else if ( ( $action == 'view' ) &&
34 (!isset( $_GET['title'] ) ||
$wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
35 !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
37 /* redirect to canonical url, make it a 301 to allow caching */
38 $wgOut->setSquidMaxage( 1200 );
39 $wgOut->redirect( $wgTitle->getFullURL(), '301');
40 } else if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
41 # actions that need to be made when we have a special pages
42 SpecialPage
::executePath( $wgTitle );
44 if ( NS_MEDIA
== $wgTitle->getNamespace() ) {
45 $wgTitle = Title
::makeTitle( NS_IMAGE
, $wgTitle->getDBkey() );
48 $ns = $wgTitle->getNamespace();
50 // Namespace might change when using redirects
51 if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) {
52 $wgArticle = new Article( $wgTitle );
53 $rTitle = Title
::newFromRedirect( $wgArticle->fetchContent() );
55 # Reload from the page pointed to later
56 $wgArticle->mContentLoaded
= false;
57 $ns = $rTitle->getNamespace();
61 // Categories and images are handled by a different class
62 if ( $ns == NS_IMAGE
) {
64 require_once( 'includes/ImagePage.php' );
65 $wgArticle = new ImagePage( $wgTitle );
66 } elseif ( $wgUseCategoryMagic && $ns == NS_CATEGORY
) {
68 require_once( 'includes/CategoryPage.php' );
69 $wgArticle = new CategoryPage( $wgTitle );
72 if ( in_array( $action, $wgDisabledActions ) ) {
73 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
75 $act = 'act_' . $action ;
76 if ( method_exists ( $this , $act ) ) {
77 $this->$act ( $action ) ;
79 $this->action_unknown ( $action ) ;
84 wfProfileOut( 'main-action' );
87 #____________________________________________________________________________________
90 function act_view ( $action ) {
91 global $wgOut , $wgSquidMaxage , $wgArticle ;
92 $wgOut->setSquidMaxage( $wgSquidMaxage );
96 function act_print ( $action ) {
101 function act_dublincore ( $action ) {
102 global $wgArticle , $wgEnableDublinCoreRdf ;
103 if( !$wgEnableDublinCoreRdf ) {
104 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
106 require_once( 'includes/Metadata.php' );
107 wfDublinCoreRdf( $wgArticle );
111 function act_creativecommons ( $action ) {
112 global $wgArticle , $wgEnableCreativeCommonsRdf ;
113 if( !$wgEnableCreativeCommonsRdf ) {
114 wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
116 require_once( 'includes/Metadata.php' );
117 wfCreativeCommonsRdf( $wgArticle );
121 function act_credits ( $action ) {
123 require_once( 'includes/Credits.php' );
124 showCreditsPage( $wgArticle );
127 function act_submit ( $action ) {
128 global $wgCommandLineMode , $wgRequest ;
129 if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
130 # Send a cookie so anons get talk message notifications
131 User
::SetupSession();
133 $this->act_edit ( $action ) ;
136 function act_edit ( $action ) {
137 global $wgRequest , $wgUseExternalEditor , $wgUser , $wgArticle ;
138 $internal = $wgRequest->getVal( 'internaledit' );
139 $external = $wgRequest->getVal( 'externaledit' );
140 $section = $wgRequest->getVal( 'section' );
141 $oldid = $wgRequest->getVal( 'oldid' );
142 if(!$wgUseExternalEditor ||
$action=='submit' ||
$internal ||
143 $section ||
$oldid ||
(!$wgUser->getOption('externaleditor') && !$external)) {
144 require_once( 'includes/EditPage.php' );
145 $editor = new EditPage( $wgArticle );
147 } elseif($wgUseExternalEditor && ($external ||
$wgUser->getOption('externaleditor'))) {
148 require_once( 'includes/ExternalEdit.php' );
149 $mode = $wgRequest->getVal( 'mode' );
150 $extedit = new ExternalEdit( $wgArticle, $mode );
155 function act_history ( $action ) {
156 global $wgTitle , $wgArticle , $wgSquidMaxage ;
157 if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {
158 $wgOut->setSquidMaxage( $wgSquidMaxage );
160 require_once( 'includes/PageHistory.php' );
161 $history = new PageHistory( $wgArticle );
165 function act_raw ( $action ) {
167 require_once( 'includes/RawPage.php' );
168 $raw = new RawPage( $wgArticle );
173 function action_unknown ( $action ) {
174 global $wgArticle , $wgOut ;
175 if (wfRunHooks('UnknownAction', array($action, $wgArticle))) {
176 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
181 function act_watch ( $action ) { $this->article_action ( $action ) ; }
182 function act_unwatch ( $action ) { $this->article_action ( $action ) ; }
183 function act_delete ( $action ) { $this->article_action ( $action ) ; }
184 function act_revert ( $action ) { $this->article_action ( $action ) ; }
185 function act_rollback ( $action ) { $this->article_action ( $action ) ; }
186 function act_protect ( $action ) { $this->article_action ( $action ) ; }
187 function act_unprotect ( $action ) { $this->article_action ( $action ) ; }
188 function act_info ( $action ) { $this->article_action ( $action ) ; }
189 function act_markpatrolled ( $action ) { $this->article_action ( $action ) ; }
190 function act_validate ( $action ) { $this->article_action ( $action ) ; }
191 function act_render ( $action ) { $this->article_action ( $action ) ; }
192 function act_deletetrackback ( $action ) { $this->article_action ( $action ) ; }
193 function act_purge ( $action ) { $this->article_action ( $action ) ; }
195 function article_action ( $action ) {
197 $wgArticle->$action() ;
201 } ; # end of class MediaWikiType