From a75010c8b906f83e3f934336c929d50e5bfe91af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 24 Oct 2017 22:27:02 -0200 Subject: [PATCH 1/2] Port database/structure/table_header to Twig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- .../Database/DatabaseStructureController.php | 44 +++++++----- libraries/classes/Twig/SanitizeExtension.php | 5 ++ libraries/classes/Twig/UtilExtension.php | 5 ++ .../structure/structure_table_row.twig | 33 +++++++++ .../database/structure/table_header.phtml | 71 ------------------- .../database/structure/table_header.twig | 67 +++++++++++++++++ 6 files changed, 137 insertions(+), 88 deletions(-) delete mode 100644 templates/database/structure/table_header.phtml create mode 100644 templates/database/structure/table_header.twig diff --git a/libraries/classes/Controllers/Database/DatabaseStructureController.php b/libraries/classes/Controllers/Database/DatabaseStructureController.php index 05ad782e81c4..67596d62654a 100644 --- a/libraries/classes/Controllers/Database/DatabaseStructureController.php +++ b/libraries/classes/Controllers/Database/DatabaseStructureController.php @@ -371,18 +371,23 @@ protected function displayTableList() { // filtering $this->response->addHTML( - Template::get('filter')->render(array('filter_value'=>'')) + Template::get('filter')->render(array('filter_value' => '')) ); // table form $this->response->addHTML( - Template::get('database/structure/table_header') - ->render( - array( - 'db' => $this->db, - 'db_is_system_schema' => $this->_db_is_system_schema, - 'replication' => $GLOBALS['replication_info']['slave']['status'], - ) - ) + Template::get('database/structure/table_header')->render([ + 'db' => $this->db, + 'db_is_system_schema' => $this->_db_is_system_schema, + 'replication' => $GLOBALS['replication_info']['slave']['status'], + 'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'], + 'is_show_stats' => $GLOBALS['is_show_stats'], + 'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'], + 'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'], + 'show_creation' => $GLOBALS['cfg']['ShowDbStructureCreation'], + 'show_last_update' => $GLOBALS['cfg']['ShowDbStructureLastUpdate'], + 'show_last_check' => $GLOBALS['cfg']['ShowDbStructureLastCheck'], + 'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'], + ]) ); $i = $sum_entries = 0; @@ -604,13 +609,19 @@ protected function displayTableList() ); $this->response->addHTML( - Template::get('database/structure/table_header')->render( - array( - 'db' => $this->db, - 'db_is_system_schema' => $this->_db_is_system_schema, - 'replication' => $GLOBALS['replication_info']['slave']['status'] - ) - ) + Template::get('database/structure/table_header')->render([ + 'db' => $this->db, + 'db_is_system_schema' => $this->_db_is_system_schema, + 'replication' => $GLOBALS['replication_info']['slave']['status'], + 'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'], + 'is_show_stats' => $GLOBALS['is_show_stats'], + 'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'], + 'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'], + 'show_creation' => $GLOBALS['cfg']['ShowDbStructureCreation'], + 'show_last_update' => $GLOBALS['cfg']['ShowDbStructureLastUpdate'], + 'show_last_check' => $GLOBALS['cfg']['ShowDbStructureLastCheck'], + 'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'], + ]) ); } @@ -654,7 +665,6 @@ protected function displayTableList() 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, - 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable( diff --git a/libraries/classes/Twig/SanitizeExtension.php b/libraries/classes/Twig/SanitizeExtension.php index 3420daa024b8..a3ca99f014f0 100644 --- a/libraries/classes/Twig/SanitizeExtension.php +++ b/libraries/classes/Twig/SanitizeExtension.php @@ -30,6 +30,11 @@ public function getFunctions() 'PhpMyAdmin\Sanitize::escapeJsString', array('is_safe' => array('html')) ), + new Twig_SimpleFunction( + 'Sanitize_sanitize', + 'PhpMyAdmin\Sanitize::sanitize', + array('is_safe' => array('html')) + ), ); } } diff --git a/libraries/classes/Twig/UtilExtension.php b/libraries/classes/Twig/UtilExtension.php index 206eff8fd5f9..b98115da7a6b 100644 --- a/libraries/classes/Twig/UtilExtension.php +++ b/libraries/classes/Twig/UtilExtension.php @@ -144,6 +144,11 @@ public function getFunctions() 'PhpMyAdmin\Util::showMySQLDocu', array('is_safe' => array('html')) ), + new Twig_SimpleFunction( + 'Util_sortableTableHeader', + 'PhpMyAdmin\Util::sortableTableHeader', + array('is_safe' => array('html')) + ), ); } } diff --git a/templates/database/structure/structure_table_row.twig b/templates/database/structure/structure_table_row.twig index c348e0d00f48..e69b1acbb19f 100644 --- a/templates/database/structure/structure_table_row.twig +++ b/templates/database/structure/structure_table_row.twig @@ -184,6 +184,39 @@ {% endif %} {% else %} + {% set count = 0 %} + {% if properties_num_columns %} + {% set count = count + 2 %} + {% endif %} + {% if is_show_stats %} + {% set count = count + 2 %} + {% endif %} + {% if show_charset %} + {% set count = count + 1 %} + {% endif %} + {% if show_comment %} + {% set count = count + 1 %} + {% endif %} + {% if show_creation %} + {% set count = count + 1 %} + {% endif %} + {% if show_last_update %} + {% set count = count + 1 %} + {% endif %} + {% if show_last_check %} + {% set count = count + 1 %} + {% endif %} + + {% if db_is_system_schema %} + {% set action_colspan = 3 %} + {% else %} + {% set action_colspan = 6 %} + {% endif %} + {% if num_favorite_tables > 0 %} + {% set action_colspan = action_colspan + 1 %} + {% endif %} + + {% set colspan_for_structure = action_colspan + 3 %} {% trans 'in use' %} diff --git a/templates/database/structure/table_header.phtml b/templates/database/structure/table_header.phtml deleted file mode 100644 index e92bbd67de78..000000000000 --- a/templates/database/structure/table_header.phtml +++ /dev/null @@ -1,71 +0,0 @@ - 0) { - $action_colspan++; -} -?> -
- -
- - - - - - - - - - - - 1)): ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/templates/database/structure/table_header.twig b/templates/database/structure/table_header.twig new file mode 100644 index 000000000000..ead52e97b229 --- /dev/null +++ b/templates/database/structure/table_header.twig @@ -0,0 +1,67 @@ + +{{ Url_getHiddenInputs(db) }} +
+
- - - - -
+ + + + + {% if replication %} + + {% endif %} + + {% if db_is_system_schema %} + {% set action_colspan = 3 %} + {% else %} + {% set action_colspan = 6 %} + {% endif %} + {% if num_favorite_tables > 0 %} + {% set action_colspan = action_colspan + 1 %} + {% endif %} + + {# larger values are more interesting so default sort order is DESC #} + + {% if not (properties_num_columns > 1) %} + + + {% endif %} + + {% if is_show_stats %} + {# larger values are more interesting so default sort order is DESC #} + + {# larger values are more interesting so default sort order is DESC #} + + {% endif %} + + {% if show_charset %} + + {% endif %} + + {% if show_comment %} + + {% endif %} + + {% if show_creation %} + {# newer values are more interesting so default sort order is DESC #} + + {% endif %} + + {% if show_last_update %} + {# newer values are more interesting so default sort order is DESC #} + + {% endif %} + + {% if show_last_check %} + {# newer values are more interesting so default sort order is DESC #} + + {% endif %} + + + From f9dd640c1ad602f1905994b207fb848de7671f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 24 Oct 2017 23:32:52 -0200 Subject: [PATCH 2/2] Port privileges/initials_row template to Twig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- libraries/classes/Server/Privileges.php | 3 ++- templates/privileges/initials_row.phtml | 28 ------------------------- templates/privileges/initials_row.twig | 24 +++++++++++++++++++++ test/classes/Server/PrivilegesTest.php | 1 + 4 files changed, 27 insertions(+), 29 deletions(-) delete mode 100644 templates/privileges/initials_row.phtml create mode 100644 templates/privileges/initials_row.twig diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index 0d78c0012915..9b8c44ec34fb 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -3759,7 +3759,8 @@ public static function getHtmlForInitials(array $array_initials) $html_output = Template::get('privileges/initials_row') ->render( array( - 'array_initials' => $array_initials + 'array_initials' => $array_initials, + 'initial' => $_REQUEST['initial'], ) ); diff --git a/templates/privileges/initials_row.phtml b/templates/privileges/initials_row.phtml deleted file mode 100644 index d867b0278a2c..000000000000 --- a/templates/privileges/initials_row.phtml +++ /dev/null @@ -1,28 +0,0 @@ -
{{ Util_sortableTableHeader('Table'|trans, 'table') }}{% trans 'Replication' %} + {% trans 'Action' %} + + {{ Util_sortableTableHeader('Rows'|trans, 'records', 'DESC') }} + {{ Util_showHint(Sanitize_sanitize( + 'May be approximate. Click on the number to get the exact count. See [doc@faq3-11]FAQ 3.11[/doc].'|trans + )) }} + {{ Util_sortableTableHeader('Type'|trans, 'type') }}{{ Util_sortableTableHeader('Collation'|trans, 'collation') }}{{ Util_sortableTableHeader('Size'|trans, 'size', 'DESC') }}{{ Util_sortableTableHeader('Overhead'|trans, 'overhead', 'DESC') }}{{ Util_sortableTableHeader('Charset'|trans, 'charset') }}{{ Util_sortableTableHeader('Comment'|trans, 'comment') }}{{ Util_sortableTableHeader('Creation'|trans, 'creation', 'DESC') }}{{ Util_sortableTableHeader('Last update'|trans, 'last_update', 'DESC') }}{{ Util_sortableTableHeader('Last check'|trans, 'last_check', 'DESC') }}
- - $initial_was_found) : ?> - - - - - - - - - - - - - -
- - $tmp_initial)); ?> - - - - - -
diff --git a/templates/privileges/initials_row.twig b/templates/privileges/initials_row.twig new file mode 100644 index 000000000000..a36e14216d1a --- /dev/null +++ b/templates/privileges/initials_row.twig @@ -0,0 +1,24 @@ + + + {% for tmp_initial, initial_was_found in array_initials if tmp_initial is not same as(null) %} + {% if initial_was_found %} + + {% else %} + + {% endif %} + {% endfor %} + + +
+ + {{- tmp_initial|raw -}} + + {{ tmp_initial|raw }} + + {% trans 'Show all' %} + +
diff --git a/test/classes/Server/PrivilegesTest.php b/test/classes/Server/PrivilegesTest.php index 00ce759881f4..45b298092eb3 100644 --- a/test/classes/Server/PrivilegesTest.php +++ b/test/classes/Server/PrivilegesTest.php @@ -38,6 +38,7 @@ public function setUp() //$_REQUEST $_REQUEST['log'] = "index1"; $_REQUEST['pos'] = 3; + $_REQUEST['initial'] = null; //$GLOBALS $GLOBALS['lang'] = 'en';