From 67b3d708f81172fac1ab2d5d8808266d00069006 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Tue, 24 Aug 2004 17:19:37 +0000 Subject: [PATCH] adds '->' links to section before autogenerated section edit comments, in recent changes, history, watchlist and contributions list. '->' is defined in MediaWiki:sectionlink. closes http://bugzilla.wikipedia.org/show_bug.cgi?id=45 --- includes/PageHistory.php | 3 +-- includes/Skin.php | 28 ++++++++++++++++++++++------ includes/SpecialContributions.php | 3 ++- languages/Language.php | 1 + 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/includes/PageHistory.php b/includes/PageHistory.php index d519385f6a..d78192bf30 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -197,8 +197,7 @@ class PageHistory { if ( '' != $c && '*' != $c ) { - - $c = $this->mSkin->formatcomment($c); + $c = $this->mSkin->formatcomment($c,$this->mTitle); $s .= " (" . $c . ")"; } $s .= "\n"; diff --git a/includes/Skin.php b/includes/Skin.php index 95fcc4fe1a..9fa3806b64 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1561,7 +1561,7 @@ class Skin { } # Pass a title object, not a title string - function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '') + function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) { global $wgOut, $wgTitle, $wgInputEncoding; @@ -1572,6 +1572,8 @@ class Skin { return $text; } $link = $nt->getPrefixedURL(); +# if ( '' != $section && substr($section,0,1) != "#" ) { +# $section = '' if ( '' == $link ) { $u = ''; @@ -2143,7 +2145,7 @@ class Skin { # Comment if ( $rc_comment != '' && $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) { - $rc_comment=$this->formatComment($rc_comment); + $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle()); $r .= $wgLang->emphasize( ' ('.$rc_comment.')' ); } @@ -2258,7 +2260,7 @@ class Skin { $r .= ') . . '.$rcObj->userlink ; $r .= $rcObj->usertalklink ; if ( $rc_comment != '' ) { - $rc_comment=$this->formatComment($rc_comment); + $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle()); $r .= $wgLang->emphasize( ' ('.$rc_comment.')' ) ; } $r .= "
\n" ; @@ -2408,7 +2410,7 @@ class Skin { # Add comment if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) { - $rc_comment=$this->formatComment($rc_comment); + $rc_comment=$this->formatComment($rc_comment,$rc->getTitle()); $s .= $wgLang->emphasize(' (' . $rc_comment . ')'); } $s .= "\n"; @@ -2530,9 +2532,12 @@ class Skin { 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) and formats [[wikilinks]]. - Main author: Erik Möller (moeller@scireview.de) + + The $title parameter, which is optional, must be a title OBJECT. It is + used to generate a direct link to the section in the autocomment. + Main author: Erik Moeller (moeller@scireview.de) */ - function formatComment($comment) + function formatComment($comment, $title='') { global $wgLang; $comment = htmlspecialchars( $comment ); @@ -2545,7 +2550,18 @@ class Skin { $pre=$match[1]; $auto=$match[2]; $post=$match[3]; + $link=''; + if($title) { + $section=$auto; + + # This is hackish but should work in most cases. + $section=str_replace('[[','',$section); + $section=str_replace(']]','',$section); + $title->mFragment=$section; + $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink')); + } $sep='-'; + $auto=$link.$auto; if($pre) { $auto = $sep.' '.$auto; } if($post) { $auto .= ' '.$sep; } $auto=''.$auto.''; diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 8b7688cef6..9f252d56a4 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -1,4 +1,5 @@ (". $sk->formatComment($comment ) .") "; + $comment="(". $sk->formatComment($comment, Title::newFromText($t) ) .") "; } $d = $wgLang->timeanddate( $ts, true ); diff --git a/languages/Language.php b/languages/Language.php index 85e4a84f85..1e1b416750 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -823,6 +823,7 @@ from server time (UTC).', 'nchanges' => "$1 changes", 'minoreditletter' => 'm', 'newpageletter' => 'N', +'sectionlink' => '→', # Upload # -- 2.20.1