1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<?php
/**
* PHPPgAdmin v6.0.0-RC2
*/
namespace PHPPgAdmin\Controller;
use PHPPgAdmin\Decorators\Decorator;
/**
* Base controller class.
*
* @package PHPPgAdmin
*/
class CastsController extends BaseController
{
public $controller_title = 'strcasts';
/**
* Default method to render the controller according to the action parameter.
*/
public function render()
{
if ('tree' == $this->action) {
return $this->doTree();
}
$this->printHeader();
$this->printBody();
switch ($this->action) {
default:
$this->doDefault();
break;
}
return $this->printFooter();
}
/**
* Show default list of casts in the database.
*
* @param mixed $msg
*/
public function doDefault($msg = '')
{
$data = $this->misc->getDatabaseAccessor();
$lang = $this->lang;
$renderCastContext = function ($val) use ($lang) {
switch ($val) {
case 'e':
return $lang['strno'];
case 'a':
return $lang['strinassignment'];
default:
return $lang['stryes'];
}
};
$this->printTrail('database');
$this->printTabs('database', 'casts');
$this->printMsg($msg);
$casts = $data->getCasts();
$columns = [
'source_type' => [
'title' => $this->lang['strsourcetype'],
'field' => Decorator::field('castsource'),
],
'target_type' => [
'title' => $this->lang['strtargettype'],
'field' => Decorator::field('casttarget'),
],
'function' => [
'title' => $this->lang['strfunction'],
'field' => Decorator::field('castfunc'),
'params' => ['null' => $this->lang['strbinarycompat']],
],
'implicit' => [
'title' => $this->lang['strimplicit'],
'field' => Decorator::field('castcontext'),
'type' => 'callback',
'params' => ['function' => $renderCastContext, 'align' => 'center'],
],
'comment' => [
'title' => $this->lang['strcomment'],
'field' => Decorator::field('castcomment'),
],
];
$actions = [];
echo $this->printTable($casts, $columns, $actions, 'casts-casts', $this->lang['strnocasts']);
}
/**
* Generate XML for the browser tree.
*/
public function doTree()
{
$data = $this->misc->getDatabaseAccessor();
$casts = $data->getCasts();
$proto = Decorator::concat(Decorator::field('castsource'), ' AS ', Decorator::field('casttarget'));
$attrs = [
'text' => $proto,
'icon' => 'Cast',
];
return $this->printTree($casts, $attrs, 'casts');
}
}
|