wiki.techinc.nl/includes/ExternalEdit.php
Erik Moeller f9d54adab1 1) we need an absolute path for the image, since it needs to be retrieved
by the external editor helper application (NB: that fatal error was probably
a PHP 4/5 thing, I'm using PHP 5 here).

2) adding some extra information for the helper, this should all be made
a little more logical (only pass on as much information as needed to
construct the proper URLs)
2005-04-07 06:29:08 +00:00

66 lines
1.7 KiB
PHP

<?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/x-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, $wgScriptPath, $wgServer;
$wgOut->disable();
$name=$this->mTitle->getText();
$pos=strrpos($name,".")+1;
header ( "Content-type: application/x-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 = Image::newFromTitle( $this->mTitle );
$url = $wgServer . $url->url; # php sucks
$extension=substr($name, $pos);
}
$control="
[Process]
Type=$type
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Server={$wgServer}
Path={$wgScriptPath}
[File]
Extension=$extension
URL=$url";
echo $control;
}
}
?>