X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FExternalEdit.php;h=bf97c1a5e1abb47e706e15b246ae623fd7d3878e;hb=de72c4ed1484f2055d6536294ee995893b81a282;hp=d7c14bd43d376c482eea68214086a774d7239797;hpb=90586917b27029042f6a2c3f4f793b9c3f653c45;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ExternalEdit.php b/includes/ExternalEdit.php index d7c14bd43d..bf97c1a5e1 100644 --- a/includes/ExternalEdit.php +++ b/includes/ExternalEdit.php @@ -1,15 +1,14 @@ - * @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' @@ -19,47 +18,66 @@ * and save the modified data back to the server. * */ - class ExternalEdit { + /** + * Title to perform the edit on + * @var Title + */ + private $title; + + /** + * Mode of editing + * @var String + */ + private $mode; - function ExternalEdit ( $article, $mode ) { - global $wgInputEncoding; - $this->mArticle =& $article; - $this->mTitle =& $article->mTitle; - $this->mCharset = $wgInputEncoding; - $this->mMode = $mode; + /** + * Constructor + * @param $title Title object we're performing the edit on + * @param $mode String What mode we're using. Only 'file' has any effect + */ + public function __construct( $title, $mode ) { + $this->title = $title; + $this->mode = $mode; } - - function edit() { - global $wgUser, $wgOut, $wgScript, $wgScriptPath, $wgServer, - $wgLang; + + /** + * Output the information for the external editor + */ + public function edit() { + global $wgOut, $wgScript, $wgScriptPath, $wgCanonicalServer, $wgLang; $wgOut->disable(); - $name=$this->mTitle->getText(); - $pos=strrpos($name,".")+1; - header ( "Content-type: application/x-external-editor; charset=".$this->mCharset ); - + header( 'Content-type: application/x-external-editor; charset=utf-8' ); + header( 'Cache-control: no-cache' ); + # $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 + if( $this->mode == "file" ) { + $type = "Edit file"; + $image = wfLocalFile( $this->title ); + $url = $image->getCanonicalURL(); + $extension = $image->getExtension(); + } else { + $type = "Edit text"; + $url = $this->title->getCanonicalURL( + array( '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 ); - $url = $wgServer . $image->getURL(); - $extension=substr($name, $pos); + $extension = "wiki"; } - $special=$wgLang->getNsText(NS_SPECIAL); + $special = $wgLang->getNsText( NS_SPECIAL ); $control = <<