BUG#15 Allow editors to view diff of their change before actually submitting an edit
authorJens Frank <jeluf@users.mediawiki.org>
Sat, 19 Mar 2005 12:01:57 +0000 (12:01 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sat, 19 Mar 2005 12:01:57 +0000 (12:01 +0000)
RELEASE-NOTES
includes/EditPage.php
languages/Language.php
languages/LanguageDe.php

index 37e7a89..78766a4 100644 (file)
@@ -14,6 +14,7 @@ New exciting things! Need further work and testing...
 * 'live preview' reduces preview reload burden on supported browsers
 * Schema reworking: http://meta.wikimedia.org/wiki/Proposed_Database_Schema_Changes/October_2004
 * New WikiSyntax: -- turns into &emdash; or &ndash; depending on context
+* (bug 15) Allow editors to view diff of their change before actually submitting an edit
 * ...and more!
 
 Need to merge:
index 9b94ed5..11e95a8 100644 (file)
@@ -19,7 +19,7 @@ class EditPage {
        var $mMetaData = '';
        
        # Form values
-       var $save = false, $preview = false;
+       var $save = false, $preview = false, $diff = false;
        var $minoredit = false, $watchthis = false;
        var $textbox1 = '', $textbox2 = '', $summary = '';
        var $edittime = '', $section = '';
@@ -150,7 +150,7 @@ class EditPage {
                        $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
                        return;
                }
-               if ( !$this->preview && $wgUser->isBlocked( !$this->save ) ) {
+               if ( !$this->preview && !$this->diff && $wgUser->isBlocked( !$this->save ) ) {
                        # When previewing, don't check blocked state - will get caught at save time.
                        # Also, check when starting edition is done against slave to improve performance.
                        $this->blockedIPpage();
@@ -163,6 +163,8 @@ class EditPage {
                if ( wfReadOnly() ) {
                        if( $this->save || $this->preview ) {
                                $this->editForm( 'preview' );
+                       } else if ( $this->diff ) {
+                               $this->editForm( 'diff' );
                        } else {
                                $wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
                        }
@@ -172,6 +174,8 @@ class EditPage {
                        $this->editForm( 'save' );
                } else if ( $this->preview ) {
                        $this->editForm( 'preview' );
+               } else if ( $this->diff ) {
+                       $this->editForm( 'diff' );
                } else { # First time through
                        if( $wgUser->getOption('previewonfirst') ) {
                                $this->editForm( 'preview', true );
@@ -206,13 +210,14 @@ class EditPage {
                                        # The unmarked state will be assumed to be a save,
                                        # if the form seems otherwise complete.
                                        $this->preview = $request->getCheck( 'wpPreview' );
+                                       $this->diff = $request->getCheck( 'wpDiff' );
                                } else {
                                        # Page might be a hack attempt posted from
                                        # an external site. Preview instead of saving.
                                        $this->preview = true;
                                }
                        }
-                       $this->save    = !$this->preview;
+                       $this->save    = ! ( $this->preview OR $this->diff );
                        if( !preg_match( '/^\d{14}$/', $this->edittime )) {
                                $this->edittime = null;
                        }
@@ -228,6 +233,7 @@ class EditPage {
                        $this->edittime  = '';
                        $this->preview   = false;
                        $this->save      = false;
+                       $this->diff      = false;
                        $this->minoredit = false;
                        $this->watchthis = false;
                }
@@ -269,7 +275,7 @@ class EditPage {
         * is made and all is well do we actually save and redirect to
         * the newly-edited page.
         *
-        * @param string $formtype Type of form either : save, initial or preview
+        * @param string $formtype Type of form either : save, initial, diff or preview
         * @param bool $firsttime True to load form data from db
         */
        function editForm( $formtype, $firsttime = false ) {
@@ -510,6 +516,7 @@ class EditPage {
                $watchthis = wfMsg ('watchthis');
                $save = wfMsg('savearticle');
                $prev = wfMsg('showpreview');
+               $diff = wfMsg('showdiff');
 
                $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(),
                                wfMsg('cancel') );
@@ -532,7 +539,7 @@ class EditPage {
                }
 
                // activate checkboxes if user wants them to be always active
-               if( !$this->preview ) {
+               if( !$this->preview && !$this->diff ) {
                        if( $wgUser->getOption( 'watchdefault' ) ) $this->watchthis = true;
                        if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
 
@@ -564,12 +571,29 @@ class EditPage {
                $wgOut->addHTML( '<div id="wikiPreview">' );
                if ( 'preview' == $formtype) {
                        $previewOutput = $this->getPreviewText( $isConflict, $isCssJsSubpage );
-                       if( $wgUser->getOption('previewontop' ) ) {
+                       if ( $wgUser->getOption('previewontop' ) ) {
                                $wgOut->addHTML( $previewOutput );
                                $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
                        }
                }
                $wgOut->addHTML( '</div>' );
+               $wgOut->addHTML( '<div id="wikiDiff">' );
+               if ( 'diff' == $formtype ) {
+                       require_once( 'DifferenceEngine.php' );
+                       $oldtext = $this->mArticle->getContent( true );
+                       $newtext = $this->textbox1;
+                       $oldtitle = wfMsg( 'currentrev' );
+                       $newtitle = wfMsg( 'yourtext' );
+                               
+                       if ( $oldtext != wfMsg( 'noarticletext' ) || $newtext != '' ) {
+                               $difftext = DifferenceEngine::getDiff( $oldtext, $newtext, $oldtitle, $newtitle );
+                       }
+                       if ( $wgUser->getOption('previewontop' ) ) {
+                               $wgOut->addHTML( $difftext );
+                               $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
+                       }
+               }
+
 
                # if this is a comment, show a subject line at the top, which is also the edit summary.
                # Otherwise, show a summary field at the bottom
@@ -582,7 +606,7 @@ class EditPage {
                                $editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
                        }
 
-               if( !$this->preview ) {
+               if( !$this->preview && !$this->diff ) {
                # Don't select the edit box on preview; this interferes with seeing what's going on.
                        $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
                }
@@ -660,6 +684,8 @@ END
 " title=\"".wfMsg('tooltip-save')."\"/>
 <input tabindex='6' id='wpPreview' type='submit' $liveOnclick value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
 " title=\"".wfMsg('tooltip-preview')."\"/>
+<input tabindex='6' id='wpDiff' type='submit' value=\"{$diff}\" name=\"wpDiff\" accesskey=\"".wfMsg('accesskey-diff')."\"".
+" title=\"".wfMsg('tooltip-diff')."\"/>
 <em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}" );
                $wgOut->addWikiText( $copywarn );
                $wgOut->addHTML( "
@@ -694,13 +720,22 @@ END
 </textarea>" );
                }
                $wgOut->addHTML( "</form>\n" );
-               if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
-                       $wgOut->addHTML('<div id="wikiPreview">' . $previewOutput . '</div>');
+               if ( $formtype == 'preview' && !$wgUser->getOption( 'previewontop' ) ) {
+                       $wgOut->addHTML( '<div id="wikiPreview">' . $previewOutput . '</div>' );
+               }
+               if ( $formtype == 'diff' && !$wgUser->getOption( 'previewontop' ) ) {
+                       $wgOut->addHTML( '<div id="wikiPreview">' . $difftext . '</div>' );
                }
        }
 
+       function getDiffText() {
+       }
+
+       /**
+        * @todo document
+        */
        function getPreviewText( $isConflict, $isCssJsSubpage ) {
-               global $wgOut, $wgUser, $wgTitle, $wgParser;
+               global $wgOut, $wgUser, $wgTitle, $wgParser, $wgAllowDiffPreview, $wgEnableDiffPreviewPreference;
                $previewhead = '<h2>' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>\n" .
                        "<p class='previewnote'>" . htmlspecialchars( wfMsg( 'previewnote' ) ) . "</p>\n";
                if ( $isConflict ) {
@@ -737,6 +772,7 @@ END
                                        $wgTitle, $parserOptions );             
                        
                        $previewHTML = $parserOutput->mText;
+
                        $wgOut->addCategoryLinks($parserOutput->getCategoryLinks());
                        $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
                        return $previewhead . $previewHTML;
index 0f0cae0..a0bb37d 100644 (file)
@@ -660,6 +660,7 @@ To authenticate, please login in with the temporary password which has been mail
 'savearticle'  => 'Save page',
 'preview'              => 'Preview',
 'showpreview'  => 'Show preview',
+'showdiff'     => 'Show changes',
 'blockedtitle' => 'User is blocked',
 'blockedtext'  => "Your user name or IP address has been blocked by $1.
 The reason given is this:<br />''$2''<p>You may contact $1 or one of the other
@@ -1591,6 +1592,7 @@ article [[Train]].
 'accesskey-minoredit' => 'i',
 'accesskey-save' => 's',
 'accesskey-preview' => 'p',
+'accesskey-diff' => 'd',
 'accesskey-compareselectedversions' => 'v',
 
 # tooltip help for some actions, most are in Monobook.js
@@ -1598,6 +1600,7 @@ article [[Train]].
 'tooltip-minoredit' => 'Mark this as a minor edit [alt-i]',
 'tooltip-save' => 'Save your changes [alt-s]',
 'tooltip-preview' => 'Preview your changes, please use this before saving! [alt-p]',
+'tooltip-diff' => 'Show which changes you made to the text. [alt-d]',
 'tooltip-compareselectedversions' => 'See the differences between the two selected versions of this page. [alt-v]',
 'tooltip-watch' => 'Add this page to your watchlist [alt-w]',
 
index 55876b6..6ecc114 100644 (file)
@@ -6,91 +6,91 @@
 # For compatibility with Latin-1 installations, please
 # don't add literal characters above U+00ff.
 #
-require_once( "LanguageUtf8.php" );
+require_once( 'LanguageUtf8.php' );
 
 # See Language.php for notes.
 
 if($wgMetaNamespace === FALSE)
-        $wgMetaNamespace = str_replace( " ", "_", $wgSitename );
+        $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
 
 /* private */ $wgNamespaceNamesDe = array(
-       NS_MEDIA            => "Media",
-       NS_SPECIAL          => "Spezial",
-       NS_MAIN             => "",
-       NS_TALK             => "Diskussion",
-       NS_USER             => "Benutzer",
-       NS_USER_TALK        => "Benutzer_Diskussion",
+       NS_MEDIA            => 'Media',
+       NS_SPECIAL          => 'Spezial',
+       NS_MAIN             => '',
+       NS_TALK             => 'Diskussion',
+       NS_USER             => 'Benutzer',
+       NS_USER_TALK        => 'Benutzer_Diskussion',
        NS_PROJECT          => $wgMetaNamespace,
-       NS_PROJECT_TALK     => $wgMetaNamespace . "_Diskussion",
-       NS_IMAGE            => "Bild",
-       NS_IMAGE_TALK       => "Bild_Diskussion",
-       NS_MEDIAWIKI        => "MediaWiki",
-       NS_MEDIAWIKI_TALK   => "MediaWiki_Diskussion",
-       NS_TEMPLATE         => "Vorlage",
-       NS_TEMPLATE_TALK    => "Vorlage_Diskussion",
-       NS_HELP             => "Hilfe",
-       NS_HELP_TALK        => "Hilfe_Diskussion",
-       NS_CATEGORY         => "Kategorie",
-       NS_CATEGORY_TALK    => "Kategorie_Diskussion"
+       NS_PROJECT_TALK     => $wgMetaNamespace . '_Diskussion',
+       NS_IMAGE            => 'Bild',
+       NS_IMAGE_TALK       => 'Bild_Diskussion',
+       NS_MEDIAWIKI        => 'MediaWiki',
+       NS_MEDIAWIKI_TALK   => 'MediaWiki_Diskussion',
+       NS_TEMPLATE         => 'Vorlage',
+       NS_TEMPLATE_TALK    => 'Vorlage_Diskussion',
+       NS_HELP             => 'Hilfe',
+       NS_HELP_TALK        => 'Hilfe_Diskussion',
+       NS_CATEGORY         => 'Kategorie',
+       NS_CATEGORY_TALK    => 'Kategorie_Diskussion'
 ) + $wgNamespaceNamesEn;
 
 /* private */ $wgQuickbarSettingsDe = array(
-       "Keine", "Links, fest", "Rechts, fest", "Links, schwebend"
+       'Keine', 'Links, fest', 'Rechts, fest', 'Links, schwebend'
 );
 
 /* private */ $wgSkinNamesDe = array(
-       'standard'      => "Klassik",
-       'nostalgia'     => "Nostalgie",
-       'cologneblue'   => "Kölnisch Blau",
-       'smarty'        => "Paddington",
-       'montparnasse'  => "Montparnasse",
-       'davinci'       => "DaVinci",
-       'mono'          => "Mono",
-       'monobook'      => "MonoBook",
-       'myskin'        => "MySkin",
-       'chick'         => "Küken"
+       'standard'      => 'Klassik',
+       'nostalgia'     => 'Nostalgie',
+       'cologneblue'   => 'Kölnisch Blau',
+       'smarty'        => 'Paddington',
+       'montparnasse'  => 'Montparnasse',
+       'davinci'       => 'DaVinci',
+       'mono'          => 'Mono',
+       'monobook'      => 'MonoBook',
+       'myskin'        => 'MySkin',
+       'chick'         => 'Küken'
 );
 
 
 /* private */ $wgBookstoreListDe = array(
-       "Verzeichnis lieferbarer B&uuml;cher" => "http://www.buchhandel.de/sixcms/list.php?page=buchhandel_profisuche_frameset&suchfeld=isbn&suchwert=$1&x=0&y=0",
-       "abebooks.de" => "http://www.abebooks.de/servlet/BookSearchPL?ph=2&isbn=$1",
-       "Amazon.de" => "http://www.amazon.de/exec/obidos/ISBN=$1",
-       "Lehmanns Fachbuchhandlung" => "http://www.lob.de/cgi-bin/work/suche?flag=new&stich1=$1",
+       'Verzeichnis lieferbarer B&uuml;cher' => 'http://www.buchhandel.de/sixcms/list.php?page=buchhandel_profisuche_frameset&suchfeld=isbn&suchwert=$1&x=0&y=0',
+       'abebooks.de' => 'http://www.abebooks.de/servlet/BookSearchPL?ph=2&isbn=$1',
+       'Amazon.de' => 'http://www.amazon.de/exec/obidos/ISBN=$1',
+       'Lehmanns Fachbuchhandlung' => 'http://www.lob.de/cgi-bin/work/suche?flag=new&stich1=$1',
 );
 
 
 /* private */ $wgValidSpecialPagesDe = array(
-  "Userlogin"           => "",
-  "Userlogout"          => "",
-  "Preferences"         => "Meine Benutzereinstellungen",
-  "Watchlist"           => "Meine Beobachtungsliste",
-  "Recentchanges"       => "Letzte Änderungen",
-  "Upload"              => "Dateien hochladen",
-  "Imagelist"           => "Hochgeladene Dateien",
-  "Listusers"           => "Registrierte Benutzer",
-  "Statistics"          => "Seitenstatistik",
-  "Randompage"          => "Zufälliger Artikel",
-
-  "Lonelypages"         => "Verwaiste Artikel",
-  "Unusedimages"        => "Verwaiste Dateien",
-  "Popularpages"        => "Beliebte Artikel",
-  "Wantedpages"         => "Gewünschte Artikel",
-  "Shortpages"          => "Kurze Artikel",
-  "Longpages"           => "Lange Artikel",
-  "Newpages"            => "Neue Artikel",
-  "Ancientpages"        => "Älteste Artikel",
+  'Userlogin'           => '',
+  'Userlogout'          => '',
+  'Preferences'         => 'Meine Benutzereinstellungen',
+  'Watchlist'           => 'Meine Beobachtungsliste',
+  'Recentchanges'       => 'Letzte Änderungen',
+  'Upload'              => 'Dateien hochladen',
+  'Imagelist'           => 'Hochgeladene Dateien',
+  'Listusers'           => 'Registrierte Benutzer',
+  'Statistics'          => 'Seitenstatistik',
+  'Randompage'          => 'Zufälliger Artikel',
+
+  'Lonelypages'         => 'Verwaiste Artikel',
+  'Unusedimages'        => 'Verwaiste Dateien',
+  'Popularpages'        => 'Beliebte Artikel',
+  'Wantedpages'         => 'Gewünschte Artikel',
+  'Shortpages'          => 'Kurze Artikel',
+  'Longpages'           => 'Lange Artikel',
+  'Newpages'            => 'Neue Artikel',
+  'Ancientpages'        => 'Älteste Artikel',
 /*  "Intl"                => "Interlanguage Links", */
-  "Allpages"            => "Alle Artikel (alphabetisch)",
-
-  "Ipblocklist"         => "Blockierte IP-Adressen",
-  "Maintenance"         => "Wartungsseite",
-  "Specialpages"        => "",
-  "Contributions"       => "",
-  "Movepage"            => "",
-  "Emailuser"           => "",
-  "Whatlinkshere"       => "",
-  "Recentchangeslinked" => "",
+  'Allpages'            => 'Alle Artikel (alphabetisch)',
+
+  'Ipblocklist'         => 'Blockierte IP-Adressen',
+  'Maintenance'         => 'Wartungsseite',
+  'Specialpages'        => '',
+  "Contributions"       => '',
+  "Movepage"            => '',
+  "Emailuser"           => '',
+  "Whatlinkshere"       => '',
+  "Recentchangeslinked" => '',
   "Booksources"         => "Externe Buchhandlungen",
   "Categories"          => "Seiten-Kategorien",
   "Export"              => "XML-Seitenexport",
@@ -168,7 +168,7 @@ if($wgMetaNamespace === FALSE)
 #
 "categories" => "Seitenkategorien",
 "category" => "Kategorie",
-"category_header" => "Artikel in der Kategorie \"$1\"",
+'category_header' => 'Artikel in der Kategorie "$1"',
 "subcategories" => "Unterkategorien",
 "linktrail"            => "/^([ä|ö|ü|ß|a-z]+)(.*)\$/sD",
 "mainpage"             => "Hauptseite",
@@ -248,11 +248,11 @@ und das [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide Benutzerhandbuc
 "protectedpage" => "Geschützte Seite",
 "administrators" => "Project:Administratoren",
 "sysoptitle"   => "Sysop-Zugang notwendig",
-"sysoptext"            => "Dieser Vorgang kann aus Sicherheitsgründen nur von Benutzern mit \"Sysop\"-Status durchgeführt werden. Siehe auch $1.",
+'sysoptext'            => 'Dieser Vorgang kann aus Sicherheitsgründen nur von Benutzern mit"Sysop"-Status durchgeführt werden. Siehe auch $1.',
 "developertitle" => "Entwickler-Zugang notwendig",
-"developertext"        => "Dieser Vorgang kann aus Sicherheitsgründen nur von Benutzern mit \"Entwickler\"-Status durchgeführt werden. Siehe auch $1.",
-"bureaucrattitle"      => "Bürokraten-Rechte notwendig",
-"bureaucrattext"       => "Dieser Vorgang kann nur von Benutzern mit \"Bürokrat\"-Status durchgeführt werden.",
+'developertext'        => 'Dieser Vorgang kann aus Sicherheitsgründen nur von Benutzern mit"Entwickler"-Status durchgeführt werden. Siehe auch $1.',
+'bureaucrattitle'      => 'Bürokraten-Rechte notwendig',
+'bureaucrattext'       => 'Dieser Vorgang kann nur von Benutzern mit "Bürokrat"-Status durchgeführt werden.',
 "nbytes"               => "$1 Byte",
 "go"                   => "Los",
 "ok"                   => "OK",
@@ -260,7 +260,7 @@ und das [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide Benutzerhandbuc
 "sitesubtitle" => "Die freie Enzyklopädie",
 "pagetitle"            => "$1 - {{SITENAME}}",
 "sitesubtitle" => "Die freie Wissensdatenbank",
-"retrievedfrom" => "Von \"$1\"",
+'retrievedfrom' => 'Von "$1"',
 "newmessages" => "Sie haben $1.",
 "newmessageslink" => "neue Nachrichten",
 "editsection" => "bearbeiten",
@@ -415,6 +415,7 @@ Bitte melden Sie sich an, sobald Sie es erhalten.",
 "savearticle"  => "Artikel speichern",
 "preview"      => "Vorschau",
 "showpreview"  => "Vorschau zeigen",
+"showdiff"     => "&Auml;nderungen zeigen",
 "blockedtitle" => "Benutzer ist blockiert",
 "blockedtext"  => "Ihr Benutzername oder Ihre IP-Adresse wurde von $1 blockiert.
 Als Grund wurde angegeben:<br />$2<p>Bitte kontaktieren Sie den Administrator, um über die Blockierung zu sprechen.",
@@ -1054,6 +1055,7 @@ Diskussions-Seite nicht, da schon eine mit dem neuen Titel existiert. Bitte glei
 'tooltip-minoredit' => 'Diese Änderung als klein markieren. [alt-i]',
 'tooltip-save' => 'Änderungen speichern [alt-s]',
 'tooltip-preview' => 'Vorschau der Änderungen an dieser Seite. Benutzen Sie dies vor dem Speichern! [alt-p]',
+'tooltip-diff' => 'Zeigt Ihre Änderungen am Text tabellarisch an [alt-d]',
 'tooltip-contributions' => 'Liste der beiträge dieses Benutzers.',
 'tooltip-emailuser' => 'Senden Sie eine Mail an diesen Benutzer',
 'tooltip-rss' => 'RSS-Feed von dieser Seite.',
@@ -1097,6 +1099,7 @@ Diskussions-Seite nicht, da schon eine mit dem neuen Titel existiert. Bitte glei
 'accesskey-minoredit' => 'i',
 'accesskey-save' => 's',
 'accesskey-preview' => 'p',
+'accesskey-diff' => 'd',
 'accesskey-contributions' => '',
 'accesskey-emailuser' => '',
 'accesskey-compareselectedversions' => 'v',