function theme_biblio_alpha_line in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 includes/biblio_theme.inc \theme_biblio_alpha_line()
- 6 biblio_theme.inc \theme_biblio_alpha_line()
- 7 includes/biblio_theme.inc \theme_biblio_alpha_line()
This function creates a string of letters (A - Z), which depending on the sorting are either linked to author or title filters i.e. clicking on the A when in the listing is sorted by authors will bring up a list of all the entries where the first character of the primary authors last name is "A"
Parameters
$type either "author or title":
Return value
a chunk of HTML code as described above
3 theme calls to theme_biblio_alpha_line()
- biblio_page_header in includes/
biblio.pages.inc - _biblio_format_author_page in includes/
biblio.pages.inc - _biblio_format_keyword_page in includes/
biblio.pages.inc
File
- includes/
biblio.theme.inc, line 1018
Code
function theme_biblio_alpha_line($variables) {
$type = $variables['type'];
$all = '';
$uri = drupal_parse_url(request_uri());
$uri['path'] = $_GET['q'];
//replace path in case we are in a multi-language environment, otherwise we end up with double language prefixes.
if (substr($uri['path'], 0, 1) == '/') {
$uri['path'] = substr($uri['path'], 1);
}
$all_uri = $uri;
$current = '';
switch ($type) {
case 'authors':
$filter = 'author';
$current = isset($uri['query']['f']['author']) ? $uri['query']['f']['author'] : '';
unset($all_uri['query']['f']['author']);
break;
case 'keywords':
case 'keyword':
$filter = 'keyword';
$current = isset($uri['query']['f']['keyword']) ? $uri['query']['f']['keyword'] : '';
unset($all_uri['query']['f']['keyword']);
break;
case 'author':
$current = isset($uri['query']['f']['ag']) ? $uri['query']['f']['ag'] : '';
$filter = 'ag';
if (!isset($uri['query']['s'])) {
$uri['query']['s'] = 'author';
}
unset($all_uri['query']['f']['ag']);
break;
case 'title':
$current = isset($uri['query']['f']['tg']) ? $uri['query']['f']['tg'] : '';
$filter = 'tg';
unset($all_uri['query']['f']['tg']);
break;
default:
}
$output = '<div class="biblio-alpha-line">';
//TODO for Cyrillic use 1040 to 1071... e.g. Ь
for ($i = 65; $i <= 90; $i++) {
if ($i == ord($current)) {
$output .= '<b>[' . chr($i) . ']</b> ';
}
else {
$uri['query']['f'][$filter] = chr($i);
$output .= l(chr($i), $uri['path'], $uri) . ' ';
}
}
if ($current) {
if (empty($all_uri['query']['f'])) {
unset($all_uri['query']['f']);
}
$output .= ' ' . '[' . l(t('Show ALL'), $all_uri['path'], $all_uri) . ']';
}
$output .= '</div>';
return $output;
}