Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-11-03 01:28:30 +01:00
commit 9ae4ae8220
12 changed files with 119 additions and 175 deletions

View File

@ -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));
}

View File

@ -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(),

View File

@ -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,
]));
}
/**

View File

@ -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?

View File

@ -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());
}

View File

@ -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',
])
);
/**

View File

@ -1,73 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Shared code for server pages
*
* @package PhpMyAdmin
*/
namespace PhpMyAdmin\Server;
use PhpMyAdmin\Util;
/**
* PhpMyAdmin\Server\Common class
*
* @package PhpMyAdmin
*/
class Common
{
/**
* Returns the html for the sub-page heading
*
* @param string $type Sub page type
* @param string $link Link to the official MySQL documentation
* @param bool $is_image Display image or icon, true: image, false: icon
*
* @return string
*/
public static function getHtmlForSubPageHeader($type, $link='', $is_image=true)
{
//array contains Sub page icon and text
$header = array();
$header['variables']['image'] = 's_vars.png';
$header['variables']['text'] = __('Server variables and settings');
$header['engines']['image'] = 'b_engine.png';
$header['engines']['text'] = __('Storage Engines');
$header['plugins']['image'] = 'b_engine.png';
$header['plugins']['text'] = __('Plugins');
$header['binlog']['image'] = 's_tbl.png';
$header['binlog']['text'] = __('Binary log');
$header['collations']['image'] = 's_asci.png';
$header['collations']['text'] = __('Character Sets and Collations');
$header['replication']['image'] = 's_replication.png';
$header['replication']['text'] = __('Replication');
$header['database_statistics']['image'] = 's_db.png';
$header['database_statistics']['text'] = __('Databases statistics');
$header['databases']['image'] = 's_db.png';
$header['databases']['text'] = __('Databases');
$header['privileges']['image'] = 'b_usrlist.png';
$header['privileges']['text'] = __('Privileges');
if ($is_image) {
$html = '<h2>' . "\n"
. Util::getImage($header[$type]['image'])
. ' ' . $header[$type]['text'] . "\n"
. $link . '</h2>' . "\n";
} else {
$html = '<h2>' . "\n"
. Util::getIcon($header[$type]['image'])
. ' ' . $header[$type]['text'] . "\n"
. $link . '</h2>' . "\n";
}
return $html;
}
}

View File

@ -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()

View File

@ -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('<div id="replication">');
$response->addHTML(Common::getHtmlForSubPageHeader('replication'));
$response->addHTML(Template::get('server/sub_page_header')->render([
'type' => 'replication',
]));
// Display error messages
$response->addHTML(ReplicationGui::getHtmlForErrorMessage());

View File

@ -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 %}
<p>{% trans 'No databases' %}</p>
{% endif %}

View File

@ -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
}
} %}
<h2>
{% 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) }}
</h2>

View File

@ -1,64 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for PhpMyAdmin\Server\Common
*
* @package PhpMyAdmin-test
*/
namespace PhpMyAdmin\Tests\Server;
use PhpMyAdmin\Server\Common;
use PhpMyAdmin\Theme;
use PHPUnit_Framework_TestCase as TestCase;
/**
* This class is for testing PhpMyAdmin\Server\Common methods
*
* @package PhpMyAdmin-test
*/
class CommonTest extends TestCase
{
/**
* Test for Common::getHtmlForSubPageHeader
*
* @return void
*/
public function testPMAGetSubPageHeader()
{
//server_engines
$html = Common::getHtmlForSubPageHeader("engines");
$this->assertContains(
'<img src="themes/dot.gif" title="" alt="" class="icon ic_b_engine" />',
$html
);
$this->assertContains(
'Storage Engines',
$html
);
//server_databases
$html = Common::getHtmlForSubPageHeader("databases");
$this->assertContains(
'<img src="themes/dot.gif" title="" alt="" class="icon ic_s_db" />',
$html
);
$this->assertContains(
'Databases',
$html
);
//server_replication
$html = Common::getHtmlForSubPageHeader("replication");
$replication_img = '<img src="themes/dot.gif" title="" '
. 'alt="" class="icon ic_s_replication" />';
$this->assertContains(
$replication_img,
$html
);
$this->assertContains(
'Replication',
$html
);
}
}