Passed
Push — master ( 442876...4ec1bc )
by Felipe
15:55 queued 10:33
created

LanguagesController::doTree()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 13
rs 9.4285
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
        $lang   = $this->lang;
24
        $action = $this->action;
25
        if ('tree' == $action) {
26
            return $this->doTree();
27
        }
28
29
        $this->printHeader($lang['strlanguages']);
30
        $this->printBody();
31
32
        switch ($action) {
33
            default:
34
                $this->doDefault();
35
36
                break;
37
        }
38
39
        $this->printFooter();
40
    }
41
42
    /**
43
     * Show default list of languages in the database.
44
     *
45
     * @param mixed $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
46
     */
47
    public function doDefault($msg = '')
48
    {
49
        $lang = $this->lang;
50
        $data = $this->misc->getDatabaseAccessor();
51
52
        $this->printTrail('database');
53
        $this->printTabs('database', 'languages');
54
        $this->printMsg($msg);
55
56
        $languages = $data->getLanguages();
57
58
        $columns = [
59
            'language' => [
60
                'title' => $lang['strname'],
61
                'field' => Decorator::field('lanname'),
62
            ],
63
            'trusted'  => [
64
                'title' => $lang['strtrusted'],
65
                'field' => Decorator::field('lanpltrusted'),
66
                'type'  => 'yesno',
67
            ],
68
            'function' => [
69
                'title' => $lang['strfunction'],
70
                'field' => Decorator::field('lanplcallf'),
71
            ],
72
        ];
73
74
        $actions = [];
75
76
        echo $this->printTable($languages, $columns, $actions, 'languages-languages', $lang['strnolanguages']);
77
    }
78
79
    /**
80
     * Generate XML for the browser tree.
81
     */
82
    public function doTree()
83
    {
84
        $lang = $this->lang;
0 ignored issues
show
Unused Code introduced by
The assignment to $lang is dead and can be removed.
Loading history...
85
        $data = $this->misc->getDatabaseAccessor();
86
87
        $languages = $data->getLanguages();
88
89
        $attrs = [
90
            'text' => Decorator::field('lanname'),
91
            'icon' => 'Language',
92
        ];
93
94
        return $this->printTree($languages, $attrs, 'languages');
95
    }
96
}
97