Translated using Weblate (Portuguese)
[phpmyadmin.git] / src / Html / MySQLDocumentation.php
blob8551ce3bbe8db546693187aa39b2d9adf18107ed
1 <?php
2 /**
3 * Generate HTML for MySQL Documentation
4 */
6 declare(strict_types=1);
8 namespace PhpMyAdmin\Html;
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Util;
13 use function __;
14 use function defined;
15 use function file_exists;
16 use function htmlspecialchars;
18 /**
19 * Generate HTML for MySQL Documentation
21 class MySQLDocumentation
23 /**
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(
35 string $link,
36 bool $bigIcon = false,
37 string|null $url = null,
38 string|null $text = null,
39 string $anchor = '',
40 ): string {
41 if ($url === null) {
42 $url = Util::getMySQLDocuURL($link, $anchor);
45 $openLink = '<a href="' . htmlspecialchars($url) . '" target="mysql_doc">';
46 $closeLink = '</a>';
48 if ($bigIcon) {
49 $html = $openLink . Generator::getImage('b_sqlhelp', __('Documentation')) . $closeLink;
50 } elseif ($text !== null) {
51 $html = $openLink . $text . $closeLink;
52 } else {
53 $html = Generator::showDocumentationLink($url, 'mysql_doc');
56 return $html;
59 /**
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(
70 string $page,
71 string $anchor = '',
72 bool $bbcode = false,
73 bool $disableTabIndex = false,
74 ): string {
75 return Generator::showDocumentationLink(
76 self::getDocumentationLink($page, $anchor),
77 'documentation',
78 $bbcode,
79 $disableTabIndex,
83 /**
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)
90 * @return string URL
92 public static function getDocumentationLink(string $page, string $anchor = '', string $pathPrefix = './'): string
94 /* Construct base URL */
95 $url = $page . '.html';
96 if ($anchor !== '') {
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);