Preliminary support for application/external-editor
[lhc/web/wiklou.git] / index.php
index ec62796..6dc4473 100644 (file)
--- a/index.php
+++ b/index.php
@@ -76,7 +76,11 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
                $interwiki = Title::newFromUrl( $_REQUEST['title'] );
                if( !is_null( $interwiki ) ) $wgTitle = $interwiki;
        }
-       $url = $wgTitle->getFullURL();
+       if( $rdfrom = $wgRequest->getVal( 'rdfrom' ) ) {
+               $url = $wgTitle->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
+       } else {
+               $url = $wgTitle->getFullURL();
+       }
        # Check for a redirect loop
        if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $wgTitle->isLocal() ) {
                $wgOut->redirect( $url );
@@ -131,6 +135,7 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
                case 'unprotect':
                case 'info':
                case 'markpatrolled':
+               case 'validate':
                        $wgArticle->$action();
                        break;
                case 'print':
@@ -162,10 +167,22 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
                                User::SetupSession();
                        }
                        # Continue...
-               case 'edit':
-                       require_once( 'includes/EditPage.php' );
-                       $editor = new EditPage( $wgArticle );
-                       $editor->submit();
+               case 'edit':                    
+                       $internal = $wgRequest->getVal( 'internaledit' );
+                       $external = $wgRequest->getVal( 'externaledit' );
+                       $section = $wgRequest->getVal( 'section' );
+                       $oldid = $wgRequest->getVal( 'oldid' );                                         
+                       if(!$wgUseExternalEditor || $action=='submit' || $internal || 
+                          $section || $oldid || (!$wgUser->getOption('externaleditor') && !$external)) {
+                               require_once( 'includes/EditPage.php' );
+                               $editor = new EditPage( $wgArticle );
+                               $editor->submit();                              
+                       } elseif($wgUseExternalEditor && ($external || $wgUser->getOption('externaleditor'))) {
+                               require_once( 'includes/ExternalEdit.php' );
+                               $mode = $wgRequest->getVal( 'mode' );
+                               $extedit = new ExternalEdit( $wgArticle, $mode );                               
+                               $extedit->edit();
+                       }
                        break;
                case 'history':
                        if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {