Passed
Push — develop ( 39eda0...90489b )
by Felipe
04:51
created

HTMLHeaderController::printHeader()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 34
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 8.439
c 0
b 0
f 0
cc 6
eloc 17
nc 16
nop 4
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-beta.44
5
 */
6
7
namespace PHPPgAdmin\XHtml;
8
9
/**
10
 * Class to render tables. Formerly part of Misc.php.
11
 */
12
class HTMLHeaderController extends HTMLController
13
{
14
    public $controller_name = 'HTMLHeaderController';
15
    private $_no_output     = false;
16
17
    /**
18
     * Sets the value of private member variable $_no_output.
19
     *
20
     * @param bool $flag [description]
21
     *
22
     * @return $this
23
     */
24
    public function setNoOutput($flag)
25
    {
26
        $this->_no_output = (bool) $flag;
27
28
        return $this;
29
    }
30
31
    /**
32
     * Prints the page header.  If member variable $this->_no_output is
33
     * set then no header is drawn.
34
     *
35
     * @param $title The title of the page
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\XHtml\The 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...
36
     * @param $script script tag
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\XHtml\script 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...
37
     * @param bool  $do_print boolean if false, the function will return the header content
38
     * @param mixed $template
39
     */
40
    public function printHeader($title = '', $script = null, $do_print = true, $template = 'header.twig')
41
    {
42
        if (function_exists('newrelic_disable_autorum')) {
43
            newrelic_disable_autorum();
44
        }
45
        $appName        = $this->appName;
0 ignored issues
show
Unused Code introduced by
The assignment to $appName is dead and can be removed.
Loading history...
46
        $lang           = $this->lang;
47
        $plugin_manager = $this->plugin_manager;
48
49
        $viewVars = [];
50
51
        $viewVars['dir']            = (0 != strcasecmp($lang['applangdir'], 'ltr')) ? ' dir="'.htmlspecialchars($lang['applangdir']).'"' : '';
52
        $viewVars['headertemplate'] = $template;
53
        $viewVars['title']          = ('' !== $title) ? ' - '.$title : '';
54
        $viewVars['appName']        = htmlspecialchars($this->appName);
55
56
        $viewVars['script'] = $script;
57
        //$this->prtrace($viewVars);
58
        $header_html = $this->view->fetch($template, $viewVars);
59
60
        /*$plugins_head = [];
61
        $_params      = ['heads' => &$plugins_head];
62
63
        $plugin_manager->doHook('head', $_params);
64
65
        foreach ($plugins_head as $tag) {
66
        $header_html .= $tag;
67
        }*/
68
69
        if (!$this->_no_output && $do_print) {
70
            header('Content-Type: text/html; charset=utf-8');
71
            echo $header_html;
72
        } else {
73
            return $header_html;
74
        }
75
    }
76
77
    /**
78
     * Prints the page body.
79
     *
80
     * @param bool   $doBody     True to output body tag, false to return
81
     * @param string $bodyClass  - name of body class
82
     * @param bool   $onloadInit - if true, call init() on body load event
83
     */
84
    public function printBody($doBody = true, $bodyClass = 'detailbody', $onloadInit = false)
85
    {
86
        $bodyClass = $this->lang['applangdir'].' '.htmlspecialchars($bodyClass);
87
        $onload    = ($onloadInit ? 'onload="init();" ' : '');
88
89
        $bodyHtml = sprintf('<body data-controller="%s" class="%s" %s >', $this->controller_name, $bodyClass, $onload);
90
        $bodyHtml .= "\n";
91
92
        if (!$this->_no_output && $doBody) {
93
            echo $bodyHtml;
94
        } else {
95
            return $bodyHtml;
96
        }
97
    }
98
99
    /**
100
     * Print out the page heading and help link.
101
     *
102
     * @param $title Title, already escaped
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\XHtml\Title 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...
103
     * @param $help (optional) The identifier for the help link
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\XHtml\optional 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...
104
     * @param mixed $do_print
105
     */
106
    public function printTitle($title, $help = null, $do_print = true)
107
    {
108
        $lang = $this->lang;
0 ignored issues
show
Unused Code introduced by
The assignment to $lang is dead and can be removed.
Loading history...
109
110
        $title_html = '<h2>';
111
        $title_html .= $this->misc->printHelp($title, $help, false);
112
        $title_html .= "</h2>\n";
113
114
        if ($do_print) {
115
            echo $title_html;
116
        } else {
117
            return $title_html;
118
        }
119
    }
120
}
121