r907 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r906‎ | r907 | r908 >
Date:14:48, 11 November 2002
Author:eloquence
Status:old
Tags:
Comment:
"Watch this article" checkbox in article editor adds articles to
a user's watchlist. There is also new preference "watchdefault".
When this preference is activated, the "Watch this article" checkbox
is active by default during all edits (but can still be deactivated).
I have added a German translation and used English strings in the
other PHP files. Post other translations to wikitech-l@wikipedia.org.
-- Erik Moeller (e.moeller@fokus.gmd.de)
Modified paths:
  • /trunk/phpwiki/newcodebase/Article.php (modified) (history)
  • /trunk/phpwiki/newcodebase/Language.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageDa.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageDe.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageEo.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageEs.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageFr.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageJa.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageKo.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageNl.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguagePl.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageZh.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/newcodebase/LanguageDe.php
@@ -38,7 +38,8 @@
3939 "numberheadings" => "�berschriften automatisch numerieren",
4040 "rememberpassword" => "Passwort merken",
4141 "editwidth" => "Text-Eingabefeld mit voller Breite",
42 - "editondblclick" => "Seiten mit Doppelklick bearbeiten (JavaScript)"
 42+ "editondblclick" => "Seiten mit Doppelklick bearbeiten (JavaScript)",
 43+ "watchdefault" => "Neue und ge�nderte Seiten beobachten"
4344 );
4445
4546 /* private */ $wgLanguageNamesDe = array(
@@ -294,6 +295,7 @@
295296 #
296297 "summary" => "Zusammenfassung",
297298 "minoredit" => "Nur Kleinigkeiten wurden ver�ndert.",
 299+"watchthis" => "Diesen Artikel beobachten",
298300 "savearticle" => "Artikel speichern",
299301 "preview" => "Vorschau",
300302 "showpreview" => "Vorschau zeigen",
Index: trunk/phpwiki/newcodebase/LanguagePl.php
@@ -31,7 +31,9 @@
3232 "justify" => "Wyrównuj tekst artykułu w kolumnie",
3333 "hideminor" => "Ukryj drobne zmiany w \"Ostatnich zmianach\"",
3434 "numberheadings" => "Automatyczna numeracja nagłówków",
35 - "rememberpassword" => "Pamiętaj hasło między sesjami"
 35+ "rememberpassword" => "Pamiętaj hasło między sesjami",
 36+ "editondblclick" => "Edit pages on doubleclick (JavaScript)",
 37+ "watchdefault" => "Watch new and modified articles"
3638 );
3739
3840 /* private */ $wgLanguageNamesPl = array(
Index: trunk/phpwiki/newcodebase/Article.php
@@ -329,7 +329,8 @@
330330 function editForm( $formtype )
331331 {
332332 global $wgOut, $wgUser, $wgTitle;
333 - global $wpTextbox1, $wpSummary, $wpSave, $wpPreview;
 333+ global $wpTextbox1, $wpSummary, $wpWatchthis;
 334+ global $wpSave, $wpPreview;
334335 global $wpMinoredit, $wpEdittime, $wpTextbox2, $wpCountable;
335336 global $oldid, $redirect;
336337
@@ -362,7 +363,7 @@
363364 return;
364365 }
365366 $this->mCountAdjustment = $this->isCountable( $wpTextbox1 );
366 - $this->insertNewArticle( $wpTextbox1, $wpSummary, $wpMinoredit );
 367+ $this->insertNewArticle( $wpTextbox1, $wpSummary, $wpMinoredit, $wpWatchthis );
367368 return;
368369 }
369370 # Article exists. Check for edit conflict.
@@ -381,7 +382,7 @@
382383
383384 $this->mCountAdjustment = $this->isCountable( $wpTextbox1 ) -
384385 $wpCountable;
385 - $this->updateArticle( $wpTextbox1, $wpSummary, $wpMinoredit );
 386+ $this->updateArticle( $wpTextbox1, $wpSummary, $wpMinoredit, $wpWatchthis );
386387 return;
387388 }
388389 }
@@ -425,8 +426,9 @@
426427 if ( "no" == $redirect ) { $q .= "&redirect=no"; }
427428 $action = wfEscapeHTML( wfLocalUrl( $wgTitle->getPrefixedURL(), $q ) );
428429
429 - $summary = wfMsg( "summary" );
 430+ $summary = wfMsg( "summary" );
430431 $minor = wfMsg( "minoredit" );
 432+ $watchthis = wfMsg ("watchthis");
