Index: trunk/phase3/skins/monobook/main.css |
— | — | @@ -1091,3 +1091,18 @@ |
1092 | 1092 | text-align: center; |
1093 | 1093 | color: #cc0000; |
1094 | 1094 | } |
| 1095 | +.editExternally { |
| 1096 | + border-style:solid; |
| 1097 | + border-width:1px; |
| 1098 | + border-color:gray; |
| 1099 | + background: #ffffff; |
| 1100 | + padding:3px; |
| 1101 | + margin-top:0.5em; |
| 1102 | + float:left; |
| 1103 | + font-size:small; |
| 1104 | + text-align:center; |
| 1105 | +} |
| 1106 | +.editExternallyHelp { |
| 1107 | + font-style:italic; |
| 1108 | + color:gray; |
| 1109 | +} |
\ No newline at end of file |
Index: trunk/phase3/skins/common/common.css |
— | — | @@ -303,3 +303,18 @@ |
304 | 304 | text-align: center; |
305 | 305 | color: #cc0000; |
306 | 306 | } |
| 307 | +.editExternally { |
| 308 | + border-style:solid; |
| 309 | + border-width:1px; |
| 310 | + border-color:gray; |
| 311 | + background: #ffffff; |
| 312 | + padding:3px; |
| 313 | + margin-top:0.5em; |
| 314 | + float:left; |
| 315 | + font-size:small; |
| 316 | + text-align:center; |
| 317 | +} |
| 318 | +.editExternallyHelp { |
| 319 | + font-style:italic; |
| 320 | + color:gray; |
| 321 | +} |
\ No newline at end of file |
Index: trunk/phase3/index.php |
— | — | @@ -167,10 +167,22 @@ |
168 | 168 | User::SetupSession(); |
169 | 169 | } |
170 | 170 | # Continue... |
171 | | - case 'edit': |
172 | | - require_once( 'includes/EditPage.php' ); |
173 | | - $editor = new EditPage( $wgArticle ); |
174 | | - $editor->submit(); |
| 171 | + case 'edit': |
| 172 | + $internal = $wgRequest->getVal( 'internaledit' ); |
| 173 | + $external = $wgRequest->getVal( 'externaledit' ); |
| 174 | + $section = $wgRequest->getVal( 'section' ); |
| 175 | + $oldid = $wgRequest->getVal( 'oldid' ); |
| 176 | + if(!$wgUseExternalEditor || $action=='submit' || $internal || |
| 177 | + $section || $oldid || (!$wgUser->getOption('externaleditor') && !$external)) { |
| 178 | + require_once( 'includes/EditPage.php' ); |
| 179 | + $editor = new EditPage( $wgArticle ); |
| 180 | + $editor->submit(); |
| 181 | + } elseif($wgUseExternalEditor && ($external || $wgUser->getOption('externaleditor'))) { |
| 182 | + require_once( 'includes/ExternalEdit.php' ); |
| 183 | + $mode = $wgRequest->getVal( 'mode' ); |
| 184 | + $extedit = new ExternalEdit( $wgArticle, $mode ); |
| 185 | + $extedit->edit(); |
| 186 | + } |
175 | 187 | break; |
176 | 188 | case 'history': |
177 | 189 | if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) { |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -21,11 +21,15 @@ |
22 | 22 | // available in doDelete etc. |
23 | 23 | |
24 | 24 | function view() { |
| 25 | + global $wgUseExternalEditor; |
25 | 26 | if( $this->mTitle->getNamespace() == NS_IMAGE ) { |
26 | 27 | $this->openShowImage(); |
27 | 28 | } |
28 | 29 | |
29 | 30 | Article::view(); |
| 31 | + if($wgUseExternalEditor) { |
| 32 | + $this->externalEditorLink(); |
| 33 | + } |
30 | 34 | |
31 | 35 | # If the article we've just shown is in the "Image" namespace, |
32 | 36 | # follow it with the history list and link list for the image |
— | — | @@ -41,7 +45,8 @@ |
42 | 46 | function openShowImage() |
43 | 47 | { |
44 | 48 | global $wgOut, $wgUser, $wgImageLimits, $wgRequest, |
45 | | - $wgUseImageResize, $wgRepositoryBaseUrl; |
| 49 | + $wgUseImageResize, $wgRepositoryBaseUrl, |
| 50 | + $wgUseExternalEditor; |
46 | 51 | $this->img = Image::newFromTitle( $this->mTitle ); |
47 | 52 | $full_url = $this->img->getViewURL(); |
48 | 53 | $anchoropen = ''; |
— | — | @@ -116,12 +121,25 @@ |
117 | 122 | $sharedtext.="</div>"; |
118 | 123 | $wgOut->addWikiText($sharedtext); |
119 | 124 | } |
| 125 | + |
120 | 126 | } |
121 | 127 | } |
122 | 128 | |
| 129 | + function externalEditorLink() |
| 130 | + { |
| 131 | + global $wgUser,$wgOut; |
| 132 | + $sk = $wgUser->getSkin(); |
| 133 | + $wgOut->addHTML("<div class=\"editExternally\">"); |
| 134 | + $wgOut->addHTML($sk->makeKnownLink($this->mTitle->getPrefixedDBkey(),wfMsg("edit-externally"), |
| 135 | + "action=edit&externaledit=true&mode=file")); |
| 136 | + $wgOut->addWikiText("<div class=\"editExternallyHelp\">".wfMsg("edit-externally-help")); |
| 137 | + $wgOut->addHTML("</div><br clear=\"all\">"); |
| 138 | + |
| 139 | + } |
123 | 140 | function closeShowImage() |
124 | 141 | { |
125 | 142 | # For overloading |
| 143 | + |
126 | 144 | } |
127 | 145 | |
128 | 146 | /** |
Index: trunk/phase3/includes/ExternalEdit.php |
— | — | @@ -0,0 +1,65 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * License: Public domain |
| 5 | + * |
| 6 | + * @author Erik Moeller <moeller@scireview.de> |
| 7 | + * @package MediaWiki |
| 8 | + */ |
| 9 | + |
| 10 | +/** |
| 11 | + * |
| 12 | + * @package MediaWiki |
| 13 | + * |
| 14 | + * Support for external editors to modify both text and files |
| 15 | + * in external application. It works as follows: MediaWiki |
| 16 | + * sends a meta-file with the MIME type 'application/external-editor' |
| 17 | + * to the client. The user has to associate that MIME type with |
| 18 | + * a helper application (a reference implementation in Perl |
| 19 | + * can be found in extensions/ee), which will launch the editor, |
| 20 | + * and save the modified data back to the server. |
| 21 | + * |
| 22 | + */ |
| 23 | + |
| 24 | +class ExternalEdit { |
| 25 | + |
| 26 | + function ExternalEdit ( $article, $mode ) { |
| 27 | + global $wgInputEncoding; |
| 28 | + $this->mArticle =& $article; |
| 29 | + $this->mTitle =& $article->mTitle; |
| 30 | + $this->mCharset = $wgInputEncoding; |
| 31 | + $this->mMode = $mode; |
| 32 | + } |
| 33 | + |
| 34 | + function edit() { |
| 35 | + global $wgUser, $wgOut, $wgScript, $wgServer; |
| 36 | + $wgOut->disable(); |
| 37 | + $name=$this->mTitle->getText(); |
| 38 | + $pos=strrpos($name,".")+1; |
| 39 | + header ( "Content-type: application/external-editor; charset=".$this->mCharset ); |
| 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 | + $url=$wgServer . Image::newFromTitle( $this->mTitle )->getURL(); |
| 49 | + $extension=substr($name, $pos); |
| 50 | + } |
| 51 | + $control= |
| 52 | +" |
| 53 | +[Process] |
| 54 | +Type=$type |
| 55 | +Engine=MediaWiki |
| 56 | +Script={$wgServer}{$wgScript} |
| 57 | + |
| 58 | +[File] |
| 59 | +Extension=$extension |
| 60 | +URL=$url"; |
| 61 | + echo $control; |
| 62 | + |
| 63 | + |
| 64 | + } |
| 65 | +} |
| 66 | +?> |
Property changes on: trunk/phase3/includes/ExternalEdit.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 67 | + native |
Added: svn:keywords |
2 | 68 | + Author Date Id Revision |
Index: trunk/phase3/includes/SpecialPreferences.php |
— | — | @@ -634,7 +634,9 @@ |
635 | 635 | $this->getToggle( "previewonfirst" ) . |
636 | 636 | $this->getToggle( "previewontop" ) . |
637 | 637 | $this->getToggle( "watchdefault" ) . |
638 | | - $this->getToggle( "minordefault" ) . " |
| 638 | + $this->getToggle( "minordefault" ) . |
| 639 | + $this->getToggle( "externaleditor" ) . |
| 640 | + " |
639 | 641 | </fieldset> |
640 | 642 | |
641 | 643 | <fieldset> |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1183,6 +1183,12 @@ |
1184 | 1184 | */ |
1185 | 1185 | $wgMinimalPasswordLength = 0; |
1186 | 1186 | |
| 1187 | +/** |
| 1188 | + * Activate external editor interface for files and pages |
| 1189 | + * See http://meta.wikimedia.org/wiki/Help:External_editors |
| 1190 | + */ |
| 1191 | +$wgUseExternalEditor = true; |
| 1192 | + |
1187 | 1193 | /** Whether or not to sort special pages in Special:Specialpages */ |
1188 | 1194 | |
1189 | 1195 | $wgSortSpecialPages = true; |