From abb1929c6a99cf015fe19d31c89255909cd4a9f8 Mon Sep 17 00:00:00 2001 From: Sharik Shaikh Date: Wed, 30 Jan 2019 20:49:36 +0530 Subject: [PATCH] Extracted html from transformation_overview.php to template/transformation_overview.twig (#14852) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Extracted html from transformation_overview.php to transformation_overview.twig Signed-off-by: Sharik Shaikh Signed-off-by: MaurĂ­cio Meneghini Fauth --- templates/transformation_overview.twig | 32 ++++++++++ transformation_overview.php | 87 +++++++++++++------------- 2 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 templates/transformation_overview.twig diff --git a/templates/transformation_overview.twig b/templates/transformation_overview.twig new file mode 100644 index 0000000000..7607d1c675 --- /dev/null +++ b/templates/transformation_overview.twig @@ -0,0 +1,32 @@ +

{% trans 'Available MIME types' %}

+ +{% for mime_type in types.mimetype %} + {% if types.empty_mimetype.mimetype %} + {{ mime_type }} + {% else %} + {{ mime_type }}
+ {% endif %} +{% endfor %} +
+{% for ttype in transformation_types %} + +

{{ ttype.label }}

+ + + + + + + {% for type in ttype.types %} + + + + + {% endfor %} + +
+ {{ table_headings_label[ttype.title] }} + + {% trans %}Description {{ ttype._pgettext }} for MIME transformation{% endtrans %} +
{{ type.transform }}{{ type.description }}
+{% endfor %} diff --git a/transformation_overview.php b/transformation_overview.php index 8af8298d7f..b2ec5f7ee9 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -9,6 +9,7 @@ declare(strict_types=1); use PhpMyAdmin\Response; use PhpMyAdmin\Transformations; +use PhpMyAdmin\Template; if (! defined('ROOT_PATH')) { define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR); @@ -20,60 +21,60 @@ if (! defined('ROOT_PATH')) { require_once ROOT_PATH . 'libraries/common.inc.php'; $response = Response::getInstance(); -$header = $response->getHeader(); +$header = $response->getHeader(); $header->disableMenuAndConsole(); $transformations = new Transformations(); $types = $transformations->getAvailableMimeTypes(); -?> -

- $mimetype) { - if (isset($types['empty_mimetype'][$mimetype])) { - echo '' , htmlspecialchars($mimetype) , '
'; - } else { - echo htmlspecialchars($mimetype) , '
'; - } -} -$transformation_types = [ - 'transformation', - 'input_transformation', -]; -$label = [ +/** + * Preparing all labels which are required on view template + */ +$labels = [ + 'available_MIME_types' => __('Available MIME types'), 'transformation' => __('Available browser display transformations'), 'input_transformation' => __('Available input transformations'), ]; -$th = [ + +/** + * Preparing labels for table Table Heading () + */ +$tableHeadLabels = [ 'transformation' => __('Browser display transformation'), 'input_transformation' => __('Input transformation'), ]; -?> -
- - -

- - - - - - - - - [], + 'input_transformation' => [], +]; + +/** + * Looping over transformations and preparing labels, titles, text and transformation types to prepare + * nested array so that view template can easily get all required information. + */ +foreach (['transformation', 'input_transformation'] as $ttype) { + // settings title, text and labels for transformation + $transformation_types[$ttype]['title'] = $ttype; + $transformation_types[$ttype]['_pgettext'] = _pgettext('for MIME transformation', 'Description'); + $transformation_types[$ttype]['label'] = $labels[$ttype]; + + $transformation_types[$ttype]['types'] = []; + + // Settings types for current transformation foreach ($types[$ttype] as $key => $transform) { - $desc = $transformations->getDescription($types[$ttype . '_file'][$key]); - ?> - - - - - $transform, + 'description' => $transformations->getDescription($types[$ttype . '_file'][$key]), + ]; } - ?> - -
- render('transformation_overview', [ + 'label' => $labels, + 'types' => $transformations->getAvailableMimeTypes(), + 'transformation_types' => $transformation_types, + 'table_headings_label' => $tableHeadLabels, +]);