Translation update done using Pootle.
[phpmyadmin-themes.git] / libraries / build_html_for_db.lib.php
blob6f4357c4cbe4794f0b59f13b8c05182a732e23d7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 /**
12 * Prepares the $column_order array
14 * @return array
16 function PMA_getColumnOrder() {
18 $column_order['DEFAULT_COLLATION_NAME'] = array(
19 'disp_name' => __('Collation'),
20 'description_function' => 'PMA_getCollationDescr',
21 'format' => 'string',
22 'footer' => PMA_getServerCollation(),
24 $column_order['SCHEMA_TABLES'] = array(
25 'disp_name' => __('Tables'),
26 'format' => 'number',
27 'footer' => 0,
29 $column_order['SCHEMA_TABLE_ROWS'] = array(
30 'disp_name' => __('Rows'),
31 'format' => 'number',
32 'footer' => 0,
34 $column_order['SCHEMA_DATA_LENGTH'] = array(
35 'disp_name' => __('Data'),
36 'format' => 'byte',
37 'footer' => 0,
39 $column_order['SCHEMA_INDEX_LENGTH'] = array(
40 'disp_name' => __('Indexes'),
41 'format' => 'byte',
42 'footer' => 0,
44 $column_order['SCHEMA_LENGTH'] = array(
45 'disp_name' => __('Total'),
46 'format' => 'byte',
47 'footer' => 0,
49 $column_order['SCHEMA_DATA_FREE'] = array(
50 'disp_name' => __('Overhead'),
51 'format' => 'byte',
52 'footer' => 0,
55 return $column_order;
59 * Builds the HTML td elements for one database to display in the list
60 * of databases from server_databases.php (which can be modified by
61 * db_create.php)
63 * @param array $current
64 * @param boolean $is_superuser
65 * @param string $checkall
66 * @param string $url_query
67 * @param array $column_order
68 * @param array $replication_types
69 * @param array $replication_info
71 * @return array $column_order, $out
73 function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info) {
75 $out = '';
76 if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
77 $out .= '<td class="tool">';
78 $out .= '<input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ';
80 if ($current['SCHEMA_NAME'] != 'mysql'
81 && $current['SCHEMA_NAME'] != 'information_schema') {
82 $out .= (empty($checkall) ? '' : 'checked="checked" ') . '/>';
83 } else {
84 $out .= ' disabled="disabled" />';
86 $out .= '</td>';
88 $out .= '<td class="name">'
89 . ' <a onclick="'
90 . 'if (window.parent.openDb &amp;&amp; window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
91 . '" href="index.php?' . $url_query . '&amp;db='
92 . urlencode($current['SCHEMA_NAME']) . '" title="'
93 . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME']))
94 . '" target="_parent">'
95 . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
96 . '</a>'
97 . '</td>';
99 foreach ($column_order as $stat_name => $stat) {
100 if (array_key_exists($stat_name, $current)) {
101 if (is_numeric($stat['footer'])) {
102 $column_order[$stat_name]['footer'] += $current[$stat_name];
104 if ($stat['format'] === 'byte') {
105 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
106 } elseif ($stat['format'] === 'number') {
107 $value = PMA_formatNumber($current[$stat_name], 0);
108 } else {
109 $value = htmlentities($current[$stat_name], 0);
111 $out .= '<td class="value">';
112 if (isset($stat['description_function'])) {
113 $out .= '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
115 $out .= $value;
116 if (isset($stat['description_function'])) {
117 $out .= '</dfn>';
119 $out .= '</td>';
120 if ($stat['format'] === 'byte') {
121 $out .= '<td class="unit">' . $unit . '</td>';
125 foreach ($replication_types as $type) {
126 if ($replication_info[$type]['status']) {
127 $out .= '<td class="tool" style="text-align: center;">';
129 if (strlen(array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB'])) > 0) {
130 $out .= PMA_getIcon('s_cancel.png', __('Not replicated'));
131 } else {
132 $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
134 if (strlen($key) > 0 || ($replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1)) {
135 // if ($key != null) did not work for index "0"
136 $out .= PMA_getIcon('s_success.png', __('Replicated'));
140 $out .= '</td>';
144 if ($is_superuser) {
145 $out .= '<td class="tool">'
146 . '<a onclick="'
147 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
148 . '" href="./server_privileges.php?' . $url_query
149 . '&amp;checkprivs=' . urlencode($current['SCHEMA_NAME'])
150 . '" title="' . sprintf(__('Check privileges for database &quot;%s&quot;.'), htmlspecialchars($current['SCHEMA_NAME']))
151 . '">'
152 . ' '
153 . PMA_getIcon('s_rights.png', __('Check Privileges'))
154 . '</a></td>';
156 return array($column_order, $out);