Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / build_html_for_db.lib.php
blob21602cc2a9733f5cfb0b6c0f77844929f6354c55
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()
19 $column_order['DEFAULT_COLLATION_NAME'] = array(
20 'disp_name' => __('Collation'),
21 'description_function' => 'PMA_getCollationDescr',
22 'format' => 'string',
23 'footer' => PMA_getServerCollation(),
25 $column_order['SCHEMA_TABLES'] = array(
26 'disp_name' => __('Tables'),
27 'format' => 'number',
28 'footer' => 0,
30 $column_order['SCHEMA_TABLE_ROWS'] = array(
31 'disp_name' => __('Rows'),
32 'format' => 'number',
33 'footer' => 0,
35 $column_order['SCHEMA_DATA_LENGTH'] = array(
36 'disp_name' => __('Data'),
37 'format' => 'byte',
38 'footer' => 0,
40 $column_order['SCHEMA_INDEX_LENGTH'] = array(
41 'disp_name' => __('Indexes'),
42 'format' => 'byte',
43 'footer' => 0,
45 $column_order['SCHEMA_LENGTH'] = array(
46 'disp_name' => __('Total'),
47 'format' => 'byte',
48 'footer' => 0,
50 $column_order['SCHEMA_DATA_FREE'] = array(
51 'disp_name' => __('Overhead'),
52 'format' => 'byte',
53 'footer' => 0,
56 return $column_order;
60 * Builds the HTML td elements for one database to display in the list
61 * of databases from server_databases.php (which can be modified by
62 * db_create.php)
64 * @param array $current
65 * @param boolean $is_superuser
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(
74 $current, $is_superuser, $url_query,
75 $column_order, $replication_types, $replication_info
76 ) {
77 $out = '';
78 if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
79 $out .= '<td class="tool">';
80 $out .= '<input type="checkbox" name="selected_dbs[]" class="checkall" '
81 . 'title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" '
82 . 'value="' . htmlspecialchars($current['SCHEMA_NAME']) . '"';
84 if (PMA_is_system_schema($current['SCHEMA_NAME'], true)) {
85 $out .= ' disabled="disabled"';
87 $out .= ' /></td>';
89 $out .= '<td class="name">'
90 . '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
91 . '?' . $url_query . '&amp;db='
92 . urlencode($current['SCHEMA_NAME']) . '" title="'
93 . sprintf(
94 __('Jump to database'),
95 htmlspecialchars($current['SCHEMA_NAME'])
97 . '">'
98 . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
99 . '</a>'
100 . '</td>';
102 foreach ($column_order as $stat_name => $stat) {
103 if (array_key_exists($stat_name, $current)) {
104 if (is_numeric($stat['footer'])) {
105 $column_order[$stat_name]['footer'] += $current[$stat_name];
107 if ($stat['format'] === 'byte') {
108 list($value, $unit) = PMA_Util::formatByteDown(
109 $current[$stat_name], 3, 1
111 } elseif ($stat['format'] === 'number') {
112 $value = PMA_Util::formatNumber(
113 $current[$stat_name], 0
115 } else {
116 $value = htmlentities($current[$stat_name], 0);
118 $out .= '<td class="value">';
119 if (isset($stat['description_function'])) {
120 $out .= '<dfn title="'
121 . $stat['description_function']($current[$stat_name]) . '">';
123 $out .= $value;
124 if (isset($stat['description_function'])) {
125 $out .= '</dfn>';
127 $out .= '</td>';
128 if ($stat['format'] === 'byte') {
129 $out .= '<td class="unit">' . $unit . '</td>';
133 foreach ($replication_types as $type) {
134 if ($replication_info[$type]['status']) {
135 $out .= '<td class="tool" style="text-align: center;">';
137 $key = array_search(
138 $current["SCHEMA_NAME"],
139 $replication_info[$type]['Ignore_DB']
141 if (strlen($key) > 0) {
142 $out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
143 } else {
144 $key = array_search(
145 $current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
148 if (strlen($key) > 0
149 || ($replication_info[$type]['Do_DB'][0] == ""
150 && count($replication_info[$type]['Do_DB']) == 1)
152 // if ($key != null) did not work for index "0"
153 $out .= PMA_Util::getIcon('s_success.png', __('Replicated'));
157 $out .= '</td>';
161 if ($is_superuser && !PMA_DRIZZLE) {
162 $out .= '<td class="tool">'
163 . '<a onclick="'
164 . 'PMA_commonActions.setDb(\''
165 . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
166 . '" href="server_privileges.php?' . $url_query
167 . '&amp;checkprivs=' . urlencode($current['SCHEMA_NAME'])
168 . '" title="'
169 . sprintf(
170 __('Check privileges for database &quot;%s&quot;.'),
171 htmlspecialchars($current['SCHEMA_NAME'])
173 . '">'
174 . ' '
175 . PMA_Util::getIcon('s_rights.png', __('Check Privileges'))
176 . '</a></td>';
178 return array($column_order, $out);