commit 306567f6fe9a3f7e371c3eda434ddafd4fac1c64 Author: Joel Pittet Date: Thu Mar 14 01:55:39 2013 -0700 1898416-11 diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index 8924b9e..82fcde8 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -5,8 +5,6 @@ * Administrative page callbacks for the Filter module. */ -use Drupal\Core\Template\Attribute; - /** * Page callback: Form constructor for a form to list and reorder text formats. * @@ -238,15 +236,14 @@ function filter_admin_format_form($form, &$form_state, $format) { // Filter order (tabledrag). $form['filters']['order'] = array( - '#type' => 'item', + '#type' => 'table', '#title' => t('Filter processing order'), - '#theme' => 'filter_admin_format_filter_order', - // This item is used as a pure wrapping container with heading. Ignore its - // value, since 'filters' should only contain filter definitions. - // @see http://drupal.org/node/1829202 - '#input' => FALSE, + '#tabledrag' => array( + array('order', 'sibling', 'filter-order-weight'), + ), ); foreach ($filter_info as $name => $filter) { + $form['filters']['order'][$name]['#attributes']['class'][] = 'draggable'; $form['filters']['order'][$name]['filter'] = array( '#markup' => $filter['title'], ); @@ -257,6 +254,7 @@ function filter_admin_format_form($form, &$form_state, $format) { '#delta' => 50, '#default_value' => $filters[$name]->weight, '#parents' => array('filters', $name, 'weight'), + '#attributes' => array('class' => array('filter-order-weight')), ); $form['filters']['order'][$name]['#weight'] = $filters[$name]->weight; } @@ -293,76 +291,6 @@ function filter_admin_format_form($form, &$form_state, $format) { } /** - * Returns HTML for a text format's filter order form. - * - * @param array $variables - * An associative array containing: - * - element: A render element representing the form. - * - * @ingroup themeable - */ -function template_preprocess_filter_admin_format_filter_order($variables) { - $element = $variables['element']; - - // Filter order (tabledrag). - $rows = array(); - foreach (element_children($element, TRUE) as $name) { - $element[$name]['weight']['#attributes']['class'][] = 'filter-order-weight'; - $rows[] = array( - 'data' => array( - drupal_render($element[$name]['filter']), - drupal_render($element[$name]['weight']), - ), - 'class' => array('draggable'), - ); - } - $output = drupal_render_children($element); - $output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'filter-order'))); - drupal_add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, TRUE); - $variables['content'] = $output; - -} - -/** - * Preprocess HTML for text format administration overview form templates. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @see filter-admin-overview.html.twig - */ -function template_preprocess_filter_admin_overview(&$variables) { - $form = $variables['form']; - - // Format the form as a table. - // @todo Maybe let templates decide format? - // @see http://drupal.org/node/1777532 - $rows = array(); - foreach (element_children($form['formats']) as $id) { - $form['formats'][$id]['weight']['#attributes']['class'] = array('text-format-order-weight'); - - $rows[] = array( - 'data' => array( - drupal_render($form['formats'][$id]['name']), - drupal_render($form['formats'][$id]['roles']), - drupal_render($form['formats'][$id]['weight']), - drupal_render($form['formats'][$id]['operations']), - ), - 'class' => array('draggable'), - ); - } - - drupal_add_tabledrag('text-format-order', 'order', 'sibling', 'text-format-order-weight'); - $header = array(t('Name'), t('Roles'), t('Weight'), t('Operations')); - $attributes = new Attribute(array('id' => 'text-format-order')); - $variables['table'] = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); - - // We call the rest of the form 'children'. - $variables['children'] = drupal_render_children($form); -} - -/** * Form validation handler for filter_admin_format_form(). * * @see filter_admin_format_form_submit() diff --git a/core/modules/filter/filter.admin.js b/core/modules/filter/filter.admin.js index f55159a..123576a 100644 --- a/core/modules/filter/filter.admin.js +++ b/core/modules/filter/filter.admin.js @@ -33,7 +33,7 @@ Drupal.behaviors.filterStatus = { } } // Restripe table after toggling visibility of table row. - Drupal.tableDrag['filter-order'].restripeTable(); + Drupal.tableDrag['edit-filters-order'].restripeTable(); }); // Attach summary for configurable filters (only for screen-readers). diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 28608fa..6c7d437 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -74,16 +74,6 @@ function filter_help($path, $arg) { */ function filter_theme() { return array( - 'filter_admin_overview' => array( - 'render element' => 'form', - 'file' => 'filter.admin.inc', - 'template' => 'filter-admin-overview', - ), - 'filter_admin_format_filter_order' => array( - 'render element' => 'element', - 'file' => 'filter.admin.inc', - 'template' => 'filter-admin-format-filter-order' - ), 'filter_tips' => array( 'variables' => array('tips' => NULL, 'long' => FALSE), 'file' => 'filter.pages.inc', @@ -93,10 +83,6 @@ function filter_theme() { 'render element' => 'element', 'template' => 'text-format-wrapper', ), - 'filter_tips_more_info' => array( - 'variables' => array(), - 'template' => 'filter-tips-more-info', - ), 'filter_guidelines' => array( 'variables' => array('format' => NULL), 'template' => 'filter-guidelines', @@ -929,11 +915,23 @@ function filter_process_format($element) { '#parents' => array_merge($element['#parents'], array('format')), ); + $filter_tips_link = array( + '#theme' => 'link', + '#text' => t('More information about text formats'), + '#path' => 'filter/tips', + '#options' => array( + 'attributes' => array('target' => '_blank'), + 'html' => FALSE, + ), + '#prefix' => '

', + '#suffix' => '

', + ); + $element['format']['help'] = array( '#type' => 'container', - '#theme' => 'filter_tips_more_info', '#attributes' => array('class' => array('filter-help')), '#weight' => 0, + $filter_tips_link, ); $all_formats = filter_formats(); @@ -1186,19 +1184,84 @@ function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, } /** + * Returns HTML for guidelines for a text format. + * + * @param array $variables + * An associative array containing: + * - format: An object representing a text format. + * + * @ingroup themeable * Preprocess filter_guidelines template. */ function template_preprocess_filter_guidelines(&$variables) { - $variables['tips']['#tips'] = _filter_tips($variables['format']->format, FALSE); - $variables['tips']['#theme'] = 'filter_tips'; + $format = $variables['format']; + $variables['attributes']['class'][] = 'filter-guidelines-item'; + $variables['attributes']['class'][] = 'filter-guidelines-' . $format->format; + $variables['tips'] = array( + '#theme' => 'filter_tips', + '#tips' => _filter_tips($format->format, FALSE), + ); } /** - * Preprocess filter_guidelines template. + * Returns HTML for a set of filter tips. + * + * @param array $variables + * An associative array containing: + * - tips: An array containing descriptions and a CSS ID in the form of + * 'module-name/filter-id' (only used when $long is TRUE) for each + * filter in one or more text formats. Example: + * @code + * array( + * 'Full HTML' => array( + * 0 => array( + * 'tip' => 'Web page addresses and e-mail addresses turn into links automatically.', + * 'id' => 'filter/2', + * ), + * ), + * ); + * @endcode + * - long: (optional) Whether the passed-in filter tips contain extended + * explanations, i.e. intended to be output on the path 'filter/tips' + * (TRUE), or are in a short format, i.e. suitable to be displayed below a + * form element. Defaults to FALSE. + * + * @see _filter_tips() + * @ingroup themeable */ function template_preprocess_filter_tips(&$variables) { - $variables['multiple'] = count($variables['tips']) > 1; + $tips = $variables['tips']; + $long = $variables['long']; + $output = ''; + + $multiple = count($tips) > 1; + + foreach ($variables['tips'] as $name => $tiplist) { + foreach ($tiplist as $tip_key => $tip) { + $tiplist[$tip_key]['attributes'] = new Attribute(array()); + if ($long) { + $tiplist[$tip_key]['attributes']['class'] = array('filter-' . str_replace("/", "-", $tip['id'])); + } + } + + $attributes = array( + 'class' => array( + 'filter-type', + 'filter-' . drupal_html_class($name), + ), + ); + + $variables['tips'][$name] = array( + 'attributes' => new Attribute($attributes), + 'name' => check_plain($name), + 'list' => $tiplist, + ); + } + + + $variables['multiple'] = $multiple; } + /** * @defgroup standard_filters Standard filters * @{ diff --git a/core/modules/filter/filter.pages.inc b/core/modules/filter/filter.pages.inc index 134c1be..f0ac5d6 100644 --- a/core/modules/filter/filter.pages.inc +++ b/core/modules/filter/filter.pages.inc @@ -19,10 +19,18 @@ */ function filter_tips_long($format = NULL) { if (!empty($format)) { - $output = theme('filter_tips', array('tips' => _filter_tips($format->format, TRUE), 'long' => TRUE)); + $filter_tips = array( + '#theme' => 'filter_tips', + '#tips' => _filter_tips($format->format, TRUE), + '#long' => TRUE, + ); } else { - $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE)); + $filter_tips = array( + '#theme' => 'filter_tips', + '#tips' => _filter_tips(-1, TRUE), + '#long' => TRUE, + ); } - return $output; + return $filter_tips; } diff --git a/core/modules/filter/templates/filter-admin-format-filter-order.html.twig b/core/modules/filter/templates/filter-admin-format-filter-order.html.twig deleted file mode 100644 index 8781a42..0000000 --- a/core/modules/filter/templates/filter-admin-format-filter-order.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{# -/** - * @file - * Default theme implementation for admin format filter order in the admin interface. - * - * Available variables: - * - content: An HTML . - * - * - * @see template_preprocess() - * @see template_preprocess_filter_admin_format_filter_order() - * - * @ingroup themeable - */ -#} -{{ content }} diff --git a/core/modules/filter/templates/filter-admin-overview.html.twig b/core/modules/filter/templates/filter-admin-overview.html.twig deleted file mode 100644 index bcbdc4c..0000000 --- a/core/modules/filter/templates/filter-admin-overview.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{# -/** - * @file - * Default theme implementation for an 'Text formats' (filters) administrative - * overview page. - * - * Available variables: - * - table: HTML for a table of text formats and their available operations. - * - children: The rendered form element children for this page. - * - * @see template_preprocess() - * @see template_preprocess_filter_admin_overview() - * - * @ingroup themeable - */ -#} -{{ table }} -{{ children }} diff --git a/core/modules/filter/templates/filter-guidelines.html.twig b/core/modules/filter/templates/filter-guidelines.html.twig index ca12dab..19eeb3e 100644 --- a/core/modules/filter/templates/filter-guidelines.html.twig +++ b/core/modules/filter/templates/filter-guidelines.html.twig @@ -10,14 +10,14 @@ * (only used when $long is TRUE) for each filter in one or more text * formats. * - * @TODO update include path once http://drupal.org/node/1777532 is resolved. + * @todo remove striptags when auto_escape is resolved http://drupal.org/node/1712444 * * @see template_preprocess() * * @ingroup themeable */ #} -
-

{{ format.name }}

+ +

{{ format.name|striptags }}

{{ tips }}
diff --git a/core/modules/filter/templates/filter-tips-more-info.html.twig b/core/modules/filter/templates/filter-tips-more-info.html.twig deleted file mode 100644 index 59b3290..0000000 --- a/core/modules/filter/templates/filter-tips-more-info.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{# -/** - * @file - * Default theme implementation for a link to the more extensive filter tips. - * - * Available variables: - * - * @see template_preprocess() - * @see template_preprocess_filter_tips_more_info() - * - * @ingroup themeable - */ - @todo: clean up once http://drupal.org/node/1812562 is resolved - @todo: remove this file once http://drupal.org/node/1595614 is resolved? -#} -

{{ 'More information about text formats' | t }}

diff --git a/core/modules/filter/templates/filter-tips.html.twig b/core/modules/filter/templates/filter-tips.html.twig index a5252da..62fff89 100644 --- a/core/modules/filter/templates/filter-tips.html.twig +++ b/core/modules/filter/templates/filter-tips.html.twig @@ -15,13 +15,13 @@ * @TODO reimplement once http://drupal.org/node/1778624 gets resolved. * * @see template_preprocess() - * @see _filter_tips() + * @see template_preprocess_filter_tips() * * @ingroup themeable */ #} {% if multiple %} -

{{ 'Text Formats' | t }}

+

{{ 'Text Formats'|t }}

{% endif %} {% if tips|length %} @@ -29,17 +29,17 @@
{% endif %} - {% for name, tiplist in tips %} + {% for tip in tips %} {% if multiple %} -
-

{{ name }}

+ +

{{ tip.name }}

{% endif %} - {% if tiplist|length > 0 %} + {% if tip.list|length > 0 %}
    - {% for tip in tiplist %} + {% for item in tip.list %} {# Only set the class if the type is long #} -
  • {{ tip.tip }}
  • + {{ item.tip }} {% endfor %}
{% endif %} diff --git a/core/modules/filter/templates/text-format-wrapper.html.twig b/core/modules/filter/templates/text-format-wrapper.html.twig index 2ac9de5..c3d332b 100644 --- a/core/modules/filter/templates/text-format-wrapper.html.twig +++ b/core/modules/filter/templates/text-format-wrapper.html.twig @@ -15,8 +15,8 @@ #}
{{ children }} - {% if description is defined %} -
{{ description }}
+ {% if description %} +
{{ description }}
{% endif %}