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