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