function theme_rules_elements

Themes a tree of rule elements in a draggable table.

1 theme call to theme_rules_elements()
RulesContainerPluginUI::form in ui/ui.core.inc
Generates a table for editing the contained elements.

File

ui/ui.theme.inc, line 13

Code

function theme_rules_elements($variables) {
    $form = $variables['element'];
    $form['#theme'] = 'table';
    $form['#header'] = array(
        t('Elements'),
        t('Weight'),
        t('Operations'),
    );
    $form['#attributes']['id'] = 'rules-' . drupal_html_id($form['#caption']) . '-id';
    foreach (element_children($form) as $element_id) {
        $element =& $form[$element_id];
        // Add special classes to be used for tabledrag.js.
        $element['parent_id']['#attributes']['class'] = array(
            'rules-parent-id',
        );
        $element['element_id']['#attributes']['class'] = array(
            'rules-element-id',
        );
        $element['weight']['#attributes']['class'] = array(
            'rules-element-weight',
        );
        $row = array();
        $row[] = theme('indentation', array(
            'size' => $element['#depth'],
        )) . drupal_render($element['label']);
        $row[] = drupal_render($element['weight']) . drupal_render($element['parent_id']) . drupal_render($element['element_id']);
        $row[] = array(
            'class' => 'rules-operations',
            'data' => $element['operations'],
        );
        $row = array(
            'data' => $row,
        ) + $element['#attributes'];
        $row['class'][] = 'draggable';
        if (!$element['#container']) {
            $row['class'][] = 'tabledrag-leaf';
        }
        $form['#rows'][] = $row;
    }
    if (!empty($form['#rows'])) {
        drupal_add_tabledrag($form['#attributes']['id'], 'match', 'parent', 'rules-parent-id', 'rules-parent-id', 'rules-element-id', TRUE, 10);
        drupal_add_tabledrag($form['#attributes']['id'], 'order', 'sibling', 'rules-element-weight');
    }
    else {
        $form['#rows'][] = array(
            array(
                'data' => t('None'),
                'colspan' => 3,
            ),
        );
    }
    if (!empty($form['#add'])) {
        $row = array();
        $row[] = array(
            'data' => $form['#add'],
            'colspan' => 3,
        );
        $form['#rows'][] = array(
            'data' => $row,
            'class' => array(
                'rules-elements-add',
            ),
        );
    }
    // Add a wrapping div.
    return '<div class="rules-elements-table">' . drupal_render($form) . '</div>';
}