diff --git a/adminer/call.inc.php b/adminer/call.inc.php index f8988675..dc4d2677 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -1,5 +1,6 @@ multi_query($query); $affected = $connection->affected_rows; // getting warnigns overwrites this echo $adminer->selectQuery($query, $start, !$result); - + if (!$result) { echo "

" . error() . "\n"; } else { @@ -42,7 +43,7 @@ if (!$error && $_POST) { if (is_object($connection2)) { $connection2->select_db(DB); } - + do { $result = $connection->store_result(); if (is_object($result)) { @@ -53,16 +54,15 @@ if (!$error && $_POST) { ; } } while ($connection->next_result()); - + if ($out) { select($connection->query("SELECT " . implode(", ", $out))); } } } -?> -

-\n"; + if ($in) { echo "\n"; foreach ($in as $key) { @@ -83,8 +83,28 @@ if ($in) { } echo "
\n"; } -?> -

- - -

+ +echo "

", + "", + "", + "

\n", + "\n"; + +$comment = $routine["comment"]; +if ($comment !== null && $comment !== "") { + $comment = h(trim($routine["comment"], "\n")); + + // Remove indenting of all lines (used in MySQL routines in 'sys' database). + if (preg_match('~^ +~', $comment, $matches)) { + preg_match_all("~^($matches[0]|$)~m", $comment, $linesWithIndent); + + if (count($linesWithIndent[0]) == substr_count($comment, "\n")) { + $comment = preg_replace("~^($matches[0])~m", "", $comment); + } + } + + // Format common headlines (used in MySQL routines in 'sys' database). + $comment = preg_replace('~(^|[^\n]\n)(Description|Parameters|Example)\n~', "$1\n$2\n", $comment); + + echo "
$comment
\n"; +} diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 03633a98..2203a3e9 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -182,25 +182,43 @@ if ($adminer->homepage()) { if (support("routine")) { echo "

" . lang('Routines') . "

\n"; + $routines = routines(); if ($routines) { + $commentsSupported = $routines[0]["ROUTINE_COMMENT"] !== null; + echo "\n"; - echo '\n"; + echo '', + '"; + if ($commentsSupported) { + echo ""; + } + echo "", + "\n"; + odd(''); foreach ($routines as $row) { - $name = ($row["SPECIFIC_NAME"] == $row["ROUTINE_NAME"] ? "" : "&name=" . urlencode($row["ROUTINE_NAME"])); // not computed on the pages to be able to print the header first - echo ''; - echo '', + '', + ''; + + if ($commentsSupported) { + echo ''; + } + + echo '"; } + echo "
' . lang('Name') . '' . lang('Type') . '' . lang('Return type') . "
', lang('Name'), '', lang('Type'), '', lang('Return type'), "", lang('Comment'), "
' . h($row["ROUTINE_NAME"]) . ''; - echo '' . h($row["ROUTINE_TYPE"]); - echo '' . h($row["DTD_IDENTIFIER"]); - echo '' . lang('Alter') . ""; + // not computed on the pages to be able to print the header first + $name = ($row["SPECIFIC_NAME"] == $row["ROUTINE_NAME"] ? "" : "&name=" . urlencode($row["ROUTINE_NAME"])); + + echo '', + '', h($row["ROUTINE_NAME"]), '', h($row["ROUTINE_TYPE"]), '', h($row["DTD_IDENTIFIER"]), '', shorten_utf8(preg_replace('~\s{2,}~', " ", trim($row["ROUTINE_COMMENT"])), 50), '' . lang('Alter') . "
\n"; } - echo '