From: MatmaRex Date: Wed, 26 Sep 2012 16:18:39 +0000 (+0200) Subject: CologneBlue rewrite: finally a proper sidebar using standard functions X-Git-Tag: 1.31.0-rc.0~22162^2 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=5a632613a3e13221e74b35f9357e4e6173b2b1e2;p=lhc%2Fweb%2Fwiklou.git CologneBlue rewrite: finally a proper sidebar using standard functions We use standard functions, then mangle the results slightly to get something that greatly resembles the old quickbar. The changes caused several items to be reworded, which is good for consistency. This causes disappearance of two links: * "Editing help" link in "Edit" menu - good riddance * "Printable version" link in "This page" menu - we can do without it, it's present in toolbox This causes appearance of two new links: * "+" (new section) in "Edit" menu * "Page" or "Discussion" in "This page" menu; previously only one of them would be shown Change-Id: I13b76a4dab27eba3eaf8cccf72199cad5f8e26db --- diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 6fd79f4cac..d6086af160 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -722,6 +722,8 @@ class CologneBlueTemplate extends BaseTemplate { /** * @param $heading string * @return string + * + * @fixed */ function menuHead( $heading ) { return "\n
" . htmlspecialchars( $heading ) . "
"; @@ -732,111 +734,111 @@ class CologneBlueTemplate extends BaseTemplate { * @access private * * @return string + * + * @fixed */ function quickBar(){ $s = "\n
"; $sep = "
\n"; - $bar = $this->data['sidebar']; - - // Always display search on top - $s .= $this->menuHead( wfMessage( 'qbfind' )->text() ); - $s .= $this->searchForm( 'sidebar' ); + $plain_bar = $this->data['sidebar']; + $bar = array(); - // Populate the toolbox - if ( isset( $bar['TOOLBOX'] ) ) { - $bar['TOOLBOX'] = $this->getToolbox(); - } - - foreach ( $bar as $heading => $browseLinks ) { - if ( $heading == 'SEARCH' || $heading == 'LANGUAGES' ) { - // discard these: - // * we display search unconditionally, on top - // * we display languages below page content - } else { - // Use the navigation heading from standard sidebar as the "browse" section - if ( $heading == 'navigation' ) { - $heading = 'qbbrowse'; - } + // Massage the sidebar + // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing) + $additions_done = false; + while ( !$additions_done ) { + $bar = array(); // Empty it out + + // Always display search on top + $bar['SEARCH'] = true; + foreach ( $plain_bar as $heading => $links ) { if ( $heading == 'TOOLBOX' ) { - $heading = 'toolbox'; - } - - $headingMsg = wfMessage( $heading ); - $s .= $this->menuHead( $headingMsg->exists() ? $headingMsg->text() : $heading ); - - if( is_array( $browseLinks ) ) { - foreach ( $browseLinks as $key => $link ) { - $s .= $this->makeLink( $key, $link ) . $sep; + if( $links !== NULL ) { + // If this is not a toolbox prosthetic we inserted outselves, fill it out + $plain_bar['TOOLBOX'] = $this->getToolbox(); } + + // And insert the stuff + + // "This page" and "Edit" menus + // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'], + // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose. + // We also don't use $...['variants'], these are displayed in the top menu. + $content_navigation = $this->data['content_navigation']; + $qbpageoptions = array_merge( + $content_navigation['namespaces'], + array( + 'history' => $content_navigation['views']['history'], + 'watch' => $content_navigation['actions']['watch'], + 'unwatch' => $content_navigation['actions']['unwatch'], + ) + ); + $content_navigation['actions']['watch'] = null; + $content_navigation['actions']['unwatch'] = null; + $qbedit = array_merge( + array( + 'edit' => $content_navigation['views']['edit'], + 'addsection' => $content_navigation['views']['addsection'], + ), + $content_navigation['actions'] + ); + $bar['qbedit'] = $qbedit; + $bar['qbpageoptions'] = $qbpageoptions; + + // Personal tools ("My pages") + $bar['qbmyoptions'] = $this->getPersonalTools(); + + $additions_done = true; } - } - } - - $user = $this->getSkin()->getUser(); - - if ( $this->data['isarticle'] ) { - $s .= $this->menuHead( wfMessage( 'qbedit' )->text() ); - $s .= '' . $this->editThisPage() . ''; - - $s .= $sep . Linker::linkKnown( - Title::newFromText( wfMessage( 'edithelppage' )->inContentLanguage()->text() ), - wfMessage( 'edithelp' )->text() - ); - - if( $this->data['loggedin'] ) { - $s .= $sep . $this->moveThisPage(); - } - if ( $user->isAllowed( 'delete' ) ) { - $dtp = $this->deleteThisPage(); - if ( $dtp != '' ) { - $s .= $sep . $dtp; - } - } - if ( $user->isAllowed( 'protect' ) ) { - $ptp = $this->protectThisPage(); - if ( $ptp != '' ) { - $s .= $sep . $ptp; + + // Re-insert current heading, unless it's SEARCH + if ( $heading != 'SEARCH' ) { + $bar[$heading] = $plain_bar[$heading]; } } - $s .= $sep; - - $s .= $this->menuHead( wfMessage( 'qbpageoptions' )->text() ); - $s .= $this->talkLink() - . $sep . $this->historyLink() - . $sep . $this->printableLink(); - if ( $this->data['loggedin'] ) { - $s .= $sep . $this->watchThisPage(); - } - - $s .= $sep; + // If TOOLBOX is missing, $additions_done is still false + if ( !$additions_done ) { + $plain_bar['TOOLBOX'] = false; + } } - - $s .= $this->menuHead( wfMessage( 'qbmyoptions' )->text() ); - if ( $this->data['loggedin'] ) { - $tl = Linker::linkKnown( - $user->getTalkPage(), - wfMessage( 'mytalk' )->escaped() - ); - if ( $user->getNewtalk() ) { - $tl .= ' *'; + + foreach ( $bar as $heading => $links ) { + if ( $heading == 'SEARCH' ) { + $s .= $this->menuHead( wfMessage( 'qbfind' )->text() ); + $s .= $this->searchForm( 'sidebar' ); + } elseif ( $heading == 'LANGUAGES' ) { + // discard these; we display languages below page content + } else { + if ( $links ) { + // Use the navigation heading from standard sidebar as the "browse" section + if ( $heading == 'navigation' ) { + $heading = 'qbbrowse'; + } + if ( $heading == 'TOOLBOX' ) { + $heading = 'toolbox'; + } + + $headingMsg = wfMessage( $heading ); + $any_link = false; + $t = $this->menuHead( $headingMsg->exists() ? $headingMsg->text() : $heading ); + + foreach ( $links as $key => $link ) { + // Can be empty due to rampant sidebar massaging we're doing above + if ( $link ) { + $any_link = true; + $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep; + } + } + + if ( $any_link ) { + $s .= $t; + } + } } - - $s .= Linker::linkKnown( - $user->getUserPage(), - wfMessage( 'mypage' )->escaped() - ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' ) - . $sep . - Linker::linkKnown( - SpecialPage::getSafeTitleFor( 'Contributions', $user->getName() ), - wfMessage( 'mycontris' )->escaped() - ) . $sep . Linker::specialLink( 'Preferences' ) - . $sep . Linker::specialLink( 'Userlogout' ); - } else { - $s .= Linker::specialLink( 'Userlogin' ); } $s .= $sep . "\n
\n";