Passed
Pull Request — develop (#92)
by Felipe
04:47
created

src/controllers/LanguagesController.php (3 issues)

1
<?php
2
0 ignored issues
show
You must use "/**" style comments for a file comment
Loading history...
3
/*
4
 * PHPPgAdmin v6.0.0-beta.30
5
 */
6
7
namespace PHPPgAdmin\Controller;
8
9
use PHPPgAdmin\Decorators\Decorator;
10
11
/**
12
 * Base controller class.
13
 */
14
class LanguagesController extends BaseController
15
{
16
    public $controller_name = 'LanguagesController';
17
18
    /**
19
     * Default method to render the controller according to the action parameter.
20
     */
21
    public function render()
22
    {
23
        $conf = $this->conf;
24
25
        $lang   = $this->lang;
26
        $action = $this->action;
27
        if ('tree' == $action) {
28
            return $this->doTree();
29
        }
30
31
        $this->printHeader($lang['strlanguages']);
32
        $this->printBody();
33
34
        switch ($action) {
35
            default:
36
                $this->doDefault();
37
38
                break;
39
        }
40
41
        $this->printFooter();
42
    }
43
44
    /**
45
     * Show default list of languages in the database.
46
     *
47
     * @param mixed $msg
1 ignored issue
show
Missing parameter comment
Loading history...
48
     */
49
    public function doDefault($msg = '')
50
    {
51
        $conf = $this->conf;
52
53
        $lang = $this->lang;
54
        $data = $this->misc->getDatabaseAccessor();
55
56
        $this->printTrail('database');
57
        $this->printTabs('database', 'languages');
58
        $this->printMsg($msg);
59
60
        $languages = $data->getLanguages();
61
62
        $columns = [
63
            'language' => [
64
                'title' => $lang['strname'],
65
                'field' => Decorator::field('lanname'),
66
            ],
67
            'trusted' => [
68
                'title' => $lang['strtrusted'],
69
                'field' => Decorator::field('lanpltrusted'),
70
                'type'  => 'yesno',
71
            ],
72
            'function' => [
73
                'title' => $lang['strfunction'],
74
                'field' => Decorator::field('lanplcallf'),
75
            ],
76
        ];
77
78
        $actions = [];
79
80
        echo $this->printTable($languages, $columns, $actions, 'languages-languages', $lang['strnolanguages']);
81
    }
82
83
    /**
84
     * Generate XML for the browser tree.
85
     */
86
    public function doTree()
87
    {
88
        $conf = $this->conf;
89
90
        $lang = $this->lang;
0 ignored issues
show
The assignment to $lang is dead and can be removed.
Loading history...
91
        $data = $this->misc->getDatabaseAccessor();
92
93
        $languages = $data->getLanguages();
94
95
        $attrs = [
96
            'text' => Decorator::field('lanname'),
97
            'icon' => 'Language',
98
        ];
99
100
        return $this->printTree($languages, $attrs, 'languages');
101
    }
102
}
103