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

OpclassesController::doDefault()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

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