r98210 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98209‎ | r98210 | r98211 >
Date:05:31, 27 September 2011
Author:dantman
Status:ok (Comments)
Tags:
Comment:
Add getSidebar method to BaseTemplate to simplify the sidebar boilerplate.
Modified paths:
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -1501,6 +1501,92 @@
15021502 return $personal_tools;
15031503 }
15041504
 1505+ function getSidebar( $options = array() ) {
 1506+ // Force the rendering of the following portals
 1507+ $sidebar = $this->data['sidebar'];
 1508+ if ( !isset( $sidebar['SEARCH'] ) ) {
 1509+ $sidebar['SEARCH'] = true;
 1510+ }
 1511+ if ( !isset( $sidebar['TOOLBOX'] ) ) {
 1512+ $sidebar['TOOLBOX'] = true;
 1513+ }
 1514+ if ( !isset( $sidebar['LANGUAGES'] ) ) {
 1515+ $sidebar['LANGUAGES'] = true;
 1516+ }
 1517+
 1518+ if ( !isset( $options['search'] ) || $options['search'] !== true ) {
 1519+ unset( $sidebar['SEARCH'] );
 1520+ }
 1521+ if ( isset( $options['toolbox'] ) && $options['toolbox'] === false ) {
 1522+ unset( $sidebar['TOOLBOX'] );
 1523+ }
 1524+ if ( isset( $options['languages'] ) && $options['languages'] === false ) {
 1525+ unset( $sidebar['LANGUAGES'] );
 1526+ }
 1527+
 1528+ $boxes = array();
 1529+ foreach ( $sidebar as $boxName => $content ) {
 1530+ if ( $content === false ) {
 1531+ continue;
 1532+ }
 1533+ switch ( $boxName ) {
 1534+ case 'SEARCH':
 1535+ // Search is a special case, skins should custom implement this
 1536+ $boxes[$boxName] = array(
 1537+ 'id' => "p-search",
 1538+ 'header' => wfMessage( 'search' )->text(),
 1539+ 'generated' => false,
 1540+ 'content' => true,
 1541+ );
 1542+ break;
 1543+ case 'TOOLBOX':
 1544+ $msgObj = wfMessage( 'toolbox' );
 1545+ $boxes[$boxName] = array(
 1546+ 'id' => "p-tb",
 1547+ 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
 1548+ 'generated' => false,
 1549+ 'content' => $this->getToolbox(),
 1550+ );
 1551+ break;
 1552+ case 'LANGUAGES':
 1553+ if ( $this->data['language_urls'] ) {
 1554+ $msgObj = wfMessage( 'otherlanguages' );
 1555+ $boxes[$boxName] = array(
 1556+ 'id' => "p-lang",
 1557+ 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
 1558+ 'generated' => false,
 1559+ 'content' => $this->data['language_urls'],
 1560+ );
 1561+ }
 1562+ break;
 1563+ default:
 1564+ $msgObj = wfMessage( $boxName );
 1565+ $boxes[$boxName] = array(
 1566+ 'id' => "p-$boxName",
 1567+ 'header' => htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $boxName ),
 1568+ 'generated' => true,
 1569+ 'content' => $content,
 1570+ );
 1571+ break;
 1572+ }
 1573+ }
 1574+
 1575+ if ( !isset($options['withLists']) || $options['withLists'] !== true ) {
 1576+ foreach ( $boxes as $boxName => $box ) {
 1577+ if ( is_array( $box['content'] ) ) {
 1578+ $content = "<ul>";
 1579+ foreach ( $box['content'] as $key => $val ) {
 1580+ $content .= "\n " . $this->makeListItem( $key, $val );
 1581+ }
 1582+ $content .= "\n</ul>\n";
 1583+ $boxes[$boxName]['content'] = $content;
 1584+ }
 1585+ }
 1586+ }
 1587+
 1588+ return $boxes;
 1589+ }
 1590+
15051591 /**
15061592 * Makes a link, usually used by makeListItem to generate a link for an item
15071593 * in a list used in navigation lists, portlets, portals, sidebars, etc...

Follow-up revisions

RevisionCommit summaryAuthorDate
r98212Followup r98210; Add an ugly hack to support old extensions using the SkinTem...dantman07:58, 27 September 2011
r100746REL1_18 MFT r97815, r98069, r98210, r98212, 98298reedy21:33, 25 October 2011

Comments

#Comment by Reedy (talk | contribs)   03:05, 22 October 2011

Why are we backporting it to 1.18 to begin with? And also, why not 1.18wmf1 aswell?

Status & tagging log