diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 6e1ba87..4ec432f 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -10,71 +10,6 @@ use Drupal\Core\Render\Element; /** - * 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. - $cell = '
' . drupal_render($form['new']['new']) . drupal_render($form['new']['add']) . '
'; - $row[] = SafeMarkup::set($cell); - $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); -} - -/** * Prepares variables for image style preview templates. * * Default template: image-style-preview.html.twig. diff --git a/core/modules/image/image.module b/core/modules/image/image.module index ba8c979..a6ce171 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -111,10 +111,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/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index f861ef1..b8c62f9 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -70,22 +70,55 @@ public function form(array $form, FormStateInterface $form_state) { // Build the list of existing image effects for this image style. $form['effects'] = array( - '#theme' => 'image_style_effects', + '#type' => 'table', + '#header' => array( + $this->t('Effect'), + $this->t('Properties'), + $this->t('Weight'), + $this->t('Operations'), + ), + '#tabledrag' => array( + array( + 'action' => 'order', + 'relationship' => 'sibling', + 'group' => 'image-effect-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()), + ), + ), ); + $form['effects'][$key]['summary'] = $effect->getSummary(); + + if (!empty($summary)) { + $summary['#prefix'] = ' '; + $form['effects'][$key]['effect']['data']['summary'] = $summary; + } + $form['effects'][$key]['weight'] = array( '#type' => 'weight', '#title' => $this->t('Weight for @title', array('@title' => $effect->label())), '#title_display' => 'invisible', '#default_value' => $effect->getWeight(), + '#attributes' => array( + 'class' => array('image-effect-order-weight'), + ), ); $links = array(); @@ -104,17 +137,6 @@ public function form(array $form, FormStateInterface $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. @@ -130,24 +152,37 @@ public function form(array $form, FormStateInterface $form_state) { '#tree' => FALSE, '#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL, ); - $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, + '#default_value' => count($this->entity->getEffects()) + 1, + '#attributes' => array('class' => array('image-effect-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);