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

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

/**
 * PHPPgAdmin 6.0.0
 */

namespace PHPPgAdmin\Controller;

use PHPPgAdmin\Decorators\Decorator;

/**
 * Base controller class.
 */
class LanguagesController extends BaseController
{
    public $controller_title = 'strlanguages';

    /**
     * Default method to render the controller according to the action parameter.
     */
    public function render()
    {
        if ('tree' === $this->action) {
            return $this->doTree();
        }

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

        switch ($this->action) {
            default:
                $this->doDefault();

                break;
        }

        $this->printFooter();
    }

    /**
     * Show default list of languages in the database.
     *
     * @param mixed $msg
     */
    public function doDefault($msg = ''): void
    {
        $data = $this->misc->getDatabaseAccessor();

        $this->printTrail('database');
        $this->printTabs('database', 'languages');
        $this->printMsg($msg);

        $languages = $data->getLanguages();

        $columns = [
            'language' => [
                'title' => $this->lang['strname'],
                'field' => Decorator::field('lanname'),
            ],
            'trusted' => [
                'title' => $this->lang['strtrusted'],
                'field' => Decorator::field('lanpltrusted'),
                'type' => 'yesno',
            ],
            'function' => [
                'title' => $this->lang['strfunction'],
                'field' => Decorator::field('lanplcallf'),
            ],
        ];

        $actions = [];

        echo $this->printTable($languages, $columns, $actions, 'languages-languages', $this->lang['strnolanguages']);
    }

    /**
     * Generate XML for the browser tree.
     */
    public function doTree()
    {
        $data = $this->misc->getDatabaseAccessor();

        $languages = $data->getLanguages();

        $attrs = [
            'text' => Decorator::field('lanname'),
            'icon' => 'Language',
        ];

        return $this->printTree($languages, $attrs, 'languages');
    }
}