3 * Generate HTML for MySQL Documentation
6 declare(strict_types
=1);
8 namespace PhpMyAdmin\Html
;
15 use function file_exists
;
16 use function htmlspecialchars
;
19 * Generate HTML for MySQL Documentation
21 class MySQLDocumentation
24 * Displays a link to the official MySQL documentation
26 * @param string $link contains name of page/anchor that is being linked
27 * @param bool $bigIcon whether to use big icon (like in left frame)
28 * @param string|null $url href attribute
29 * @param string|null $text text of link
30 * @param string $anchor anchor to page part
32 * @return string the html link
34 public static function show(
36 bool $bigIcon = false,
37 string|
null $url = null,
38 string|
null $text = null,
42 $url = Util
::getMySQLDocuURL($link, $anchor);
45 $openLink = '<a href="' . htmlspecialchars($url) . '" target="mysql_doc">';
49 $html = $openLink . Generator
::getImage('b_sqlhelp', __('Documentation')) . $closeLink;
50 } elseif ($text !== null) {
51 $html = $openLink . $text . $closeLink;
53 $html = Generator
::showDocumentationLink($url, 'mysql_doc');
60 * Displays a link to the phpMyAdmin documentation
62 * @param string $page Page in documentation
63 * @param string $anchor Optional anchor in page
64 * @param bool $bbcode Optional flag indicating whether to output bbcode
65 * @param bool $disableTabIndex Optional flag indicating that a negative tabindex should be set on the link
67 * @return string the html link
69 public static function showDocumentation(
73 bool $disableTabIndex = false,
75 return Generator
::showDocumentationLink(
76 self
::getDocumentationLink($page, $anchor),
84 * Returns link to documentation.
86 * @param string $page Page in documentation
87 * @param string $anchor Optional anchor in page
88 * @param string $pathPrefix Optional path in case it is called in a folder (e.g. setup)
92 public static function getDocumentationLink(string $page, string $anchor = '', string $pathPrefix = './'): string
94 /* Construct base URL */
95 $url = $page . '.html';
97 $url .= '#' . $anchor;
101 * Check if we have built local documentation, however
102 * provide consistent URL for testsuite
104 if (! defined('TESTSUITE') && @file_exists
(ROOT_PATH
. 'docs/html/index.html')) {
105 return $pathPrefix . 'docs/html/' . $url;
108 return Core
::linkURL('https://docs.phpmyadmin.net/en/latest/' . $url);