A rewrite especially for Tim :-)
[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 , &$user ) {
20 global $wgRequest ; # Unavoidable for now
21
22 $title = &$article->getTitle() ;
23 switch( $action ) {
24 case 'view':
25 $output->setSquidMaxage( $this->getVal('SquidMaxage') );
26 $article->view();
27 break;
28 case 'watch':
29 case 'unwatch':
30 case 'delete':
31 case 'revert':
32 case 'rollback':
33 case 'protect':
34 case 'unprotect':
35 case 'info':
36 case 'markpatrolled':
37 case 'validate':
38 case 'render':
39 case 'deletetrackback':
40 case 'purge':
41 $article->$action();
42 break;
43 case 'print':
44 $article->view();
45 break;
46 case 'dublincore':
47 if( !$this->getVal('EnableDublinCoreRdf') ) {
48 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
49 } else {
50 require_once( 'includes/Metadata.php' );
51 wfDublinCoreRdf( $article );
52 }
53 break;
54 case 'creativecommons':
55 if( !$this->getVal('EnableCreativeCommonsRdf') ) {
56 wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
57 } else {
58 require_once( 'includes/Metadata.php' );
59 wfCreativeCommonsRdf( $article );
60 }
61 break;
62 case 'credits':
63 require_once( 'includes/Credits.php' );
64 showCreditsPage( $article );
65 break;
66 case 'submit':
67 if( !$this->getVal('CommandLineMode') && !$wgRequest->checkSessionCookie() ) {
68 # Send a cookie so anons get talk message notifications
69 User::SetupSession();
70 }
71 # Continue...
72 case 'edit':
73 $internal = $wgRequest->getVal( 'internaledit' );
74 $external = $wgRequest->getVal( 'externaledit' );
75 $section = $wgRequest->getVal( 'section' );
76 $oldid = $wgRequest->getVal( 'oldid' );
77 if(!$this->getVal('UseExternalEditor') || $action=='submit' || $internal ||
78 $section || $oldid || (!$user->getOption('externaleditor') && !$external)) {
79 require_once( 'includes/EditPage.php' );
80 $editor = new EditPage( $article );
81 $editor->submit();
82 } elseif($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) {
83 require_once( 'includes/ExternalEdit.php' );
84 $mode = $wgRequest->getVal( 'mode' );
85 $extedit = new ExternalEdit( $article, $mode );
86 $extedit->edit();
87 }
88 break;
89 case 'history':
90 if ($_SERVER['REQUEST_URI'] == $title->getInternalURL('action=history')) {
91 $output->setSquidMaxage( $this->getVal('SquidMaxage') );
92 }
93 require_once( 'includes/PageHistory.php' );
94 $history = new PageHistory( $article );
95 $history->history();
96 break;
97 case 'raw':
98 require_once( 'includes/RawPage.php' );
99 $raw = new RawPage( $article );
100 $raw->view();
101 break;
102 default:
103 if (wfRunHooks('UnknownAction', array($action, $article))) {
104 $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
105 }
106 }
107 }
108
109 } ; # End of class MediaWiki
110
111 ?>
112