From dbc5dc019da8e78125ddfcb2c19e347d1c055129 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Wed, 24 Mar 2004 01:49:46 +0000 Subject: [PATCH] 1) section editing auto-summaries are now formatted as /* foo */ 2) in RC, SpecialContributions and PageHistory, these are displayed using the CSS class "autocomment" (gray in the standard skin) --- includes/EditPage.php | 2 +- includes/PageHistory.php | 4 +- includes/Skin.php | 96 +++++++++++++++++++------------ includes/SpecialContributions.php | 2 +- stylesheets/wikistandard.css | 3 + 5 files changed, 66 insertions(+), 41 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 556cf9831e..bfe95e2eb1 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -226,7 +226,7 @@ class EditPage { $sectitle=preg_match("/^=+(.*?)=+/mi", $this->textbox1, $matches); - if($matches[1]) { $this->summary = "=". trim($matches[1])."= "; } + if($matches[1]) { $this->summary = "/* ". trim($matches[1])." */ "; } } } $wgOut->setPageTitle( $s ); diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 65f041e6a9..88677edc40 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -197,7 +197,9 @@ class PageHistory { $s .= " {$link} . . {$ul}"; if ( "" != $c && "*" != $c ) { - $s .= " (" . wfEscapeHTML($c) . ")"; + + $c = $this->mSkin->formatcomment($c); + $s .= " (" . $c . ")"; } $s .= "\n"; diff --git a/includes/Skin.php b/includes/Skin.php index 2836a244da..78da8c46a5 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -630,7 +630,7 @@ class Skin { if ( $wgTitle->getNamespace() == Namespace::getUser() || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) ) - { + { $id=User::idFromName($wgTitle->getText()); $ip=User::isIP($wgTitle->getText()); @@ -780,13 +780,13 @@ class Skin { if user edits article, then loads "watch this article" in background and then saves article with "Watch this article" checkbox disabled, the article is transparently unwatched. Therefore we do not show the "Watch this page" link in edit mode - */ + */ if ( 0 != $wgUser->getID() && $articleExists) { - if($action!="edit" && $action != "submit" ) + if($action!="edit" && $action != "submit" ) { - $s .= $sep . $this->watchThisPage(); + $s .= $sep . $this->watchThisPage(); } - if ( $wgTitle->userCanEdit() ) + if ( $wgTitle->userCanEdit() ) $s .= $sep . $this->moveThisPage(); } if ( $wgUser->isSysop() and $articleExists ) { @@ -794,7 +794,7 @@ class Skin { $sep . $this->protectThisPage(); } $s .= $sep . $this->talkLink(); - if ($articleExists && $action !="history") { + if ($articleExists && $action !="history") { $s .= $sep . $this->historyLink(); } $s.=$sep . $this->whatLinksHere(); @@ -1168,7 +1168,7 @@ class Skin { $text= wfMsg("articlepage"); } } else { - + $lns = Namespace::getTalk( $tns ); $text=$tp; } @@ -1738,25 +1738,26 @@ class Skin { } # Enhanced RC ungrouped line - function recentChangesBlockLine ( $rcObj ) + function recentChangesBlockLine ( $rcObj ) { global $wgUploadPath, $wgLang ; - + # Get rc_xxxx variables extract( $rcObj->mAttribs ) ; $curIdEq = "curid=$rc_cur_id"; - + # Spacer image $r = "" ; + $r .= "" ; $r .= "" ; - + if ( $rc_type == RC_MOVE ) { $r .= "  "; } else { # M & N (minor & new) $M = wfMsg( "minoreditletter" ); $N = wfMsg( "newpageletter" ); - + if ( $rc_type == RC_NEW ) { $r .= $N ; } else { @@ -1768,7 +1769,7 @@ class Skin { $r .= " " ; } } - + # Timestamp $r .= " ".$rcObj->timestamp." " ; $r .= "" ; @@ -1782,31 +1783,33 @@ class Skin { $r .= " (" ; $r .= $rcObj->curlink ; $r .= "; " ; - + # Hist $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" ); # User/talk $r .= ") . . ".$rcObj->userlink ; $r .= $rcObj->usertalklink ; - + # Comment if ( $rc_comment != "" && $rc_type != RC_MOVE ) { - $r .= $wgLang->emphasize( " (".wfEscapeHTML($rc_comment).")" ); + $rc_comment=$this->formatComment($rc_comment); + $r .= $wgLang->emphasize( " (".$rc_comment.")" ); } + $r .= "
\n" ; return $r ; } # Enhanced RC group - function recentChangesBlockGroup ( $block ) + function recentChangesBlockGroup ( $block ) { global $wgUploadPath, $wgLang ; - + $r = "" ; $M = wfMsg( "minoreditletter" ); $N = wfMsg( "newpageletter" ); - + # Collate list of users $isnew = false ; $userlinks = array () ; @@ -1849,7 +1852,7 @@ class Skin { # Timestamp $r .= " ".$block[0]->timestamp." " ; $r .= "" ; - + # Article link $link = $block[0]->link ; if ( $block[0]->watched ) $link = "{$link}" ; @@ -1905,7 +1908,8 @@ class Skin { $r .= ") . . ".$rcObj->userlink ; $r .= $rcObj->usertalklink ; if ( $rc_comment != "" ) { - $r .= $wgLang->emphasize( " (".wfEscapeHTML($rc_comment).")" ) ; + $rc_comment=$this->formatComment($rc_comment); + $r .= $wgLang->emphasize( " (".$rc_comment.")" ) ; } $r .= "
\n" ; } @@ -1945,15 +1949,15 @@ class Skin { $line = $this->recentChangesLineOld ( $rc, $watched ) ; return $line ; } - + function recentChangesLineOld( &$rc, $watched = false ) { global $wgTitle, $wgLang, $wgUser; - + # Extract DB fields into local scope extract( $rc->mAttribs ); $curIdEq = "curid=" . $rc_cur_id; - + # Make date header if necessary $date = $wgLang->date( $rc_timestamp, true); $s = ""; @@ -1963,7 +1967,7 @@ class Skin { $this->lastdate = $date; } $s .= "
  • "; - + if ( $rc_type == RC_MOVE ) { # Diff $s .= "(" . wfMsg( "diff" ) . ") ("; @@ -1985,9 +1989,9 @@ class Skin { "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}" ); } $s .= "($diffLink) ("; - + # History link - $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" ); + $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( "hist" ), "{$curIdEq}&action=history" ); $s .= ") . . "; # M and N (minor and new) @@ -2005,19 +2009,19 @@ class Skin { $s .= " $articleLink"; } - + # Timestamp $s .= "; " . $wgLang->time( $rc_timestamp, true ) . " . . "; - + # User link (or contributions for unregistered users) if ( 0 == $rc_user ) { $userLink = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ), - $rc_user_text, "target=" . $rc_user_text ); - } else { - $userLink = $this->makeLink( $wgLang->getNsText( NS_USER ) . ":{$rc_user_text}", $rc_user_text ); + $rc_user_text, "target=" . $rc_user_text ); + } else { + $userLink = $this->makeLink( $wgLang->getNsText( NS_USER ) . ":{$rc_user_text}", $rc_user_text ); } $s .= $userLink; - + # User talk link $talkname=$wgLang->getNsText(NS_TALK); # use the shorter name global $wgDisableAnonTalk; @@ -2032,9 +2036,9 @@ class Skin { if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) { $blockLink = $this->makeKnownLink( $wgLang->specialPage( "Blockip" ), wfMsg( "blocklink" ), "ip={$rc_user_text}" ); - + } - if($blockLink) { + if($blockLink) { if($userTalkLink) $userTalkLink .= " | "; $userTalkLink .= $blockLink; } @@ -2042,13 +2046,14 @@ class Skin { # Add comment if ( "" != $rc_comment && "*" != $rc_comment && $rc_type != RC_MOVE ) { - $s .= $wgLang->emphasize(" (" . wfEscapeHTML( $rc_comment ) . ")"); + $rc_comment=$this->formatComment($rc_comment); + $s .= $wgLang->emphasize(" (" . $rc_comment . ")"); } $s .= "
  • \n"; return $s; } - + # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched = false, $oldid = 0 , $diffid = 0 ) function recentChangesLineNew( &$baseRC, $watched = false ) { @@ -2156,6 +2161,21 @@ class Skin { return $s; } + /* This function is called by all recent changes variants, by the page history, + and by the user contributions list. It is responsible for formatting edit + comments. It escapes any HTML in the comment, but adds some CSS to format + auto-generated comments (from section editing). + */ + function formatComment($comment) + { + $comment=wfEscapeHTML($comment); + + # format text between /* .. */ with autocomment CSS class + $comment=preg_replace("/\/\*\s*(.*?)\s*\*\//i", + "$1",$comment); + return $comment; + } + function imageHistoryLine( $iscur, $ts, $img, $u, $ut, $size, $c ) { global $wgUser, $wgLang, $wgTitle; @@ -2168,7 +2188,7 @@ class Skin { $url = wfImageUrl( $img ); $rlink = $cur; if ( $wgUser->isSysop() ) { - $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() . + $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() . "&action=delete" ); $style = $this->getInternalLinkAttributes( $link, $del ); diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 216ae6c165..6c954a301f 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -172,7 +172,7 @@ function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew ) if($comment) { - $comment="(". htmlspecialchars( $comment ) .") "; + $comment="(". $sk->formatComment($comment ) .") "; } $d = $wgLang->timeanddate( $ts, true ); diff --git a/stylesheets/wikistandard.css b/stylesheets/wikistandard.css index 9610c7571e..40ae278cf0 100644 --- a/stylesheets/wikistandard.css +++ b/stylesheets/wikistandard.css @@ -8,6 +8,9 @@ #quickbar { width: 140px; padding: 4px; visibility: visible; z-index:99;font-size:95%;} #topbar { padding: 4px;font-size:95%; } +/* automatically generated edit summaries */ +#autocomment { color: gray; } + /* Table of contents */ #toc { border: 1px solid #8888aa; -- 2.20.1