Introduce 'CustomEditor' hook; see docs/hooks.txt for more information
authorRob Church <robchurch@users.mediawiki.org>
Sat, 20 Jan 2007 19:51:21 +0000 (19:51 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 20 Jan 2007 19:51:21 +0000 (19:51 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/Wiki.php

index e53ac88..7666911 100644 (file)
@@ -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 ==
 
index 347ad5b..213171e 100644 (file)
@@ -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)
index 26fd6dd..a0624e9 100644 (file)
@@ -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':