diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 078904a5..60fb6dee 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -61,7 +61,7 @@ if ($adminer->homepage()) { echo " \n"; if ($adminer->operator_regexp !== null) { echo "
'; - echo doc_link(['sql' => 'regexp.html', 'pgsql' => 'functions-matching.html#FUNCTIONS-POSIX-REGEXP']) . "
\n"; + echo doc_link(['sql' => 'regexp.html', 'pgsql' => 'functions-matching.html#FUNCTIONS-POSIX-REGEXP', 'elastic' => "regexp-syntax.html"]) . "\n"; } echo "\n"; if ($_POST["search"] && $_POST["query"] != "") { diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 611f94e7..7a4e0a32 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -556,27 +556,39 @@ function ini_bytes($ini) { return $val; } -/** Create link to database documentation -* @param array $jush => $path -* @param string HTML code -* @return string HTML code -*/ -function doc_link($paths, $text = "?") { +/** + * Creates link to database documentation. + * + * @param array $paths $jush => $path + * @param string $text HTML code + * + * @return string HTML code + */ +function doc_link(array $paths, $text = "?") { global $jush, $connection; + $server_info = $connection->server_info; $version = preg_replace('~^(\d\.?\d).*~s', '\1', $server_info); // two most significant digits - $urls = array( + + $urls = [ 'sql' => "https://dev.mysql.com/doc/refman/$version/en/", 'sqlite' => "https://www.sqlite.org/", 'pgsql' => "https://www.postgresql.org/docs/$version/", 'mssql' => "https://msdn.microsoft.com/library/", 'oracle' => "https://www.oracle.com/pls/topic/lookup?ctx=db" . preg_replace('~^.* (\d+)\.(\d+)\.\d+\.\d+\.\d+.*~s', '\1\2', $server_info) . "&id=", - ); + 'elastic' => "https://www.elastic.co/guide/en/elasticsearch/reference/$version/", + ]; + if (preg_match('~MariaDB~', $server_info)) { $urls['sql'] = "https://mariadb.com/kb/en/library/"; $paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql'])); } - return ($paths[$jush] ? "$text" : ""); + + if (!isset($paths[$jush]) || !$paths[$jush] ) { + return ""; + } + + return "$text"; } /** Wrap gzencode() for usage in ob_start()