HuasoFoundries /
phpPgAdmin6
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
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 | */ |
||
| 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
|
|||
| 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; |
||
| 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 |