function node_filter_form in Drupal 5
Same name and namespace in other branches
- 4 modules/node.module \node_filter_form()
- 6 modules/node/node.admin.inc \node_filter_form()
- 7 modules/node/node.admin.inc \node_filter_form()
Return form for node administration filters.
1 string reference to 'node_filter_form'
- node_admin_content in modules/
node/ node.module - Menu callback: content administration.
File
- modules/
node/ node.module, line 1463 - The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.
Code
function node_filter_form() {
$session =& $_SESSION['node_overview_filter'];
$session = is_array($session) ? $session : array();
$filters = node_filters();
$i = 0;
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Show only items where'),
'#theme' => 'node_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 {
$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,
)),
);
if ($type == 'type') {
// Remove the type option if it is already being filtered on.
unset($filters['type']);
}
}
foreach ($filters as $key => $filter) {
$names[$key] = $filter['title'];
$form['filters']['status'][$key] = array(
'#type' => 'select',
'#options' => $filter['options'],
);
}
$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;
}