From e7bf509eab29fa27d6f85e5229485feb0ed9cf0f Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 20 Jan 2007 19:51:21 +0000 Subject: [PATCH] Introduce 'CustomEditor' hook; see docs/hooks.txt for more information --- RELEASE-NOTES | 1 + docs/hooks.txt | 8 ++++++++ includes/Wiki.php | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e53ac884fe..7666911340 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -129,6 +129,7 @@ lighter making things easier to read. * ar: fix the 'create a new page' on search page when no exact match found * (bug 8703) Corrected Talk namespace name for Limburgish (li) * (bug 8712) Expose user groups as a JavaScript global +* Introduce 'CustomEditor' hook; see docs/hooks.txt for more information == Languages updated == diff --git a/docs/hooks.txt b/docs/hooks.txt index 347ad5baa7..213171e043 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -317,6 +317,14 @@ $user: the user who did the block (not the one being blocked) $isbn: ISBN to show information for $output: OutputPage object in use +'CustomEditor': When invoking the page editor +$article: Article being edited +$user: User performing the edit + +Return true to allow the normal editor to be used, or false +if implementing a custom editor, e.g. for a special namespace, +etc. + 'DiffViewHeader': called before diff display $diff: DifferenceEngine object that's calling $oldRev: Revision object of the "old" revision (may be null/invalid) diff --git a/includes/Wiki.php b/includes/Wiki.php index 26fd6dd64b..a0624e906d 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -405,18 +405,20 @@ class MediaWiki { } /* Continue... */ case 'edit': - $internal = $request->getVal( 'internaledit' ); - $external = $request->getVal( 'externaledit' ); - $section = $request->getVal( 'section' ); - $oldid = $request->getVal( 'oldid' ); - if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal || - $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { - $editor = new EditPage( $article ); - $editor->submit(); - } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { - $mode = $request->getVal( 'mode' ); - $extedit = new ExternalEdit( $article, $mode ); - $extedit->edit(); + if( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { + $internal = $request->getVal( 'internaledit' ); + $external = $request->getVal( 'externaledit' ); + $section = $request->getVal( 'section' ); + $oldid = $request->getVal( 'oldid' ); + if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal || + $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { + $editor = new EditPage( $article ); + $editor->submit(); + } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { + $mode = $request->getVal( 'mode' ); + $extedit = new ExternalEdit( $article, $mode ); + $extedit->edit(); + } } break; case 'history': -- 2.20.1