diff options
author | Krinkle <krinkle@users.mediawiki.org> | 2012-01-17 19:56:08 +0000 |
---|---|---|
committer | Krinkle <krinkle@users.mediawiki.org> | 2012-01-17 19:56:08 +0000 |
commit | d03087df359e4c5bdc2dd0cff0db15ae5f129b48 (patch) | |
tree | 50122676713bc4c379728b9cde7e06767ca43ce5 /includes/actions | |
parent | 68cc777cea7c6d3db5089d51af475d9f1721403e (diff) | |
download | mediawikicore-d03087df359e4c5bdc2dd0cff0db15ae5f129b48.tar.gz mediawikicore-d03087df359e4c5bdc2dd0cff0db15ae5f129b48.zip |
[Actions] Move the remaining actions out of MediaWiki::performAction into single action classes (finally).
- [Actions] -
* I am aware that eventually these classes should be more than just a few lines re-directing control to WikiPage, but I'm keeping these commits as uncontroversial as possible due to feature freeze. Refactor could be done later.
* Contributes to solution of bug 27930 - Ablity to get current action (The Right Way)
* Final goal: Get the current action without needing access to Wiki.php internals (i.e. with Action::factory in one hand and an instance of IContextSource in the other)
* Required for proper fix of r108342/108343 (currently marked FIXME)
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/109195
Diffstat (limited to 'includes/actions')
-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 |
5 files changed, 257 insertions, 0 deletions
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(); + } + +} |