diff --git a/libraries/classes/Controllers/Server/ServerBinlogController.php b/libraries/classes/Controllers/Server/ServerBinlogController.php index ddacdacc12..875089687b 100644 --- a/libraries/classes/Controllers/Server/ServerBinlogController.php +++ b/libraries/classes/Controllers/Server/ServerBinlogController.php @@ -67,7 +67,11 @@ class ServerBinlogController extends Controller $url_params['dontlimitchars'] = 1; } - $this->response->addHTML(Common::getHtmlForSubPageHeader('binlog')); + $this->response->addHTML( + Template::get('server/sub_page_header')->render([ + 'type' => 'binlog', + ]) + ); $this->response->addHTML($this->_getLogSelector($url_params)); $this->response->addHTML($this->_getLogInfo($url_params)); } diff --git a/libraries/classes/Controllers/Server/ServerCollationsController.php b/libraries/classes/Controllers/Server/ServerCollationsController.php index 6b28dc958f..6063d0bd7b 100644 --- a/libraries/classes/Controllers/Server/ServerCollationsController.php +++ b/libraries/classes/Controllers/Server/ServerCollationsController.php @@ -33,7 +33,11 @@ class ServerCollationsController extends Controller */ include_once 'libraries/server_common.inc.php'; - $this->response->addHTML(Common::getHtmlForSubPageHeader('collations')); + $this->response->addHTML( + Template::get('server/sub_page_header')->render([ + 'type' => 'collations', + ]) + ); $this->response->addHTML( $this->_getHtmlForCharsets( Charsets::getMySQLCharsets(), diff --git a/libraries/classes/Controllers/Server/ServerDatabasesController.php b/libraries/classes/Controllers/Server/ServerDatabasesController.php index 9de61c4a0a..ca863578df 100644 --- a/libraries/classes/Controllers/Server/ServerDatabasesController.php +++ b/libraries/classes/Controllers/Server/ServerDatabasesController.php @@ -89,27 +89,6 @@ class ServerDatabasesController extends Controller $this->_dbstats = empty($_REQUEST['dbstats']) ? false : true; $this->_pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos']; - /** - * Displays the sub-page heading - */ - $header_type = $this->_dbstats ? "database_statistics" : "databases"; - $this->response->addHTML(Common::getHtmlForSubPageHeader($header_type)); - - /** - * Displays For Create database. - */ - $html = ''; - if ($GLOBALS['cfg']['ShowCreateDb']) { - $html .= Template::get('server/databases/create')->render([ - 'is_create_db_priv' => $GLOBALS['is_create_db_priv'], - 'dbstats' => $this->_dbstats, - 'db_to_create' => $GLOBALS['db_to_create'], - 'server_collation' => $GLOBALS['dbi']->getServerCollation(), - ]); - } - - $html .= Template::get('filter')->render(array('filter_value'=>'')); - /** * Gets the databases list */ @@ -123,16 +102,18 @@ class ServerDatabasesController extends Controller $this->_database_count = 0; } - /** - * Displays the page - */ if ($this->_database_count > 0 && ! empty($this->_databases)) { - $html .= $this->_getHtmlForDatabases($replication_types); - } else { - $html .= __('No databases'); + $databases = $this->_getHtmlForDatabases($replication_types); } - $this->response->addHTML($html); + $this->response->addHTML(Template::get('server/databases/index')->render([ + 'show_create_db' => $GLOBALS['cfg']['ShowCreateDb'], + 'is_create_db_priv' => $GLOBALS['is_create_db_priv'], + 'dbstats' => $this->_dbstats, + 'db_to_create' => $GLOBALS['db_to_create'], + 'server_collation' => $GLOBALS['dbi']->getServerCollation(), + 'databases' => isset($databases) ? $databases : null, + ])); } /** diff --git a/libraries/classes/Controllers/Server/ServerEnginesController.php b/libraries/classes/Controllers/Server/ServerEnginesController.php index 59e385a9d6..5362f5c6f9 100644 --- a/libraries/classes/Controllers/Server/ServerEnginesController.php +++ b/libraries/classes/Controllers/Server/ServerEnginesController.php @@ -37,7 +37,11 @@ class ServerEnginesController extends Controller /** * Displays the sub-page heading */ - $this->response->addHTML(Common::getHtmlForSubPageHeader('engines')); + $this->response->addHTML( + Template::get('server/sub_page_header')->render([ + 'type' => 'engines', + ]) + ); /** * Did the user request information about a certain storage engine? diff --git a/libraries/classes/Controllers/Server/ServerPluginsController.php b/libraries/classes/Controllers/Server/ServerPluginsController.php index 79a194214c..f02c03b1ad 100644 --- a/libraries/classes/Controllers/Server/ServerPluginsController.php +++ b/libraries/classes/Controllers/Server/ServerPluginsController.php @@ -51,7 +51,11 @@ class ServerPluginsController extends Controller /** * Displays the page */ - $this->response->addHTML(Common::getHtmlForSubPageHeader('plugins')); + $this->response->addHTML( + Template::get('server/sub_page_header')->render([ + 'type' => 'plugins', + ]) + ); $this->response->addHTML($this->_getPluginsHtml()); } diff --git a/libraries/classes/Controllers/Server/ServerVariablesController.php b/libraries/classes/Controllers/Server/ServerVariablesController.php index a3068c384e..8e800c843a 100644 --- a/libraries/classes/Controllers/Server/ServerVariablesController.php +++ b/libraries/classes/Controllers/Server/ServerVariablesController.php @@ -72,9 +72,11 @@ class ServerVariablesController extends Controller /** * Displays the sub-page heading */ - $doc_link = Util::showMySQLDocu('server_system_variables'); - $this->response->addHtml( - Common::getHtmlForSubPageHeader('variables', $doc_link) + $this->response->addHTML( + Template::get('server/sub_page_header')->render([ + 'type' => 'variables', + 'link' => 'server_system_variables', + ]) ); /** diff --git a/libraries/classes/Server/Common.php b/libraries/classes/Server/Common.php deleted file mode 100644 index 6c7e0fbf11..0000000000 --- a/libraries/classes/Server/Common.php +++ /dev/null @@ -1,73 +0,0 @@ -' . "\n" - . Util::getImage($header[$type]['image']) - . ' ' . $header[$type]['text'] . "\n" - . $link . '' . "\n"; - } else { - $html = '

' . "\n" - . Util::getIcon($header[$type]['image']) - . ' ' . $header[$type]['text'] . "\n" - . $link . '

' . "\n"; - } - return $html; - } -} diff --git a/server_privileges.php b/server_privileges.php index 9a1fd540ff..804ec40029 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -13,6 +13,7 @@ use PhpMyAdmin\Response; use PhpMyAdmin\Server\Common; use PhpMyAdmin\Server\Privileges; use PhpMyAdmin\Server\Users; +use PhpMyAdmin\Template; /** * include common file @@ -132,7 +133,12 @@ list( if (!$GLOBALS['dbi']->isSuperuser() && !$GLOBALS['is_grantuser'] && !$GLOBALS['is_createuser'] ) { - $response->addHTML(Common::getHtmlForSubPageHeader('privileges', '', false)); + $response->addHTML( + Template::get('server/sub_page_header')->render([ + 'type' => 'privileges', + 'is_image' => false, + ]) + ); $response->addHTML( Message::error(__('No Privileges')) ->getDisplay() diff --git a/server_replication.php b/server_replication.php index 3e33c3232a..9ba60b41f9 100644 --- a/server_replication.php +++ b/server_replication.php @@ -9,6 +9,7 @@ use PhpMyAdmin\ReplicationGui; use PhpMyAdmin\Response; use PhpMyAdmin\Server\Common; +use PhpMyAdmin\Template; /** * include files @@ -31,7 +32,9 @@ $scripts->addFile('vendor/zxcvbn.js'); * Checks if the user is allowed to do what he tries to... */ if (! $GLOBALS['dbi']->isSuperuser()) { - $html = Common::getHtmlForSubPageHeader('replication'); + $html = Template::get('server/sub_page_header')->render([ + 'type' => 'replication', + ]); $html .= PhpMyAdmin\Message::error(__('No Privileges'))->getDisplay(); $response->addHTML($html); exit; @@ -52,7 +55,9 @@ ReplicationGui::handleControlRequest(); * start output */ $response->addHTML('
'); -$response->addHTML(Common::getHtmlForSubPageHeader('replication')); +$response->addHTML(Template::get('server/sub_page_header')->render([ + 'type' => 'replication', +])); // Display error messages $response->addHTML(ReplicationGui::getHtmlForErrorMessage()); diff --git a/templates/server/databases/index.twig b/templates/server/databases/index.twig new file mode 100644 index 0000000000..9f164b3e28 --- /dev/null +++ b/templates/server/databases/index.twig @@ -0,0 +1,23 @@ +{# Displays the sub-page heading #} +{% include 'server/sub_page_header.twig' with { + 'type': dbstats ? 'database_statistics' : 'databases' +} only %} + +{# Displays For Create database #} +{% if show_create_db %} + {% include 'server/databases/create.twig' with { + 'is_create_db_priv': is_create_db_priv, + 'dbstats': dbstats, + 'db_to_create': db_to_create, + 'server_collation': server_collation + } only %} +{% endif %} + +{% include 'filter.twig' with {'filter_value': ''} only %} + +{# Displays the page #} +{% if databases is not null %} + {{ databases|raw }} +{% else %} +

{% trans 'No databases' %}

+{% endif %} diff --git a/templates/server/sub_page_header.twig b/templates/server/sub_page_header.twig new file mode 100644 index 0000000000..4d04a296b5 --- /dev/null +++ b/templates/server/sub_page_header.twig @@ -0,0 +1,48 @@ +{# array contains Sub page icon and text #} +{% set header = { + 'variables': { + 'image': 's_vars.png', + 'text': 'Server variables and settings'|trans + }, + 'engines': { + 'image': 'b_engine.png', + 'text': 'Storage engines'|trans + }, + 'plugins': { + 'image': 'b_engine.png', + 'text': 'Plugins'|trans + }, + 'binlog': { + 'image': 's_tbl.png', + 'text': 'Binary log'|trans + }, + 'collations': { + 'image': 's_asci.png', + 'text': 'Character sets and collations'|trans + }, + 'replication': { + 'image': 's_replication.png', + 'text': 'Replication'|trans + }, + 'database_statistics': { + 'image': 's_db.png', + 'text': 'Databases statistics'|trans + }, + 'databases': { + 'image': 's_db.png', + 'text': 'Databases'|trans + }, + 'privileges': { + 'image': 'b_usrlist.png', + 'text': 'Privileges'|trans + } +} %} +

+ {% if is_image|default(true) %} + {{ Util_getImage(header[type]['image']) }} + {% else %} + {{ Util_getIcon(header[type]['image']) }} + {% endif %} + {{ header[type]['text'] }} + {{ link is defined ? Util_showMySQLDocu(link) }} +

diff --git a/test/classes/Server/CommonTest.php b/test/classes/Server/CommonTest.php deleted file mode 100644 index e18ae5532b..0000000000 --- a/test/classes/Server/CommonTest.php +++ /dev/null @@ -1,64 +0,0 @@ -assertContains( - '', - $html - ); - $this->assertContains( - 'Storage Engines', - $html - ); - - //server_databases - $html = Common::getHtmlForSubPageHeader("databases"); - $this->assertContains( - '', - $html - ); - $this->assertContains( - 'Databases', - $html - ); - - //server_replication - $html = Common::getHtmlForSubPageHeader("replication"); - $replication_img = ''; - $this->assertContains( - $replication_img, - $html - ); - $this->assertContains( - 'Replication', - $html - ); - } - -}