r7859 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7858‎ | r7859 | r7860 >
Date:13:30, 24 March 2005
Author:eloquence
Status:old
Tags:
Comment:
Preliminary support for application/external-editor
allows editing wiki pages or files with an external application, by using
an intermediate helper application (such as the reference one in
extensions/ee) which fetches the data and transmits the changes back to the
server.

This version adds external editor support for uploaded files, as well as for
pages. More operations, such as diffs and merges, should support
application/external-editor in the future.

See extensions/ee/README for some more info on the concept. Documentation
will also be placed on http://meta.wikimedia.org/wiki/Help:External_editors
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/ExternalEdit.php (added) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)
  • /trunk/phase3/skins/common/common.css (modified) (history)
  • /trunk/phase3/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/monobook/main.css
@@ -1091,3 +1091,18 @@
10921092 text-align: center;
10931093 color: #cc0000;
10941094 }
 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 @@
304304 text-align: center;
305305 color: #cc0000;
306306 }
 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 @@
168168 User::SetupSession();
169169 }
170170 # 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+ }
175187 break;
176188 case 'history':
177189 if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {
Index: trunk/phase3/includes/ImagePage.php
@@ -21,11 +21,15 @@
2222 // available in doDelete etc.
2323
2424 function view() {
 25+ global $wgUseExternalEditor;
2526 if( $this->mTitle->getNamespace() == NS_IMAGE ) {
2627 $this->openShowImage();
2728 }
2829
2930 Article::view();
 31+ if($wgUseExternalEditor) {
 32+ $this->externalEditorLink();
 33+ }
3034
3135 # If the article we've just shown is in the "Image" namespace,
3236 # follow it with the history list and link list for the image
@@ -41,7 +45,8 @@
4246 function openShowImage()
4347 {
4448 global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
45 - $wgUseImageResize, $wgRepositoryBaseUrl;
 49+ $wgUseImageResize, $wgRepositoryBaseUrl,
 50+ $wgUseExternalEditor;
4651 $this->img = Image::newFromTitle( $this->mTitle );
4752 $full_url = $this->img->getViewURL();
4853 $anchoropen = '';
@@ -116,12 +121,25 @@
117122 $sharedtext.="</div>";
118123 $wgOut->addWikiText($sharedtext);
119124 }
 125+
120126 }
121127 }
122128
 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+ }
123140 function closeShowImage()
124141 {
125142 # For overloading
 143+
126144 }
127145
128146 /**
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
167 + native
Added: svn:keywords
268 + Author Date Id Revision
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -634,7 +634,9 @@
635635 $this->getToggle( "previewonfirst" ) .
636636 $this->getToggle( "previewontop" ) .
637637 $this->getToggle( "watchdefault" ) .
638 - $this->getToggle( "minordefault" ) . "
 638+ $this->getToggle( "minordefault" ) .
 639+ $this->getToggle( "externaleditor" ) .
 640+ "
639641 </fieldset>
640642
641643 <fieldset>
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1183,6 +1183,12 @@
11841184 */
11851185 $wgMinimalPasswordLength = 0;
11861186
 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+
11871193 /** Whether or not to sort special pages in Special:Specialpages */
11881194
11891195 $wgSortSpecialPages = true;

Status & tagging log