Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 206 lines (176 sloc) 5.61 kB
ca8a9a8 @lem9 new
lem9 authored
1 <?php
817e790 synced/fixed vim line
Sebastian Mendel authored
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
374abd5 fixed/added page level docblock
Sebastian Mendel authored
3 /**
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
4 * Renders data dictionary
374abd5 fixed/added page level docblock
Sebastian Mendel authored
5 *
e56949f @nijel Use package name PhpMyAdmin
nijel authored
6 * @package PhpMyAdmin
374abd5 fixed/added page level docblock
Sebastian Mendel authored
7 */
b7b7b05 @lem9 Loic cleanup
lem9 authored
8
ca8a9a8 @lem9 new
lem9 authored
9 /**
10 * Gets the variables sent or posted to this script, then displays headers
11 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
12 require_once 'libraries/common.inc.php';
fcf387b common.lib.php should REALLY REALLY and ALWAYS be the first include
Sebastian Mendel authored
13
13b3195 @lem9 For easier reading, replace "!isset" with "! isset"
lem9 authored
14 if (! isset($selected_tbl)) {
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
15 include 'libraries/db_common.inc.php';
16 include 'libraries/db_info.inc.php';
ca8a9a8 @lem9 new
lem9 authored
17 }
18
0a08733 @roccivic The data dictionary is a print view page
roccivic authored
19 $response = PMA_Response::getInstance();
20 $header = $response->getHeader();
21 $header->enablePrintView();
b7b7b05 @lem9 Loic cleanup
lem9 authored
22
ca8a9a8 @lem9 new
lem9 authored
23 /**
24 * Gets the relations settings
25 */
ee767e2 @nijel No need to explicitely include relation.lib its anyway included in co…
nijel authored
26 $cfgRelation = PMA_getRelationsParam();
27
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
28 require_once 'libraries/transformations.lib.php';
5629560 @hiddenpearls Patch #3506552 (Contest-2) Show index information in the data dictionary
hiddenpearls authored
29 require_once 'libraries/Index.class.php';
b7b7b05 @lem9 Loic cleanup
lem9 authored
30
5c87b95 @lem9 path disclosure
lem9 authored
31 /**
32 * Check parameters
33 */
6971295 @Chanaka Renamed PMA_CommonFunctions::getInstance()-> with PMA_Util::
Chanaka authored
34 PMA_Util::checkParameters(array('db'));
b7b7b05 @lem9 Loic cleanup
lem9 authored
35
ca8a9a8 @lem9 new
lem9 authored
36 /**
37 * Defines the url to return to in case of error in a sql statement
38 */
b1a7039 @ZweiSteinSoft Convert PMA_URL_getCommon calls to new style
ZweiSteinSoft authored
39 $err_url = 'db_sql.php' . PMA_URL_getCommon(array('db' => $db));
b7b7b05 @lem9 Loic cleanup
lem9 authored
40
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
41 if ($cfgRelation['commwork']) {
640bece make use of PMA_getDbComment()
Sebastian Mendel authored
42 $comment = PMA_getDbComment($db);
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
43
44 /**
45 * Displays DB comment
46 */
640bece make use of PMA_getDbComment()
Sebastian Mendel authored
47 if ($comment) {
561233b @lem9 Streamline message
lem9 authored
48 echo '<p>' . __('Database comment')
49 . '<br /><i>' . htmlspecialchars($comment) . '</i></p>';
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
50 } // end if
51 }
b7b7b05 @lem9 Loic cleanup
lem9 authored
52
ca8a9a8 @lem9 new
lem9 authored
53 /**
b7b7b05 @lem9 Loic cleanup
lem9 authored
54 * Selects the database and gets tables names
ca8a9a8 @lem9 new
lem9 authored
55 */
650a8cd @madhuracj Convert database interface to a class
madhuracj authored
56 $GLOBALS['dbi']->selectDb($db);
57 $tables = $GLOBALS['dbi']->getTables($db);
5c87b95 @lem9 path disclosure
lem9 authored
58
b7b7b05 @lem9 Loic cleanup
lem9 authored
59 $count = 0;
94c6836 @ruleant fix coding style : control structures
ruleant authored
60 foreach ($tables as $table) {
e1fd395 removed MySQL < 5 code
Sebastian Mendel authored
61 $comments = PMA_getComments($db, $table);
01d7338 @derrabus bug #632515
derrabus authored
62
1b187c9 @nijel rfe #1105678 [interface] Drop page-break-before as it is useless for …
nijel authored
63 echo '<div>' . "\n";
32cc65c Bug #942359 - Data dictionary had wrong <div>- count. Replace h1…
Garvin Hicking authored
64
e7d6cab @nijel Missing escaping
nijel authored
65 echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\n";
01d7338 @derrabus bug #632515
derrabus authored
66
b7b7b05 @lem9 Loic cleanup
lem9 authored
67 /**
37f6b99 @Tithugues Fix typos.
Tithugues authored
68 * Gets table information
b7b7b05 @lem9 Loic cleanup
lem9 authored
69 */
08919d9 @Tithugues Make PHPCS happy.
Tithugues authored
70 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
71 ->sGetStatusInfo('TABLE_COMMENT');
01d7338 @derrabus bug #632515
derrabus authored
72
b7b7b05 @lem9 Loic cleanup
lem9 authored
73 /**
74 * Gets table keys and retains them
75 */
650a8cd @madhuracj Convert database interface to a class
madhuracj authored
76 $GLOBALS['dbi']->selectDb($db);
f8d68e6 @madhuracj Eliminate duplicate code
madhuracj authored
77 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
78 list($primary, $pk_array, $indexes_info, $indexes_data)
79 = PMA_Util::processIndexData($indexes);
01d7338 @derrabus bug #632515
derrabus authored
80
b7b7b05 @lem9 Loic cleanup
lem9 authored
81 /**
caa9844 @lem9 conform to relational terminology regarding columns and rows
lem9 authored
82 * Gets columns properties
b7b7b05 @lem9 Loic cleanup
lem9 authored
83 */
650a8cd @madhuracj Convert database interface to a class
madhuracj authored
84 $columns = $GLOBALS['dbi']->getColumns($db, $table);
9957659 @lem9 TIMESTAMP and NULL bugs
lem9 authored
85
ae0af9e @lem9 Remove author name
lem9 authored
86 // Check if we can use Relations
9680410 @lem9 Refactor code duplication
lem9 authored
87 list($res_rel, $have_rel) = PMA_getRelationsAndStatus(
88 ! empty($cfgRelation['relation']), $db, $table
89 );
01d7338 @derrabus bug #632515
derrabus authored
90
b7b7b05 @lem9 Loic cleanup
lem9 authored
91 /**
92 * Displays the comments of the table if MySQL >= 3.23
93 */
ca8a9a8 @lem9 new
lem9 authored
94 if (!empty($show_comment)) {
5858ca4 @nijel Wrap some long lines
nijel authored
95 echo __('Table comments:') . ' ';
96 echo htmlspecialchars($show_comment) . '<br /><br />';
ca8a9a8 @lem9 new
lem9 authored
97 }
01d7338 @derrabus bug #632515
derrabus authored
98
b7b7b05 @lem9 Loic cleanup
lem9 authored
99 /**
100 * Displays the table structure
101 */
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
102
103 echo '<table width="100%" class="print">';
104 echo '<tr><th width="50">' . __('Column') . '</th>';
105 echo '<th width="80">' . __('Type') . '</th>';
106 echo '<th width="40">' . __('Null') . '</th>';
107 echo '<th width="70">' . __('Default') . '</th>';
b7b7b05 @lem9 Loic cleanup
lem9 authored
108 if ($have_rel) {
f55823f @lem9 strings to gettext, first batch
lem9 authored
109 echo ' <th>' . __('Links to') . '</th>' . "\n";
b7b7b05 @lem9 Loic cleanup
lem9 authored
110 }
f55823f @lem9 strings to gettext, first batch
lem9 authored
111 echo ' <th>' . __('Comments') . '</th>' . "\n";
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
112 if ($cfgRelation['mimework']) {
113 echo ' <th>MIME</th>' . "\n";
114 }
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
115 echo '</tr>';
e033b3f - replaced $cfg['Bgcolor*'] with classes
Sebastian Mendel authored
116 $odd_row = true;
bd526dd @nijel Use PMA_DBI_get_columns
nijel authored
117 foreach ($columns as $row) {
b7b7b05 @lem9 Loic cleanup
lem9 authored
118
c7672b5 MySQL bug #20910 fixed in 5.0.25 (http://bugs.mysql.com/20910)
Sebastian Mendel authored
119 if ($row['Null'] == '') {
120 $row['Null'] = 'NO';
121 }
7664661 @Chanaka Implement class behavior of common.lib.php file
Chanaka authored
122 $extracted_columnspec
6971295 @Chanaka Renamed PMA_CommonFunctions::getInstance()-> with PMA_Util::
Chanaka authored
123 = PMA_Util::extractColumnSpec($row['Type']);
ba16e22 @madhuracj Coding style improvements
madhuracj authored
124
819324e @lem9 remove author names, as discussed at the 2010 developer meeting and a…
lem9 authored
125 // reformat mysql query output
126 // set or enum types: slashes single quotes inside options
cac9bb9 @nijel Fixed bug #667682 ("UNSIGNED" option in SET or ENUM).
nijel authored
127
3da49e3 @lem9 Clarify variable name
lem9 authored
128 $type = htmlspecialchars($extracted_columnspec['print_type']);
129 $attribute = $extracted_columnspec['attribute'];
13b3195 @lem9 For easier reading, replace "!isset" with "! isset"
lem9 authored
130 if (! isset($row['Default'])) {
c7672b5 MySQL bug #20910 fixed in 5.0.25 (http://bugs.mysql.com/20910)
Sebastian Mendel authored
131 if ($row['Null'] != 'NO') {
b7b7b05 @lem9 Loic cleanup
lem9 authored
132 $row['Default'] = '<i>NULL</i>';
133 }
134 } else {
135 $row['Default'] = htmlspecialchars($row['Default']);
136 }
01fb62b @lem9 Use correct SQL terminology
lem9 authored
137 $column_name = $row['Field'];
9957659 @lem9 TIMESTAMP and NULL bugs
lem9 authored
138
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
139 echo '<tr class="';
140 echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row;
141 echo '">';
142 echo '<td class="nowrap">';
71fb505 @ZweiSteinSoft rfe #1523 Better visual clue for table structure primary key column
ZweiSteinSoft authored
143 echo htmlspecialchars($column_name);
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
144
b7b7b05 @lem9 Loic cleanup
lem9 authored
145 if (isset($pk_array[$row['Field']])) {
71fb505 @ZweiSteinSoft rfe #1523 Better visual clue for table structure primary key column
ZweiSteinSoft authored
146 echo ' <em>(' . __('Primary') . ')</em>';
b7b7b05 @lem9 Loic cleanup
lem9 authored
147 }
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
148 echo '</td>';
14e8e4b @lem9 - Remove code duplication
lem9 authored
149 echo '<td'
150 . PMA_Util::getClassForType(
151 $extracted_columnspec['type']
152 )
153 . ' lang="en" dir="ltr">' . $type . '</td>';
154
5858ca4 @nijel Wrap some long lines
nijel authored
155 echo '<td>';
156 echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
157 echo '</td>';
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
158 echo '<td class="nowrap">';
159 if (isset($row['Default'])) {
160 echo $row['Default'];
161 }
162 echo '</td>';
163
b7b7b05 @lem9 Loic cleanup
lem9 authored
164 if ($have_rel) {
e033b3f - replaced $cfg['Bgcolor*'] with classes
Sebastian Mendel authored
165 echo ' <td>';
508f0a7 @ashutoshdhundhara RFE#919: Multiple-column foreign key relation.
ashutoshdhundhara authored
166 if ($foreigner = PMA_searchColumnInForeigners($res_rel, $column_name)) {
5858ca4 @nijel Wrap some long lines
nijel authored
167 echo htmlspecialchars(
508f0a7 @ashutoshdhundhara RFE#919: Multiple-column foreign key relation.
ashutoshdhundhara authored
168 $foreigner['foreign_table']
5858ca4 @nijel Wrap some long lines
nijel authored
169 . ' -> '
508f0a7 @ashutoshdhundhara RFE#919: Multiple-column foreign key relation.
ashutoshdhundhara authored
170 . $foreigner['foreign_field']
5858ca4 @nijel Wrap some long lines
nijel authored
171 );
b7b7b05 @lem9 Loic cleanup
lem9 authored
172 }
e033b3f - replaced $cfg['Bgcolor*'] with classes
Sebastian Mendel authored
173 echo '</td>' . "\n";
b7b7b05 @lem9 Loic cleanup
lem9 authored
174 }
e1fd395 removed MySQL < 5 code
Sebastian Mendel authored
175 echo ' <td>';
01fb62b @lem9 Use correct SQL terminology
lem9 authored
176 if (isset($comments[$column_name])) {
177 echo htmlspecialchars($comments[$column_name]);
b7b7b05 @lem9 Loic cleanup
lem9 authored
178 }
e1fd395 removed MySQL < 5 code
Sebastian Mendel authored
179 echo '</td>' . "\n";
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
180 if ($cfgRelation['mimework']) {
181 $mime_map = PMA_getMIME($db, $table, true);
fdff6ab @derrabus bug #712055
derrabus authored
182
e033b3f - replaced $cfg['Bgcolor*'] with classes
Sebastian Mendel authored
183 echo ' <td>';
01fb62b @lem9 Use correct SQL terminology
lem9 authored
184 if (isset($mime_map[$column_name])) {
5858ca4 @nijel Wrap some long lines
nijel authored
185 echo htmlspecialchars(
01fb62b @lem9 Use correct SQL terminology
lem9 authored
186 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
5858ca4 @nijel Wrap some long lines
nijel authored
187 );
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
188 }
e033b3f - replaced $cfg['Bgcolor*'] with classes
Sebastian Mendel authored
189 echo '</td>' . "\n";
2a3bd1c RFE #700307 - Display DB comments / MIME-types where appropriate.
Garvin Hicking authored
190 }
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
191 echo '</tr>';
bd526dd @nijel Use PMA_DBI_get_columns
nijel authored
192 } // end foreach
e033b3f - replaced $cfg['Bgcolor*'] with classes
Sebastian Mendel authored
193 $count++;
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
194 echo '</table>';
195 // display indexes information
b2243f0 @nijel Fix spacing around brackets
nijel authored
196 if (count(PMA_Index::getFromTable($table, $db)) > 0) {
1659f80 @lem9 Clarify method name (avoid confusion with SQL's VIEW)
lem9 authored
197 echo PMA_Index::getHtmlForIndexes($table, $db, true);
5629560 @hiddenpearls Patch #3506552 (Contest-2) Show index information in the data dictionary
hiddenpearls authored
198 }
61c9e4d @nijel Replace HTML/PHP mix with PHP
nijel authored
199 echo '</div>';
b7b7b05 @lem9 Loic cleanup
lem9 authored
200 } //ends main while
01d7338 @derrabus bug #632515
derrabus authored
201
ca8a9a8 @lem9 new
lem9 authored
202 /**
203 * Displays the footer
204 */
6971295 @Chanaka Renamed PMA_CommonFunctions::getInstance()-> with PMA_Util::
Chanaka authored
205 echo PMA_Util::getButton();
Something went wrong with that request. Please try again.