Index: trunk/phase3/includes/ExternalEdit.php |
— | — | @@ -19,38 +19,54 @@ |
20 | 20 | * |
21 | 21 | */ |
22 | 22 | class ExternalEdit { |
| 23 | + /** |
| 24 | + * Title to perform the edit on |
| 25 | + * @var Title |
| 26 | + */ |
| 27 | + private $title; |
23 | 28 | |
24 | | - function __construct( $article, $mode ) { |
25 | | - $this->mArticle =& $article; |
26 | | - $this->mTitle = $article->getTitle(); |
27 | | - $this->mCharset = 'UTF-8'; |
28 | | - $this->mMode = $mode; |
| 29 | + /** |
| 30 | + * Mode of editing |
| 31 | + * @var String |
| 32 | + */ |
| 33 | + private $mode; |
| 34 | + |
| 35 | + /** |
| 36 | + * Constructor |
| 37 | + * @param $title Title object we're performing the edit on |
| 38 | + * @param $mode String What mode we're using. Only 'file' has any effect |
| 39 | + */ |
| 40 | + public function __construct( $title, $mode ) { |
| 41 | + $this->title = $article->getTitle(); |
| 42 | + $this->mode = $mode; |
29 | 43 | } |
30 | 44 | |
31 | | - function edit() { |
| 45 | + /** |
| 46 | + * Output the information for the external editor |
| 47 | + */ |
| 48 | + public function edit() { |
32 | 49 | global $wgOut, $wgScript, $wgScriptPath, $wgServer, $wgLang; |
33 | 50 | $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" ); |
| 51 | + header( 'Content-type: application/x-external-editor; charset=utf-8' ); |
| 52 | + header( 'Cache-control: no-cache' ); |
38 | 53 | |
39 | 54 | # $type can be "Edit text", "Edit file" or "Diff text" at the moment |
40 | 55 | # See the protocol specifications at [[m:Help:External editors/Tech]] for |
41 | 56 | # details. |
42 | | - if(!isset($this->mMode)) { |
43 | | - $type="Edit text"; |
44 | | - $url=$this->mTitle->getFullURL("action=edit&internaledit=true"); |
| 57 | + if( $this->mode == "file" ) { |
| 58 | + $type = "Edit file"; |
| 59 | + $image = wfLocalFile( $this->title ); |
| 60 | + $url = $image->getFullURL(); |
| 61 | + $extension = $image->getExtension(); |
| 62 | + } else { |
| 63 | + $type = "Edit text"; |
| 64 | + $url = $this->title->getFullURL( |
| 65 | + array( 'action' => 'edit', 'internaledit' => 'true' ) ); |
45 | 66 | # *.wiki file extension is used by some editors for syntax |
46 | 67 | # 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); |
| 68 | + $extension = "wiki"; |
53 | 69 | } |
54 | | - $special=$wgLang->getNsText(NS_SPECIAL); |
| 70 | + $special = $wgLang->getNsText( NS_SPECIAL ); |
55 | 71 | $control = <<<CONTROL |
56 | 72 | ; You're seeing this file because you're using Mediawiki's External Editor |
57 | 73 | ; feature. This is probably because you selected use external editor |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -498,7 +498,7 @@ |
499 | 499 | && ( $external || $user->getOption( 'externaleditor' ) ) ) |
500 | 500 | { |
501 | 501 | $mode = $request->getVal( 'mode' ); |
502 | | - $extedit = new ExternalEdit( $article, $mode ); |
| 502 | + $extedit = new ExternalEdit( $article->getTitle(), $mode ); |
503 | 503 | $extedit->edit(); |
504 | 504 | } |
505 | 505 | } |