Commit 1d9f387c authored by Dries's avatar Dries

- Patch #732914 by Jacine, sun, reglogge, cosmicdreams: improve the markup/CSS...

- Patch #732914 by Jacine, sun, reglogge, cosmicdreams: improve the markup/CSS for content and user filter forms.
parent faf272e9
......@@ -5958,6 +5958,9 @@ function drupal_common_theme() {
'date' => array(
'render element' => 'element',
),
'exposed_filters' => array(
'render element' => 'form',
),
'checkbox' => array(
'render element' => 'element',
),
......
......@@ -148,7 +148,7 @@ function node_filter_form() {
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Show only items where'),
'#theme' => 'node_filters',
'#theme' => 'exposed_filters__node',
);
foreach ($session as $filter) {
list($type, $value) = $filter;
......@@ -163,11 +163,12 @@ function node_filter_form() {
else {
$value = $filters[$type]['options'][$value];
}
$t_args = array('%property' => $filters[$type]['title'], '%value' => $value);
if ($i++) {
$form['filters']['current'][] = array('#markup' => t('<em>and</em> where <strong>%type</strong> is <strong>%value</strong>', array('%type' => $filters[$type]['title'], '%value' => $value)));
$form['filters']['current'][] = array('#markup' => t('and where %property is %value', $t_args));
}
else {
$form['filters']['current'][] = array('#markup' => t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => $filters[$type]['title'], '%value' => $value)));
$form['filters']['current'][] = array('#markup' => t('where %property is %value', $t_args));
}
if (in_array($type, array('type', 'language'))) {
// Remove the option if it is already being filtered on.
......@@ -175,9 +176,17 @@ function node_filter_form() {
}
}
$form['filters']['status'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('clearfix')),
'#prefix' => ($i ? '<div class="additional-filters">' . t('and where') . '</div>' : ''),
);
$form['filters']['status']['filters'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('filters')),
);
foreach ($filters as $key => $filter) {
$names[$key] = $filter['title'];
$form['filters']['status'][$key] = array(
$form['filters']['status']['filters'][$key] = array(
'#type' => 'select',
'#options' => $filter['options'],
'#title' => $filter['title'],
......@@ -185,15 +194,17 @@ function node_filter_form() {
);
}
$form['filters']['actions'] = array(
$form['filters']['status']['actions'] = array(
'#type' => 'actions',
'#id' => 'node-admin-buttons',
'#attributes' => array('class' => array('container-inline')),
);
$form['filters']['actions']['submit'] = array('#type' => 'submit', '#value' => (count($session) ? t('Refine') : t('Filter')));
$form['filters']['status']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => count($session) ? t('Refine') : t('Filter'),
);
if (count($session)) {
$form['filters']['actions']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
$form['filters']['actions']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
$form['filters']['status']['actions']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
$form['filters']['status']['actions']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
}
drupal_add_js('misc/form.js');
......@@ -201,46 +212,6 @@ function node_filter_form() {
return $form;
}
/**
* Returns HTML for a node administration filter selector.
*
* @param $variables
* An associative array containing:
* - form: A render element representing the form.
*
* @ingroup themeable
*/
function theme_node_filters($variables) {
$form = $variables['form'];
$output = '';
$output .= '<ul class="clearfix">';
if (!empty($form['current'])) {
foreach (element_children($form['current']) as $key) {
$output .= '<li>' . drupal_render($form['current'][$key]) . '</li>';
}
}
$output .= '</ul>';
$output .= '<div class="clearfix">';
$output .= '<dl class="multiselect">' . (!empty($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '');
$output .= '<dd>';
foreach (element_children($form['status']) as $key) {
$output .= drupal_render($form['status'][$key]);
}
$output .= '</dd>';
$output .= '</dl>';
$output .= drupal_render($form['actions']);
$output .= '</div>';
return $output;
}
/**
* Process result from node administration filter form.
*/
......
......@@ -6,22 +6,6 @@
.preview .node {
background-color: #ffffea;
}
/* Override the default multiselect layout in system-behavior.css. */
#node-admin-content dl.multiselect dd,
dl.multiselect dd .form-item {
width: 20em; /* 6em label + 14em select */
}
#node-admin-content dl.multiselect dd .form-item label {
display: block;
float: left; /* LTR */
width: 6em;
font-weight: normal;
}
#node-admin-buttons {
float: left; /* LTR */
margin-left: 0.5em; /* LTR */
clear: right; /* LTR */
}
td.revision-current {
background: #ffc;
}
......@@ -132,10 +132,6 @@ function node_theme() {
'node_search_admin' => array(
'render element' => 'form',
),
'node_filters' => array(
'render element' => 'form',
'file' => 'node.admin.inc',
),
'node_add_list' => array(
'variables' => array('content' => NULL),
'file' => 'node.pages.inc',
......
......@@ -1224,7 +1224,9 @@ class NodeAdminTestCase extends DrupalWebTestCase {
'status' => 'status-1',
);
$this->drupalPost(NULL, $edit, t('Filter'));
$this->assertRaw(t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => t('status'), '%value' => t('published'))), t('Content list is filtered by status.'));
$this->assertRaw(t('where %property is %value', array('%property' => t('status'), '%value' => 'published')), t('Content list is filtered by status.'));
$this->assertLinkByHref('node/' . $nodes['published_page']->nid . '/edit');
$this->assertLinkByHref('node/' . $nodes['published_article']->nid . '/edit');
$this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid . '/edit');
......@@ -1234,8 +1236,10 @@ class NodeAdminTestCase extends DrupalWebTestCase {
'type' => 'page',
);
$this->drupalPost(NULL, $edit, t('Refine'));
$this->assertRaw(t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => t('status'), '%value' => t('published'))), t('Content list is filtered by status.'));
$this->assertRaw(t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => t('type'), '%value' => 'Basic page')), t('Content list is filtered by content type.'));
$this->assertRaw(t('where %property is %value', array('%property' => t('status'), '%value' => 'published')), t('Content list is filtered by status.'));
$this->assertRaw(t('and where %property is %value', array('%property' => t('type'), '%value' => 'Basic page')), t('Content list is filtered by content type.'));
$this->assertLinkByHref('node/' . $nodes['published_page']->nid . '/edit');
$this->assertNoLinkByHref('node/' . $nodes['published_article']->nid . '/edit');
......
......@@ -48,3 +48,20 @@ table.screenshot {
margin-right: 15px;
}
/**
* Exposed filters
*/
.exposed-filters .filters {
float: right;
margin-left: 1em;
margin-right: 0;
}
.exposed-filters .form-item label {
float: right;
}
/* Current filters */
.exposed-filters .additional-filters {
float: right;
margin-left: 1em;
margin-right: 0;
}
......@@ -138,3 +138,36 @@ table.screenshot {
html.js .custom-container label {
visibility: hidden;
}
/**
* Exposed filters
*/
.exposed-filters .filters {
float: left; /* LTR */
margin-right: 1em; /* LTR */
width: 25em; /* IE6 */
}
.exposed-filters .form-item {
margin: 0 0 0.1em 0;
padding: 0;
}
.exposed-filters .form-item label {
float: left; /* LTR */
font-weight: normal;
width: 10em;
}
.exposed-filters .form-select {
width: 14em;
}
/* Current filters */
.exposed-filters .current-filters {
margin-bottom: 1em;
}
.exposed-filters .current-filters .placeholder {
font-style: normal;
font-weight: bold;
}
.exposed-filters .additional-filters {
float: left; /* LTR */
margin-right: 1em; /* LTR */
}
......@@ -182,28 +182,6 @@ tr .ajax-progress .throbber {
width: 16em;
}
/**
* Multiselect form
*/
dl.multiselect dd,
dl.multiselect dd .form-item,
dl.multiselect dd select {
font-family: inherit;
font-size: inherit;
width: 14em;
}
dl.multiselect dt,
dl.multiselect dd {
float: left; /* LTR */
line-height: 1.75em;
padding: 0;
margin: 0 1em 0 0; /* LTR */
}
dl.multiselect .form-item {
height: 1.75em;
margin: 0;
}
/**
* Password strength indicator
*/
......
......@@ -82,7 +82,6 @@ thead th {
.item-list ul li {
margin: 0 0 0.25em 1.5em; /* LTR */
padding: 0;
list-style: disc;
}
.form-item {
margin-top: 1em;
......
......@@ -3769,6 +3769,35 @@ function theme_system_settings_form($variables) {
return drupal_render_children($variables['form']);
}
/**
* Returns HTML for an exposed filter form.
*
* @param $variables
* An associative array containing:
* - form: An associative array containing the structure of the form.
*
* @return
* A string containing an HTML-formatted form.
*
* @ingroup themeable
*/
function theme_exposed_filters($variables) {
$form = $variables['form'];
$output = '';
if (isset($form['current'])) {
$items = array();
foreach (element_children($form['current']) as $key) {
$items[] = drupal_render($form['current'][$key]);
}
$output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters'))));
}
$output .= drupal_render_children($form);
return '<div class="exposed-filters">' . $output . '</div>';
}
/**
* Implements hook_admin_paths().
*/
......
......@@ -4,18 +4,6 @@
padding-left: 0;
padding-right: 1.5em;
}
#user-filter-form dl.multiselect dd .form-item label {
float: right;
}
#user-admin-buttons {
float: right;
margin-left: 0;
margin-right: 0.5em;
clear: left;
}
.profile .user-picture {
float: left;
margin: 0 0 1em 1em;
......
......@@ -40,7 +40,7 @@ function user_filter_form() {
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Show only users where'),
'#theme' => 'user_filters',
'#theme' => 'exposed_filters__user',
);
foreach ($session as $filter) {
list($type, $value) = $filter;
......@@ -53,18 +53,26 @@ function user_filter_form() {
else {
$value = $filters[$type]['options'][$value];
}
$params = array('%property' => $filters[$type]['title'] , '%value' => $value);
$t_args = array('%property' => $filters[$type]['title'], '%value' => $value);
if ($i++) {
$form['filters']['current'][] = array('#markup' => t('<em>and</em> where <strong>%property</strong> is <strong>%value</strong>', $params));
$form['filters']['current'][] = array('#markup' => t('and where %property is %value', $t_args));
}
else {
$form['filters']['current'][] = array('#markup' => t('<strong>%property</strong> is <strong>%value</strong>', $params));
$form['filters']['current'][] = array('#markup' => t('%property is %value', $t_args));
}
}
$form['filters']['status'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('clearfix')),
'#prefix' => ($i ? '<div class="additional-filters">' . t('and where') . '</div>' : ''),
);
$form['filters']['status']['filters'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('filters')),
);
foreach ($filters as $key => $filter) {
$names[$key] = $filter['title'];
$form['filters']['status'][$key] = array(
$form['filters']['status']['filters'][$key] = array(
'#type' => 'select',
'#options' => $filter['options'],
'#title' => $filter['title'],
......@@ -72,21 +80,20 @@ function user_filter_form() {
);
}
$form['filters']['actions'] = array(
$form['filters']['status']['actions'] = array(
'#type' => 'actions',
'#id' => 'user-admin-buttons',
'#attributes' => array('class' => array('container-inline')),
);
$form['filters']['actions']['submit'] = array(
$form['filters']['status']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => (count($session) ? t('Refine') : t('Filter')),
);
if (count($session)) {
$form['filters']['actions']['undo'] = array(
$form['filters']['status']['actions']['undo'] = array(
'#type' => 'submit',
'#value' => t('Undo'),
);
$form['filters']['actions']['reset'] = array(
$form['filters']['status']['actions']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset'),
);
......@@ -1017,41 +1024,3 @@ function user_admin_role_delete_confirm_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/people/permissions/roles';
}
/**
* Returns HTML for the user administration filter selector.
*
* @param $variables
* An associative array containing:
* - form: A render element representing the form.
*
* @ingroup themeable
*/
function theme_user_filters($variables) {
$form = $variables['form'];
$output = '<ul class="clearfix">';
if (!empty($form['current'])) {
foreach (element_children($form['current']) as $key) {
$output .= '<li>' . drupal_render($form['current'][$key]) . '</li>';
}
}
$output .= '</ul>';
$output .= '<div class="clearfix">';
$output .= '<dl class="multiselect">' . (!empty($form['current']) ? '<dt><em>' . t('and') . '</em> ' . t('where') . '</dt>' : '');
$output .= '<dd>';
foreach (element_children($form['status']) as $key) {
$output .= drupal_render($form['status'][$key]);
}
$output .= '</dd>';
$output .= '</dl>';
$output .= drupal_render($form['actions']);
$output .= '</div>';
return $output;
}
......@@ -10,22 +10,6 @@
#permissions tr.even .form-item {
white-space: normal;
}
/* Override the default multiselect layout in system-behavior.css. */
#user-filter-form dl.multiselect dd,
dl.multiselect dd .form-item {
width: 20em; /* 6em label + 14em select */
}
#user-filter-form dl.multiselect dd .form-item label {
display: block;
float: left; /* LTR */
width: 6em;
font-weight: normal;
}
#user-admin-buttons {
float: left; /* LTR */
margin-left: 0.5em; /* LTR */
clear: right; /* LTR */
}
#user-admin-settings fieldset .fieldset-description {
font-size: 0.85em;
padding-bottom: .5em;
......
......@@ -122,10 +122,6 @@ function user_theme() {
'render element' => 'form',
'file' => 'user.admin.inc',
),
'user_filters' => array(
'render element' => 'form',
'file' => 'user.admin.inc',
),
'user_permission_description' => array(
'variables' => array('permission_item' => NULL, 'hide' => NULL),
'file' => 'user.admin.inc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment