mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
Move HTML function, fix types
This commit is contained in:
@@ -11,17 +11,15 @@ function connection(): Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get Adminer object
|
/** Get Adminer object
|
||||||
* @return Adminer
|
* @return Adminer|Plugins
|
||||||
*/
|
*/
|
||||||
function adminer() {
|
function adminer() {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
return $adminer;
|
return $adminer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Driver object
|
/** Get Driver object */
|
||||||
* @return Driver
|
function driver(): Driver {
|
||||||
*/
|
|
||||||
function driver() {
|
|
||||||
global $driver;
|
global $driver;
|
||||||
return $driver;
|
return $driver;
|
||||||
}
|
}
|
||||||
@@ -70,7 +68,7 @@ function number_type(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Disable magic_quotes_gpc
|
/** Disable magic_quotes_gpc
|
||||||
* @param list<array> $process e.g. (&$_GET, &$_POST, &$_COOKIE)
|
* @param list<array> $process e.g. [&$_GET, &$_POST, &$_COOKIE]
|
||||||
* @param bool $filter whether to leave values as is
|
* @param bool $filter whether to leave values as is
|
||||||
* @return void modified in place
|
* @return void modified in place
|
||||||
*/
|
*/
|
||||||
@@ -172,7 +170,7 @@ function get_val(string $query, int $field = 0, ?Db $conn = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get list of values from database
|
/** Get list of values from database
|
||||||
* @param mixed $column
|
* @param array-key $column
|
||||||
* @return list<string>
|
* @return list<string>
|
||||||
*/
|
*/
|
||||||
function get_vals(string $query, $column = 0): array {
|
function get_vals(string $query, $column = 0): array {
|
||||||
@@ -566,16 +564,6 @@ function is_utf8(?string $val): bool {
|
|||||||
return (preg_match('~~u', $val) && !preg_match('~[\0-\x8\xB\xC\xE-\x1F]~', $val));
|
return (preg_match('~~u', $val) && !preg_match('~[\0-\x8\xB\xC\xE-\x1F]~', $val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shorten UTF-8 string
|
|
||||||
* @return string escaped string with appended ...
|
|
||||||
*/
|
|
||||||
function shorten_utf8(string $string, int $length = 80, string $suffix = ""): string {
|
|
||||||
if (!preg_match("(^(" . repeat_pattern("[\t\r\n -\x{10FFFF}]", $length) . ")($)?)u", $string, $match)) { // ~s causes trash in $match[2] under some PHP versions, (.|\n) is slow
|
|
||||||
preg_match("(^(" . repeat_pattern("[\t\r\n -~]", $length) . ")($)?)", $string, $match);
|
|
||||||
}
|
|
||||||
return h($match[1]) . $suffix . (isset($match[2]) ? "" : "<i>…</i>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Format decimal number
|
/** Format decimal number
|
||||||
* @param float|numeric-string $val
|
* @param float|numeric-string $val
|
||||||
*/
|
*/
|
||||||
|
@@ -467,6 +467,16 @@ function edit_form(string $table, array $fields, $row, ?bool $update, string $er
|
|||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Shorten UTF-8 string
|
||||||
|
* @return string escaped string with appended ...
|
||||||
|
*/
|
||||||
|
function shorten_utf8(string $string, int $length = 80, string $suffix = ""): string {
|
||||||
|
if (!preg_match("(^(" . repeat_pattern("[\t\r\n -\x{10FFFF}]", $length) . ")($)?)u", $string, $match)) { // ~s causes trash in $match[2] under some PHP versions, (.|\n) is slow
|
||||||
|
preg_match("(^(" . repeat_pattern("[\t\r\n -~]", $length) . ")($)?)", $string, $match);
|
||||||
|
}
|
||||||
|
return h($match[1]) . $suffix . (isset($match[2]) ? "" : "<i>…</i>");
|
||||||
|
}
|
||||||
|
|
||||||
/** Get button with icon */
|
/** Get button with icon */
|
||||||
function icon(string $icon, string $name, string $html, string $title): string {
|
function icon(string $icon, string $name, string $html, string $title): string {
|
||||||
return "<button type='submit' name='$name' title='" . h($title) . "' class='icon icon-$icon'><span>$html</span></button>";
|
return "<button type='submit' name='$name' title='" . h($title) . "' class='icon icon-$icon'><span>$html</span></button>";
|
||||||
|
@@ -64,7 +64,7 @@ class Plugins {
|
|||||||
* @param mixed[] $params
|
* @param mixed[] $params
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function __call($name, array $params) {
|
function __call(string $name, array $params) {
|
||||||
$args = array();
|
$args = array();
|
||||||
foreach ($params as $key => $val) {
|
foreach ($params as $key => $val) {
|
||||||
// some plugins accept params by reference - we don't need to propage it outside, just to the other plugins
|
// some plugins accept params by reference - we don't need to propage it outside, just to the other plugins
|
||||||
|
Reference in New Issue
Block a user