diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index b8f9c96..7f108cb 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -16,50 +16,47 @@ */ function theme_image_style_effects($variables) { $form = $variables['form']; - $rows = array(); - foreach (element_children($form) as $key) { - $row = array(); - $form[$key]['weight']['#attributes']['class'] = array('image-effect-order-weight'); - if ($key != 'new') { - $summary = drupal_render($form[$key]['summary']); - $row[] = drupal_render($form[$key]['label']) . (empty($summary) ? '' : ' ' . $summary); - $row[] = drupal_render($form[$key]['weight']); - $row[] = array('data' => $form[$key]['operations']); - } - else { - // Add the row for adding a new image effect. - $row[] = '
' . drupal_render($form['new']['new']) . drupal_render($form['new']['add']) . '
'; - $row[] = drupal_render($form['new']['weight']); - $row[] = ''; - } + $table = array( + '#type' => 'table', + '#header' => array( + t('Effect'), + t('Weight'), + t('Operations'), + ), + '#tabledrag' => array( + array('image-style-effects', 'order', 'sibling', 'image-effect-order-weight'), + ), + '#empty' => t('There are currently no effects in this style. Add one by selecting an option below.'), + ); - $rows[] = array( - 'data' => $row, + $row_defaults = array( + '#attributes' => array( 'class' => array('draggable'), - ); - } - - $header = array( - t('Effect'), - t('Weight'), - t('Operations'), + ) ); - if (count($rows) == 1 && (!isset($form['new']['#access']) || $form['new']['#access'])) { - array_unshift($rows, array(array( - 'data' => t('There are currently no effects in this style. Add one by selecting an option below.'), - 'colspan' => 4, - ))); + foreach (element_children($form) as $key) { + if ($key != 'new') { + $summary = drupal_render($form[$key]['summary']); + + $table[$key] = $row_defaults + array( + 'label_summary' => array( + '#markup' => drupal_render($form[$key]['label']) . (empty($summary) ? '' : ' ' . $summary), + ), + 'weight' => $form[$key]['weight'], + 'operations' => $form[$key]['operations'], + ); + } else { + $table[$key] = $row_defaults + array( + 'image_style_new' => array( + 'image_style_new_add' => $form[$key]['new'], + 'image_style_new_submit' => $form[$key]['add'], + ), + ); + } } - $table = array( - '#theme' => 'table', - '#header' => $header, - '#rows' => $rows, - '#attributes' => array('id' => 'image-style-effects'), - ); - drupal_add_tabledrag('image-style-effects', 'order', 'sibling', 'image-effect-order-weight'); return drupal_render($table); }