diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index 9761ac81..3028e7d5 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -246,6 +246,45 @@ focus(document.getElementById('username'));
return $val;
}
+ /** Print table structure in tabular format
+ * @param array data about individual fields
+ * @return null
+ */
+ function tableStructurePrint($fields) {
+ echo "
\n";
+ echo "" . lang('Column') . " | " . lang('Type') . (support("comment") ? " | " . lang('Comment') : "") . " |
\n";
+ foreach ($fields as $field) {
+ echo "" . h($field["field"]);
+ echo " | " . h($field["full_type"]) . "";
+ echo ($field["null"] ? " NULL" : "");
+ echo ($field["auto_increment"] ? " " . lang('Auto Increment') . "" : "");
+ echo (isset($field["default"]) ? " [" . h($field["default"]) . "]" : "");
+ echo (support("comment") ? " | " . nbsp($field["comment"]) : "");
+ echo "\n";
+ }
+ echo " |
---|
\n";
+ }
+
+ /** Print list of indexes on table in tabular format
+ * @param array data about all indexes on a table
+ * @return null
+ */
+ function tableIndexesPrint($indexes) {
+ echo "\n";
+ foreach ($indexes as $name => $index) {
+ ksort($index["columns"]); // enforce correct columns order
+ $print = array();
+ foreach ($index["columns"] as $key => $val) {
+ $print[] = "" . h($val) . ""
+ . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
+ . ($index["descs"][$key] ? " DESC" : "")
+ ;
+ }
+ echo "$index[type] | " . implode(", ", $print) . "\n";
+ }
+ echo " |
---|
\n";
+ }
+
/** Print columns box in select
* @param array result of selectColumnsProcess()[0]
* @param array selectable columns
diff --git a/adminer/table.inc.php b/adminer/table.inc.php
index 11e8ced6..ef1dbc81 100644
--- a/adminer/table.inc.php
+++ b/adminer/table.inc.php
@@ -15,18 +15,7 @@ if ($comment != "") {
}
if ($fields) {
- echo "\n";
- echo "" . lang('Column') . " | " . lang('Type') . (support("comment") ? " | " . lang('Comment') : "") . " |
\n";
- foreach ($fields as $field) {
- echo "" . h($field["field"]);
- echo " | " . h($field["full_type"]) . "";
- echo ($field["null"] ? " NULL" : "");
- echo ($field["auto_increment"] ? " " . lang('Auto Increment') . "" : "");
- echo (isset($field["default"]) ? " [" . h($field["default"]) . "]" : "");
- echo (support("comment") ? " | " . nbsp($field["comment"]) : "");
- echo "\n";
- }
- echo " |
---|
\n";
+ $adminer->tableStructurePrint($fields);
}
if (!is_view($table_status)) {
@@ -34,19 +23,7 @@ if (!is_view($table_status)) {
echo "" . lang('Indexes') . "
\n";
$indexes = indexes($TABLE);
if ($indexes) {
- echo "\n";
- foreach ($indexes as $name => $index) {
- ksort($index["columns"]); // enforce correct columns order
- $print = array();
- foreach ($index["columns"] as $key => $val) {
- $print[] = "" . h($val) . ""
- . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
- . ($index["descs"][$key] ? " DESC" : "")
- ;
- }
- echo "$index[type] | " . implode(", ", $print) . "\n";
- }
- echo " |
---|
\n";
+ $adminer->tableIndexesPrint($indexes);
}
echo '' . lang('Alter indexes') . "\n";
}
diff --git a/plugins/plugin.php b/plugins/plugin.php
index b686a736..aae72c35 100644
--- a/plugins/plugin.php
+++ b/plugins/plugin.php
@@ -202,6 +202,16 @@ class AdminerPlugin extends Adminer {
return $this->_applyPlugin(__FUNCTION__, $args);
}
+ function tableStructurePrint($fields) {
+ $args = func_get_args();
+ return $this->_applyPlugin(__FUNCTION__, $args);
+ }
+
+ function tableIndexesPrint($indexes) {
+ $args = func_get_args();
+ return $this->_applyPlugin(__FUNCTION__, $args);
+ }
+
function selectColumnsPrint($select, $columns) {
$args = func_get_args();
return $this->_applyPlugin(__FUNCTION__, $args);