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
|
<?php
/**
* PHPPgAdmin v6.0.0-beta.51
*/
namespace PHPPgAdmin\Controller;
use PHPPgAdmin\Decorators\Decorator;
/**
* Base controller class.
*
* @package PHPPgAdmin
*/
class ConversionsController extends BaseController
{
public $controller_title = 'strconversions';
/**
* 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 conversions in the database.
*
* @param string $msg
*
* @return string|void
*/
public function doDefault($msg = '')
{
$data = $this->misc->getDatabaseAccessor();
$this->printTrail('schema');
$this->printTabs('schema', 'conversions');
$this->printMsg($msg);
$conversions = $data->getconversions();
$columns = [
'conversion' => [
'title' => $this->lang['strname'],
'field' => Decorator::field('conname'),
],
'source_encoding' => [
'title' => $this->lang['strsourceencoding'],
'field' => Decorator::field('conforencoding'),
],
'target_encoding' => [
'title' => $this->lang['strtargetencoding'],
'field' => Decorator::field('contoencoding'),
],
'default' => [
'title' => $this->lang['strdefault'],
'field' => Decorator::field('condefault'),
'type' => 'yesno',
],
'comment' => [
'title' => $this->lang['strcomment'],
'field' => Decorator::field('concomment'),
],
];
$actions = [];
echo $this->printTable($conversions, $columns, $actions, 'conversions-conversions', $this->lang['strnoconversions']);
}
public function doTree()
{
$data = $this->misc->getDatabaseAccessor();
$constraints = $data->getConstraints($_REQUEST['table']);
$getIcon = function ($f) {
switch ($f['contype']) {
case 'u':
return 'UniqueConstraint';
case 'c':
return 'CheckConstraint';
case 'f':
return 'ForeignKey';
case 'p':
return 'PrimaryKey';
}
};
$attrs = [
'text' => Decorator::field('conname'),
'icon' => Decorator::callback($getIcon),
];
return $this->printTree($constraints, $attrs, 'constraints');
}
}
|