function _biblio_sort_tabs in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 includes/biblio.pages.inc \_biblio_sort_tabs()
- 6 biblio.pages.inc \_biblio_sort_tabs()
1 call to _biblio_sort_tabs()
- biblio_page_header in includes/
biblio.pages.inc
File
- includes/
biblio.pages.inc, line 546
Code
function _biblio_sort_tabs() {
global $base_path;
$content = '';
$sort_links = array();
$tabs = variable_get('biblio_sort_tabs_style', 0);
$uri = drupal_parse_url(request_uri());
$uri['path'] = variable_get('biblio_base', 'biblio');
if (substr($uri['path'], 0, 1) == '/') {
$uri['path'] = substr($uri['path'], 1);
}
if (isset($uri['query']['s'])) {
$sort = $uri['query']['s'];
}
else {
$sort = variable_get('biblio_sort', 'year');
}
if (isset($uri['query']['o'])) {
$order = $uri['query']['o'] == 'desc' || $uri['query']['o'] == 'DESC' ? 'asc' : 'desc';
}
else {
$order = strtolower(variable_get('biblio_order', 'desc'));
$order = $order == 'desc' || $order == 'DESC' ? 'asc' : 'desc';
}
$path = drupal_get_path('module', 'biblio');
$order_arrow = $order == 'asc' ? '<img src ="' . $base_path . $path . '/misc/arrow-asc.png" alt =" (Desc)" />' : '<img src ="' . $base_path . $path . '/misc/arrow-desc.png" alt = " (Asc)" />';
$sort_links = variable_get('biblio_sort_tabs', array(
'author' => 'author',
'title' => 'title',
'type' => 'type',
'year' => 'year',
'keyword' => 'keyword',
));
ksort($sort_links);
$content .= $tabs ? '<ul class="tabs secondary ">' : '';
foreach ($sort_links as $key => $title) {
$uri['attributes'] = array(
"title" => t("Click a second time to reverse the sort order"),
);
$uri['html'] = TRUE;
$uri['text'] = t(ucfirst($title));
if ($key === $title && $title == $sort) {
$uri['query']['s'] = $title;
$uri['query']['o'] = $order;
$uri['attributes']['class'][] = "active";
$uri['active'] = TRUE;
$uri['pfx'] = ' [ ';
$uri['sfx'] = '] ';
$uri['arrow'] = $order_arrow;
$content .= _biblio_sort_tab($uri, $tabs);
}
elseif ($key === $title) {
$uri['query']['s'] = $title;
$uri['query']['o'] = $order;
$uri['active'] = FALSE;
$uri['pfx'] = ' ';
$uri['sfx'] = ' ';
$uri['arrow'] = '';
$content .= _biblio_sort_tab($uri, $tabs);
}
}
if (!$tabs) {
$content = t('Sort by') . ': ' . $content;
}
$content .= $tabs ? '</ul>' : '';
return $content;
}