Commit 3615ebbb authored by catch's avatar catch
Browse files

Issue #1938904 by joelpittet, duellj: Convert filter theme tables to table #type.

parent f3af3911
......@@ -236,15 +236,20 @@ function filter_admin_format_form($form, &$form_state, $format) {
// Filter order (tabledrag).
$form['filters']['order'] = array(
'#type' => 'item',
'#type' => 'table',
// For filter.admin.js
'#attributes' => array('id' => 'filter-order'),
'#title' => t('Filter processing order'),
'#theme' => 'filter_admin_format_filter_order',
// This item is used as a pure wrapping container with heading. Ignore its
// value, since 'filters' should only contain filter definitions.
// @see http://drupal.org/node/1829202
'#tabledrag' => array(
array('order', 'sibling', 'filter-order-weight'),
),
'#tree' => FALSE,
'#input' => FALSE,
'#theme_wrappers' => array('form_element'),
);
foreach ($filter_info as $name => $filter) {
$form['filters']['order'][$name]['#attributes']['class'][] = 'draggable';
$form['filters']['order'][$name]['#weight'] = $filters[$name]->weight;
$form['filters']['order'][$name]['filter'] = array(
'#markup' => $filter['title'],
);
......@@ -255,9 +260,12 @@ function filter_admin_format_form($form, &$form_state, $format) {
'#delta' => 50,
'#default_value' => $filters[$name]->weight,
'#parents' => array('filters', $name, 'weight'),
'#attributes' => array('class' => array('filter-order-weight')),
);
$form['filters']['order'][$name]['#weight'] = $filters[$name]->weight;
}
// Make sure filters are in the correct order, since filter_get_filters()
// doesn't return sorted filters.
uasort($form['filters']['order'], 'element_sort');
// Filter settings.
$form['filter_settings'] = array(
......@@ -290,37 +298,6 @@ function filter_admin_format_form($form, &$form_state, $format) {
return $form;
}
/**
* Returns HTML for a text format's filter order form.
*
* @param array $variables
* An associative array containing:
* - element: A render element representing the form.
*
* @ingroup themeable
*/
function theme_filter_admin_format_filter_order($variables) {
$element = $variables['element'];
// Filter order (tabledrag).
$rows = array();
foreach (element_children($element, TRUE) as $name) {
$element[$name]['weight']['#attributes']['class'][] = 'filter-order-weight';
$rows[] = array(
'data' => array(
drupal_render($element[$name]['filter']),
drupal_render($element[$name]['weight']),
),
'class' => array('draggable'),
);
}
$output = drupal_render_children($element);
$output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'filter-order')));
drupal_add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, TRUE);
return $output;
}
/**
* Form validation handler for filter_admin_format_form().
*
......
......@@ -67,10 +67,6 @@ function filter_help($path, $arg) {
*/
function filter_theme() {
return array(
'filter_admin_format_filter_order' => array(
'render element' => 'element',
'file' => 'filter.admin.inc',
),
'filter_tips' => array(
'variables' => array('tips' => NULL, 'long' => FALSE),
'file' => 'filter.pages.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