From e57fac565a11a7350abebd26ec3a47c642330e7a Mon Sep 17 00:00:00 2001 From: Neil Drumm <drumm@3064.no-reply.drupal.org> Date: Wed, 30 Aug 2006 07:37:14 +0000 Subject: [PATCH] #65151 by m3avrck. theme_links() is now marked up as a list. --- includes/theme.inc | 40 ++++++++++++++----- modules/menu/menu.css | 12 ++++++ themes/bluemarine/page.tpl.php | 4 +- themes/bluemarine/style.css | 18 ++++++--- themes/chameleon/chameleon.theme | 10 ++--- themes/chameleon/common.css | 2 +- themes/chameleon/marvin/style.css | 11 ++++- themes/chameleon/style.css | 13 +++++- themes/engines/phptemplate/phptemplate.engine | 4 +- themes/pushbutton/page.tpl.php | 12 ++---- themes/pushbutton/style.css | 21 +++++++--- 11 files changed, 103 insertions(+), 44 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index 69c6957c6e07..10478d195aa9 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -499,35 +499,53 @@ function theme_status_messages($display = NULL) { * * @param $links * A keyed array of links to be themed. - * @param $delimiter - * A string used to separate the links. + * @param $attributes + * A keyed array of attributes * @return - * A string containing the themed links. + * A string containing an unordered list of links. */ -function theme_links($links, $delimiter = ' | ') { - $output = array(); +function theme_links($links, $attributes = array('class' => 'links')) { + $output = ''; if (is_array($links)) { + $output = '<ul'. drupal_attributes($attributes) .'>'; + + $num_links = count($links); + $i = 1; + foreach ($links as $key => $link) { - // Automatically add a class to each link and convert all _ to - for XHTML compliance + $class = ''; + + // Automatically add a class to each link and also to each LI if (isset($link['attributes']) && isset($link['attributes']['class'])) { - $link['attributes']['class'] .= ' '. str_replace('_', '-', $key); + $link['attributes']['class'] .= ' ' . $key; + $class = $key; } else { - $link['attributes']['class'] = str_replace('_', '-', $key); + $link['attributes']['class'] = $key; + $class = $key; } + // Add first and last classes to the list of links to help out themers + $extra_class = ($i == 1) ? 'first ' : (($i == $num_links) ? 'last ' : ''); + $output .= '<li class="'. $extra_class . $class .'">'; + if ($link['href']) { - $output[] = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']); + $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']); } else if ($link['title']) { //Some links are actually not links, but we wrap these in <span> for adding title and class attributes - $output[] = '<span'. drupal_attributes($link['attributes']) .'>'. check_plain($link['title']) .'</span>'; + $output .= '<span'. drupal_attributes($link['attributes']) .'>'. check_plain($link['title']) .'</span>'; } + + $i++; + $output .= '</li>'; } + + $output .= '</ul>'; } - return implode($delimiter, $output); + return $output; } /** diff --git a/modules/menu/menu.css b/modules/menu/menu.css index 2ec4e314d560..d815cfdb250c 100644 --- a/modules/menu/menu.css +++ b/modules/menu/menu.css @@ -32,3 +32,15 @@ li a.active { td.menu-disabled { background: #ccc; } +ul.links { + margin: 0; + padding: 0; +} +ul.links.inline { + display: inline; +} +ul.links li { + display: inline; + list-style-type: none; + padding: 0 0.5em; +} diff --git a/themes/bluemarine/page.tpl.php b/themes/bluemarine/page.tpl.php index 88b255398926..5298c1d0ff7f 100644 --- a/themes/bluemarine/page.tpl.php +++ b/themes/bluemarine/page.tpl.php @@ -19,8 +19,8 @@ <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?> </td> <td id="menu"> - <?php if (isset($secondary_links)) { ?><div id="secondary"><?php print theme('links', $secondary_links) ?></div><?php } ?> - <?php if (isset($primary_links)) { ?><div id="primary"><?php print theme('links', $primary_links) ?></div><?php } ?> + <?php if (isset($secondary_links)) { ?><?php print theme('links', $secondary_links, array('class' =>'links', 'id' => 'subnavlist')) ?><?php } ?> + <?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' =>'links', 'id' => 'navlist')) ?><?php } ?> <?php print $search_box ?> </td> </tr> diff --git a/themes/bluemarine/style.css b/themes/bluemarine/style.css index 670882d7f432..48fde14bf07c 100644 --- a/themes/bluemarine/style.css +++ b/themes/bluemarine/style.css @@ -94,24 +94,30 @@ table { text-align: right; vertical-align: middle; } -#primary { +#navlist { font-size: 1.0em; - padding: 0em 0.8em 0.5em 0; + padding: 0 0.8em 1.2em 0; color: #9cf; } -#primary a { +#navlist a { font-weight: bold; color: #fff; } -#secondary { - padding: 0 1em 0.5em 0; +#subnavlist { + padding: 0.5em 1.2em 0.4em 0; font-size: 0.8em; color: #9cf; } -#secondary a { +#subnavlist a { font-weight: bold; color: #9cf; } +ul.links li { + border-left: 1px solid #9cf; +} +ul.links li.first { + border: none; +} #search .form-text, #search .form-submit { border: 1px solid #369; font-size: 1.1em; diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index ca67eaa4b073..086bf2128c1c 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -55,15 +55,15 @@ function chameleon_page($content, $show_blocks = TRUE) { $output .= "</div>\n"; - $primary_links = theme('links', menu_primary_links()); - $secondary_links = theme('links', menu_secondary_links()); + $primary_links = theme('links', menu_primary_links(), array('class' => 'links', 'id' => 'navlist')); + $secondary_links = theme('links', menu_secondary_links(), array('class' => 'links', 'id' => 'subnavlist')); if (isset($primary_links) || isset($secondary_links)) { $output .= ' <div class="navlinks">'; if (isset($primary_links)) { - $output .= '<div class="primary">'. $primary_links .'</div>'; + $output .= $primary_links; } if (isset($secondary_links)) { - $output .= '<div class="secondary">'. $secondary_links .'</div>'; + $output .= $secondary_links; } $output .= " </div>\n"; } @@ -150,7 +150,7 @@ function chameleon_node($node, $teaser = 0, $page = 0) { $links = array_merge($links, $node->links); } if (count($links)) { - $output .= " <div class=\"links\">". theme('links', $links) ."</div>\n"; + $output .= '<div class="links">'. theme('links', $links, array('class' => 'links inline')) ."</div>\n"; } $output .= "</div>\n"; diff --git a/themes/chameleon/common.css b/themes/chameleon/common.css index 14192d89d641..f1f213b8995b 100644 --- a/themes/chameleon/common.css +++ b/themes/chameleon/common.css @@ -93,7 +93,7 @@ br { .content { margin: 0 0 .5em 0; } -.links { +ul.links.inline { font-size: 0.8em; line-height: 1.25em; } diff --git a/themes/chameleon/marvin/style.css b/themes/chameleon/marvin/style.css index c24c7dd82e95..0e6b799f5bdc 100644 --- a/themes/chameleon/marvin/style.css +++ b/themes/chameleon/marvin/style.css @@ -45,6 +45,15 @@ table { #header .title { padding-top: .75em; } +#subnavlist { + font-size: 0.8em; +} +ul.links li { + border-left: 1px solid #888; +} +ul.links li.first { + border: none; +} /* ** Common declarations for child classes of node, comment, block, box etc @@ -65,7 +74,7 @@ table { padding-left: 1em; } .node .links { - padding: 1em; + padding: 1em 0 1em 0.2em; } .comment { border: solid 1px #777; diff --git a/themes/chameleon/style.css b/themes/chameleon/style.css index 33c34c6aa2ff..aee4706edfe7 100644 --- a/themes/chameleon/style.css +++ b/themes/chameleon/style.css @@ -55,6 +55,15 @@ ul { margin-top: -0.1em; font-size: 0.8em; } +#subnavlist { + font-size: 0.8em; +} +ul.links li { + border-left: 1px solid #000; +} +ul.links li.first { + border-left: none; +} .node .title { font-size: 1.2em; } @@ -68,10 +77,10 @@ ul { .node .title a:hover { text-decoration: underline; } -.links { +div.links { margin: 1em 0 3em 0; text-align: right; - } +} .comment .content, .block .content, .menu { font-size: 0.9em; } diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine index 831e35059dd1..a51501a042aa 100644 --- a/themes/engines/phptemplate/phptemplate.engine +++ b/themes/engines/phptemplate/phptemplate.engine @@ -269,14 +269,14 @@ function phptemplate_node($node, $teaser = 0, $page = 0) { $variables = array( 'content' => ($teaser && $node->teaser) ? $node->teaser : $node->body, 'date' => format_date($node->created), - 'links' => $node->links ? theme('links', $node->links) : '', + 'links' => $node->links ? theme('links', $node->links, array('class' => 'links inline')) : '', 'name' => theme('username', $node), 'node' => $node, // we pass the actual node to allow more customization 'node_url' => url('node/'. $node->nid), 'page' => $page, 'taxonomy' => $taxonomy, 'teaser' => $teaser, - 'terms' => theme('links', $taxonomy), + 'terms' => theme('links', $taxonomy, array('class' => 'links inline')), 'title' => check_plain($node->title) ); diff --git a/themes/pushbutton/page.tpl.php b/themes/pushbutton/page.tpl.php index cdfe447716ca..2a1e34184348 100644 --- a/themes/pushbutton/page.tpl.php +++ b/themes/pushbutton/page.tpl.php @@ -29,7 +29,7 @@ <?php endif;?> </td> <td class="primary-links" width="70%" align="center" valign="middle"> - <?php print theme('links', $primary_links) ?> + <?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?> </td> </tr> </table> @@ -37,7 +37,7 @@ <table id="secondary-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td class="secondary-links" width="75%" align="center" valign="middle"> - <?php print theme('links', $secondary_links) ?> + <?php print theme('links', $secondary_links, array('class' => 'links', 'id' => 'subnavlist')) ?> </td> <td width="25%" align="center" valign="middle"> <?php print $search_box ?> @@ -99,14 +99,10 @@ <tr> <td align="center" valign="middle"> <?php if (isset($primary_links)) : ?> - <div class="primary-links"> - <?php print theme('links', $primary_links) ?> - </div> + <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?> <?php endif; ?> <?php if (isset($secondary_links)) : ?> - <div class="secondary-links"> - <?php print theme('links', $secondary_links) ?> - </div> + <?php print theme('links', $secondary_links, array('class' => 'links secondary-links',)) ?> <?php endif; ?> </td> </tr> diff --git a/themes/pushbutton/style.css b/themes/pushbutton/style.css index 65068e3dae0a..47e9c286c8ec 100644 --- a/themes/pushbutton/style.css +++ b/themes/pushbutton/style.css @@ -125,6 +125,18 @@ td#home a:hover img { #secondary-menu .secondary-links { font-size: 0.85em; } +ul.links li { + border-left: 1px solid #ff8c00; +} +#navlist li { + border-left: 1px solid #369; +} +#subnavlist li, ul.primary-links li, ul.secondary-links li { + border-left: 1px solid #fff; +} +#navlist li.first, #subnavlist li.first, ul.links li.first { + border: none; +} .tabs { margin: 15px 0; } @@ -362,11 +374,8 @@ table#footer-menu { color: #999; font-size: 0.79em; } -.links { +div.links { color: #ff8c00; - font-size: 0.8em; - padding: 0; - margin: 0; } .links a { font-weight: bold; @@ -436,10 +445,10 @@ table#footer-menu { float: right; margin: 10px; } -.links { +div.links { font-size: 0.75em; } -.links .prev, .links .next, .links .up { +div.links .prev, div.links .next, div.links .up { font-size: 1.15em; } .titles .prev, .titles .next { -- GitLab