Translated using Weblate (Dutch)
[phpmyadmin.git] / libraries / build_html_for_db.lib.php
blobe998272372dc94133746f20245fe77542ea6b857
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * HTML geneartor for database listing
7 * @package PhpMyAdmin
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /**
14 * Prepares the $column_order array
16 * @return array
18 function PMA_getColumnOrder()
20 $column_order['DEFAULT_COLLATION_NAME'] = array(
21 'disp_name' => __('Collation'),
22 'description_function' => 'PMA_getCollationDescr',
23 'format' => 'string',
24 'footer' => PMA_getServerCollation(),
26 $column_order['SCHEMA_TABLES'] = array(
27 'disp_name' => __('Tables'),
28 'format' => 'number',
29 'footer' => 0,
31 $column_order['SCHEMA_TABLE_ROWS'] = array(
32 'disp_name' => __('Rows'),
33 'format' => 'number',
34 'footer' => 0,
36 $column_order['SCHEMA_DATA_LENGTH'] = array(
37 'disp_name' => __('Data'),
38 'format' => 'byte',
39 'footer' => 0,
41 $column_order['SCHEMA_INDEX_LENGTH'] = array(
42 'disp_name' => __('Indexes'),
43 'format' => 'byte',
44 'footer' => 0,
46 $column_order['SCHEMA_LENGTH'] = array(
47 'disp_name' => __('Total'),
48 'format' => 'byte',
49 'footer' => 0,
51 $column_order['SCHEMA_DATA_FREE'] = array(
52 'disp_name' => __('Overhead'),
53 'format' => 'byte',
54 'footer' => 0,
57 return $column_order;
60 /**
61 * Builds the HTML td elements for one database to display in the list
62 * of databases from server_databases.php (which can be modified by
63 * db_create.php)
65 * @param array $current current database
66 * @param boolean $is_superuser user status
67 * @param string $url_query url query
68 * @param array $column_order column order
69 * @param array $replication_types replication types
70 * @param array $replication_info replication info
72 * @return array $column_order, $out
74 function PMA_buildHtmlForDb(
75 $current, $is_superuser, $url_query,
76 $column_order, $replication_types, $replication_info
77 ) {
78 $out = '';
79 if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
80 $out .= '<td class="tool">';
81 $out .= '<input type="checkbox" name="selected_dbs[]" class="checkall" '
82 . 'title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" '
83 . 'value="' . htmlspecialchars($current['SCHEMA_NAME']) . '"';
85 if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
86 $out .= ' disabled="disabled"';
88 $out .= ' /></td>';
90 $out .= '<td class="name">'
91 . '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
92 . '?' . $url_query . '&amp;db='
93 . urlencode($current['SCHEMA_NAME']) . '" title="'
94 . sprintf(
95 __('Jump to database'),
96 htmlspecialchars($current['SCHEMA_NAME'])
98 . '">'
99 . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
100 . '</a>'
101 . '</td>';
103 foreach ($column_order as $stat_name => $stat) {
104 if (array_key_exists($stat_name, $current)) {
105 if (is_numeric($stat['footer'])) {
106 $column_order[$stat_name]['footer'] += $current[$stat_name];
108 if ($stat['format'] === 'byte') {
109 list($value, $unit) = PMA_Util::formatByteDown(
110 $current[$stat_name], 3, 1
112 } elseif ($stat['format'] === 'number') {
113 $value = PMA_Util::formatNumber(
114 $current[$stat_name], 0
116 } else {
117 $value = htmlentities($current[$stat_name], 0);
119 $out .= '<td class="value">';
120 if (isset($stat['description_function'])) {
121 $out .= '<dfn title="'
122 . $stat['description_function']($current[$stat_name]) . '">';
124 $out .= $value;
125 if (isset($stat['description_function'])) {
126 $out .= '</dfn>';
128 $out .= '</td>';
129 if ($stat['format'] === 'byte') {
130 $out .= '<td class="unit">' . $unit . '</td>';
134 foreach ($replication_types as $type) {
135 if ($replication_info[$type]['status']) {
136 $out .= '<td class="tool" style="text-align: center;">';
138 $key = array_search(
139 $current["SCHEMA_NAME"],
140 $replication_info[$type]['Ignore_DB']
142 if (strlen($key) > 0) {
143 $out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
144 } else {
145 $key = array_search(
146 $current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
149 if (strlen($key) > 0
150 || ($replication_info[$type]['Do_DB'][0] == ""
151 && count($replication_info[$type]['Do_DB']) == 1)
153 // if ($key != null) did not work for index "0"
154 $out .= PMA_Util::getIcon('s_success.png', __('Replicated'));
158 $out .= '</td>';
162 if ($is_superuser && !PMA_DRIZZLE) {
163 $out .= '<td class="tool">'
164 . '<a onclick="'
165 . 'PMA_commonActions.setDb(\''
166 . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
167 . '" href="server_privileges.php?' . $url_query
168 . '&amp;db=' . urlencode($current['SCHEMA_NAME'])
169 . '&amp;checkprivsdb=' . urlencode($current['SCHEMA_NAME'])
170 . '" title="'
171 . sprintf(
172 __('Check privileges for database &quot;%s&quot;.'),
173 htmlspecialchars($current['SCHEMA_NAME'])
175 . '">'
176 . ' '
177 . PMA_Util::getIcon('s_rights.png', __('Check Privileges'))
178 . '</a></td>';
180 return array($column_order, $out);