Skip to content
Snippets Groups Projects
Commit e57fac56 authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

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

parent c0d00699
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -499,35 +499,53 @@ function theme_status_messages($display = NULL) { ...@@ -499,35 +499,53 @@ function theme_status_messages($display = NULL) {
* *
* @param $links * @param $links
* A keyed array of links to be themed. * A keyed array of links to be themed.
* @param $delimiter * @param $attributes
* A string used to separate the links. * A keyed array of attributes
* @return * @return
* A string containing the themed links. * A string containing an unordered list of links.
*/ */
function theme_links($links, $delimiter = ' | ') { function theme_links($links, $attributes = array('class' => 'links')) {
$output = array(); $output = '';
if (is_array($links)) { if (is_array($links)) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) { 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'])) { if (isset($link['attributes']) && isset($link['attributes']['class'])) {
$link['attributes']['class'] .= ' '. str_replace('_', '-', $key); $link['attributes']['class'] .= ' ' . $key;
$class = $key;
} }
else { 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']) { 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']) { else if ($link['title']) {
//Some links are actually not links, but we wrap these in <span> for adding title and class attributes //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 { ...@@ -32,3 +32,15 @@ li a.active {
td.menu-disabled { td.menu-disabled {
background: #ccc; 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 @@ ...@@ -19,8 +19,8 @@
<?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?> <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
</td> </td>
<td id="menu"> <td id="menu">
<?php if (isset($secondary_links)) { ?><div id="secondary"><?php print theme('links', $secondary_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)) { ?><div id="primary"><?php print theme('links', $primary_links) ?></div><?php } ?> <?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' =>'links', 'id' => 'navlist')) ?><?php } ?>
<?php print $search_box ?> <?php print $search_box ?>
</td> </td>
</tr> </tr>
......
...@@ -94,24 +94,30 @@ table { ...@@ -94,24 +94,30 @@ table {
text-align: right; text-align: right;
vertical-align: middle; vertical-align: middle;
} }
#primary { #navlist {
font-size: 1.0em; font-size: 1.0em;
padding: 0em 0.8em 0.5em 0; padding: 0 0.8em 1.2em 0;
color: #9cf; color: #9cf;
} }
#primary a { #navlist a {
font-weight: bold; font-weight: bold;
color: #fff; color: #fff;
} }
#secondary { #subnavlist {
padding: 0 1em 0.5em 0; padding: 0.5em 1.2em 0.4em 0;
font-size: 0.8em; font-size: 0.8em;
color: #9cf; color: #9cf;
} }
#secondary a { #subnavlist a {
font-weight: bold; font-weight: bold;
color: #9cf; color: #9cf;
} }
ul.links li {
border-left: 1px solid #9cf;
}
ul.links li.first {
border: none;
}
#search .form-text, #search .form-submit { #search .form-text, #search .form-submit {
border: 1px solid #369; border: 1px solid #369;
font-size: 1.1em; font-size: 1.1em;
......
...@@ -55,15 +55,15 @@ function chameleon_page($content, $show_blocks = TRUE) { ...@@ -55,15 +55,15 @@ function chameleon_page($content, $show_blocks = TRUE) {
$output .= "</div>\n"; $output .= "</div>\n";
$primary_links = theme('links', menu_primary_links()); $primary_links = theme('links', menu_primary_links(), array('class' => 'links', 'id' => 'navlist'));
$secondary_links = theme('links', menu_secondary_links()); $secondary_links = theme('links', menu_secondary_links(), array('class' => 'links', 'id' => 'subnavlist'));
if (isset($primary_links) || isset($secondary_links)) { if (isset($primary_links) || isset($secondary_links)) {
$output .= ' <div class="navlinks">'; $output .= ' <div class="navlinks">';
if (isset($primary_links)) { if (isset($primary_links)) {
$output .= '<div class="primary">'. $primary_links .'</div>'; $output .= $primary_links;
} }
if (isset($secondary_links)) { if (isset($secondary_links)) {
$output .= '<div class="secondary">'. $secondary_links .'</div>'; $output .= $secondary_links;
} }
$output .= " </div>\n"; $output .= " </div>\n";
} }
...@@ -150,7 +150,7 @@ function chameleon_node($node, $teaser = 0, $page = 0) { ...@@ -150,7 +150,7 @@ function chameleon_node($node, $teaser = 0, $page = 0) {
$links = array_merge($links, $node->links); $links = array_merge($links, $node->links);
} }
if (count($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"; $output .= "</div>\n";
......
...@@ -93,7 +93,7 @@ br { ...@@ -93,7 +93,7 @@ br {
.content { .content {
margin: 0 0 .5em 0; margin: 0 0 .5em 0;
} }
.links { ul.links.inline {
font-size: 0.8em; font-size: 0.8em;
line-height: 1.25em; line-height: 1.25em;
} }
......
...@@ -45,6 +45,15 @@ table { ...@@ -45,6 +45,15 @@ table {
#header .title { #header .title {
padding-top: .75em; 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 ** Common declarations for child classes of node, comment, block, box etc
...@@ -65,7 +74,7 @@ table { ...@@ -65,7 +74,7 @@ table {
padding-left: 1em; padding-left: 1em;
} }
.node .links { .node .links {
padding: 1em; padding: 1em 0 1em 0.2em;
} }
.comment { .comment {
border: solid 1px #777; border: solid 1px #777;
......
...@@ -55,6 +55,15 @@ ul { ...@@ -55,6 +55,15 @@ ul {
margin-top: -0.1em; margin-top: -0.1em;
font-size: 0.8em; 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 { .node .title {
font-size: 1.2em; font-size: 1.2em;
} }
...@@ -68,10 +77,10 @@ ul { ...@@ -68,10 +77,10 @@ ul {
.node .title a:hover { .node .title a:hover {
text-decoration: underline; text-decoration: underline;
} }
.links { div.links {
margin: 1em 0 3em 0; margin: 1em 0 3em 0;
text-align: right; text-align: right;
} }
.comment .content, .block .content, .menu { .comment .content, .block .content, .menu {
font-size: 0.9em; font-size: 0.9em;
} }
......
...@@ -269,14 +269,14 @@ function phptemplate_node($node, $teaser = 0, $page = 0) { ...@@ -269,14 +269,14 @@ function phptemplate_node($node, $teaser = 0, $page = 0) {
$variables = array( $variables = array(
'content' => ($teaser && $node->teaser) ? $node->teaser : $node->body, 'content' => ($teaser && $node->teaser) ? $node->teaser : $node->body,
'date' => format_date($node->created), '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), 'name' => theme('username', $node),
'node' => $node, // we pass the actual node to allow more customization 'node' => $node, // we pass the actual node to allow more customization
'node_url' => url('node/'. $node->nid), 'node_url' => url('node/'. $node->nid),
'page' => $page, 'page' => $page,
'taxonomy' => $taxonomy, 'taxonomy' => $taxonomy,
'teaser' => $teaser, 'teaser' => $teaser,
'terms' => theme('links', $taxonomy), 'terms' => theme('links', $taxonomy, array('class' => 'links inline')),
'title' => check_plain($node->title) 'title' => check_plain($node->title)
); );
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<?php endif;?> <?php endif;?>
</td> </td>
<td class="primary-links" width="70%" align="center" valign="middle"> <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> </td>
</tr> </tr>
</table> </table>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<table id="secondary-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%"> <table id="secondary-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
<tr> <tr>
<td class="secondary-links" width="75%" align="center" valign="middle"> <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>
<td width="25%" align="center" valign="middle"> <td width="25%" align="center" valign="middle">
<?php print $search_box ?> <?php print $search_box ?>
...@@ -99,14 +99,10 @@ ...@@ -99,14 +99,10 @@
<tr> <tr>
<td align="center" valign="middle"> <td align="center" valign="middle">
<?php if (isset($primary_links)) : ?> <?php if (isset($primary_links)) : ?>
<div class="primary-links"> <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
<?php print theme('links', $primary_links) ?>
</div>
<?php endif; ?> <?php endif; ?>
<?php if (isset($secondary_links)) : ?> <?php if (isset($secondary_links)) : ?>
<div class="secondary-links"> <?php print theme('links', $secondary_links, array('class' => 'links secondary-links',)) ?>
<?php print theme('links', $secondary_links) ?>
</div>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
......
...@@ -125,6 +125,18 @@ td#home a:hover img { ...@@ -125,6 +125,18 @@ td#home a:hover img {
#secondary-menu .secondary-links { #secondary-menu .secondary-links {
font-size: 0.85em; 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 { .tabs {
margin: 15px 0; margin: 15px 0;
} }
...@@ -362,11 +374,8 @@ table#footer-menu { ...@@ -362,11 +374,8 @@ table#footer-menu {
color: #999; color: #999;
font-size: 0.79em; font-size: 0.79em;
} }
.links { div.links {
color: #ff8c00; color: #ff8c00;
font-size: 0.8em;
padding: 0;
margin: 0;
} }
.links a { .links a {
font-weight: bold; font-weight: bold;
...@@ -436,10 +445,10 @@ table#footer-menu { ...@@ -436,10 +445,10 @@ table#footer-menu {
float: right; float: right;
margin: 10px; margin: 10px;
} }
.links { div.links {
font-size: 0.75em; font-size: 0.75em;
} }
.links .prev, .links .next, .links .up { div.links .prev, div.links .next, div.links .up {
font-size: 1.15em; font-size: 1.15em;
} }
.titles .prev, .titles .next { .titles .prev, .titles .next {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment