wiki.techinc.nl/includes/ExternalEdit.php
Tim Starling ed4303922f Merged filerepo-work branch:
* Added support for configuration of an arbitrary number of commons-style file repositories.
* Split Image.php into filerepo/File.php and filerepo/LocalFile.php
* Renamed Image::getImagePath() to File::getPath()
* Added initial support for timestamp-based file fetching (OldLocalFile), to be expanded upon by aaron.
* Changed the interface for Image/File object creation: use wfFindFile() or wfLocalFile() depending on semantics
* ImageGallery::add() now accepts a title object as the first parameter
* Moved file handling operations on upload from SpecialUpload to File
* Removed path-related functions from ImageFunctions.php. Removed static path accessors from File. 
* Added a Content-Disposition header to thumb.php output
* Improved thumb.php error handling
* Updated the unit test suite to kind of partially work with modern computers. RunTests.php doesn't work just yet. Fixed an actual regression that the test suite detected -- moved some defines to Defines.php where they will be loaded consistently.
2007-05-30 21:02:32 +00:00

75 lines
1.9 KiB
PHP

<?php
/**
* License: Public domain
*
* @author Erik Moeller <moeller@scireview.de>
*/
/**
*
*
* Support for external editors to modify both text and files
* in external applications. 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 __construct( $article, $mode ) {
global $wgInputEncoding;
$this->mArticle =& $article;
$this->mTitle =& $article->mTitle;
$this->mCharset = $wgInputEncoding;
$this->mMode = $mode;
}
function edit() {
global $wgOut, $wgScript, $wgScriptPath, $wgServer, $wgLang;
$wgOut->disable();
$name=$this->mTitle->getText();
$pos=strrpos($name,".")+1;
header ( "Content-type: application/x-external-editor; charset=".$this->mCharset );
# $type can be "Edit text", "Edit file" or "Diff text" at the moment
# See the protocol specifications at [[m:Help:External editors/Tech]] for
# details.
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";
$image = wfLocalFile( $this->mTitle );
$img_url = $image->getURL();
if(strpos($img_url,"://")) {
$url = $img_url;
} else {
$url = $wgServer . $img_url;
}
$extension=substr($name, $pos);
}
$special=$wgLang->getNsText(NS_SPECIAL);
$control = <<<CONTROL
[Process]
Type=$type
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Server={$wgServer}
Path={$wgScriptPath}
Special namespace=$special
[File]
Extension=$extension
URL=$url
CONTROL;
echo $control;
}
}
?>