2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * HTML geneartor for database listing
9 if (! defined('PHPMYADMIN')) {
14 * Prepares the $column_order array
18 function PMA_getColumnOrder()
20 $column_order['DEFAULT_COLLATION_NAME'] = array(
21 'disp_name' => __('Collation'),
22 'description_function' => 'PMA_getCollationDescr',
24 'footer' => PMA_getServerCollation(),
26 $column_order['SCHEMA_TABLES'] = array(
27 'disp_name' => __('Tables'),
31 $column_order['SCHEMA_TABLE_ROWS'] = array(
32 'disp_name' => __('Rows'),
36 $column_order['SCHEMA_DATA_LENGTH'] = array(
37 'disp_name' => __('Data'),
41 $column_order['SCHEMA_INDEX_LENGTH'] = array(
42 'disp_name' => __('Indexes'),
46 $column_order['SCHEMA_LENGTH'] = array(
47 'disp_name' => __('Total'),
51 $column_order['SCHEMA_DATA_FREE'] = array(
52 'disp_name' => __('Overhead'),
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
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
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"';
90 $out .= '<td class="name">'
91 . '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
92 . '?' . $url_query . '&db='
93 . urlencode($current['SCHEMA_NAME']) . '" title="'
95 __('Jump to database'),
96 htmlspecialchars($current['SCHEMA_NAME'])
99 . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
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
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]) . '">';
125 if (isset($stat['description_function'])) {
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;">';
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'));
146 $current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
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'));
162 if ($is_superuser && !PMA_DRIZZLE
) {
163 $out .= '<td class="tool">'
165 . 'PMA_commonActions.setDb(\''
166 . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
167 . '" href="server_privileges.php?' . $url_query
168 . '&db=' . urlencode($current['SCHEMA_NAME'])
169 . '&checkprivsdb=' . urlencode($current['SCHEMA_NAME'])
172 __('Check privileges for database "%s".'),
173 htmlspecialchars($current['SCHEMA_NAME'])
177 . PMA_Util
::getIcon('s_rights.png', __('Check Privileges'))
180 return array($column_order, $out);