431433 $save = wfMsg( "savearticle" );
432434 $prev = wfMsg( "showpreview" );
433435
@@ -440,6 +442,21 @@
441443 $wpTextbox1 = wfEscapeHTML( $wpTextbox1 );
442444 $wpTextbox2 = wfEscapeHTML( $wpTextbox2 );
443445 $wpSummary = wfEscapeHTML( $wpSummary );
 446+
 447+ // activate checkbox if user wants it to be always active
 448+ if ($wgUser->getOption("watchdefault")) $wpWatchthis=1;
 449+
 450+ // activate checkbox also if user is already watching the page,
 451+ // require wpWatchthis to be unset so that second condition is not
 452+ // checked unnecessarily
 453+ if (!$wpWatchthis && !$wpPreview && $wgTitle->userIsWatching()) $wpWatchthis=1;
 454+
 455+ if ( 0 != $wgUser->getID() ) {
 456+
 457+ $watchhtml="<input tabindex=4 type=checkbox name='wpWatchthis'".($wpWatchthis?" checked":"").">{$watchthis}<br>";
 458+ } else {
 459+ $watchhtml="<br>";
 460+ }
444461
445462 $wgOut->addHTML( "
446463 <form method=post action=\"$action\"
@@ -448,9 +465,10 @@
449466 {$wpTextbox1}
450467 </textarea><br>
451468 {$summary}: <input tabindex=2 type=text value=\"{$wpSummary}\" name='wpSummary' maxlength=200>
452 -<input tabindex=3 type=checkbox value=1 name='wpMinoredit'".($wpMinoredit?" checked":"").">{$minor}<br>
453 -<input tabindex=4 type=submit value=\"{$save}\" name='wpSave'>
454 -<input tabindex=5 type=submit value=\"{$prev}\" name='wpPreview'>
 469+<input tabindex=3 type=checkbox value=1 name='wpMinoredit'".($wpMinoredit?" checked":"").">{$minor}
 470+{$watchhtml}
 471+<input tabindex=5 type=submit value=\"{$save}\" name='wpSave'>
 472+<input tabindex=6 type=submit value=\"{$prev}\" name='wpPreview'>
455473 <em>{$cancel}</em> | <em>{$edithelp}</em>
456474 <br><br>{$copywarn}
457475 <input type=hidden value=\"{$wpEdittime}\" name='wpEdittime'>
@@ -486,7 +504,7 @@
487505 # leap of faith, and I want to be able to report database
488506 # errors at some point.
489507
490 - /* private */ function insertNewArticle( $text, $summary, $isminor )
 508+ /* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis )
491509 {
492510 global $wgOut, $wgUser, $wgTitle, $wgLinkCache;
493511 $fname = "Article::insertNewArticle";
@@ -521,17 +539,24 @@
522540 wfStrencode( $wgUser->getName() ) . "','" .
523541 wfStrencode( $summary ) . "',0,0)";
524542 wfQuery( $sql, $fname );
525 -
 543+ if ($watchthis ) {
 544+ $this->watch();
 545+ } else {
 546+ if ( $wgTitle->userIsWatching() ) {
 547+ $this->unwatch();
 548+ }
 549+ }
 550+
526551 $this->showArticle( $text, wfMsg( "newarticle" ) );
527552 }
528553
529 - function updateArticle( $text, $summary, $minor )
 554+ function updateArticle( $text, $summary, $minor, $watchthis )
530555 {
531556 global $wgOut, $wgUser, $wgTitle, $wgLinkCache;
532557 $fname = "Article::updateArticle";
533558
534559 if ( $this->mMinorEdit ) { $me1 = 1; } else { $me1 = 0; }
535 - if ( $minor ) { $me2 = 1; } else { $me2 = 0; }
 560+ if ( $minor ) { $me2 = 1; } else { $me2 = 0; }
536561 if ( preg_match( "/^(#redirect[^\\n]+)/i", $text, $m ) ) {
537562 $redir = 1;
538563 $text = $m[1] . "\n"; # Remove all content but redirect
@@ -587,7 +612,16 @@
588613 "WHERE rc_cur_id=" . $this->getID();
589614 wfQuery( $sql, $fname );
590615 }
591 - $this->showArticle( $text, wfMsg( "updated" ) );
 616+
 617+ if ($watchthis ) {
 618+ $this->watch();
 619+ } else {
 620+ if ( $wgTitle->userIsWatching() ) {
 621+ $this->unwatch();
 622+ }
 623+ }
 624+
 625+ $this->showArticle( $text, wfMsg( "updated" ) );
592626 }
593627
594628 # After we've either updated or inserted the article, update
Index: trunk/phpwiki/newcodebase/LanguageEo.php
@@ -37,7 +37,8 @@
3838 "numberheadings" => "Aŭtomate nombrigu sekciojn",
3939 "rememberpassword" => "Rememoru mian pasvorton de seanco al seanco",
4040 "editwidth" => "Redaktilo estu plenlarĝa",
41 - "editondblclick" => "Redaktu per duobla alklako (JavaScript)"
 41+ "editondblclick" => "Redaktu per duobla alklako (JavaScript)",
 42+ "watchdefault" => "Watch new and modified articles"
4243 );
4344
4445 # Se eble, trovu Esperantajn libroservoj traserĉeblaj laŭ ISBN
Index: trunk/phpwiki/newcodebase/LanguageEs.php
@@ -36,7 +36,8 @@
3737 "numberheadings" => "Auto-numerar encabezados",
3838 "rememberpassword" => "Recordar la contrase�a entre sesiones",
3939 "editwidth" => "La caja de edici�n tiene el ancho m�ximo",
40 - "editondblclick" => "Edit pages on double click (JavaScript)"
 40+ "editondblclick" => "Edit pages on double click (JavaScript)",
 41+ "watchdefault" => "Watch new and modified articles"
4142 );
4243
4344 /* Please customize this with some Spanish-language bookshops
Index: trunk/phpwiki/newcodebase/LanguageJa.php
@@ -33,7 +33,8 @@
3434 "numberheadings" => "Auto-number headings",
3535 "rememberpassword" => "Remember password across sessions",
3636 "editwidth" => "Edit box has full width",
37 - "editondblclick" => "Edit pages on double click (JavaScript)"
 37+ "editondblclick" => "Edit pages on double click (JavaScript)",
 38+ "watchdefault" => "Watch new and modified articles"
3839 );
3940
4041 /* Native/local names should be available where known for consistency
Index: trunk/phpwiki/newcodebase/LanguageFr.php
@@ -38,7 +38,8 @@
3939 "numberheadings" => "Num�rotation automatique des titres",
4040 "rememberpassword" => "Se souvenir de mon mot de passe (cookie)",
4141 "editwidth" => "La fenetre d'�dition est en pleine largeur",
42 - "editondblclick" => "Edit pages on double click (JavaScript)"
 42+ "editondblclick" => "Edit pages on double click (JavaScript)",
 43+ "watchdefault" => "Watch new and modified articles"
4344 );
4445
4546 /* Replace these with some French bookshops/lookup places */
Index: trunk/phpwiki/newcodebase/LanguageNl.php
@@ -40,8 +40,9 @@
4141 "hideminor" => "Kleine wijzigingen verbergen in recente wijzigingen",
4242 "numberheadings" => "Koppen automatisch nummeren",
4343 "rememberpassword" => "Wachtwoord onthouden",
44 - "editwidth" => "Edit box has full width",
45 - "editondblclick" => "Edit pages on double click (JavaScript)"
 44+ "editwidth" => "Edit box has full width",
 45+ "editondblclick" => "Edit pages on double click (JavaScript)",
 46+ "watchdefault" => "Watch new and modified articles"
4647 );
4748
4849 /* private */ $wgLanguageNamesNl = array(
Index: trunk/phpwiki/newcodebase/Language.php
@@ -44,7 +44,8 @@
4545 "numberheadings" => "Auto-number headings",
4646 "rememberpassword" => "Remember password across sessions",
4747 "editwidth" => "Edit box has full width",
48 - "editondblclick" => "Edit pages on double click (JavaScript)"
 48+ "editondblclick" => "Edit pages on double click (JavaScript)",
 49+ "watchdefault" => "Watch new and modified articles"
4950 );
5051
5152 /* private */ $wgBookstoreListEn = array(
@@ -425,7 +426,8 @@
426427 # Edit pages
427428 #
428429 "summary" => "Summary",
429 -"minoredit" => "This is a minor edit.",
 430+"minoredit" => "This is a minor edit",
 431+"watchthis" => "Watch this article",
430432 "savearticle" => "Save page",
431433 "preview" => "Preview",
432434 "showpreview" => "Show preview",
Index: trunk/phpwiki/newcodebase/LanguageZh.php
@@ -49,7 +49,8 @@
5050 "numberheadings" => "Auto-number headings",
5151 "rememberpassword" => "Remember password across sessions",
5252 "editwidth" => "Edit box has full width",
53 - "editondblclick" => "Edit pages on double click (JavaScript)"
 53+ "editondblclick" => "Edit pages on double click (JavaScript)",
 54+ "watchdefault" => "Watch new and modified articles"
5455 );
5556
5657 /* private */ $wgBookstoreListZh = array(
Index: trunk/phpwiki/newcodebase/LanguageKo.php
@@ -53,7 +53,8 @@
5454 "numberheadings" => "머릿글 번호 매기기",
5555 "rememberpassword" => "세션동안 암호 기억",
5656 "editwidth" => "편집상자 너비 최대",
57 - "editondblclick" => "Edit pages on double click (JavaScript)"
 57+ "editondblclick" => "Edit pages on double click (JavaScript)",
 58+ "watchdefault" => "Watch new and modified articles"
5859 );
5960
6061 /* private */ $wgBookstoreListKo = array(
Index: trunk/phpwiki/newcodebase/LanguageDa.php
@@ -41,7 +41,8 @@
4242 "numberheadings" => "Automatisk nummerering af overskrifter",
4343 "rememberpassword" => "Husk password til n�ste bes�g",
4444 "editwidth" => "Redigeringsboksen har fuld bredde",
45 - "editondblclick" => "Edit pages on double click (JavaScript)"
 45+ "editondblclick" => "Edit pages on double click (JavaScript)",
 46+ "watchdefault" => "Watch new and modified articles"
4647 );
4748
4849 /* private */ $wgBookstoreListDa = array(

Status & tagging log