r98212 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98211‎ | r98212 | r98213 >
Date:07:58, 27 September 2011
Author:dantman
Status:ok
Tags:
Comment:
Followup r98210; Add an ugly hack to support old extensions using the SkinTemplateToolboxEnd hook, erm... 'thanks' Tim.
((Also fix an extra htmlspecialchars that shouldn't have been there))
Modified paths:
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -1563,7 +1563,7 @@
15641564 $msgObj = wfMessage( $boxName );
15651565 $boxes[$boxName] = array(
15661566 'id' => "p-$boxName",
1567 - 'header' => htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $boxName ),
 1567+ 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
15681568 'generated' => true,
15691569 'content' => $content,
15701570 );
@@ -1571,17 +1571,59 @@
15721572 }
15731573 }
15741574
1575 - if ( !isset($options['withLists']) || $options['withLists'] !== true ) {
 1575+ // HACK: Compatibility with extensions still using SkinTemplateToolboxEnd
 1576+ $hookContents = null;
 1577+ if ( isset( $boxes['TOOLBOX'] ) ) {
 1578+ ob_start();
 1579+ // We pass an extra 'true' at the end so extensions using BaseTemplateToolbox
 1580+ // can abort and avoid outputting double toolbox links
 1581+ wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
 1582+ $hookContents = ob_get_contents();
 1583+ ob_end_clean();
 1584+ if ( !trim( $hookContents ) ) {
 1585+ $hookContents = null;
 1586+ }
 1587+ }
 1588+ // END hack
 1589+
 1590+ if ( isset( $options['htmlOnly'] ) && $options['htmlOnly'] === true ) {
15761591 foreach ( $boxes as $boxName => $box ) {
15771592 if ( is_array( $box['content'] ) ) {
15781593 $content = "<ul>";
15791594 foreach ( $box['content'] as $key => $val ) {
15801595 $content .= "\n " . $this->makeListItem( $key, $val );
15811596 }
 1597+ // HACK, shove the toolbox end onto the toolbox if we're rendering itself
 1598+ if ( $hookContents ) {
 1599+ $content .= "\n $hookContents";
 1600+ }
 1601+ // END hack
15821602 $content .= "\n</ul>\n";
15831603 $boxes[$boxName]['content'] = $content;
15841604 }
15851605 }
 1606+ } else {
 1607+ if ( $hookContents ) {
 1608+ $boxes['TOOLBOXEND'] = array(
 1609+ 'id' => "p-toolboxend",
 1610+ 'header' => $boxes['TOOLBOX']['header'],
 1611+ 'generated' => false,
 1612+ 'content' => "<ul>{$hookContents}</ul>",
 1613+ );
 1614+ // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
 1615+ $boxes2 = array();
 1616+ foreach ( $boxes as $key => $box ) {
 1617+ if ( $key === 'TOOLBOXEND' ) {
 1618+ continue;
 1619+ }
 1620+ $boxes2[$key] = $box;
 1621+ if ( $key === 'TOOLBOX' ) {
 1622+ $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
 1623+ }
 1624+ }
 1625+ $boxes = $boxes2;
 1626+ // END hack
 1627+ }
15861628 }
15871629
15881630 return $boxes;

Follow-up revisions

RevisionCommit summaryAuthorDate
r99370Followup r98212; Hook documentation.dantman19:42, 9 October 2011
r99371Followup r98212; Ensure that true is passed to all uses of SkinTemplateToolbo...dantman19:54, 9 October 2011
r100746REL1_18 MFT r97815, r98069, r98210, r98212, 98298reedy21:33, 25 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98210Add getSidebar method to BaseTemplate to simplify the sidebar boilerplate.dantman05:31, 27 September 2011

Status & tagging log