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: dd1a6a6d52f0521759e980a9d3b5ad8b199ada53 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php

/**
 * PHPPgAdmin 6.1.3
 */

namespace PHPPgAdmin\XHtml;

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

    private $_no_output = false;

    private $_reload_drop_database = 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')
    {
        $lang = $this->lang;

        $viewVars = [];

        $viewVars['dir'] = (0 !== \strcasecmp($lang['applangdir'], 'ltr')) ? ' dir="' . \htmlspecialchars($lang['applangdir']) . '"' : '';
        $viewVars['headertemplate'] = $template;
        $viewVars['headerFlags'][str_replace('.twig', '', basename($template))] = 1;
        $viewVars['includeJsTree'] = true;
        //$viewVars['excludeJsTree']=$template==='header_sqledit.twig';
        $viewVars['title'] = ('' !== $title) ? ' - ' . $title : '';
        $viewVars['lang'] = $lang;
        $viewVars['appName'] = \htmlspecialchars($this->appName);

        $reload_param = 'none';
        if ($this->view->getReloadBrowser()) {
            $reload_param = 'other';
        } elseif ($this->_reload_drop_database) {
            $reload_param = 'database';
        }
        $viewVars['reload'] = $reload_param;
        $viewVars['script'] = $script;
        if (!$this->view->offsetExists('excludeJsTree')) {
            $this->view->offsetSet('excludeJsTree', false);
        }
        $template = $this->view->offsetGet('excludeJsTree') === true && $template === 'header_sqledit.twig' ? $template : 'header.twig';
        $header_html = $this->view->fetch($template, $viewVars);

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

        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;

            return '';
        }

        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
     * @param bool   $includeJsTree - if true, include the jstree section
     *
     * @return string the parsed template
     */
    public function printBody(
        $doBody = true,
        $bodyClass = 'detailbody',
        $onloadInit = false,
        $includeJsTree = true
    ) {

        // $includeJsTree=$includeJsTree||(       $this->view->offsetExists('includeJsTree')?$this->view->offsetGet('includeJsTree'):false);
        $viewVars = [
            'bodyClass' => $this->lang['applangdir'] . ' ' . \htmlspecialchars($bodyClass) . ' ' . $includeJsTree ? 'flexbox_body' : '',
            'onload' => ($onloadInit ? 'onload="init();" ' : ''),
            'controller_name' => $this->controller_name,
            'includeJsTree' => $includeJsTree
        ];

        $bodyHtml = $this->view->fetch('components/common_body.twig', $viewVars);

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

            return '';
        }

        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
     *
     * @return string the parsed template
     */
    public function printTitle($title, $help = null, $do_print = true)
    {
        $title_html = '<h2>';
        $title_html .= $this->view->printHelp($title, $help, false);
        $title_html .= '</h2>' . \PHP_EOL;

        if ($do_print) {
            echo $title_html;

            return '';
        }

        return $title_html;
    }
}