Extensibility basics

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@782 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-07-03 04:40:48 +00:00
parent ac4f13088f
commit 2c445a86c1
4 changed files with 24 additions and 5 deletions

View file

@ -0,0 +1,18 @@
<?php
class AdminerBase {
function table_list($row) {
global $SELF;
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . $this->table_name($row) . "</a><br />\n";
}
function table_name($row) {
return htmlspecialchars($row["Name"]);
}
function field_name($fields, $key) {
return htmlspecialchars($key);
}
}

View file

@ -56,7 +56,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
} }
function page_footer($missing = false) { function page_footer($missing = false) {
global $SELF, $VERSION, $dbh; global $SELF, $VERSION, $dbh, $adminer;
?> ?>
</div> </div>
@ -95,8 +95,7 @@ function page_footer($missing = false) {
} else { } else {
echo "<p>\n"; echo "<p>\n";
foreach ($table_status as $row) { foreach ($table_status as $row) {
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> '; $adminer->table_list($row);
echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a><br />\n";
} }
echo "</p>\n"; echo "</p>\n";
} }

View file

@ -87,6 +87,7 @@ include "./include/version.inc.php";
include "./include/functions.inc.php"; include "./include/functions.inc.php";
include "./include/lang.inc.php"; include "./include/lang.inc.php";
include "./lang/$LANG.inc.php"; include "./lang/$LANG.inc.php";
include "./include/adminer.inc.php";
include "./include/design.inc.php"; include "./include/design.inc.php";
if (isset($_GET["coverage"])) { if (isset($_GET["coverage"])) {
include "./coverage.inc.php"; include "./coverage.inc.php";
@ -98,6 +99,7 @@ include "./include/connect.inc.php";
include "./include/editing.inc.php"; include "./include/editing.inc.php";
include "./include/export.inc.php"; include "./include/export.inc.php";
$adminer = (class_exists("Adminer") ? new Adminer : new AdminerBase);
$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION"); $on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION");
$enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"'; $enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"';
$inout = array("IN", "OUT", "INOUT"); $inout = array("IN", "OUT", "INOUT");

View file

@ -143,7 +143,7 @@ if ($_POST && !$error) {
$error = lang('Unable to upload a file.'); $error = lang('Unable to upload a file.');
} }
} }
page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]), $error); page_header(lang('Select') . ": " . $adminer->table_name($table_status), $error);
echo "<p>"; echo "<p>";
if (isset($rights["insert"])) { if (isset($rights["insert"])) {
@ -250,7 +250,7 @@ if (!$columns) {
if (!$j) { if (!$j) {
echo '<thead><tr><td><input type="checkbox" id="all-page" onclick="form_check(this, /check/);" /></td>'; echo '<thead><tr><td><input type="checkbox" id="all-page" onclick="form_check(this, /check/);" /></td>';
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . htmlspecialchars($key) . '</a></th>'; echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . $adminer->field_name($fields, $key) . '</a></th>';
} }
echo "</tr></thead>\n"; echo "</tr></thead>\n";
} }