HuasoFoundries /
phpPgAdmin6
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * PHPPgAdmin 6.1.3 |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace PHPPgAdmin\XHtml; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class to render tables. Formerly part of Misc.php. |
||
| 11 | */ |
||
| 12 | class HTMLFooterController extends HTMLController |
||
| 13 | { |
||
| 14 | public $controller_name = 'HTMLFooterController'; |
||
| 15 | |||
| 16 | private $_reload_drop_database = false; |
||
| 17 | |||
| 18 | private $_no_bottom_link = false; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Sets the value of $_reload_drop_database which in turn will trigger a reload in the browser frame. |
||
| 22 | * |
||
| 23 | * @param bool $flag sets internal $_reload_drop_database var which will be passed to the footer methods |
||
| 24 | * |
||
| 25 | * @return HTMLFooterController $this the instance of this class |
||
| 26 | */ |
||
| 27 | public function setReloadDropDatabase($flag) |
||
| 28 | { |
||
| 29 | $this->_reload_drop_database = (bool) $flag; |
||
| 30 | |||
| 31 | return $this; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Sets $_no_bottom_link boolean value. |
||
| 36 | * |
||
| 37 | * @param bool $flag [description] |
||
| 38 | * |
||
| 39 | * @return HTMLFooterController $this the instance of this class |
||
| 40 | */ |
||
| 41 | public function setNoBottomLink($flag) |
||
| 42 | { |
||
| 43 | $this->_no_bottom_link = (bool) $flag; |
||
| 44 | |||
| 45 | return $this; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Prints the page footer. |
||
| 50 | * |
||
| 51 | * @param bool $doBody True to output body tag, false to return the html |
||
| 52 | * @param mixed $template |
||
| 53 | */ |
||
| 54 | public function printFooter($doBody = true, $template = 'footer.twig') |
||
| 55 | { |
||
| 56 | $reload_param = 'none'; |
||
| 57 | |||
| 58 | if ($this->view->getReloadBrowser()) { |
||
| 59 | $reload_param = 'other'; |
||
| 60 | } elseif ($this->_reload_drop_database) { |
||
| 61 | $reload_param = 'database'; |
||
| 62 | } |
||
| 63 | |||
| 64 | $this->view->offsetSet('script_footer', ''); |
||
| 65 | $this->view->offsetSet('reload', $reload_param); |
||
| 66 | $this->view->offsetSet('footer_template', $template); |
||
| 67 | $this->view->offsetSet('print_bottom_link', !$this->_no_bottom_link); |
||
| 68 | |||
| 69 | $footer_html = $this->view->fetch($template); |
||
| 70 | |||
| 71 | if ($doBody) { |
||
| 72 | echo $footer_html; |
||
| 73 | } else { |
||
| 74 | return $footer_html; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Outputs JavaScript to set default focus. |
||
| 80 | * |
||
| 81 | * @param string $object eg. forms[0].username |
||
| 82 | */ |
||
| 83 | public function setFocus($object): void |
||
| 84 | { |
||
| 85 | echo '<script type="text/javascript">' . \PHP_EOL; |
||
| 86 | echo " document.{$object}.focus();\n"; |
||
| 87 | echo '</script>' . \PHP_EOL; |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Outputs JavaScript to set the name of the browser window. |
||
| 92 | * |
||
| 93 | * @param string $name the window name |
||
| 94 | * @param bool $addServer if true (default) then the server id is |
||
| 95 | * attached to the name |
||
| 96 | */ |
||
| 97 | public function setWindowName($name, $addServer = true): void |
||
| 98 | { |
||
| 99 | echo '<script type="text/javascript">' . \PHP_EOL; |
||
| 100 | echo "//<![CDATA[\n"; |
||
| 101 | echo " window.name = '{$name}", ($addServer ? ':' . \htmlspecialchars($this->misc->getServerId()) : ''), "';\n"; |
||
| 102 | echo '//]]>' . \PHP_EOL; |
||
| 103 | echo '</script>' . \PHP_EOL; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Display the navlinks, below the table results. |
||
| 108 | * |
||
| 109 | * @param array $navlinks An array with the the attributes and values that will be shown. |
||
| 110 | * See printLinksList for array format. |
||
| 111 | * @param string $place Place where the $navlinks are displayed. Like 'display-browse', |
||
| 112 | * where 'display' is the file (display) and 'browse' is the action |
||
| 113 | * @param array $env - Associative array of defined variables in the scope of the caller. |
||
| 114 | * Allows to give some environnement details to plugins. |
||
| 115 | * and 'browse' is the place inside that code (doBrowse). |
||
| 116 | * @param bool $do_print if true, print html, if false, return html |
||
| 117 | * @param mixed $from can either be null, false or the method calling this one |
||
| 118 | */ |
||
| 119 | public function printNavLinks($navlinks, $place, $env, $do_print, $from) |
||
| 120 | { |
||
| 121 | if (null === $from || false === $from) { |
||
| 122 | $from = __METHOD__; |
||
| 123 | } |
||
| 124 | |||
| 125 | // Navlinks hook's place |
||
| 126 | $plugin_functions_parameters = [ |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 127 | 'navlinks' => &$navlinks, |
||
| 128 | 'place' => $place, |
||
| 129 | 'env' => $env, |
||
| 130 | ]; |
||
| 131 | |||
| 132 | if (0 < \count($navlinks)) { |
||
| 133 | if ($do_print) { |
||
| 134 | $this->printLinksList($navlinks, 'navlink', true, $from); |
||
| 135 | } else { |
||
| 136 | return $this->printLinksList($navlinks, 'navlink', false, $from); |
||
| 137 | } |
||
| 138 | } |
||
| 139 | } |
||
| 140 | } |
||
| 141 |