$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 '
' . drupal_render($form) . '
'; } /** * Themes the rules form for editing the used variables. * * @see RulesPluginUI::getVariableForm() * @ingroup themeable */ function theme_rules_ui_variable_form($variables) { $elements = $variables['element']; $table['#theme'] = 'table'; $table['#header'] = array(t('Data type'), t('Label'), t('Machine name'), 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['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 = '' . "\n"; $output .= theme('form_element_label', $variables); if (!empty($elements['#description'])) { $output .= '
' . $elements['#description'] . "
\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 .= "\n"; return $output; } /** * Themes a view of multiple configuration items. * @ingroup themeable */ function theme_rules_content_group($variables) { $element = $variables['element']; foreach (element_children($element) as $key) { $output[] = drupal_render($element[$key]); } $heading = !empty($element['#caption']) ? "" . $element['#caption'] . ': ' : ''; if (!empty($output)) { return '
' . $heading . implode(', ', $output) . '
'; } } /** * Themes the view of a single parameter configuration. * @ingroup themeable */ function theme_rules_parameter_configuration($variables) { $element = $variables['element']; $content = drupal_render_children($element); // Add the full content to the span's title, but don't use drupal_attributes // for that as this would invoke check_plain() again. $title = strip_tags($content); $element['#attributes']['class'][] = 'rules-parameter-configuration'; $attributes = drupal_attributes($element['#attributes']) . " title='$title'"; $label_attributes['class'][] = 'rules-parameter-label'; if (!empty($element['#info']['description'])) { $label_attributes['title'] = $element['#info']['description']; } $label_attributes = drupal_attributes($label_attributes); $output = "" . check_plain($element['#info']['label']) . ': '; $output .= "" . truncate_utf8($content, 30, TRUE, TRUE) . ""; return $output; } /** * Themes the view of a provided variable. * @ingroup themeable */ function theme_rules_provides_variable_view($variables) { $element = $variables['element']; $label_attributes['class'][] = 'rules-variable-label'; if (!empty($element['#info']['description'])) { $label_attributes['title'] = $element['#info']['description']; } $label_attributes = drupal_attributes($label_attributes); $output = check_plain($element['#name']); $output .= ' (' . check_plain($element['#info']['label']) . ')'; return "" . $output . ''; } /** * Themes help for using the data selector. * @ingroup themeable */ function theme_rules_data_selector_help($variables) { $variables_info = $variables['variables']; $param_info = $variables['parameter']; $render = array( '#type' => 'fieldset', '#title' => t('Data selectors'), '#pre_render' => array(), '#attributes' => array(), ); // Make it manually collapsible as we cannot use #collapsible without the // FAPI element processor. $render['#attached']['js'][] = 'misc/collapse.js'; $render['#attributes']['class'][] = 'collapsible'; $render['#attributes']['class'][] = 'collapsed'; $render['table'] = array( '#theme' => 'table', '#header' => array(t('Selector'), t('Label'), t('Description')), ); foreach (RulesData::matchingDataSelector($variables_info, $param_info) as $selector => $info) { $info += array('label' => '', 'description' => ''); $render['table']['#rows'][] = array(check_plain($selector), check_plain(drupal_ucfirst($info['label'])), check_plain($info['description'])); } return drupal_render($render); } /** * Themes the rules log debug output. * @ingroup themeable */ function theme_rules_log($variables) { $element = $variables['element']; drupal_add_css(drupal_get_path('module', 'rules') . '/ui/rules.ui.css'); $output = '
'; $output .= '

' . t('Rules evaluation log') . '

'; $output .= $element['#children']; $output .= '
'; return $output; } /** * Themes rules autocomplete forms. * @ingroup themeable */ function theme_rules_autocomplete($variables) { $element = $variables['element']; drupal_add_js(drupal_get_path('module', 'rules') . '/ui/rules.autocomplete.js'); drupal_add_library('system', 'ui.autocomplete'); drupal_add_library('system', 'ui.button'); $element['#attributes']['type'] = 'text'; element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength')); _form_set_class($element, array('form-text', 'rules-autocomplete')); $id = $element['#attributes']['id']; $id_button = drupal_html_id($id . '-button'); $js_vars['rules_autocomplete'][$id] = array( 'inputId' => $id, 'source' => url($element['#autocomplete_path'], array('absolute' => TRUE)), ); drupal_add_js($js_vars, 'setting'); $output = '
'; $output .= ''; $output .= '
'; return $output; }