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

OpclassesController::doDefault()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 1
dl 0
loc 38
rs 8.8571
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 OpclassesController extends BaseController
15
{
16
    public $controller_name = 'OpclassesController';
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
25
        $action = $this->action;
26
        if ('tree' == $action) {
27
            return $this->doTree();
28
        }
29
30
        $this->printHeader($lang['stropclasses']);
31
        $this->printBody();
32
33
        switch ($action) {
34
            default:
35
                $this->doDefault();
36
37
                break;
38
        }
39
40
        $this->printFooter();
41
    }
42
43
    /**
44
     * Show default list of opclasss in the database.
45
     *
46
     * @param string $msg
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
47
     *
48
     * @return string|void
49
     */
50
    public function doDefault($msg = '')
51
    {
52
        $lang = $this->lang;
53
        $data = $this->misc->getDatabaseAccessor();
54
55
        $this->printTrail('schema');
56
        $this->printTabs('schema', 'opclasses');
57
        $this->printMsg($msg);
58
59
        $opclasses = $data->getOpClasses();
60
61
        $columns = [
62
            'accessmethod' => [
63
                'title' => $lang['straccessmethod'],
64
                'field' => Decorator::field('amname'),
65
            ],
66
            'opclass'      => [
67
                'title' => $lang['strname'],
68
                'field' => Decorator::field('opcname'),
69
            ],
70
            'type'         => [
71
                'title' => $lang['strtype'],
72
                'field' => Decorator::field('opcintype'),
73
            ],
74
            'default'      => [
75
                'title' => $lang['strdefault'],
76
                'field' => Decorator::field('opcdefault'),
77
                'type'  => 'yesno',
78
            ],
79
            'comment'      => [
80
                'title' => $lang['strcomment'],
81
                'field' => Decorator::field('opccomment'),
82
            ],
83
        ];
84
85
        $actions = [];
86
87
        echo $this->printTable($opclasses, $columns, $actions, 'opclasses-opclasses', $lang['strnoopclasses']);
88
    }
89
90
    /**
91
     * Generate XML for the browser tree.
92
     */
93
    public function doTree()
94
    {
95
        $lang = $this->lang;
0 ignored issues
show
Unused Code introduced by
The assignment to $lang is dead and can be removed.
Loading history...
96
        $data = $this->misc->getDatabaseAccessor();
97
98
        $opclasses = $data->getOpClasses();
99
100
        // OpClass prototype: "op_class/access_method"
101
        $proto = Decorator::concat(Decorator::field('opcname'), '/', Decorator::field('amname'));
102
103
        $attrs = [
104
            'text'    => $proto,
105
            'icon'    => 'OperatorClass',
106
            'toolTip' => Decorator::field('opccomment'),
107
        ];
108
109
        return $this->printTree($opclasses, $attrs, 'opclasses');
110
    }
111
}
112