diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 9675e98..9c7ed0b 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -6,70 +6,6 @@ */ /** - * Returns HTML for a listing of the effects within a specific image style. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -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[] = ''; - } - - $rows[] = array( - 'data' => $row, - '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, - ))); - } - - $table = array( - '#type' => 'table', - '#header' => $header, - '#rows' => $rows, - '#attributes' => array('id' => 'image-style-effects'), - '#tabledrag' => array( - array( - 'action' => 'order', - 'relationship' => 'sibling', - 'group' => 'image-effect-order-weight', - ), - ), - ); - return drupal_render($table); -} - -/** * Returns HTML for a preview of an image style. * * @param $variables diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 1f5d8a5..8cdddff 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -164,10 +164,6 @@ function image_theme() { ), // Theme functions in image.admin.inc. - 'image_style_effects' => array( - 'render element' => 'form', - 'file' => 'image.admin.inc', - ), 'image_style_preview' => array( 'variables' => array('style' => NULL), 'file' => 'image.admin.inc', diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index c00b009..c8b125c 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -68,17 +68,39 @@ public function form(array $form, array &$form_state) { // Build the list of existing image effects for this image style. $form['effects'] = array( - '#theme' => 'image_style_effects', + '#type' => 'table', + '#header' => array( + t('Effect'), + t('Weight'), + t('Operations'), + ), + '#tabledrag' => array( + array( + 'action' => 'order', + 'relationship' => 'sibling', + 'group' => 'image-style-order-weight', + ), + ), + '#attributes' => array( + 'id' => 'image-style-effects', + ), + '#empty' => t('There are currently no effects in this style. Add one by selecting an option below.'), // Render effects below parent elements. '#weight' => 5, ); foreach ($this->entity->getEffects() as $effect) { $key = $effect->getUuid(); + $form['effects'][$key]['#attributes']['class'][] = 'draggable'; $form['effects'][$key]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$key]['weight'] : NULL; - $form['effects'][$key]['label'] = array( - '#markup' => String::checkPlain($effect->label()), + $form['effects'][$key]['effect'] = array( + '#tree' => FALSE, + 'data' => array( + 'label' => array( + '#markup' => String::checkPlain($effect->label()), + ), + ), + 'summary' => $effect->getSummary(), ); - $form['effects'][$key]['summary'] = $effect->getSummary(); $form['effects'][$key]['weight'] = array( '#type' => 'weight', '#title' => $this->t('Weight for @title', array('@title' => $effect->label())), @@ -86,6 +108,7 @@ public function form(array $form, array &$form_state) { '#default_value' => $effect->getWeight(), ); + $form[$key]['weight']['#attributes']['class'] = array('image-style-order-weight'); $links = array(); $is_configurable = $effect instanceof ConfigurableImageEffectInterface; if ($is_configurable) { @@ -102,17 +125,6 @@ public function form(array $form, array &$form_state) { '#type' => 'operations', '#links' => $links, ); - $form['effects'][$key]['configure'] = array( - '#type' => 'link', - '#title' => $this->t('edit'), - '#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key, - '#access' => $is_configurable, - ); - $form['effects'][$key]['remove'] = array( - '#type' => 'link', - '#title' => $this->t('delete'), - '#href' => 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/effects/' . $key . '/delete', - ); } // Build the new image effect addition form and add it to the effect list. @@ -127,25 +139,39 @@ public function form(array $form, array &$form_state) { $form['effects']['new'] = array( '#tree' => FALSE, '#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL, + '#attributes' => array('class' => array('draggable')), ); - $form['effects']['new']['new'] = array( - '#type' => 'select', - '#title' => $this->t('Effect'), - '#title_display' => 'invisible', - '#options' => $new_effect_options, - '#empty_option' => $this->t('Select a new effect'), + $form['effects']['new']['effect'] = array( + 'data' => array( + 'new' => array( + '#type' => 'select', + '#title' => $this->t('Effect'), + '#title_display' => 'invisible', + '#options' => $new_effect_options, + '#empty_option' => $this->t('Select a new effect'), + ), + array( + 'add' => array( + '#type' => 'submit', + '#value' => $this->t('Add'), + '#validate' => array(array($this, 'effectValidate')), + '#submit' => array(array($this, 'effectSave')), + ), + ), + ), + '#prefix' => '
', + '#suffix' => '
', ); + $form['effects']['new']['weight'] = array( '#type' => 'weight', '#title' => $this->t('Weight for new effect'), '#title_display' => 'invisible', '#default_value' => count($form['effects']) - 1, + '#attributes' => array('class' => array('image-style-order-weight')), ); - $form['effects']['new']['add'] = array( - '#type' => 'submit', - '#value' => $this->t('Add'), - '#validate' => array(array($this, 'effectValidate')), - '#submit' => array(array($this, 'effectSave')), + $form['effects']['new']['operations'] = array( + 'data' => array(), ); return parent::form($form, $form_state);