Passed
Push — develop ( c6d385...331c63 )
by Felipe
05:01
created

HTMLFooterController::getFooter()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 13
c 0
b 0
f 0
nc 6
nop 2
dl 0
loc 18
rs 9.8333
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-RC1.
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
    private $_reload_drop_database = false;
16
    private $_no_bottom_link       = false;
17
18
    /**
19
     * Sets the value of $_reload_drop_database which in turn will trigger a reload in the browser frame.
20
     *
21
     * @param bool $flag sets internal $_reload_drop_database var which will be passed to the footer methods
22
     *
23
     * @return HTMLFooterController $this the instance of this class
24
     */
25
    public function setReloadDropDatabase($flag)
26
    {
27
        $this->_reload_drop_database = (bool) $flag;
28
29
        return $this;
30
    }
31
32
    /**
33
     * Sets $_no_bottom_link boolean value.
34
     *
35
     * @param bool $flag [description]
36
     *
37
     * @return HTMLFooterController $this the instance of this class
38
     */
39
    public function setNoBottomLink($flag)
40
    {
41
        $this->_no_bottom_link = (bool) $flag;
42
43
        return $this;
44
    }
45
46
    /**
47
     * fetches the page footer.
48
     *
49
     * @param string  $template    the template's name
50
     * @param array   $viewParams  Optional - extra view parameters
51
     *
52
     * @return string  the html content for the footer section
53
     */
54
    public function getFooter($template = 'footer.twig', $viewParams = [])
55
    {
56
        $reload_param = 'none';
57
        if ($this->misc->getReloadBrowser()) {
58
            $reload_param = 'other';
59
        } elseif ($this->_reload_drop_database) {
60
            $reload_param = 'database';
61
        }
62
63
        $this->view->offsetSet('script_footer', '');
64
        $this->view->offsetSet('inPopUp', $inPopUp);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $inPopUp seems to be never defined.
Loading history...
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
        foreach ($viewParams as $key => $value) {
69
            $this->view->offsetSet($key, $value);
70
        }
71
        return $this->view->fetch($template);
72
73
    }
74
75
    /**
76
     * Outputs JavaScript to set default focus.
77
     *
78
     * @param string $object eg. forms[0].username
79
     */
80
    public function setFocus($object)
81
    {
82
        echo '<script type="text/javascript">' . PHP_EOL;
83
        echo "   document.{$object}.focus();\n";
84
        echo '</script>' . PHP_EOL;
85
    }
86
87
    /**
88
     * Outputs JavaScript to set the name of the browser window.
89
     *
90
     * @param string $name      the window name
91
     * @param bool   $addServer if true (default) then the server id is
92
     *                          attached to the name
93
     */
94
    public function setWindowName($name, $addServer = true)
95
    {
96
        echo '<script type="text/javascript">' . PHP_EOL;
97
        echo "//<![CDATA[\n";
98
        echo "   window.name = '{$name}", ($addServer ? ':' . htmlspecialchars($this->misc->getServerId()) : ''), "';\n";
99
        echo '//]]>' . PHP_EOL;
100
        echo '</script>' . PHP_EOL;
101
    }
102
103
    /**
104
     * Display the navlinks, below the table results.
105
     *
106
     * @param array  $navlinks An array with the the attributes and values that will be shown.
107
     *                         See printLinksList for array format.
108
     * @param string $place    Place where the $navlinks are displayed. Like 'display-browse',
109
     *                         where 'display' is the file (display) and 'browse' is the action
110
     * @param array  $env      - Associative array of defined variables in the scope of the caller.
111
     *                         Allows to give some environnement details to plugins.
112
     *                         and 'browse' is the place inside that code (doBrowse).
113
     * @param bool   $do_print if true, print html, if false, return html
114
     * @param stromg  $from     who is calling this method (mostly for debug)
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\XHtml\stromg was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
115
     */
116
    public function printNavLinks($navlinks, $place, $env, $do_print, $from)
117
    {
118
119
        //$this->prtrace($navlinks);
120
        $plugin_manager = $this->plugin_manager;
121
122
        // Navlinks hook's place
123
        $plugin_functions_parameters = [
124
            'navlinks' => &$navlinks,
125
            'place'    => $place,
126
            'env'      => $env,
127
        ];
128
        $plugin_manager->doHook('navlinks', $plugin_functions_parameters);
129
130
        if (count($navlinks) > 0) {
131
132
            return $this->printLinksList($navlinks, 'navlink', $do_print, $from);
133
134
        }
135
    }
136
}
137