Translated using Weblate (Interlingua)
[phpmyadmin.git] / db_datadict.php
blob94e8beb860ac98fc58fbe2c9e763755439b5d629
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Renders data dictionary
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Relation;
9 use PhpMyAdmin\Response;
10 use PhpMyAdmin\Transformations;
11 use PhpMyAdmin\Url;
13 /**
14 * Gets the variables sent or posted to this script, then displays headers
16 require_once 'libraries/common.inc.php';
18 if (! isset($selected_tbl)) {
19 include 'libraries/db_common.inc.php';
20 list(
21 $tables,
22 $num_tables,
23 $total_num_tables,
24 $sub_part,
25 $is_show_stats,
26 $db_is_system_schema,
27 $tooltip_truename,
28 $tooltip_aliasname,
29 $pos
30 ) = PhpMyAdmin\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
33 $response = Response::getInstance();
34 $header = $response->getHeader();
35 $header->enablePrintView();
37 /**
38 * Gets the relations settings
40 $cfgRelation = Relation::getRelationsParam();
42 /**
43 * Check parameters
45 PhpMyAdmin\Util::checkParameters(array('db'));
47 /**
48 * Defines the url to return to in case of error in a sql statement
50 $err_url = 'db_sql.php' . Url::getCommon(array('db' => $db));
52 if ($cfgRelation['commwork']) {
53 $comment = Relation::getDbComment($db);
55 /**
56 * Displays DB comment
58 if ($comment) {
59 echo '<p>' , __('Database comment')
60 , '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
61 } // end if
64 /**
65 * Selects the database and gets tables names
67 $GLOBALS['dbi']->selectDb($db);
68 $tables = $GLOBALS['dbi']->getTables($db);
70 $count = 0;
71 foreach ($tables as $table) {
72 $comments = Relation::getComments($db, $table);
74 echo '<div>' , "\n";
76 echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
78 /**
79 * Gets table information
81 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
82 ->getStatusInfo('TABLE_COMMENT');
84 /**
85 * Gets table keys and retains them
87 $GLOBALS['dbi']->selectDb($db);
88 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
89 list($primary, $pk_array, $indexes_info, $indexes_data)
90 = PhpMyAdmin\Util::processIndexData($indexes);
92 /**
93 * Gets columns properties
95 $columns = $GLOBALS['dbi']->getColumns($db, $table);
97 // Check if we can use Relations
98 list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
99 ! empty($cfgRelation['relation']), $db, $table
103 * Displays the comments of the table if MySQL >= 3.23
105 if (!empty($show_comment)) {
106 echo __('Table comments:') , ' ';
107 echo htmlspecialchars($show_comment) , '<br /><br />';
111 * Displays the table structure
114 echo '<table width="100%" class="print">';
115 echo '<tr><th width="50">' , __('Column') , '</th>';
116 echo '<th width="80">' , __('Type') , '</th>';
117 echo '<th width="40">' , __('Null') , '</th>';
118 echo '<th width="70">' , __('Default') , '</th>';
119 if ($have_rel) {
120 echo ' <th>' , __('Links to') , '</th>' , "\n";
122 echo ' <th>' , __('Comments') , '</th>' , "\n";
123 if ($cfgRelation['mimework']) {
124 echo ' <th>MIME</th>' , "\n";
126 echo '</tr>';
127 foreach ($columns as $row) {
129 if ($row['Null'] == '') {
130 $row['Null'] = 'NO';
132 $extracted_columnspec
133 = PhpMyAdmin\Util::extractColumnSpec($row['Type']);
135 // reformat mysql query output
136 // set or enum types: slashes single quotes inside options
138 $type = htmlspecialchars($extracted_columnspec['print_type']);
139 $attribute = $extracted_columnspec['attribute'];
140 if (! isset($row['Default'])) {
141 if ($row['Null'] != 'NO') {
142 $row['Default'] = '<i>NULL</i>';
144 } else {
145 $row['Default'] = htmlspecialchars($row['Default']);
147 $column_name = $row['Field'];
149 echo '<tr>';
150 echo '<td class="nowrap">';
151 echo htmlspecialchars($column_name);
153 if (isset($pk_array[$row['Field']])) {
154 echo ' <em>(' , __('Primary') , ')</em>';
156 echo '</td>';
157 echo '<td'
158 , PhpMyAdmin\Util::getClassForType(
159 $extracted_columnspec['type']
161 , ' lang="en" dir="ltr">' , $type , '</td>';
163 echo '<td>';
164 echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
165 echo '</td>';
166 echo '<td class="nowrap">';
167 if (isset($row['Default'])) {
168 echo $row['Default'];
170 echo '</td>';
172 if ($have_rel) {
173 echo ' <td>';
174 if ($foreigner = Relation::searchColumnInForeigners($res_rel, $column_name)) {
175 echo htmlspecialchars(
176 $foreigner['foreign_table']
177 . ' -> '
178 . $foreigner['foreign_field']
181 echo '</td>' , "\n";
183 echo ' <td>';
184 if (isset($comments[$column_name])) {
185 echo htmlspecialchars($comments[$column_name]);
187 echo '</td>' , "\n";
188 if ($cfgRelation['mimework']) {
189 $mime_map = Transformations::getMIME($db, $table, true);
191 echo ' <td>';
192 if (isset($mime_map[$column_name])) {
193 echo htmlspecialchars(
194 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
197 echo '</td>' , "\n";
199 echo '</tr>';
200 } // end foreach
201 $count++;
202 echo '</table>';
203 // display indexes information
204 if (count(PhpMyAdmin\Index::getFromTable($table, $db)) > 0) {
205 echo PhpMyAdmin\Index::getHtmlForIndexes($table, $db, true);
207 echo '</div>';
208 } //ends main while
211 * Displays the footer
213 echo PhpMyAdmin\Util::getButton();