Merge "(bug 40857) fix non-array sidebar links handling in CologneBlue"
authorIAlex <ialex.wiki@gmail.com>
Sat, 20 Oct 2012 20:05:45 +0000 (20:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 20 Oct 2012 20:05:45 +0000 (20:05 +0000)
1  2 
skins/CologneBlue.php

diff --combined skins/CologneBlue.php
@@@ -43,7 -43,7 +43,7 @@@ class SkinCologneBlue extends SkinTempl
                $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
                $out->addModuleStyles( 'skins.cologneblue' );
        }
 -      
 +
        /**
         * Override langlink formatting behavior not to uppercase the language names.
         * See otherLanguages() in CologneBlueTemplate.
@@@ -64,6 -64,7 +64,6 @@@ class CologneBlueTemplate extends BaseT
                $this->printTrail();
                echo "\n</body></html>";
        }
 -      
  
        /**
         * Language/charset variant links for classic-style skins
@@@ -82,7 -83,7 +82,7 @@@
  
                return $this->getSkin()->getLanguage()->pipeList( $s );
        }
 -      
 +
        // @fixed
        function otherLanguages() {
                global $wgHideInterlanguageLinks;
        function pageTitleLinks() {
                $s = array();
                $footlinks = $this->getFooterLinks();
 -              
 +
                foreach ( $footlinks['places'] as $item ) {
                        $s[] = $this->data[$item];
                }
 -              
 +
                return $this->getSkin()->getLanguage()->pipeList( $s );
        }
  
  
                return $s;
        }
 -      
 +
        /**
         * @return string
 -       * 
 +       *
         * @fixed
         */
        function beforeContent() {
                        </a>
                </p>
                <p id="sitesub"><?php echo wfMessage( 'sitesubtitle' )->escaped() ?></p>
 -              
                <div id="toplinks">
                        <p id="syslinks"><?php echo $this->sysLinks() ?></p>
                        <p id="variantlinks"><?php echo $this->variantLinks() ?></p>
  <?php
                $s = ob_get_contents();
                ob_end_clean();
 -              
 +
                return $s;
        }
  
        /**
         * @return string
 -       * 
 +       *
         * @fixed
         */
        function afterContent() {
                // Page-related links
                echo $this->bottomLinks();
                echo "\n<br />";
 -              
 +
                // Footer and second searchbox
                echo $this->getSkin()->getLanguage()->pipeList( array(
                        $this->getSkin()->mainPageLink(),
                        $this->searchForm( 'footer' )
                ) );
                echo "\n<br />";
 -              
 +
                // Standard footer info
                $footlinks = $this->getFooterLinks();
                if ( $footlinks['info'] ) {
  
        /**
         * @return string
 -       * 
 +       *
         * @fixed
         */
        function sysLinks() {
                return $this->getSkin()->getLanguage()->pipeList( $s );
        }
  
 -
 -
 -      
        /**
         * @param $heading string
         * @return string
 -       * 
 +       *
         * @fixed
         */
        function menuHead( $heading ) {
         * @access private
         *
         * @return string
 -       * 
 +       *
         * @fixed
         */
        function quickBar(){
                $s = "\n<div id='quickbar'>";
  
                $sep = "<br />\n";
 -              
 +
                $plain_bar = $this->data['sidebar'];
                $bar = array();
 -              
 +
                // 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' ) {
                                        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.
                                        );
                                        $bar['qbedit'] = $qbedit;
                                        $bar['qbpageoptions'] = $qbpageoptions;
 -                                      
 +
                                        // Personal tools ("My pages")
                                        $bar['qbmyoptions'] = $this->getPersonalTools();
                                        foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
-                                               $bar['qbmyoptions'][$key] = false;
+                                               $bar['qbmyoptions'][$key] = null;
                                        }
 -                                      
 +
                                        $additions_done = true;
                                }
 -                              
 +
                                // Re-insert current heading, unless it's SEARCH
                                if ( $heading != 'SEARCH' ) {
                                        $bar[$heading] = $plain_bar[$heading];
                                }
                        }
 -                      
 +
                        // If TOOLBOX is missing, $additions_done is still false
                        if ( !$additions_done ) {
                                $plain_bar['TOOLBOX'] = false;
                        }
                }
 -              
 +
                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 ) {
+                       } elseif ( $links ) {
+                               if ( is_array( $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 ) {
                                                        $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
                                                }
                                        }
 -                                      
 +
                                        if ( $any_link ) {
                                                $s .= $t;
                                        }
+                               } else {
+                                       // $links can be a HTML string
+                                       $s .= $links;
                                }
                        }
                }
        /**
         * @param $label string
         * @return string
 -       * 
 +       *
         * @fixed
         */
        function searchForm( $which ) {
                        . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
  
                if( $wgUseTwoButtonsSearchForm ) {
 -                      $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
 +                      $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
                } else {
                        $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";
                }