File: table-structure.php

package info (click to toggle)
adminer 5.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,828 kB
  • sloc: php: 28,768; javascript: 1,188; xml: 107; makefile: 48; sh: 3
file content (48 lines) | stat: -rw-r--r-- 1,975 bytes parent folder | download | duplicates (2)
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
<?php

/** Expanded table structure output
* @link https://www.adminer.org/plugins/#use
* @author Matthew Gamble, https://www.matthewgamble.net/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerTableStructure extends Adminer\Plugin {

	/** Print table structure in tabular format
	* @param Field[] $fields data about individual fields
	*/
	function tableStructurePrint(array $fields, $tableStatus = null): bool {
		echo "<div class='scrollable'>\n";
		echo "<table class='nowrap odds'>\n";
		echo "<thead><tr>"
			. "<th>" . Adminer\lang('Column')
			. "<th>" . Adminer\lang('Type')
			. "<th>" . Adminer\lang('Collation')
			. "<th>" . Adminer\lang('Nullable')
			. "<th>" . Adminer\lang('Default')
			. (Adminer\support("comment") ? "<th>" . Adminer\lang('Comment') : "")
			. "</thead>\n"
		;
		foreach ($fields as $field) {
			echo "<tr><th>" . Adminer\h($field["field"]) . ($field["primary"] ? " (PRIMARY)" : "");
			echo "<td><span>" . Adminer\h($field["full_type"]) . "</span>";
			echo ($field["auto_increment"] ? " <i>" . Adminer\lang('Auto Increment') . "</i>" : "");
			echo "<td>" . ($field["collation"] ? " <i>" . Adminer\h($field["collation"]) . "</i>" : "");
			echo "<td>" . ($field["null"] ? Adminer\lang('Yes') : Adminer\lang('No'));
			echo "<td>" . Adminer\h($field["default"]);
			echo (Adminer\support("comment") ? "<td>" . Adminer\h($field["comment"]) : "");
			echo "\n";
		}
		echo "</table>\n";
		echo "</div>\n";
		return true;
	}

	protected $translations = array(
		'cs' => array('' => 'Rozšířené informace o tabulkách'),
		'de' => array('' => 'Erweiterte Ausgabe der Tabellenstruktur'),
		'pl' => array('' => 'Rozszerzone wyjście struktury tabeli'),
		'ro' => array('' => 'Ieșirea expandată a structurii tabelei'),
		'ja' => array('' => 'テーブル構造を拡張表示'),
	);
}