00001 <?php 00019 class ExternalEdit { 00020 00021 function __construct( $article, $mode ) { 00022 global $wgInputEncoding; 00023 $this->mArticle =& $article; 00024 $this->mTitle =& $article->mTitle; 00025 $this->mCharset = $wgInputEncoding; 00026 $this->mMode = $mode; 00027 } 00028 00029 function edit() { 00030 global $wgOut, $wgScript, $wgScriptPath, $wgServer, $wgLang; 00031 $wgOut->disable(); 00032 $name=$this->mTitle->getText(); 00033 $pos=strrpos($name,".")+1; 00034 header ( "Content-type: application/x-external-editor; charset=".$this->mCharset ); 00035 header( "Cache-control: no-cache" ); 00036 00037 # $type can be "Edit text", "Edit file" or "Diff text" at the moment 00038 # See the protocol specifications at [[m:Help:External editors/Tech]] for 00039 # details. 00040 if(!isset($this->mMode)) { 00041 $type="Edit text"; 00042 $url=$this->mTitle->getFullURL("action=edit&internaledit=true"); 00043 # *.wiki file extension is used by some editors for syntax 00044 # highlighting, so we follow that convention 00045 $extension="wiki"; 00046 } elseif($this->mMode=="file") { 00047 $type="Edit file"; 00048 $image = wfLocalFile( $this->mTitle ); 00049 $url = $image->getFullURL(); 00050 $extension=substr($name, $pos); 00051 } 00052 $special=$wgLang->getNsText(NS_SPECIAL); 00053 $control = <<<CONTROL 00054 [Process] 00055 Type=$type 00056 Engine=MediaWiki 00057 Script={$wgServer}{$wgScript} 00058 Server={$wgServer} 00059 Path={$wgScriptPath} 00060 Special namespace=$special 00061 00062 [File] 00063 Extension=$extension 00064 URL=$url 00065 CONTROL; 00066 echo $control; 00067 } 00068 }