From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- includes/ExternalEdit.php | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 includes/ExternalEdit.php (limited to 'includes/ExternalEdit.php') diff --git a/includes/ExternalEdit.php b/includes/ExternalEdit.php new file mode 100644 index 00000000..21f632ec --- /dev/null +++ b/includes/ExternalEdit.php @@ -0,0 +1,77 @@ + + * @package MediaWiki + */ + +/** + * + * @package MediaWiki + * + * 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 ExternalEdit ( $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 = Image::newFromTitle( $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 = << -- cgit v1.2.3-54-g00ecf