(bug 4855) Section edit links now have the section name in the title attribute
authorLupin <lupin-wp@users.mediawiki.org>
Sat, 4 Mar 2006 03:24:33 +0000 (03:24 +0000)
committerLupin <lupin-wp@users.mediawiki.org>
Sat, 4 Mar 2006 03:24:33 +0000 (03:24 +0000)
RELEASE-NOTES
includes/Linker.php
includes/Parser.php
languages/Messages.php

index 06e0502..aa446db 100644 (file)
@@ -676,6 +676,7 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 5141) Gracefully handle the new account link when createaccount off
 * (bug 5150 and related) Fix missing ID attribute in HTML namespace selector
 * (bug 5152) Proper HTML escaping on subpage breadcrumbs
+* (bug 4855) Section edit links now have the section name in the title attribute.
 
 
 === Caveats ===
index c84ccd4..4b180ef 100644 (file)
@@ -270,15 +270,16 @@ class Linker {
         * it doesn't have to do a database query. It's also valid for interwiki titles and special
         * pages.
         *
-        * @param object Title of target page
-        * @param string Text to replace the title
-        * @param string Link target
-        * @param string Text after link
-        * @param string Text before link text
-        * @param string Extra attributes to the a-element
+        * @param object $nt Title of target page
+        * @param string $text Text to replace the title
+        * @param string $query Link target
+        * @param string $trail Text after link
+        * @param string $prefix Text before link text
+        * @param string $aprops Extra attributes to the a-element
+        * @param string $style Style to apply - if empty, use getInternalLinkAttributesObj instead
         * @return the a-element
         */
-       function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
+       function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
 
                $fname = 'Linker::makeKnownLinkObj';
                wfProfileIn( $fname );
@@ -289,7 +290,7 @@ class Linker {
                }
 
                $u = $nt->escapeLocalURL( $query );
-               if ( '' != $nt->getFragment() ) {
+               if ( $nt->getFragment() != '' ) {
                        if( $nt->getPrefixedDbkey() == '' ) {
                                $u = '';
                                if ( '' == $text ) {
@@ -303,10 +304,12 @@ class Linker {
                        );
                        $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
                }
-               if ( '' == $text ) {
+               if ( $text == '' ) {
                        $text = htmlspecialchars( $nt->getPrefixedText() );
                }
-               $style = $this->getInternalLinkAttributesObj( $nt, $text );
+               if ( $style == '' ) {
+                       $style = $this->getInternalLinkAttributesObj( $nt, $text );
+               }
 
                if ( $aprops !== '' ) $aprops = ' ' . $aprops;
 
@@ -902,12 +905,17 @@ class Linker {
 
        }
 
-       /** @todo document */
-       function editSectionLink( $nt, $section ) {
+       /** 
+        * @param Title $title
+        * @param integer $section
+        * @param string $hint Link title, or default if omitted or empty
+        */
+       function editSectionLink( $nt, $section, $hint='' ) {
                global $wgContLang;
 
                $editurl = '&section='.$section;
-               $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl );
+               $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"';
+               $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '',  $hint );
 
                if( $wgContLang->isRTL() ) {
                        $farside = 'left';
index b3f13aa..90b382a 100644 (file)
@@ -3020,6 +3020,8 @@ class Parser
                        # strip out HTML
                        $canonized_headline = preg_replace( '/<.*?' . '>/','',$canonized_headline );
                        $tocline = trim( $canonized_headline );
+                       # Save headline for section edit hint before it's escaped
+                       $headline_hint = trim( $canonized_headline ); 
                        $canonized_headline = Sanitizer::escapeId( $tocline );
                        $refers[$headlineCount] = $canonized_headline;
 
@@ -3048,7 +3050,7 @@ class Parser
                                if( $istemplate )
                                        $head[$headlineCount] .= $sk->editSectionLinkForOther($templatetitle, $templatesection);
                                else
-                                       $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1);
+                                       $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
                        }
 
                        # give headline the correct <h#> tag
index 6a1d489..5951cd8 100644 (file)
@@ -239,6 +239,7 @@ See $1.',
 'newmessageslink' => 'new messages',
 'newmessagesdifflink' => 'diff to penultimate revision',
 'editsection'=>'edit',
+'editsectionhint' => 'Edit section: $1',
 'toc' => 'Contents',
 'showtoc' => 'show',
 'hidetoc' => 'hide',