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

HelpController.php « controllers « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 146fe294c02a7424e51f781d6bee9bb196be9eb6 (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
<?php

/**
 * PHPPgAdmin 6.1.2
 */

namespace PHPPgAdmin\Controller;

/**
 * Base controller class.
 */
class HelpController extends BaseController
{
    public $controller_title = 'strhelppagebrowser';

    /**
     * Default method to render the controller according to the action parameter.
     */
    public function render(): void
    {
        switch ($this->action) {
            case 'browse':
                $this->doBrowse();

                break;

            default:
                $this->doDefault();

                break;
        }
    }

    public function doDefault(): void
    {
        $data = $this->misc->getDatabaseAccessor();

        if (isset($_REQUEST['help'])) {
            $url = $data->getHelp($_REQUEST['help']);

            if (\is_array($url)) {
                $this->doChoosePage($url);

                return;
            }

            if ($url) {
                \header("Location: {$url}");

                return;
            }
        }

        $this->doBrowse($this->lang['strinvalidhelppage']);
    }

    public function doBrowse($msg = ''): void
    {
        $data = $this->misc->getDatabaseAccessor();

        $this->printHeader();
        $this->printBody();

        $this->printTitle($this->lang['strselecthelppage']);

        echo $this->printMsg($msg);

        echo '<dl>' . \PHP_EOL;

        $pages = $data->getHelpPages();

        foreach ($pages as $page => $dummy) {
            echo "<dt>{$page}</dt>" . \PHP_EOL;

            $urls = $data->getHelp($page);

            if (!\is_array($urls)) {
                $urls = [$urls];
            }

            foreach ($urls as $url) {
                echo "<dd><a href=\"{$url}\">{$url}</a></dd>" . \PHP_EOL;
            }
        }

        echo '</dl>' . \PHP_EOL;

        $this->printFooter();
    }

    public function doChoosePage(array $urls): void
    {
        $this->printHeader();
        $this->printBody();

        $this->printTitle($this->lang['strselecthelppage']);

        echo '<ul>' . \PHP_EOL;

        foreach ($urls as $url) {
            echo "<li><a href=\"{$url}\">{$url}</a></li>" . \PHP_EOL;
        }
        echo '</ul>' . \PHP_EOL;

        $this->printFooter();
    }
}