function theme_facetapi_facet_settings_form in Facet API 6
Themes the facet sort form into a draggable table.
Parameters
$form: A FAPI array containing a fieldset.
Return value
A themed form element.
1 theme call to theme_facetapi_facet_settings_form()
- facetapi_facet_settings_form in ./
facetapi.admin.inc - Returns settings for an individual facet that apply to a realm.
File
- ./
facetapi.admin.inc, line 385 - Administrative settings for Facet API modules.
Code
function theme_facetapi_facet_settings_form($form) {
$output = '';
// Gets all sort definitions.
$sorts = facetapi_sorts_get();
// Initializes table headers.
$headers = array();
$headers[] = array(
'data' => '',
'class' => 'checkbox',
);
$headers[] = t('Type');
$headers[] = t('Order');
$headers[] = t('Description');
$headers[] = t('Weight');
// Builds table rows.
$rows = array();
foreach (element_children($form['sort']) as $sort_var) {
// Pulls information from variable, iterates over available sorts.
list($module, $variable, $searcher, $realm_name, $facet_name) = explode(':', $sort_var);
foreach (element_children($form['sort'][$sort_var]) as $option) {
// Captures longer variable names for code readability.
$weight_var = "facetapi:sort_weight:{$searcher}:{$realm_name}:{$facet_name}:{$option}";
$order_var = "facetapi:sort_order:{$searcher}:{$realm_name}:{$facet_name}:{$option}";
// Extracts the titile form the checkbox, hides title.
$title = $form['sort'][$sort_var][$option]['#title'];
$form['sort'][$sort_var][$option]['#title'] = '';
// Builds the table rows.
$rows[] = array(
'weight' => $form['sort_weight'][$weight_var]['#default_value'],
'class' => 'draggable',
'data' => array(
array(
'data' => drupal_render($form['sort'][$sort_var][$option]),
'class' => 'checkbox',
),
array(
'data' => check_plain($title),
),
array(
'data' => drupal_render($form['sort_order'][$order_var]),
),
array(
'data' => filter_xss($sorts[$option]['description']),
),
array(
'data' => drupal_render($form['sort_weight'][$weight_var]),
'class' => 'dropbox',
),
),
);
}
}
// Sorts rows by weight.
// @todo Replace with drupal_sort_weight() in D7.
usort($rows, 'facetapi_sort_weight');
// Builds the sort options table.
$table_id = "facetapi-sort-{$searcher}-{$realm_name}-{$facet_name}";
drupal_add_tabledrag($table_id, 'order', 'sibling', 'facetapi-sort-weight');
$form['#value'] = theme('table', $headers, $rows, array(
'id' => $table_id,
));
// Renders and returns table.
$output .= drupal_render($form);
return $output;
}