* @package MediaWiki not Mediawiki
[lhc/web/wiklou.git] / includes / ExternalEdit.php
1 <?php
2 /**
3 * License: Public domain
4 *
5 * @author Erik Moeller <moeller@scireview.de>
6 * @package MediaWiki
7 */
8
9 /**
10 *
11 * @package MediaWiki
12 *
13 * Support for external editors to modify both text and files
14 * in external application. It works as follows: MediaWiki
15 * sends a meta-file with the MIME type 'application/x-external-editor'
16 * to the client. The user has to associate that MIME type with
17 * a helper application (a reference implementation in Perl
18 * can be found in extensions/ee), which will launch the editor,
19 * and save the modified data back to the server.
20 *
21 */
22
23 class ExternalEdit {
24
25 function ExternalEdit ( $article, $mode ) {
26 global $wgInputEncoding;
27 $this->mArticle =& $article;
28 $this->mTitle =& $article->mTitle;
29 $this->mCharset = $wgInputEncoding;
30 $this->mMode = $mode;
31 }
32
33 function edit() {
34 global $wgUser, $wgOut, $wgScript, $wgServer;
35 $wgOut->disable();
36 $name=$this->mTitle->getText();
37 $pos=strrpos($name,".")+1;
38 header ( "Content-type: application/x-external-editor; charset=".$this->mCharset );
39 if(!isset($this->mMode)) {
40 $type="Edit text";
41 $url=$this->mTitle->getFullURL("action=edit&internaledit=true");
42 # *.wiki file extension is used by some editors for syntax
43 # highlighting, so we follow that convention
44 $extension="wiki";
45 } elseif($this->mMode=="file") {
46 $type="Edit file";
47 $url = Image::newFromTitle( $this->mTitle );
48 $url = $url->url; # php sucks
49
50 $extension=substr($name, $pos);
51 }
52 $control="
53 [Process]
54 Type=$type
55 Engine=MediaWiki
56 Script={$wgServer}{$wgScript}
57
58 [File]
59 Extension=$extension
60 URL=$url";
61 echo $control;
62 }
63 }
64 ?>