#551034 by brandonojc, mgifford, Everett Zufelt, and Cliff: Improved Content filter usability and accessibility.

merge-requests/26/head
Angie Byron 2009-11-03 04:35:01 +00:00
parent 2353d1413a
commit c6e2dfa573
4 changed files with 53 additions and 28 deletions

View File

@ -1,5 +1,12 @@
/* $Id$ */ /* $Id$ */
#node-admin-content dl.multiselect dd.b .form-item label {
display: block;
float: right;
width: 6em;
font-weight: normal;
}
#node-admin-buttons { #node-admin-buttons {
float: right; float: right;
margin-left: 0; margin-left: 0;

View File

@ -73,6 +73,7 @@ function node_filters() {
$filters['status'] = array( $filters['status'] = array(
'title' => t('status'), 'title' => t('status'),
'options' => array( 'options' => array(
'[any]' => t('any'),
'status-1' => t('published'), 'status-1' => t('published'),
'status-0' => t('not published'), 'status-0' => t('not published'),
'promote-1' => t('promoted'), 'promote-1' => t('promoted'),
@ -89,16 +90,31 @@ function node_filters() {
); );
} }
$filters['type'] = array('title' => t('type'), 'options' => node_type_get_names()); $filters['type'] = array(
'title' => t('type'),
'options' => array(
'[any]' => t('any'),
) + node_type_get_names(),
);
// The taxonomy filter // The taxonomy filter
if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) { if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
$filters['term'] = array('title' => t('term'), 'options' => $taxonomy); $filters['term'] = array(
'title' => t('term'),
'options' => array(
'[any]' => t('any'),
) + $taxonomy,
);
} }
// Language filter if there is a list of languages // Language filter if there is a list of languages
if ($languages = module_invoke('locale', 'language_list')) { if ($languages = module_invoke('locale', 'language_list')) {
$languages = array('' => t('Language neutral')) + $languages; $languages = array('' => t('Language neutral')) + $languages;
$filters['language'] = array('title' => t('language'), 'options' => $languages); $filters['language'] = array(
'title' => t('language'),
'options' => array(
'[any]' => t('any'),
) + $languages,
);
} }
return $filters; return $filters;
} }
@ -172,10 +188,14 @@ function node_filter_form() {
foreach ($filters as $key => $filter) { foreach ($filters as $key => $filter) {
$names[$key] = $filter['title']; $names[$key] = $filter['title'];
$form['filters']['status'][$key] = array('#type' => 'select', '#options' => $filter['options']); $form['filters']['status'][$key] = array(
'#type' => 'select',
'#options' => $filter['options'],
'#title' => $filter['title'],
'#default_value' => '[any]',
);
} }
$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'))); $form['filters']['buttons']['submit'] = array('#type' => 'submit', '#value' => (count($session) ? t('Refine') : t('Filter')));
if (count($session)) { if (count($session)) {
$form['filters']['buttons']['undo'] = array('#type' => 'submit', '#value' => t('Undo')); $form['filters']['buttons']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
@ -218,14 +238,11 @@ function theme_node_filters($variables) {
$output .= '<li>' . drupal_render($form['current'][$key]) . '</li>'; $output .= '<li>' . drupal_render($form['current'][$key]) . '</li>';
} }
} }
$output .= '</ul>';
$output .= '<li><dl class="multiselect">' . (!empty($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '') . '<dd class="a">'; $output .= '<dl class="multiselect">' . (!empty($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '');
foreach (element_children($form['filter']) as $key) {
$output .= drupal_render($form['filter'][$key]);
}
$output .= '</dd>';
$output .= '<dt>' . t('is') . '</dt><dd class="b">'; $output .= '<dd class="b">';
foreach (element_children($form['status']) as $key) { foreach (element_children($form['status']) as $key) {
$output .= drupal_render($form['status'][$key]); $output .= drupal_render($form['status'][$key]);
@ -234,7 +251,6 @@ function theme_node_filters($variables) {
$output .= '</dl>'; $output .= '</dl>';
$output .= '<div class="container-inline" id="node-admin-buttons">' . drupal_render($form['buttons']) . '</div>'; $output .= '<div class="container-inline" id="node-admin-buttons">' . drupal_render($form['buttons']) . '</div>';
$output .= '</li></ul>';
return $output; return $output;
} }
@ -247,14 +263,15 @@ function node_filter_form_submit($form, &$form_state) {
switch ($form_state['values']['op']) { switch ($form_state['values']['op']) {
case t('Filter'): case t('Filter'):
case t('Refine'): case t('Refine'):
if (isset($form_state['values']['filter'])) { // Apply every filter that has a choice selected other than 'any'.
$filter = $form_state['values']['filter']; foreach ($filters as $filter => $options) {
if (isset($form_state['values'][$filter]) && $form_state['values'][$filter] != '[any]') {
// Flatten the options array to accommodate hierarchical/nested options. // Flatten the options array to accommodate hierarchical/nested options.
$flat_options = form_options_flatten($filters[$filter]['options']); $flat_options = form_options_flatten($filters[$filter]['options']);
// Only accept valid selections offered on the dropdown, block bad input.
if (isset($flat_options[$form_state['values'][$filter]])) { if (isset($flat_options[$form_state['values'][$filter]])) {
$_SESSION['node_overview_filter'][] = array($filter, $form_state['values'][$filter]); $_SESSION['node_overview_filter'][] = array($filter, $form_state['values'][$filter]);
}
} }
} }
break; break;

View File

@ -6,12 +6,15 @@
.preview .node { .preview .node {
background-color: #ffffea; background-color: #ffffea;
} }
#node-admin-filter ul { /* Override the default multiselect layout in system.css. */
list-style-type: none; #node-admin-content dl.multiselect dd.b, dl.multiselect dd.b .form-item {
list-style-image: none; width: 20em; /* 6em label + 14em select */
padding: 0; }
margin: 0; #node-admin-content dl.multiselect dd.b .form-item label {
width: 100%; display: block;
float: left; /* LTR */
width: 6em;
font-weight: normal;
} }
#node-admin-buttons { #node-admin-buttons {
float: left; /* LTR */ float: left; /* LTR */

View File

@ -982,7 +982,6 @@ class NodeAdminTestCase extends DrupalWebTestCase {
// Filter the node listing by status. // Filter the node listing by status.
$edit = array( $edit = array(
'filter' => 'status',
'status' => 'status-1', 'status' => 'status-1',
); );
$this->drupalPost('admin/content', $edit, t('Filter')); $this->drupalPost('admin/content', $edit, t('Filter'));
@ -992,7 +991,6 @@ class NodeAdminTestCase extends DrupalWebTestCase {
// Filter the node listing by content type. // Filter the node listing by content type.
$edit = array( $edit = array(
'filter' => 'type',
'type' => 'article', 'type' => 'article',
); );
$this->drupalPost('admin/content', $edit, t('Refine')); $this->drupalPost('admin/content', $edit, t('Refine'));