make addPortletLink work with CologneBlue
authorMatmaRex <matma.rex@gmail.com>
Wed, 31 Oct 2012 21:52:40 +0000 (22:52 +0100)
committerMatmaRex <matma.rex@gmail.com>
Sun, 4 Nov 2012 15:28:44 +0000 (16:28 +0100)
To achieve this:
* remove the special-casing in mw.util
* use standard portlet ids to make existing scripts work

Change-Id: I4ac3bc143fc235f700144244b0ad5b1f681ae5b5

resources/mediawiki/mediawiki.util.js
skins/CologneBlue.php

index 4e515bc..0174325 100644 (file)
                        // just add it to the bottom of their 'sidebar' element as a fallback
                        switch ( mw.config.get( 'skin' ) ) {
                        case 'standard':
-                       case 'cologneblue':
                                $( '#quickbar' ).append( $link.after( '<br/>' ) );
                                return $link[0];
                        case 'nostalgia':
index c140e33..b81b1aa 100644 (file)
@@ -430,9 +430,10 @@ class CologneBlueTemplate extends BaseTemplate {
                        $qbmyoptions[$key] = null;
                }
 
-               $bar['qbedit'] = $qbedit;
-               $bar['qbpageoptions'] = $qbpageoptions;
-               $bar['qbmyoptions'] = $qbmyoptions;
+               // Use the closest reasonable name
+               $bar['cactions'] = $qbedit;
+               $bar['pageoptions'] = $qbpageoptions; // this is a non-standard portlet name, but nothing fits
+               $bar['personal'] = $qbmyoptions;
 
                return $bar;
        }
@@ -479,12 +480,9 @@ class CologneBlueTemplate extends BaseTemplate {
                $bar = array();
                foreach ( $orig_bar as $heading => $data ) {
                        if ( $heading == 'SEARCH' ) {
-                               $bar['qbfind'] = $this->searchForm( 'sidebar' );
+                               $bar['search'] = $this->searchForm( 'sidebar' );
                        } elseif ( $heading == 'TOOLBOX' ) {
-                               $bar['toolbox'] = $this->getToolbox();
-                       } elseif ( $heading == 'navigation' ) {
-                               // Use the navigation heading from standard sidebar as the "browse" section
-                               $bar['qbbrowse'] = $data;
+                               $bar['tb'] = $this->getToolbox();
                        } else {
                                $bar[$heading] = $data;
                        }
@@ -492,12 +490,22 @@ class CologneBlueTemplate extends BaseTemplate {
 
 
                // Output the sidebar
+               // CologneBlue uses custom messages for some portlets, but we should keep the ids for consistency
+               $idToMessage = array(
+                       'search' => 'qbfind',
+                       'navigation' => 'qbbrowse',
+                       'tb' => 'toolbox',
+                       'cactions' => 'qbedit',
+                       'personal' => 'qbmyoptions',
+                       'pageoptions' => 'qbpageoptions',
+               );
+
                $s = "<div id='quickbar'>\n";
 
                foreach ( $bar as $heading => $data ) {
-                       $headingMsg = wfMessage( $heading );
-                       $headingHTML = "<h6>" . ( $headingMsg->exists() ? $headingMsg->escaped() : htmlspecialchars( $heading ) ) . "</h6>";
                        $portletId = Sanitizer::escapeId( "p-$heading" );
+                       $headingMsg = wfMessage( $idToMessage[$heading] ? $idToMessage[$heading] : $heading );
+                       $headingHTML = "<h6>" . ( $headingMsg->exists() ? $headingMsg->escaped() : htmlspecialchars( $heading ) ) . "</h6>";
                        $listHTML = "";
 
                        if ( is_array( $data ) ) {
@@ -517,7 +525,7 @@ class CologneBlueTemplate extends BaseTemplate {
                        }
 
                        if ( $listHTML ) {
-                               $role = ( $heading == 'qbfind' ) ? 'search' : 'navigation';
+                               $role = ( $heading == 'search' ) ? 'search' : 'navigation';
                                $s .= "<div class=\"portlet\" id=\"$portletId\" role=\"$role\">\n$headingHTML\n$listHTML\n</div>\n";
                        }
                }