function biblio_form_filter in Bibliography Module 5
Same name and namespace in other branches
- 6.2 includes/biblio.pages.inc \biblio_form_filter()
- 6 biblio.pages.inc \biblio_form_filter()
- 7 includes/biblio.pages.inc \biblio_form_filter()
- 7.2 includes/biblio.pages.inc \biblio_form_filter()
1 string reference to 'biblio_form_filter'
- biblio_menu in ./
biblio.module - Implementation of hook_menu().
File
- ./
biblio.module, line 1441
Code
function biblio_form_filter() {
$session =& $_SESSION['biblio_filter'];
$session = is_array($session) ? $session : array();
$filters = _get_biblio_filters();
$i = 0;
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Show only items where'),
'#theme' => 'biblio_filters',
);
foreach ($session as $filter) {
list($type, $value) = $filter;
if ($type == 'category') {
// Load term name from DB rather than search and parse options array.
$value = module_invoke('taxonomy', 'get_term', $value);
$value = $value->name;
}
else {
if ($type == 'keyword') {
$filters[$type]['title'] = 'Keyword';
}
else {
$value = $filters[$type]['options'][$value];
}
}
$string = $i++ ? '<em>and</em> where <strong>%a</strong> is <strong>%b</strong>' : '<strong>%a</strong> is <strong>%b</strong>';
$form['filters']['current'][] = array(
'#value' => t($string, array(
'%a' => $filters[$type]['title'],
'%b' => $value,
)),
);
}
foreach ($filters as $key => $filter) {
if (count($filter['options'])) {
$names[$key] = $filter['title'];
$form['filters']['status'][$key] = array(
'#type' => 'select',
'#options' => $filter['options'],
);
}
}
$form['filters']['status']['keyword'] = array(
'#type' => 'textfield',
'#size' => 25,
'#maxlength' => 255,
);
$names['keyword'] = "Keyword";
$form['filters']['filter'] = array(
'#type' => 'radios',
'#options' => $names,
'#default_value' => 'status',
);
$form['filters']['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => count($session) ? t('Refine') : t('Filter'),
);
if (count($session)) {
$form['filters']['buttons']['undo'] = array(
'#type' => 'submit',
'#value' => t('Undo'),
);
$form['filters']['buttons']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset'),
);
}
return $form;
}