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

LanguagesController::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 0
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
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
 */
5 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
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;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
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
Coding Style introduced by
Missing parameter comment
Loading history...
48
     */
49
    public function doDefault($msg = '')
50
    {
51
        $conf = $this->conf;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
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;
0 ignored issues
show
Unused Code introduced by
The assignment to $conf is dead and can be removed.
Loading history...
89
90
        $lang = $this->lang;
0 ignored issues
show
Unused Code introduced by
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