Don't look for pipes in the root node.
[lhc/web/wiklou.git] / includes / ExternalEdit.php
1 <?php
2 /**
3 * External editors support
4 *
5 * License: Public domain
6 *
7 * @file
8 * @author Erik Moeller <moeller@scireview.de>
9 */
10
11 /**
12 * Support for external editors to modify both text and files
13 * in external applications. It works as follows: MediaWiki
14 * sends a meta-file with the MIME type 'application/x-external-editor'
15 * to the client. The user has to associate that MIME type with
16 * a helper application (a reference implementation in Perl
17 * can be found in extensions/ee), which will launch the editor,
18 * and save the modified data back to the server.
19 *
20 */
21 class ExternalEdit {
22
23 function __construct( $article, $mode ) {
24 global $wgInputEncoding;
25 $this->mArticle =& $article;
26 $this->mTitle =& $article->mTitle;
27 $this->mCharset = $wgInputEncoding;
28 $this->mMode = $mode;
29 }
30
31 function edit() {
32 global $wgOut, $wgScript, $wgScriptPath, $wgServer, $wgLang;
33 $wgOut->disable();
34 $name=$this->mTitle->getText();
35 $pos=strrpos($name,".")+1;
36 header ( "Content-type: application/x-external-editor; charset=".$this->mCharset );
37 header( "Cache-control: no-cache" );
38
39 # $type can be "Edit text", "Edit file" or "Diff text" at the moment
40 # See the protocol specifications at [[m:Help:External editors/Tech]] for
41 # details.
42 if(!isset($this->mMode)) {
43 $type="Edit text";
44 $url=$this->mTitle->getFullURL("action=edit&internaledit=true");
45 # *.wiki file extension is used by some editors for syntax
46 # highlighting, so we follow that convention
47 $extension="wiki";
48 } elseif($this->mMode=="file") {
49 $type="Edit file";
50 $image = wfLocalFile( $this->mTitle );
51 $url = $image->getFullURL();
52 $extension=substr($name, $pos);
53 }
54 $special=$wgLang->getNsText(NS_SPECIAL);
55 $control = <<<CONTROL
56 ; You're seeing this file because you're using Mediawiki's External Editor
57 ; feature. This is probably because you selected use external editor
58 ; in your preferences. To edit normally, either disable that preference
59 ; or go to the URL $url .
60 ; See http://www.mediawiki.org/wiki/Manual:External_editors for details.
61 [Process]
62 Type=$type
63 Engine=MediaWiki
64 Script={$wgServer}{$wgScript}
65 Server={$wgServer}
66 Path={$wgScriptPath}
67 Special namespace=$special
68
69 [File]
70 Extension=$extension
71 URL=$url
72 CONTROL;
73 echo $control;
74 }
75 }