From 461cc87521f16cea9e36275a998bf633c3f8ae28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 12 Sep 2020 20:43:55 -0300 Subject: [PATCH] Remove list templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - templates/list/item.twig - templates/list/unordered.twig Signed-off-by: MaurĂ­cio Meneghini Fauth --- .../classes/Config/FormDisplayTemplate.php | 18 +------ .../classes/Controllers/HomeController.php | 51 +------------------ libraries/classes/Relation.php | 24 +-------- templates/config/form_display/tabs_top.twig | 6 +++ templates/home/index.twig | 25 +++++++-- templates/list/item.twig | 19 ------- templates/list/unordered.twig | 14 ----- templates/relation/diagnostic_info.twig | 19 +++++++ 8 files changed, 49 insertions(+), 127 deletions(-) create mode 100644 templates/config/form_display/tabs_top.twig delete mode 100644 templates/list/item.twig delete mode 100644 templates/list/unordered.twig create mode 100644 templates/relation/diagnostic_info.twig diff --git a/libraries/classes/Config/FormDisplayTemplate.php b/libraries/classes/Config/FormDisplayTemplate.php index 5341b2144d..9ea26e92bc 100644 --- a/libraries/classes/Config/FormDisplayTemplate.php +++ b/libraries/classes/Config/FormDisplayTemplate.php @@ -91,23 +91,7 @@ class FormDisplayTemplate */ public function displayTabsTop(array $tabs): string { - $items = []; - foreach ($tabs as $tabId => $tabName) { - $items[] = [ - 'content' => htmlspecialchars($tabName), - 'url' => [ - 'href' => '#' . $tabId, - ], - ]; - } - - $htmlOutput = $this->template->render('list/unordered', [ - 'class' => 'tabs responsivetable row', - 'items' => $items, - ]); - $htmlOutput .= '
'; - - return $htmlOutput; + return $this->template->render('config/form_display/tabs_top', ['tabs' => $tabs]); } /** diff --git a/libraries/classes/Controllers/HomeController.php b/libraries/classes/Controllers/HomeController.php index a0ab20eea7..5f9aed4965 100644 --- a/libraries/classes/Controllers/HomeController.php +++ b/libraries/classes/Controllers/HomeController.php @@ -109,23 +109,6 @@ class HomeController extends AbstractController $checkUserPrivileges = new CheckUserPrivileges($this->dbi); $checkUserPrivileges->getPrivileges(); - if (($cfg['Server']['auth_type'] !== 'config') && $cfg['ShowChgPassword']) { - $changePassword = $this->template->render('list/item', [ - 'content' => Generator::getImage('s_passwd') . ' ' . __( - 'Change password' - ), - 'id' => 'li_change_password', - 'class' => 'list-group-item', - 'url' => [ - 'href' => Url::getFromRoute('/user-password'), - 'target' => null, - 'id' => 'change_password_anchor', - 'class' => 'ajax', - ], - 'mysql_help_page' => null, - ]); - } - $charsets = Charsets::getCharsets($this->dbi, $cfg['Server']['DisableIS']); $collations = Charsets::getCollations($this->dbi, $cfg['Server']['DisableIS']); $charsetsList = []; @@ -146,21 +129,6 @@ class HomeController extends AbstractController 'collations' => $collationsList, ]; } - - $userPreferences = $this->template->render('list/item', [ - 'content' => Generator::getImage('b_tblops') . ' ' . __( - 'More settings' - ), - 'id' => 'li_user_preferences', - 'class' => 'list-group-item', - 'url' => [ - 'href' => Url::getFromRoute('/preferences/manage'), - 'target' => null, - 'id' => null, - 'class' => null, - ], - 'mysql_help_page' => null, - ]); } } @@ -217,20 +185,6 @@ class HomeController extends AbstractController $webServer['php_version'] = PHP_VERSION; } } - if ($cfg['ShowPhpInfo']) { - $phpInfo = $this->template->render('list/item', [ - 'content' => __('Show PHP information'), - 'id' => null, - 'class' => 'list-group-item', - 'url' => [ - 'href' => Url::getFromRoute('/phpinfo'), - 'target' => '_blank', - 'id' => null, - 'class' => null, - ], - 'mysql_help_page' => null, - ]); - } $relation = new Relation($this->dbi); if ($server > 0) { @@ -278,14 +232,13 @@ class HomeController extends AbstractController 'is_demo' => $cfg['DBG']['demo'], 'has_server_selection' => $hasServerSelection ?? false, 'server_selection' => $serverSelection ?? '', - 'change_password' => $changePassword ?? '', + 'has_change_password_link' => $cfg['Server']['auth_type'] !== 'config' && $cfg['ShowChgPassword'], 'charsets' => $charsetsList ?? [], 'language_selector' => $languageSelector, 'theme_selection' => $themeSelection, - 'user_preferences' => $userPreferences ?? '', 'database_server' => $databaseServer, 'web_server' => $webServer, - 'php_info' => $phpInfo ?? '', + 'show_php_info' => $cfg['ShowPhpInfo'], 'is_version_checked' => $cfg['VersionCheck'], 'phpmyadmin_version' => PMA_VERSION, 'config_storage_message' => $configStorageMessage ?? '', diff --git a/libraries/classes/Relation.php b/libraries/classes/Relation.php index dae1c4d1c0..85d792cced 100644 --- a/libraries/classes/Relation.php +++ b/libraries/classes/Relation.php @@ -403,29 +403,7 @@ class Relation $retval .= '' . "\n"; if (! $cfgRelation['allworks']) { - $retval .= '

' . __('Quick steps to set up advanced features:') - . '

'; - - $items = []; - $items[] = sprintf( - __( - 'Create the needed tables with the ' - . '%screate_tables.sql.' - ), - htmlspecialchars(SQL_DIR) - ) . ' ' . MySQLDocumentation::showDocumentation('setup', 'linked-tables'); - $items[] = __('Create a pma user and give access to these tables.') . ' ' - . MySQLDocumentation::showDocumentation('config', 'cfg_Servers_controluser'); - $items[] = __( - 'Enable advanced features in configuration file ' - . '(config.inc.php), for example by ' - . 'starting from config.sample.inc.php.' - ) . ' ' . MySQLDocumentation::showDocumentation('setup', 'quick-install'); - $items[] = __( - 'Re-login to phpMyAdmin to load the updated configuration file.' - ); - - $retval .= $this->template->render('list/unordered', ['items' => $items]); + $retval .= $this->template->render('relation/diagnostic_info', ['sql_dir' => SQL_DIR]); } } diff --git a/templates/config/form_display/tabs_top.twig b/templates/config/form_display/tabs_top.twig new file mode 100644 index 0000000000..ec50f7939b --- /dev/null +++ b/templates/config/form_display/tabs_top.twig @@ -0,0 +1,6 @@ +
    + {% for id, name in tabs %} +
  • {{ name }}
  • + {% endfor %} +
+
diff --git a/templates/home/index.twig b/templates/home/index.twig index e958ab514c..867cdef6b4 100644 --- a/templates/home/index.twig +++ b/templates/home/index.twig @@ -40,7 +40,13 @@ {% endif %} {% if server > 0 %} - {{ change_password is not empty ? change_password|raw }} + {% if has_change_password_link %} +
  • + + {{ get_icon('s_passwd', 'Change password'|trans, true) }} + +
  • + {% endif %}
  • @@ -67,8 +73,13 @@ {% endif %}
  • + +
  • + + {{ get_icon('b_tblops', 'More settings'|trans, true) }} + +
  • {% endif %} - {{ user_preferences is not empty ? user_preferences|raw }}
    {% endif %} @@ -136,7 +147,7 @@
    {% endif %} - {% if web_server is not empty or php_info is not empty %} + {% if web_server is not empty or show_php_info %}
    {% trans 'Web server' %} @@ -162,8 +173,12 @@ {{ web_server.php_version }} {% endif %} - {% if php_info is not empty %} - {{ php_info|raw }} + {% if show_php_info %} +
  • + + {% trans 'Show PHP information' %} + +
  • {% endif %}
    diff --git a/templates/list/item.twig b/templates/list/item.twig deleted file mode 100644 index 78f5e38750..0000000000 --- a/templates/list/item.twig +++ /dev/null @@ -1,19 +0,0 @@ - - - {% if url is defined and url is iterable and url['href'] is not empty %} - - {% endif %} - {{ content|raw }} - {% if url is defined and url is iterable and url['href'] is not empty %} - - {% endif %} - {% if mysql_help_page is not empty %} - {{ show_mysql_docu(mysql_help_page) }} - {% endif %} - diff --git a/templates/list/unordered.twig b/templates/list/unordered.twig deleted file mode 100644 index 11f114e1b4..0000000000 --- a/templates/list/unordered.twig +++ /dev/null @@ -1,14 +0,0 @@ - - - {% if items is not empty %} - {% for item in items %} - {% if item is not iterable %} - {% set item = {'content': item} %} - {% endif %} - {% include 'list/item.twig' with item only %} - {% endfor %} - {% elseif content is not empty %} - {{ content|raw }} - {% endif %} - diff --git a/templates/relation/diagnostic_info.twig b/templates/relation/diagnostic_info.twig new file mode 100644 index 0000000000..266121dc11 --- /dev/null +++ b/templates/relation/diagnostic_info.twig @@ -0,0 +1,19 @@ +

    {% trans 'Quick steps to set up advanced features:' %}

    + +
      +
    • + {{ 'Create the needed tables with the %screate_tables.sql.'|trans|format(sql_dir|e)|raw }} + {{ show_docu('setup', 'linked-tables') }} +
    • +
    • + {% trans 'Create a pma user and give access to these tables.' %} + {{ show_docu('config', 'cfg_Servers_controluser') }} +
    • +
    • + {% trans 'Enable advanced features in configuration file (config.inc.php), for example by starting from config.sample.inc.php.' %} + {{ show_docu('setup', 'quick-install') }} +
    • +
    • + {% trans 'Re-login to phpMyAdmin to load the updated configuration file.' %} +
    • +