r13163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13162‎ | r13163 | r13164 >
Date:03:24, 4 March 2006
Author:lupin-wp
Status:old
Tags:
Comment:
(bug 4855) Section edit links now have the section name in the title attribute
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/languages/Messages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -270,15 +270,16 @@
271271 * it doesn't have to do a database query. It's also valid for interwiki titles and special
272272 * pages.
273273 *
274 - * @param object Title of target page
275 - * @param string Text to replace the title
276 - * @param string Link target
277 - * @param string Text after link
278 - * @param string Text before link text
279 - * @param string Extra attributes to the a-element
 274+ * @param object $nt Title of target page
 275+ * @param string $text Text to replace the title
 276+ * @param string $query Link target
 277+ * @param string $trail Text after link
 278+ * @param string $prefix Text before link text
 279+ * @param string $aprops Extra attributes to the a-element
 280+ * @param string $style Style to apply - if empty, use getInternalLinkAttributesObj instead
280281 * @return the a-element
281282 */
282 - function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
 283+ function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
283284
284285 $fname = 'Linker::makeKnownLinkObj';
285286 wfProfileIn( $fname );
@@ -289,7 +290,7 @@
290291 }
291292
292293 $u = $nt->escapeLocalURL( $query );
293 - if ( '' != $nt->getFragment() ) {
 294+ if ( $nt->getFragment() != '' ) {
294295 if( $nt->getPrefixedDbkey() == '' ) {
295296 $u = '';
296297 if ( '' == $text ) {
@@ -303,10 +304,12 @@
304305 );
305306 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
306307 }
307 - if ( '' == $text ) {
 308+ if ( $text == '' ) {
308309 $text = htmlspecialchars( $nt->getPrefixedText() );
309310 }
310 - $style = $this->getInternalLinkAttributesObj( $nt, $text );
 311+ if ( $style == '' ) {
 312+ $style = $this->getInternalLinkAttributesObj( $nt, $text );
 313+ }
311314
312315 if ( $aprops !== '' ) $aprops = ' ' . $aprops;
313316
@@ -902,12 +905,17 @@
903906
904907 }
905908
906 - /** @todo document */
907 - function editSectionLink( $nt, $section ) {
 909+ /**
 910+ * @param Title $title
 911+ * @param integer $section
 912+ * @param string $hint Link title, or default if omitted or empty
 913+ */
 914+ function editSectionLink( $nt, $section, $hint='' ) {
908915 global $wgContLang;
909916
910917 $editurl = '&section='.$section;
911 - $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl );
 918+ $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"';
 919+ $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint );
912920
913921 if( $wgContLang->isRTL() ) {
914922 $farside = 'left';
Index: trunk/phase3/includes/Parser.php
@@ -3020,6 +3020,8 @@
30213021 # strip out HTML
30223022 $canonized_headline = preg_replace( '/<.*?' . '>/','',$canonized_headline );
30233023 $tocline = trim( $canonized_headline );
 3024+ # Save headline for section edit hint before it's escaped
 3025+ $headline_hint = trim( $canonized_headline );
30243026 $canonized_headline = Sanitizer::escapeId( $tocline );
30253027 $refers[$headlineCount] = $canonized_headline;
30263028
@@ -3048,7 +3050,7 @@
30493051 if( $istemplate )
30503052 $head[$headlineCount] .= $sk->editSectionLinkForOther($templatetitle, $templatesection);
30513053 else
3052 - $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1);
 3054+ $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
30533055 }
30543056
30553057 # give headline the correct <h#> tag
Index: trunk/phase3/RELEASE-NOTES
@@ -676,6 +676,7 @@
677677 * (bug 5141) Gracefully handle the new account link when createaccount off
678678 * (bug 5150 and related) Fix missing ID attribute in HTML namespace selector
679679 * (bug 5152) Proper HTML escaping on subpage breadcrumbs
 680+* (bug 4855) Section edit links now have the section name in the title attribute.
680681
681682
682683 === Caveats ===
Index: trunk/phase3/languages/Messages.php
@@ -239,6 +239,7 @@
240240 'newmessageslink' => 'new messages',
241241 'newmessagesdifflink' => 'diff to penultimate revision',
242242 'editsection'=>'edit',
 243+'editsectionhint' => 'Edit section: $1',
243244 'toc' => 'Contents',
244245 'showtoc' => 'show',
245246 'hidetoc' => 'hide',

Status & tagging log