From a0a8b770cc385891b51abd73a0e32fdfa5223c50 Mon Sep 17 00:00:00 2001 From: Leo Koppelkamm Date: Wed, 13 Jul 2011 10:41:21 +0000 Subject: [PATCH] Render category links as an HTML list. Bug 12261. Based on patch by Thana & Bergi. It's removing the textual pipe separator, wrapping the links inside li elements and adding a left 1px border as separator. This makes it much easier to manipulate the list via JS or CSS and is also semantically correct --- includes/Skin.php | 13 +++++-------- languages/messages/MessagesEn.php | 2 -- maintenance/language/messageTypes.inc | 1 - maintenance/language/messages.inc | 1 - skins/CologneBlue.php | 2 +- skins/Nostalgia.php | 2 +- skins/common/shared.css | 21 +++++++++++++++++++++ 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index 20ba348052..87c1b02787 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -530,26 +530,23 @@ abstract class Skin { return ''; } - # Separator - $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) ); - // Use Unicode bidi embedding override characters, // to make sure links don't smash each other up in ugly ways. $dir = $wgContLang->getDir(); - $embed = ""; - $pop = ''; + $embed = "
  • "; + $pop = "
  • "; $allCats = $out->getCategoryLinks(); $s = ''; $colon = wfMsgExt( 'colon-separator', 'escapenoentities' ); if ( !empty( $allCats['normal'] ) ) { - $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop; + $t = $embed . implode( "{$pop} {$embed}" , $allCats['normal'] ) . $pop; $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) ); $s .= ''; + . $colon . '' . ''; } # Hidden categories @@ -564,7 +561,7 @@ abstract class Skin { $s .= "
    " . wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) . - $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop . + $colon . '' . '
    '; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index f831a9422e..b3f294dc0d 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -510,7 +510,6 @@ $preloadedMessages = array( 'accesskey-t-specialpages', 'accesskey-t-whatlinkshere', 'anonnotice', - 'catseparator', 'colon-separator', 'currentevents', 'currentevents-url', @@ -4293,7 +4292,6 @@ Please confirm that you really want to recreate this page.", 'confirm-unwatch-top' => 'Remove this page to your watchlist?', # Separators for various lists, etc. -'catseparator' => '|', # only translate this message to other languages if you have to change it 'semicolon-separator' => '; ', # only translate this message to other languages if you have to change it 'comma-separator' => ', ', # only translate this message to other languages if you have to change it 'colon-separator' => ': ', # only translate this message to other languages if you have to change it diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 01db6f34c9..caf62ccb21 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -378,7 +378,6 @@ $wgOptionalMessages = array( 'hebrew-calendar-m12-gen', 'version-api', 'version-svn-revision', - 'catseparator', 'semicolon-separator', 'comma-separator', 'colon-separator', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index b9decd6eec..f996d4d9fc 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -3192,7 +3192,6 @@ $wgMessageStructure = array( 'confirm-purge-bottom', ), 'separators' => array( - 'catseparator', 'semicolon-separator', 'comma-separator', 'colon-separator', diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index bc4fc7215a..859db2c794 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -77,7 +77,7 @@ class CologneBlueTemplate extends LegacyTemplate { $s .= ''; $s .= str_replace( '
    ', '', $this->otherLanguages() ); - $cat = $this->getSkin()->getCategoryLinks(); + $cat = ''; if( $cat ) { $s .= "
    $cat\n"; } diff --git a/skins/Nostalgia.php b/skins/Nostalgia.php index 24dc90bc60..c23e289bbe 100644 --- a/skins/Nostalgia.php +++ b/skins/Nostalgia.php @@ -54,7 +54,7 @@ class NostalgiaTemplate extends LegacyTemplate { $s .= '
    ' . $ol; } - $cat = $this->getSkin()->getCategoryLinks(); + $cat = ''; if( $cat ) { $s .= '
    ' . $cat; } diff --git a/skins/common/shared.css b/skins/common/shared.css index 3898b995d8..b08853c9b4 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -178,6 +178,27 @@ input#wpSummary { .thumbcaption { text-align: left; } .magnify { float: right; } +/** + * Categories + */ +#catlinks ul, #catlinks li { + display:inline; + margin: 0px; + list-style:none; + list-style-type:none; + list-style-image:none; +} + +#catlinks li { + padding: 0 .7em; + border-left: 1px solid #AAA; +} + +#catlinks li:first-child { + padding-left: .4em; + border-left: none; +} + /** * Hidden categories */ -- 2.20.1