Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -1501,6 +1501,92 @@ |
1502 | 1502 | return $personal_tools; |
1503 | 1503 | } |
1504 | 1504 | |
| 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 | + |
1505 | 1591 | /** |
1506 | 1592 | * Makes a link, usually used by makeListItem to generate a link for an item |
1507 | 1593 | * in a list used in navigation lists, portlets, portals, sidebars, etc... |