*/
$wgMinimalPasswordLength = 0;
+/**
+ * Activate external editor interface for files and pages
+ * See http://meta.wikimedia.org/wiki/Help:External_editors
+ */
+$wgUseExternalEditor = true;
+
/** Whether or not to sort special pages in Special:Specialpages */
$wgSortSpecialPages = true;
--- /dev/null
+<?php
+/**
+ * License: Public domain
+ *
+ * @author Erik Moeller <moeller@scireview.de>
+ * @package MediaWiki
+ */
+
+/**
+ *
+ * @package MediaWiki
+ *
+ * Support for external editors to modify both text and files
+ * in external application. It works as follows: MediaWiki
+ * sends a meta-file with the MIME type 'application/external-editor'
+ * to the client. The user has to associate that MIME type with
+ * a helper application (a reference implementation in Perl
+ * can be found in extensions/ee), which will launch the editor,
+ * and save the modified data back to the server.
+ *
+ */
+
+class ExternalEdit {
+
+ function ExternalEdit ( $article, $mode ) {
+ global $wgInputEncoding;
+ $this->mArticle =& $article;
+ $this->mTitle =& $article->mTitle;
+ $this->mCharset = $wgInputEncoding;
+ $this->mMode = $mode;
+ }
+
+ function edit() {
+ global $wgUser, $wgOut, $wgScript, $wgServer;
+ $wgOut->disable();
+ $name=$this->mTitle->getText();
+ $pos=strrpos($name,".")+1;
+ header ( "Content-type: application/external-editor; charset=".$this->mCharset );
+ if(!isset($this->mMode)) {
+ $type="Edit text";
+ $url=$this->mTitle->getFullURL("action=edit&internaledit=true");
+ # *.wiki file extension is used by some editors for syntax
+ # highlighting, so we follow that convention
+ $extension="wiki";
+ } elseif($this->mMode=="file") {
+ $type="Edit file";
+ $url=$wgServer . Image::newFromTitle( $this->mTitle )->getURL();
+ $extension=substr($name, $pos);
+ }
+ $control=
+"
+[Process]
+Type=$type
+Engine=MediaWiki
+Script={$wgServer}{$wgScript}
+
+[File]
+Extension=$extension
+URL=$url";
+ echo $control;
+
+
+ }
+}
+?>
// available in doDelete etc.
function view() {
+ global $wgUseExternalEditor;
if( $this->mTitle->getNamespace() == NS_IMAGE ) {
$this->openShowImage();
}
Article::view();
+ if($wgUseExternalEditor) {
+ $this->externalEditorLink();
+ }
# If the article we've just shown is in the "Image" namespace,
# follow it with the history list and link list for the image
function openShowImage()
{
global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
- $wgUseImageResize, $wgRepositoryBaseUrl;
+ $wgUseImageResize, $wgRepositoryBaseUrl,
+ $wgUseExternalEditor;
$this->img = Image::newFromTitle( $this->mTitle );
$full_url = $this->img->getViewURL();
$anchoropen = '';
$sharedtext.="</div>";
$wgOut->addWikiText($sharedtext);
}
+
}
}
+ function externalEditorLink()
+ {
+ global $wgUser,$wgOut;
+ $sk = $wgUser->getSkin();
+ $wgOut->addHTML("<div class=\"editExternally\">");
+ $wgOut->addHTML($sk->makeKnownLink($this->mTitle->getPrefixedDBkey(),wfMsg("edit-externally"),
+ "action=edit&externaledit=true&mode=file"));
+ $wgOut->addWikiText("<div class=\"editExternallyHelp\">".wfMsg("edit-externally-help"));
+ $wgOut->addHTML("</div><br clear=\"all\">");
+
+ }
function closeShowImage()
{
# For overloading
+
}
/**
$this->getToggle( "previewonfirst" ) .
$this->getToggle( "previewontop" ) .
$this->getToggle( "watchdefault" ) .
- $this->getToggle( "minordefault" ) . "
+ $this->getToggle( "minordefault" ) .
+ $this->getToggle( "externaleditor" ) .
+ "
</fieldset>
<fieldset>
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')) {
text-align: center;
color: #cc0000;
}
+.editExternally {
+ border-style:solid;
+ border-width:1px;
+ border-color:gray;
+ background: #ffffff;
+ padding:3px;
+ margin-top:0.5em;
+ float:left;
+ font-size:small;
+ text-align:center;
+}
+.editExternallyHelp {
+ font-style:italic;
+ color:gray;
+}
\ No newline at end of file
text-align: center;
color: #cc0000;
}
+.editExternally {
+ border-style:solid;
+ border-width:1px;
+ border-color:gray;
+ background: #ffffff;
+ padding:3px;
+ margin-top:0.5em;
+ float:left;
+ font-size:small;
+ text-align:center;
+}
+.editExternallyHelp {
+ font-style:italic;
+ color:gray;
+}
\ No newline at end of file