Translated using Weblate (Slovenian)
[phpmyadmin.git] / db_datadict.php
blob1057d161fd8e95c14d43aab345f32888b3bf4d31
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Renders data dictionary
6 * @package PhpMyAdmin
7 */
9 /**
10 * Gets the variables sent or posted to this script, then displays headers
12 require_once 'libraries/common.inc.php';
14 if (! isset($selected_tbl)) {
15 include 'libraries/db_common.inc.php';
16 list(
17 $tables,
18 $num_tables,
19 $total_num_tables,
20 $sub_part,
21 $is_show_stats,
22 $db_is_system_schema,
23 $tooltip_truename,
24 $tooltip_aliasname,
25 $pos
26 ) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
29 $response = PMA\libraries\Response::getInstance();
30 $header = $response->getHeader();
31 $header->enablePrintView();
33 /**
34 * Gets the relations settings
36 $cfgRelation = PMA_getRelationsParam();
38 require_once 'libraries/transformations.lib.php';
40 /**
41 * Check parameters
43 PMA\libraries\Util::checkParameters(array('db'));
45 /**
46 * Defines the url to return to in case of error in a sql statement
48 $err_url = 'db_sql.php' . PMA_URL_getCommon(array('db' => $db));
50 if ($cfgRelation['commwork']) {
51 $comment = PMA_getDbComment($db);
53 /**
54 * Displays DB comment
56 if ($comment) {
57 echo '<p>' . __('Database comment')
58 . '<br /><i>' . htmlspecialchars($comment) . '</i></p>';
59 } // end if
62 /**
63 * Selects the database and gets tables names
65 $GLOBALS['dbi']->selectDb($db);
66 $tables = $GLOBALS['dbi']->getTables($db);
68 $count = 0;
69 foreach ($tables as $table) {
70 $comments = PMA_getComments($db, $table);
72 echo '<div>' . "\n";
74 echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\n";
76 /**
77 * Gets table information
79 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
80 ->getStatusInfo('TABLE_COMMENT');
82 /**
83 * Gets table keys and retains them
85 $GLOBALS['dbi']->selectDb($db);
86 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
87 list($primary, $pk_array, $indexes_info, $indexes_data)
88 = PMA\libraries\Util::processIndexData($indexes);
90 /**
91 * Gets columns properties
93 $columns = $GLOBALS['dbi']->getColumns($db, $table);
95 // Check if we can use Relations
96 list($res_rel, $have_rel) = PMA_getRelationsAndStatus(
97 ! empty($cfgRelation['relation']), $db, $table
101 * Displays the comments of the table if MySQL >= 3.23
103 if (!empty($show_comment)) {
104 echo __('Table comments:') . ' ';
105 echo htmlspecialchars($show_comment) . '<br /><br />';
109 * Displays the table structure
112 echo '<table width="100%" class="print">';
113 echo '<tr><th width="50">' . __('Column') . '</th>';
114 echo '<th width="80">' . __('Type') . '</th>';
115 echo '<th width="40">' . __('Null') . '</th>';
116 echo '<th width="70">' . __('Default') . '</th>';
117 if ($have_rel) {
118 echo ' <th>' . __('Links to') . '</th>' . "\n";
120 echo ' <th>' . __('Comments') . '</th>' . "\n";
121 if ($cfgRelation['mimework']) {
122 echo ' <th>MIME</th>' . "\n";
124 echo '</tr>';
125 $odd_row = true;
126 foreach ($columns as $row) {
128 if ($row['Null'] == '') {
129 $row['Null'] = 'NO';
131 $extracted_columnspec
132 = PMA\libraries\Util::extractColumnSpec($row['Type']);
134 // reformat mysql query output
135 // set or enum types: slashes single quotes inside options
137 $type = htmlspecialchars($extracted_columnspec['print_type']);
138 $attribute = $extracted_columnspec['attribute'];
139 if (! isset($row['Default'])) {
140 if ($row['Null'] != 'NO') {
141 $row['Default'] = '<i>NULL</i>';
143 } else {
144 $row['Default'] = htmlspecialchars($row['Default']);
146 $column_name = $row['Field'];
148 echo '<tr class="';
149 echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row;
150 echo '">';
151 echo '<td class="nowrap">';
152 echo htmlspecialchars($column_name);
154 if (isset($pk_array[$row['Field']])) {
155 echo ' <em>(' . __('Primary') . ')</em>';
157 echo '</td>';
158 echo '<td'
159 . PMA\libraries\Util::getClassForType(
160 $extracted_columnspec['type']
162 . ' lang="en" dir="ltr">' . $type . '</td>';
164 echo '<td>';
165 echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
166 echo '</td>';
167 echo '<td class="nowrap">';
168 if (isset($row['Default'])) {
169 echo $row['Default'];
171 echo '</td>';
173 if ($have_rel) {
174 echo ' <td>';
175 if ($foreigner = PMA_searchColumnInForeigners($res_rel, $column_name)) {
176 echo htmlspecialchars(
177 $foreigner['foreign_table']
178 . ' -> '
179 . $foreigner['foreign_field']
182 echo '</td>' . "\n";
184 echo ' <td>';
185 if (isset($comments[$column_name])) {
186 echo htmlspecialchars($comments[$column_name]);
188 echo '</td>' . "\n";
189 if ($cfgRelation['mimework']) {
190 $mime_map = PMA_getMIME($db, $table, true);
192 echo ' <td>';
193 if (isset($mime_map[$column_name])) {
194 echo htmlspecialchars(
195 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
198 echo '</td>' . "\n";
200 echo '</tr>';
201 } // end foreach
202 $count++;
203 echo '</table>';
204 // display indexes information
205 if (count(PMA\libraries\Index::getFromTable($table, $db)) > 0) {
206 echo PMA\libraries\Index::getHtmlForIndexes($table, $db, true);
208 echo '</div>';
209 } //ends main while
212 * Displays the footer
214 echo PMA\libraries\Util::getButton();