Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -533,6 +533,17 @@ |
534 | 534 | $article: article (object) being viewed |
535 | 535 | $oldid: oldid (int) being viewed |
536 | 536 | |
| 537 | +'DoEditSectionLink': Override the HTML generated for section edit links |
| 538 | +$skin: Skin object rendering the UI |
| 539 | +$title: Title object for the title being linked to (may not be the same as |
| 540 | + $wgTitle, if the section is included from a template) |
| 541 | +$section: The designation of the section being pointed to, to be included in |
| 542 | + the link, like "§ion=$section" |
| 543 | +$tooltip: The default tooltip. Escape with htmlspecialchars() before using. |
| 544 | + By default, this is wrapped in the 'editsectionhint' message. |
| 545 | +$result: The HTML to return, prefilled with the default plus whatever other |
| 546 | + changes earlier hooks have made |
| 547 | + |
537 | 548 | 'EditFilter': Perform checks on an edit |
538 | 549 | $editor: Edit form (see includes/EditPage.php) |
539 | 550 | $text: Contents of the edit box |
— | — | @@ -579,21 +590,13 @@ |
580 | 591 | &$editpage: The current EditPage object |
581 | 592 | &$buttons: Array of edit buttons "Save", "Preview", "Live", and "Diff" |
582 | 593 | |
583 | | -'EditSectionLink': Override the return value of Linker::editSectionLink() |
| 594 | +'EditSectionLink': Do not use, use DoEditSectionLink instead. |
584 | 595 | $skin: Skin rendering the UI |
585 | 596 | $title: Title being linked to |
586 | 597 | $section: Section to link to |
587 | 598 | $link: Default link |
588 | 599 | $result: Result (alter this to override the generated links) |
589 | 600 | |
590 | | -'EditSectionLinkForOther': Override the return value of Linker::editSectionLinkForOther() |
591 | | -$skin: Skin rendering the UI |
592 | | -$title: Title being linked to |
593 | | -$section: Section to link to |
594 | | -$hint: Anchor title/tooltip attributes |
595 | | -$link: Default link |
596 | | -$result: Result (alter this to override the generated links) |
597 | | - |
598 | 601 | 'EmailConfirmed': When checking that the user's email address is "confirmed" |
599 | 602 | $user: User being checked |
600 | 603 | $confirmed: Whether or not the email address is confirmed |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -3609,9 +3609,9 @@ |
3610 | 3610 | if( $isTemplate ) { |
3611 | 3611 | # Put a T flag in the section identifier, to indicate to extractSections() |
3612 | 3612 | # that sections inside <includeonly> should be counted. |
3613 | | - $editlink = $sk->editSectionLinkForOther($titleText, "T-$sectionIndex"); |
| 3613 | + $editlink = $sk->doEditSectionLink(Title::newFromText( $titleText ), "T-$sectionIndex"); |
3614 | 3614 | } else { |
3615 | | - $editlink = $sk->editSectionLink($this->mTitle, $sectionIndex, $headlineHint); |
| 3615 | + $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint); |
3616 | 3616 | } |
3617 | 3617 | } else { |
3618 | 3618 | $editlink = ''; |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -1276,6 +1276,7 @@ |
1277 | 1277 | * @param $section Integer: section number. |
1278 | 1278 | */ |
1279 | 1279 | public function editSectionLinkForOther( $title, $section ) { |
| 1280 | + wfDeprecated( __METHOD__ ); |
1280 | 1281 | $title = Title::newFromText( $title ); |
1281 | 1282 | return $this->doEditSectionLink( $title, $section, '', 'EditSectionLinkForOther' ); |
1282 | 1283 | } |
— | — | @@ -1286,48 +1287,55 @@ |
1287 | 1288 | * @param $hint Link String: title, or default if omitted or empty |
1288 | 1289 | */ |
1289 | 1290 | public function editSectionLink( Title $nt, $section, $hint='' ) { |
1290 | | - if( $hint != '' ) { |
1291 | | - $hint = wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ); |
1292 | | - $hint = " title=\"$hint\""; |
1293 | | - } |
| 1291 | + wfDeprecated( __METHOD__ ); |
1294 | 1292 | return $this->doEditSectionLink( $nt, $section, $hint, 'EditSectionLink' ); |
1295 | 1293 | } |
1296 | 1294 | |
1297 | 1295 | /** |
1298 | | - * Implement editSectionLink and editSectionLinkForOther. |
| 1296 | + * Create a section edit link. This supersedes editSectionLink() and |
| 1297 | + * editSectionLinkForOther(). |
1299 | 1298 | * |
1300 | | - * @param $nt Title object |
1301 | | - * @param $section Integer, section number |
1302 | | - * @param $hint String, for HTML title attribute |
1303 | | - * @param $hook String, name of hook to run |
1304 | | - * @return String, HTML to use for edit link |
| 1299 | + * @param $nt Title The title being linked to (may not be the same as |
| 1300 | + * $wgTitle, if the section is included from a template) |
| 1301 | + * @param $section string The designation of the section being pointed to, |
| 1302 | + * to be included in the link, like "§ion=$section" |
| 1303 | + * @param $tooltip string The tooltip to use for the link: will be escaped |
| 1304 | + * and wrapped in the 'editsectionhint' message |
| 1305 | + * @return string HTML to use for edit link |
1305 | 1306 | */ |
1306 | | - protected function doEditSectionLink( Title $nt, $section, $hint, $hook ) { |
1307 | | - global $wgContLang; |
1308 | | - $editurl = '§ion='.$section; |
| 1307 | + public function doEditSectionLink( Title $nt, $section, $tooltip='' ) { |
| 1308 | + $attribs = ''; |
| 1309 | + if( $tooltip ) { |
| 1310 | + $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchars( $tooltip ) ); |
| 1311 | + $attribs = " title=\"$attribs\""; |
| 1312 | + } |
| 1313 | + |
1309 | 1314 | $url = $this->makeKnownLinkObj( |
1310 | 1315 | $nt, |
1311 | 1316 | htmlspecialchars(wfMsg('editsection')), |
1312 | | - 'action=edit'.$editurl, |
1313 | | - '', '', '', $hint |
| 1317 | + "action=edit§ion=$section", |
| 1318 | + '', '', '', $attribs |
1314 | 1319 | ); |
| 1320 | + |
| 1321 | + # Run the old hook |
1315 | 1322 | $result = null; |
1316 | | - |
1317 | | - // The two hooks have slightly different interfaces . . . |
1318 | | - if( $hook == 'EditSectionLink' ) { |
1319 | | - wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $hint, $url, &$result ) ); |
1320 | | - } elseif( $hook == 'EditSectionLinkForOther' ) { |
1321 | | - wfRunHooks( 'EditSectionLinkForOther', array( &$this, $nt, $section, $url, &$result ) ); |
| 1323 | + wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $url, &$result ) ); |
| 1324 | + if( !is_null( $result ) ) { |
| 1325 | + # For reverse compatibility, add the brackets *after* the hook is |
| 1326 | + # run, and even add them to hook-provided text. (This is the main |
| 1327 | + # reason that the EditSectionLink hook is deprecated in favor of |
| 1328 | + # DoEditSectionLink: it can't change the brackets or the span.) |
| 1329 | + $result = wfMsgHtml( 'editsection-brackets', $url ); |
| 1330 | + return "<span class=\"editsection\">$result</span>"; |
1322 | 1331 | } |
1323 | 1332 | |
1324 | | - // For reverse compatibility, add the brackets *after* the hook is run, |
1325 | | - // and even add them to hook-provided text. |
1326 | | - if( is_null( $result ) ) { |
1327 | | - $result = wfMsgHtml( 'editsection-brackets', $url ); |
1328 | | - } else { |
1329 | | - $result = wfMsgHtml( 'editsection-brackets', $result ); |
1330 | | - } |
1331 | | - return "<span class=\"editsection\">$result</span>"; |
| 1333 | + # Add the brackets and the span, and *then* run the nice new hook, with |
| 1334 | + # clean and non-redundant arguments. |
| 1335 | + $result = wfMsgHtml( 'editsection-brackets', $url ); |
| 1336 | + $result = "<span class=\"editsection\">$result</span>"; |
| 1337 | + |
| 1338 | + wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result ) ); |
| 1339 | + return $result; |
1332 | 1340 | } |
1333 | 1341 | |
1334 | 1342 | /** |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -29,6 +29,11 @@ |
30 | 30 | * (bug 8068) New __INDEX__ and __NOINDEX__ magic words allow user control of |
31 | 31 | search engine indexing on a per-article basis. |
32 | 32 | * Handheld stylesheet options |
| 33 | +* Added 'DoEditSectionLink' hook as a cleaner unified version of the old |
| 34 | + 'EditSectionLink' and 'EditSectionLinkForOther' hooks. Note that the |
| 35 | + 'EditSectionLinkForOther' hook has been removed, but 'EditSectionLink' is |
| 36 | + run in all cases instead, so extensions using the old hooks should still work |
| 37 | + if they ran roughly the same code for both hooks (as is almost certain). |
33 | 38 | |
34 | 39 | === Bug fixes in 1.14 === |
35 | 40 | |