diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/AutoLoader.php | 7 | ||||
-rw-r--r-- | includes/DefaultSettings.php | 7 | ||||
-rw-r--r-- | includes/Wiki.php | 43 | ||||
-rw-r--r-- | includes/actions/DeleteAction.php | 42 | ||||
-rw-r--r-- | includes/actions/EditAction.php | 74 | ||||
-rw-r--r-- | includes/actions/ProtectAction.php | 56 | ||||
-rw-r--r-- | includes/actions/RenderAction.php | 42 | ||||
-rw-r--r-- | includes/actions/ViewAction.php | 43 |
8 files changed, 275 insertions, 39 deletions
diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 8c92b6b9cbe0..c7d4632cbd28 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -253,19 +253,26 @@ $wgAutoloadLocalClasses = array( # includes/actions 'CreditsAction' => 'includes/actions/CreditsAction.php', + 'DeleteAction' => 'includes/actions/DeleteAction.php', + 'EditAction' => 'includes/actions/EditAction.php', 'HistoryAction' => 'includes/actions/HistoryAction.php', 'HistoryPage' => 'includes/actions/HistoryAction.php', 'HistoryPager' => 'includes/actions/HistoryAction.php', 'InfoAction' => 'includes/actions/InfoAction.php', 'MarkpatrolledAction' => 'includes/actions/MarkpatrolledAction.php', + 'ProtectAction' => 'includes/actions/ProtectAction.php', 'PurgeAction' => 'includes/actions/PurgeAction.php', 'RawAction' => 'includes/actions/RawAction.php', 'RawPage' => 'includes/actions/RawAction.php', + 'RenderAction' => 'includes/actions/RenderAction.php', 'RevertAction' => 'includes/actions/RevertAction.php', 'RevertFileAction' => 'includes/actions/RevertAction.php', 'RevisiondeleteAction' => 'includes/actions/RevisiondeleteAction.php', 'RollbackAction' => 'includes/actions/RollbackAction.php', + 'SubmitAction' => 'includes/actions/EditAction.php', + 'UnprotectAction' => 'includes/actions/ProtectAction.php', 'UnwatchAction' => 'includes/actions/WatchAction.php', + 'ViewAction' => 'includes/actions/ViewAction.php', 'WatchAction' => 'includes/actions/WatchAction.php', # includes/api diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3fec4c864364..aea3eda74c87 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5303,15 +5303,22 @@ $wgMaxRedirectLinksRetrieved = 500; */ $wgActions = array( 'credits' => true, + 'delete' => true, + 'edit' => true, 'history' => true, 'info' => true, 'markpatrolled' => true, + 'protect' => true, 'purge' => true, 'raw' => true, + 'render' => true, 'revert' => true, 'revisiondelete' => true, 'rollback' => true, + 'submit' => true, + 'unprotect' => true, 'unwatch' => true, + 'view' => true, 'watch' => true, ); diff --git a/includes/Wiki.php b/includes/Wiki.php index 55ff89ed8cd9..c896f4966043 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -516,46 +516,11 @@ class MediaWiki { return; } - switch( $act ) { - case 'view': - $output->setSquidMaxage( $wgSquidMaxage ); - $this->performedAction = $act; - $article->view(); - break; - case 'delete': - case 'protect': - case 'unprotect': - case 'render': - $this->performedAction = $act; - $article->$act(); - break; - case 'submit': - if ( session_id() == '' ) { - // Send a cookie so anons get talk message notifications - wfSetupSession(); - } - // Continue... - case 'edit': - if ( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { - $this->performedAction = 'edit'; - if ( ExternalEdit::useExternalEngine( $this->context, 'edit' ) - && $act == 'edit' && !$request->getVal( 'section' ) - && !$request->getVal( 'oldid' ) ) - { - $extedit = new ExternalEdit( $this->context ); - $extedit->execute(); - } else { - $editor = new EditPage( $article ); - $editor->edit(); - } - } - break; - default: - if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { - $this->performedAction = 'nosuchaction'; - $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); - } + if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { + $this->performedAction = 'nosuchaction'; + $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); } + wfProfileOut( __METHOD__ ); } diff --git a/includes/actions/DeleteAction.php b/includes/actions/DeleteAction.php new file mode 100644 index 000000000000..5a5a382b20c2 --- /dev/null +++ b/includes/actions/DeleteAction.php @@ -0,0 +1,42 @@ +<?php +/** + * Handle page deletion + * + * Copyright © 2012 Timo Tijhof + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * @file + * @ingroup Actions + * @author Timo Tijhof + */ + +class DeleteAction extends FormlessAction { + + public function getName() { + return 'delete'; + } + + public function onView(){ + return null; + } + + public function show(){ + + $this->page->delete(); + + } + +} diff --git a/includes/actions/EditAction.php b/includes/actions/EditAction.php new file mode 100644 index 000000000000..08a33f4c0d9f --- /dev/null +++ b/includes/actions/EditAction.php @@ -0,0 +1,74 @@ +<?php +/** + * action=edit / action=submit handler + * + * Copyright © 2012 Timo Tijhof + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * @file + * @ingroup Actions + * @author Timo Tijhof + */ + +class EditAction extends FormlessAction { + + public function getName() { + return 'edit'; + } + + public function onView(){ + return null; + } + + public function show(){ + $page = $this->page; + $request = $this->getRequest(); + $user = $this->getUser(); + $context = $this->getContext(); + + if ( wfRunHooks( 'CustomEditor', array( $page, $user ) ) ) { + if ( ExternalEdit::useExternalEngine( $context, 'edit' ) + && $this->getName() == 'edit' && !$request->getVal( 'section' ) + && !$request->getVal( 'oldid' ) ) + { + $extedit = new ExternalEdit( $context ); + $extedit->execute(); + } else { + $editor = new EditPage( $page ); + $editor->edit(); + } + } + + } + +} + +class SubmitAction extends EditAction { + + public function getName() { + return 'submit'; + } + + public function show(){ + if ( session_id() == '' ) { + // Send a cookie so anons get talk message notifications + wfSetupSession(); + } + + parent::show(); + } + +} diff --git a/includes/actions/ProtectAction.php b/includes/actions/ProtectAction.php new file mode 100644 index 000000000000..f053ede779bf --- /dev/null +++ b/includes/actions/ProtectAction.php @@ -0,0 +1,56 @@ +<?php +/** + * action=protect handler + * + * Copyright © 2012 Timo Tijhof + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * @file + * @ingroup Actions + * @author Timo Tijhof + */ + +class ProtectAction extends FormlessAction { + + public function getName() { + return 'protect'; + } + + public function onView(){ + return null; + } + + public function show(){ + + $this->page->protect(); + + } + +} + +class UnprotectAction extends ProtectAction { + + public function getName() { + return 'unprotect'; + } + + public function show(){ + + $this->page->unprotect(); + + } + +} diff --git a/includes/actions/RenderAction.php b/includes/actions/RenderAction.php new file mode 100644 index 000000000000..80af79cc646e --- /dev/null +++ b/includes/actions/RenderAction.php @@ -0,0 +1,42 @@ +<?php +/** + * Handle action=render + * + * Copyright © 2012 Timo Tijhof + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * @file + * @ingroup Actions + * @author Timo Tijhof + */ + +class RenderAction extends FormlessAction { + + public function getName() { + return 'render'; + } + + public function onView(){ + return null; + } + + public function show(){ + + $this->page->render(); + + } + +} diff --git a/includes/actions/ViewAction.php b/includes/actions/ViewAction.php new file mode 100644 index 000000000000..4e37381b5481 --- /dev/null +++ b/includes/actions/ViewAction.php @@ -0,0 +1,43 @@ +<?php +/** + * An action that views article content + * + * Copyright © 2012 Timo Tijhof + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * @file + * @ingroup Actions + * @author Timo Tijhof + */ + +class ViewAction extends FormlessAction { + + public function getName() { + return 'view'; + } + + public function onView(){ + return null; + } + + public function show(){ + global $wgSquidMaxage; + + $this->getOutput()->setSquidMaxage( $wgSquidMaxage ); + $this->page->view(); + } + +} |