Translated using Weblate (Indonesian)
[phpmyadmin.git] / db_datadict.php
blob544709acce6a1d317fb4850d54323b1d6c3c2c8f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Renders data dictionary
6 * @package PhpMyAdmin
7 */
8 use PMA\libraries\URL;
9 use PMA\libraries\Response;
11 /**
12 * Gets the variables sent or posted to this script, then displays headers
14 require_once 'libraries/common.inc.php';
16 if (! isset($selected_tbl)) {
17 include 'libraries/db_common.inc.php';
18 list(
19 $tables,
20 $num_tables,
21 $total_num_tables,
22 $sub_part,
23 $is_show_stats,
24 $db_is_system_schema,
25 $tooltip_truename,
26 $tooltip_aliasname,
27 $pos
28 ) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
31 $response = Response::getInstance();
32 $header = $response->getHeader();
33 $header->enablePrintView();
35 /**
36 * Gets the relations settings
38 $cfgRelation = PMA_getRelationsParam();
40 require_once 'libraries/transformations.lib.php';
42 /**
43 * Check parameters
45 PMA\libraries\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 = PMA_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 = PMA_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 = PMA\libraries\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) = PMA_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 = PMA\libraries\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 , PMA\libraries\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 = PMA_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 = PMA_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(PMA\libraries\Index::getFromTable($table, $db)) > 0) {
205 echo PMA\libraries\Index::getHtmlForIndexes($table, $db, true);
207 echo '</div>';
208 } //ends main while
211 * Displays the footer
213 echo PMA\libraries\Util::getButton();