From: Lupin Date: Sat, 4 Mar 2006 03:24:33 +0000 (+0000) Subject: (bug 4855) Section edit links now have the section name in the title attribute X-Git-Tag: 1.6.0~235 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=3c75c6d69d5ab182edabe3ed9855bb9504365a5f;p=lhc%2Fweb%2Fwiklou.git (bug 4855) Section edit links now have the section name in the title attribute --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 06e0502c11..aa446dbcfb 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Linker.php b/includes/Linker.php index c84ccd462e..4b180ef213 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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 = '§ion='.$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'; diff --git a/includes/Parser.php b/includes/Parser.php index b3f13aa3cd..90b382a744 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 tag diff --git a/languages/Messages.php b/languages/Messages.php index 6a1d489604..5951cd8e81 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -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',