function theme_rules_ui_variable_form

Themes the rules form for editing the used variables.

See also

RulesPluginUI::getVariableForm()

1 theme call to theme_rules_ui_variable_form()
RulesPluginUI::settingsForm in ui/ui.core.inc
Adds the configuration settings form (label, tags, description, ...).

File

ui/ui.theme.inc, line 64

Code

function theme_rules_ui_variable_form($variables) {
    $elements = $variables['element'];
    $table['#theme'] = 'table';
    $table['#header'] = array(
        t('Data type'),
        t('Label'),
        t('Machine name'),
        t('Usage'),
        array(
            'data' => t('Weight'),
            'class' => array(
                'tabledrag-hide',
            ),
        ),
    );
    $table['#attributes']['id'] = 'rules-' . drupal_html_id($elements['#title']) . '-id';
    foreach (element_children($elements['items']) as $key) {
        $element =& $elements['items'][$key];
        // Add special classes to be used for tabledrag.js.
        $element['weight']['#attributes']['class'] = array(
            'rules-element-weight',
        );
        $row = array();
        $row[] = array(
            'data' => $element['type'],
        );
        $row[] = array(
            'data' => $element['label'],
        );
        $row[] = array(
            'data' => $element['name'],
        );
        $row[] = array(
            'data' => $element['usage'],
        );
        $row[] = array(
            'data' => $element['weight'],
        );
        $row = array(
            'data' => $row,
        ) + $element['#attributes'];
        $row['class'][] = 'draggable';
        $table['#rows'][] = $row;
    }
    $elements['items']['#printed'] = TRUE;
    if (!empty($table['#rows'])) {
        drupal_add_tabledrag($table['#attributes']['id'], 'order', 'sibling', 'rules-element-weight');
    }
    // Theme it like a form item, but with the description above the content.
    $attributes['class'][] = 'form-item';
    $attributes['class'][] = 'rules-variables-form';
    $output = '<div' . drupal_attributes($attributes) . '>' . "\n";
    $output .= theme('form_element_label', $variables);
    if (!empty($elements['#description'])) {
        $output .= ' <div class="description">' . $elements['#description'] . "</div>\n";
    }
    $output .= ' ' . drupal_render($table) . "\n";
    // Add in any further children elements.
    foreach (element_children($elements, TRUE) as $key) {
        $output .= drupal_render($elements[$key]);
    }
    $output .= "</div>\n";
    return $output;
}