Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HTMLHeaderController.php « xhtml « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 54bd698edbf79cccbaf2dd1a438ac9e80d32985c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php

/**
 * PHPPgAdmin v6.0.0-RC7
 */

namespace PHPPgAdmin\XHtml;

/**
 * Class to render tables. Formerly part of Misc.php.
 */
class HTMLHeaderController extends HTMLController
{
    public $controller_name = 'HTMLHeaderController';
    private $_no_output     = false;

    /**
     * Sets the value of private member variable $_no_output.
     *
     * @param bool $flag [description]
     *
     * @return $this
     */
    public function setNoOutput($flag)
    {
        $this->_no_output = (bool) $flag;

        return $this;
    }

    /**
     * Prints the page header.  If member variable $this->_no_output is
     * set then no header is drawn.
     *
     * @param string $title    The title of the page
     * @param string $script   script tag
     * @param bool   $do_print boolean if false, the function will return the header content
     * @param string $template the template to render
     *
     * @return string the parsed template
     */
    public function printHeader($title = '', $script = null, $do_print = true, $template = 'header.twig')
    {
        if (function_exists('newrelic_disable_autorum')) {
            newrelic_disable_autorum();
        }

        $lang           = $this->lang;
        $plugin_manager = $this->plugin_manager;

        $viewVars = [];

        $viewVars['dir']            = (0 != strcasecmp($lang['applangdir'], 'ltr')) ? ' dir="'.htmlspecialchars($lang['applangdir']).'"' : '';
        $viewVars['headertemplate'] = $template;
        $viewVars['title']          = ('' !== $title) ? ' - '.$title : '';
        $viewVars['appName']        = htmlspecialchars($this->appName);

        $viewVars['script'] = $script;
        //$this->prtrace($viewVars);
        $header_html = $this->view->fetch($template, $viewVars);

        /*$plugins_head = [];
        $_params      = ['heads' => &$plugins_head];

        $plugin_manager->doHook('head', $_params);

        foreach ($plugins_head as $tag) {
        $header_html .= $tag;
        }*/

        if (!$this->_no_output && $do_print) {
            header('Content-Type: text/html; charset=utf-8');
            echo $header_html;
        } else {
            return $header_html;
        }
    }

    /**
     * Prints the page body.
     *
     * @param bool   $doBody     True to output body tag, false to return
     * @param string $bodyClass  - name of body class
     * @param bool   $onloadInit - if true, call init() on body load event
     */
    public function printBody($doBody = true, $bodyClass = 'detailbody', $onloadInit = false)
    {
        $bodyClass = $this->lang['applangdir'].' '.htmlspecialchars($bodyClass);
        $onload    = ($onloadInit ? 'onload="init();" ' : '');

        $bodyHtml = sprintf('<body data-controller="%s" class="%s" %s >', $this->controller_name, $bodyClass, $onload);
        $bodyHtml .= PHP_EOL;

        if (!$this->_no_output && $doBody) {
            echo $bodyHtml;
        } else {
            return $bodyHtml;
        }
    }

    /**
     * Print out the page heading and help link.
     *
     * @param string $title    Title, already escaped
     * @param string $help     (optional) The identifier for the help link
     * @param bool   $do_print
     */
    public function printTitle($title, $help = null, $do_print = true)
    {
        $title_html = '<h2>';
        $title_html .= $this->misc->printHelp($title, $help, false);
        $title_html .= '</h2>'.PHP_EOL;

        if ($do_print) {
            echo $title_html;
        } else {
            return $title_html;
        }
    }
}