display_structure.phtml
9.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php $rownum = 0; $odd_row = true; ?>
<form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm" class="ajax<?php echo $HideStructureActions; ?>">
<?php echo PMA_URL_getHiddenInputs($db, $table); ?>
<input type="hidden" name="table_type" value=
<?php if ($db_is_system_schema): ?>
"information_schema" />
<?php elseif ($tbl_is_view): ?>
"view" />
<?php else: ?>
"table" />
<?php endif; ?>
<table id="tablestructure" class="data topmargin">
<!-- table header -->
<?php echo PMA\Template::get('table/structure/table_structure_header')->render(
array(
'db_is_system_schema' => $db_is_system_schema,
'tbl_is_view' => $tbl_is_view
)
); ?>
<tbody>
<!-- table body -->
<?php foreach($fields as $row): ?>
<?php
$rownum++;
$columns_list[] = $row['Field'];
$extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
$attribute = $extracted_columnspec['attribute'];
$field_charset = $row['Collation'];
// prepare a common variable to reuse below; however,
// in case of a VIEW, $create_table_fields is empty
if (isset($create_table_fields[$row['Field']])) {
$tempField = $create_table_fields[$row['Field']];
} else {
$tempField = array();
}
// MySQL 4.1.2+ TIMESTAMP options
// (if on_update_current_timestamp is set, then it's TRUE)
if (isset($tempField['on_update_current_timestamp'])) {
$attribute = 'on update CURRENT_TIMESTAMP';
}
// here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
// the latter.
if (! empty($tempField['type'])
&& $tempField['type'] == 'TIMESTAMP'
&& $tempField['timestamp_not_null']
) {
$row['Null'] = '';
}
if (! isset($row['Default'])) {
if ($row['Null'] == 'YES') {
$row['Default'] = '<i>NULL</i>';
}
} else {
$row['Default'] = htmlspecialchars($row['Default']);
}
$field_name = htmlspecialchars($row['Field']);
$displayed_field_name = $field_name;
// underline commented fields and display a hover-title (CSS only)
if (isset($comments_map[$row['Field']])) {
$displayed_field_name = '<span class="commented_column" title="'
. htmlspecialchars($comments_map[$row['Field']]) . '">'
. $field_name . '</span>';
}
if ($primary && $primary->hasColumn($field_name)) {
$displayed_field_name .= PMA_Util::getImage(
'b_primary.png', __('Primary')
);
}
if (in_array($field_name, $columns_with_index)) {
$displayed_field_name .= PMA_Util::getImage(
'bd_primary.png', __('Index')
);
}
?>
<tr class="<?php echo ($odd_row ? 'odd': 'even'); ?>">
<?php $odd_row = !$odd_row; ?>
<?php echo PMA\Template::get('table/structure/table_structure_row')->render(
array(
'row' => $row,
'rownum' => $rownum,
'displayed_field_name' => $displayed_field_name,
'type_nowrap' => PMA_Util::getClassForType($extracted_columnspec['type']),
'extracted_columnspec' => $extracted_columnspec,
'attribute' => $attribute,
'tbl_is_view' => $tbl_is_view,
'db_is_system_schema' => $db_is_system_schema,
'url_query' => $url_query,
'field_encoded' => urlencode($row['Field']),
'titles' => $titles,
'table' => $table,
'tbl_storage_engine' => $tbl_storage_engine,
'field_charset' => $field_charset
)
); ?>
<?php if (! $tbl_is_view && ! $db_is_system_schema): ?>
<?php echo PMA\Template::get('table/structure/actions_in_table_structure')->render(
array(
'extracted_columnspec' => $extracted_columnspec,
'type' => (!empty($extracted_columnspec['print_type'])) ? $extracted_columnspec['print_type'] : ' ',
'tbl_storage_engine' => $tbl_storage_engine,
'primary' => $primary,
'field_name' => $field_name,
'url_query' => $url_query,
'titles' => $titles,
'row' => $row,
'rownum' => $rownum,
'columns_with_unique_index' => $columns_with_unique_index,
'isInCentralColumns' => in_array($row['Field'], $central_list) ? true : false
)
); ?>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php echo PMA\Template::get('table/structure/check_all_table_column')->render(
array(
'pmaThemeImage' => $GLOBALS['pmaThemeImage'],
'text_dir' => $GLOBALS['text_dir'],
'tbl_is_view' => $tbl_is_view,
'db_is_system_schema' => $db_is_system_schema,
'tbl_storage_engine' => $tbl_storage_engine
)
); ?>
</form>
<hr class="print_ignore"/>
<?php echo PMA\Template::get('table/structure/move_columns_dialog')->render(); ?>
<!--Work on the table-->
<div id="structure-action-links">
<?php if ($tbl_is_view && ! $db_is_system_schema): ?>
<?php echo PMA_Util::linkOrButton(
$edit_view_url,
PMA_Util::getIcon('b_edit.png', __('Edit view'), true)
); ?>
<?php endif; ?>
<?php echo PMA\Template::get('table/structure/optional_action_links')->render(
array(
'url_query' => $url_query,
'tbl_is_view' => $tbl_is_view,
'db_is_system_schema' => $db_is_system_schema
)
); ?>
</div>
<?php if (! $tbl_is_view && ! $db_is_system_schema): ?>
<br />
<?php echo PMA\Template::get('table/structure/add_column')->render(
array('columns_list' => $columns_list)
); ?>
<?php endif; ?>
<!--Displays indexes-->
<?php if (! $tbl_is_view
&& ! $db_is_system_schema && 'ARCHIVE' != $tbl_storage_engine): ?>
<?php echo PMA_getHtmlForDisplayIndexes(); ?>
<?php endif; ?>
<!--Display partition details-->
<?php
$partition_names = PMA_Partition::getPartitionNames($db, $table);
// detect partitioning
if (! empty($partition_names) && ! is_null($partition_names[0])) {
$partitions = PMA_Partition::getPartitions($db, $table);
$firstPartition = $partitions[0];
$rangeOrList = $firstPartition->getMethod() == 'RANGE'
|| $firstPartition->getMethod() == 'LIST';
$subParitions = $firstPartition->getSubPartitions();
$hasSubPartitions = $firstPartition->hasSubPartitions();
if ($hasSubPartitions) {
$firstSubPartition = $subParitions[0];
}
$actionIcons = array(
'ANALYZE' => PMA_Util::getIcon('b_search.png', __('Analyze')),
'CHECK' => PMA_Util::getIcon('eye.png', __('Check')),
'OPTIMIZE' => PMA_Util::getIcon('normalize.png', __('Optimize')),
'REBUILD' => PMA_Util::getIcon('s_tbl.png', __('Rebuild')),
'REPAIR' => PMA_Util::getIcon('b_tblops.png', __('Repair')),
'TRUNCATE' => PMA_Util::getIcon('b_empty.png', __('Truncate')),
);
if ($rangeOrList) {
$actionIcons['DROP'] = PMA_Util::getIcon('b_drop.png', __('Drop'));
}
echo PMA_Util::getDivForSliderEffect(
'partitions', __('Partitions')
);
$tmp_partition_description = $firstPartition->getDescription();
echo PMA\Template::get('table/structure/display_partitions')->render(
array(
'table' => $table,
'url_query' => $url_query,
'partitions' => $partitions,
'partitionMethod' => $firstPartition->getMethod(),
'partitionExpression' => $firstPartition->getExpression(),
'hasDescription' => ! empty($tmp_partition_description),
'hasSubPartitions' => $hasSubPartitions,
'subPartitionMethod' => $hasSubPartitions ? $firstSubPartition->getMethod() : null,
'subPartitionExpression' => $hasSubPartitions ? $firstSubPartition->getExpression() : null,
'actionIcons' => $actionIcons,
'rangeOrList' => $rangeOrList,
)
);
?>
<!-- For closing Slider effect div-->
</div>
<?php } ?>
<!--Displays Space usage and row statistics-->
<?php if ($GLOBALS['cfg']['ShowStats']): ?>
<?php echo $tablestats; ?>
<?php endif; ?>
<div class="clearfloat"></div>