No more globals here :-)
[lhc/web/wiklou.git] / includes / Wiki.php
1 <?php
2
3 class MediaWiki {
4
5 var $params = array () ;
6
7 function setVal ( $key , &$value ) {
8 $this->param[strtolower($key)] = $value ;
9 }
10
11 function getVal ( $key , $default = "" ) {
12 $key = strtolower ( $key ) ;
13 if ( isset ( $this->params[$key] ) ) {
14 return $this->params[$key] ;
15 }
16 return $default ;
17 }
18
19 function performAction ( $action , &$output , &$article , &$title , &$user , &$request ) {
20 switch( $action ) {
21 case 'view':
22 $output->setSquidMaxage( $this->getVal('SquidMaxage') );
23 $article->view();
24 break;
25 case 'watch':
26 case 'unwatch':
27 case 'delete':
28 case 'revert':
29 case 'rollback':
30 case 'protect':
31 case 'unprotect':
32 case 'info':
33 case 'markpatrolled':
34 case 'validate':
35 case 'render':
36 case 'deletetrackback':
37 case 'purge':
38 $article->$action();
39 break;
40 case 'print':
41 $article->view();
42 break;
43 case 'dublincore':
44 if( !$this->getVal('EnableDublinCoreRdf') ) {
45 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
46 } else {
47 require_once( 'includes/Metadata.php' );
48 wfDublinCoreRdf( $article );
49 }
50 break;
51 case 'creativecommons':
52 if( !$this->getVal('EnableCreativeCommonsRdf') ) {
53 wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
54 } else {
55 require_once( 'includes/Metadata.php' );
56 wfCreativeCommonsRdf( $article );
57 }
58 break;
59 case 'credits':
60 require_once( 'includes/Credits.php' );
61 showCreditsPage( $article );
62 break;
63 case 'submit':
64 if( !$this->getVal('CommandLineMode') && !$request->checkSessionCookie() ) {
65 # Send a cookie so anons get talk message notifications
66 User::SetupSession();
67 }
68 # Continue...
69 case 'edit':
70 $internal = $request->getVal( 'internaledit' );
71 $external = $request->getVal( 'externaledit' );
72 $section = $request->getVal( 'section' );
73 $oldid = $request->getVal( 'oldid' );
74 if(!$this->getVal('UseExternalEditor') || $action=='submit' || $internal ||
75 $section || $oldid || (!$user->getOption('externaleditor') && !$external)) {
76 require_once( 'includes/EditPage.php' );
77 $editor = new EditPage( $article );
78 $editor->submit();
79 } elseif($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) {
80 require_once( 'includes/ExternalEdit.php' );
81 $mode = $request->getVal( 'mode' );
82 $extedit = new ExternalEdit( $article, $mode );
83 $extedit->edit();
84 }
85 break;
86 case 'history':
87 if ($_SERVER['REQUEST_URI'] == $title->getInternalURL('action=history')) {
88 $output->setSquidMaxage( $this->getVal('SquidMaxage') );
89 }
90 require_once( 'includes/PageHistory.php' );
91 $history = new PageHistory( $article );
92 $history->history();
93 break;
94 case 'raw':
95 require_once( 'includes/RawPage.php' );
96 $raw = new RawPage( $article );
97 $raw->view();
98 break;
99 default:
100 if (wfRunHooks('UnknownAction', array($action, $article))) {
101 $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
102 }
103 }
104 }
105
106 } ; # End of class MediaWiki
107
108 ?>
109