Translated using Weblate (Slovak)
[phpmyadmin.git] / libraries / display_structure.inc.php
blobee22d2c533aeaddad8511d2a4d19e45cdeec7e16
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays the table structure ('show table' works correct since 3.23.03)
6 * @package PhpMyAdmin
7 */
9 require_once 'libraries/common.inc.php';
10 require_once 'libraries/mysql_charsets.inc.php';
11 require_once 'libraries/structure.lib.php';
12 require_once 'libraries/index.lib.php';
13 require_once 'libraries/tbl_info.inc.php';
15 if (! defined('PHPMYADMIN')) {
16 exit;
19 /* TABLE INFORMATION */
20 // table header
23 $HideStructureActions = '';
24 if ($GLOBALS['cfg']['HideStructureActions'] === true) {
25 $HideStructureActions .= ' HideStructureActions';
28 $html_form = '<form method="post" action="tbl_structure.php" name="fieldsForm" '
29 . 'id="fieldsForm" class="ajax' . $HideStructureActions . '">';
31 $response->addHTML($html_form);
32 $response->addHTML(PMA_URL_getHiddenInputs($db, $table));
34 $tabletype = '<input type="hidden" name="table_type" value=';
35 if ($db_is_system_schema) {
36 $tabletype .= '"information_schema" />';
37 } else if ($tbl_is_view) {
38 $tabletype .= '"view" />';
39 } else {
40 $tabletype .= '"table" />';
42 $response->addHTML($tabletype);
44 $tablestructure = '<table id="tablestructure" class="data topmargin">';
45 $response->addHTML($tablestructure);
48 $response->addHTML(
49 PMA_getHtmlForTableStructureHeader(
50 $db_is_system_schema,
51 $tbl_is_view
55 $response->addHTML('<tbody>');
57 // table body
59 // prepare comments
60 $comments_map = array();
61 $mime_map = array();
63 if ($GLOBALS['cfg']['ShowPropertyComments']) {
64 include_once 'libraries/transformations.lib.php';
65 $comments_map = PMA_getComments($db, $table);
66 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
67 $mime_map = PMA_getMIME($db, $table, true);
70 require_once 'libraries/central_columns.lib.php';
71 $central_list = PMA_getCentralColumnsFromTable($db, $table);
72 $rownum = 0;
73 $columns_list = array();
74 $save_row = array();
75 $odd_row = true;
76 foreach ($fields as $row) {
77 $save_row[] = $row;
78 $rownum++;
79 $columns_list[] = $row['Field'];
81 $type = $row['Type'];
82 $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
84 $class_for_type = PMA_Util::getClassForType(
85 $extracted_columnspec['type']
88 $type = $extracted_columnspec['print_type'];
89 if (empty($type)) {
90 $type = ' ';
93 $field_charset = '';
94 if ($extracted_columnspec['can_contain_collation']
95 && ! empty($row['Collation'])
96 ) {
97 $field_charset = $row['Collation'];
100 // Display basic mimetype [MIME]
101 if ($cfgRelation['commwork']
102 && $cfgRelation['mimework']
103 && $cfg['BrowseMIME']
104 && isset($mime_map[$row['Field']]['mimetype'])
106 $type_mime = '<br />MIME: '
107 . strtolower(str_replace('_', '/', $mime_map[$row['Field']]['mimetype']));
108 } else {
109 $type_mime = '';
112 $attribute = $extracted_columnspec['attribute'];
114 // prepare a common variable to reuse below; however,
115 // in case of a VIEW, $create_table_fields is empty
116 if (isset($create_table_fields[$row['Field']])) {
117 $tempField = $create_table_fields[$row['Field']];
118 } else {
119 $tempField = array();
122 // MySQL 4.1.2+ TIMESTAMP options
123 // (if on_update_current_timestamp is set, then it's TRUE)
124 if (isset($tempField['on_update_current_timestamp'])) {
125 $attribute = 'on update CURRENT_TIMESTAMP';
128 // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
129 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
130 // the latter.
131 if (! empty($tempField['type'])
132 && $tempField['type'] == 'TIMESTAMP'
133 && $tempField['timestamp_not_null']
135 $row['Null'] = '';
139 if (! isset($row['Default'])) {
140 if ($row['Null'] == 'YES') {
141 $row['Default'] = '<i>NULL</i>';
143 } else {
144 $row['Default'] = htmlspecialchars($row['Default']);
147 $field_encoded = urlencode($row['Field']);
148 $field_name = htmlspecialchars($row['Field']);
149 $displayed_field_name = $field_name;
151 // underline commented fields and display a hover-title (CSS only)
153 if (isset($comments_map[$row['Field']])) {
154 $displayed_field_name = '<span class="commented_column" title="'
155 . htmlspecialchars($comments_map[$row['Field']]) . '">'
156 . $field_name . '</span>';
159 if ($primary && $primary->hasColumn($field_name)) {
160 $displayed_field_name .= PMA_Util::getImage(
161 'b_primary.png', __('Primary')
164 if (in_array($field_name, $columns_with_index)) {
165 $displayed_field_name .= PMA_Util::getImage(
166 'bd_primary.png', __('Index')
169 $response->addHTML(
170 '<tr class="' . ($odd_row ? 'odd': 'even') . '">'
172 $odd_row = !$odd_row;
173 $isInCentralColumns = in_array($row['Field'], $central_list) ? true : false;
174 $response->addHTML(
175 PMA_getHtmlTableStructureRow(
176 $row, $rownum, $displayed_field_name,
177 $class_for_type, $extracted_columnspec, $type_mime,
178 $field_charset, $attribute, $tbl_is_view,
179 $db_is_system_schema, $url_query, $field_encoded, $titles, $table
183 if (! $tbl_is_view && ! $db_is_system_schema) {
184 $response->addHTML(
185 PMA_getHtmlForActionsInTableStructure(
186 $type, $tbl_storage_engine, $primary,
187 $field_name, $url_query, $titles, $row, $rownum,
188 $columns_with_unique_index,
189 $isInCentralColumns
192 } // end if (! $tbl_is_view && ! $db_is_system_schema)
194 $response->addHTML('</tr>');
196 unset($field_charset);
197 } // end foreach
199 $response->addHTML('</tbody></table>');
201 $response->addHTML(
202 PMA_getHtmlForCheckAllTableColumn(
203 $pmaThemeImage, $text_dir, $tbl_is_view,
204 $db_is_system_schema, $tbl_storage_engine
208 $response->addHTML(
209 '</form><hr class="print_ignore"/>'
211 $response->addHTML(
212 PMA_getHtmlDivForMoveColumnsDialog()
216 * Work on the table
219 $response->addHTML('<div id="structure-action-links">');
221 if ($tbl_is_view) {
222 $response->addHTML(PMA_getHtmlForEditView($url_params));
224 $response->addHTML(
225 PMA_getHtmlForOptionalActionLinks(
226 $url_query, $tbl_is_view, $db_is_system_schema
230 $response->addHTML('</div>');
232 if (! $tbl_is_view && ! $db_is_system_schema) {
233 $response->addHTML('<br />');
234 $response->addHTML(PMA_getHtmlForAddColumn($columns_list));
238 * Displays indexes
241 if (! $tbl_is_view
242 && ! $db_is_system_schema
243 && 'ARCHIVE' != $tbl_storage_engine
245 //return the list of index
246 $response->addJSON(
247 'indexes_list',
248 PMA_Index::getHtmlForIndexes($GLOBALS['table'], $GLOBALS['db'])
250 $response->addHTML(PMA_getHtmlForDisplayIndexes());
254 * Displays Space usage and row statistics
256 // BEGIN - Calc Table Space
257 // Get valid statistics whatever is the table type
258 if ($cfg['ShowStats']) {
259 //get table stats in HTML format
260 $tablestats = PMA_getHtmlForDisplayTableStats(
261 $showtable, $table_info_num_rows, $tbl_is_view,
262 $db_is_system_schema, $tbl_storage_engine,
263 $url_query, $tbl_collation
265 //returning the response in JSON format to be used by Ajax
266 $response->addJSON('tableStat', $tablestats);
267 $response->addHTML($tablestats);
269 // END - Calc Table Space
271 $response->addHTML(
272 '<div class="clearfloat"></div>'