Fixed: Not selecting a datalabel used to issue a notice(undefined offset)
[phpmyadmin/ammaryasirr.git] / libraries / build_html_for_db.lib.php
blob8d64549c31ed20976451281efa25b4af13ca7f2b
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 $checkall
67 * @param string $url_query
68 * @param array $column_order
69 * @param array $replication_types
70 * @param array $replication_info
72 * @return array $column_order, $out
74 function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info)
77 $out = '';
78 if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
79 $out .= '<td class="tool">';
80 $out .= '<input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ';
82 if ($current['SCHEMA_NAME'] != 'mysql'
83 && $current['SCHEMA_NAME'] != 'information_schema') {
84 $out .= (empty($checkall) ? '' : 'checked="checked" ') . '/>';
85 } else {
86 $out .= ' disabled="disabled" />';
88 $out .= '</td>';
90 $out .= '<td class="name">'
91 . ' <a onclick="'
92 . 'if (window.parent.openDb &amp;&amp; window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
93 . '" href="index.php?' . $url_query . '&amp;db='
94 . urlencode($current['SCHEMA_NAME']) . '" title="'
95 . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME']))
96 . '" target="_parent">'
97 . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
98 . '</a>'
99 . '</td>';
101 foreach ($column_order as $stat_name => $stat) {
102 if (array_key_exists($stat_name, $current)) {
103 if (is_numeric($stat['footer'])) {
104 $column_order[$stat_name]['footer'] += $current[$stat_name];
106 if ($stat['format'] === 'byte') {
107 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
108 } elseif ($stat['format'] === 'number') {
109 $value = PMA_formatNumber($current[$stat_name], 0);
110 } else {
111 $value = htmlentities($current[$stat_name], 0);
113 $out .= '<td class="value">';
114 if (isset($stat['description_function'])) {
115 $out .= '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
117 $out .= $value;
118 if (isset($stat['description_function'])) {
119 $out .= '</dfn>';
121 $out .= '</td>';
122 if ($stat['format'] === 'byte') {
123 $out .= '<td class="unit">' . $unit . '</td>';
127 foreach ($replication_types as $type) {
128 if ($replication_info[$type]['status']) {
129 $out .= '<td class="tool" style="text-align: center;">';
131 if (strlen(array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB'])) > 0) {
132 $out .= PMA_getIcon('s_cancel.png', __('Not replicated'));
133 } else {
134 $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
136 if (strlen($key) > 0 || ($replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1)) {
137 // if ($key != null) did not work for index "0"
138 $out .= PMA_getIcon('s_success.png', __('Replicated'));
142 $out .= '</td>';
146 if ($is_superuser) {
147 $out .= '<td class="tool">'
148 . '<a onclick="'
149 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
150 . '" href="./server_privileges.php?' . $url_query
151 . '&amp;checkprivs=' . urlencode($current['SCHEMA_NAME'])
152 . '" title="' . sprintf(__('Check privileges for database &quot;%s&quot;.'), htmlspecialchars($current['SCHEMA_NAME']))
153 . '">'
154 . ' '
155 . PMA_getIcon('s_rights.png', __('Check Privileges'))
156 . '</a></td>';
158 return array($column_order, $out);