1. Check existence of mb_string, mysql and xml extensions before installation.
[openemr.git] / phpmyadmin / libraries / build_html_for_db.lib.php
blob2ccd68e7acdca3383573dcff0f1a9b5498e35a98
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * HTML generator 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 = array();
21 $column_order['DEFAULT_COLLATION_NAME'] = array(
22 'disp_name' => __('Collation'),
23 'description_function' => 'PMA_getCollationDescr',
24 'format' => 'string',
25 'footer' => PMA_getServerCollation(),
27 $column_order['SCHEMA_TABLES'] = array(
28 'disp_name' => __('Tables'),
29 'format' => 'number',
30 'footer' => 0,
32 $column_order['SCHEMA_TABLE_ROWS'] = array(
33 'disp_name' => __('Rows'),
34 'format' => 'number',
35 'footer' => 0,
37 $column_order['SCHEMA_DATA_LENGTH'] = array(
38 'disp_name' => __('Data'),
39 'format' => 'byte',
40 'footer' => 0,
42 $column_order['SCHEMA_INDEX_LENGTH'] = array(
43 'disp_name' => __('Indexes'),
44 'format' => 'byte',
45 'footer' => 0,
47 $column_order['SCHEMA_LENGTH'] = array(
48 'disp_name' => __('Total'),
49 'format' => 'byte',
50 'footer' => 0,
52 // At this point we were preparing the display of Overhead using DATA_FREE
53 // but its content does not represent the real overhead in the case
54 // of InnoDB
56 return $column_order;
59 /**
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 current database
65 * @param boolean $is_superuser user status
66 * @param string $url_query url query
67 * @param array $column_order column order
68 * @param array $replication_types replication types
69 * @param array $replication_info 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 ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
85 $out .= ' disabled="disabled"';
87 $out .= ' /></td>';
89 $out .= '<td class="name">'
90 . '<a href="' . PMA_Util::getScriptNameForOption(
91 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
93 . $url_query . '&amp;db='
94 . urlencode($current['SCHEMA_NAME']) . '" title="'
95 . sprintf(
96 __('Jump to database'),
97 htmlspecialchars($current['SCHEMA_NAME'])
99 . '">'
100 . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
101 . '</a>'
102 . '</td>';
104 foreach ($column_order as $stat_name => $stat) {
105 if (array_key_exists($stat_name, $current)) {
106 $unit = '';
107 if (is_numeric($stat['footer'])) {
108 $column_order[$stat_name]['footer'] += $current[$stat_name];
110 if ($stat['format'] === 'byte') {
111 list($value, $unit) = PMA_Util::formatByteDown(
112 $current[$stat_name], 3, 1
114 } elseif ($stat['format'] === 'number') {
115 $value = PMA_Util::formatNumber(
116 $current[$stat_name], 0
118 } else {
119 $value = htmlentities($current[$stat_name], 0);
121 $out .= '<td class="value">';
122 if (isset($stat['description_function'])) {
123 $out .= '<dfn title="'
124 . $stat['description_function']($current[$stat_name]) . '">';
126 $out .= $value;
127 if (isset($stat['description_function'])) {
128 $out .= '</dfn>';
130 $out .= '</td>';
131 if ($stat['format'] === 'byte') {
132 $out .= '<td class="unit">' . $unit . '</td>';
137 foreach ($replication_types as $type) {
138 if ($replication_info[$type]['status']) {
139 $out .= '<td class="tool" style="text-align: center;">';
141 $key = array_search(
142 $current["SCHEMA_NAME"],
143 $replication_info[$type]['Ignore_DB']
145 if (/*overload*/mb_strlen($key) > 0) {
146 $out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
147 } else {
148 $key = array_search(
149 $current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
152 if (/*overload*/mb_strlen($key) > 0
153 || (isset($replication_info[$type]['Do_DB'][0])
154 && $replication_info[$type]['Do_DB'][0] == ""
155 && count($replication_info[$type]['Do_DB']) == 1)
157 // if ($key != null) did not work for index "0"
158 $out .= PMA_Util::getIcon('s_success.png', __('Replicated'));
162 $out .= '</td>';
166 if ($is_superuser && !PMA_DRIZZLE) {
167 $out .= '<td class="tool">'
168 . '<a onclick="'
169 . 'PMA_commonActions.setDb(\''
170 . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
171 . '" href="server_privileges.php' . $url_query
172 . '&amp;db=' . urlencode($current['SCHEMA_NAME'])
173 . '&amp;checkprivsdb=' . urlencode($current['SCHEMA_NAME'])
174 . '" title="'
175 . sprintf(
176 __('Check privileges for database "%s".'),
177 htmlspecialchars($current['SCHEMA_NAME'])
179 . '">'
180 . ' '
181 . PMA_Util::getIcon('s_rights.png', __('Check privileges'))
182 . '</a></td>';
184 return array($column_order, $out);