Commit e57fac56 authored by drumm's avatar drumm

#65151 by m3avrck. theme_links() is now marked up as a list.

parent c0d00699
......@@ -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;
}
/**
......
......@@ -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;
}
......@@ -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>
......
......@@ -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;
......
......@@ -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";
......
......@@ -93,7 +93,7 @@ br {
.content {
margin: 0 0 .5em 0;
}
.links {
ul.links.inline {
font-size: 0.8em;
line-height: 1.25em;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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)
);
......
......@@ -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>
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment