adds '->' links to section before autogenerated section edit comments,
authorErik Moeller <erik@users.mediawiki.org>
Tue, 24 Aug 2004 17:19:37 +0000 (17:19 +0000)
committerErik Moeller <erik@users.mediawiki.org>
Tue, 24 Aug 2004 17:19:37 +0000 (17:19 +0000)
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
includes/Skin.php
includes/SpecialContributions.php
languages/Language.php

index d519385..d78192b 100644 (file)
@@ -197,8 +197,7 @@ class PageHistory {
                
 
                if ( '' != $c && '*' != $c ) {
-
-                       $c = $this->mSkin->formatcomment($c);
+                       $c = $this->mSkin->formatcomment($c,$this->mTitle);
                        $s .= " <em>(" . $c . ")</em>";
                }
                $s .= "</li>\n";
index 95fcc4f..9fa3806 100644 (file)
@@ -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 .= "<br />\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 .= "</li>\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='<span class="autocomment">'.$auto.'</span>';
index 8b7688c..9f252d5 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+require_once('SpecialValidate.php');
 
 function wfSpecialContributions( $par = "" )
 {
@@ -197,7 +198,7 @@ function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $t
 
        if($comment) {
 
-               $comment="<em>(". $sk->formatComment($comment ) .")</em> ";
+               $comment="<em>(". $sk->formatComment($comment, Title::newFromText($t) ) .")</em> ";
 
        }
        $d = $wgLang->timeanddate( $ts, true );
index 85e4a84..1e1b416 100644 (file)
@@ -823,6 +823,7 @@ from server time (UTC).',
 'nchanges'             => "$1 changes",
 'minoreditletter' => 'm',
 'newpageletter' => 'N',
+'sectionlink' => '&rarr;',
 
 # Upload
 #