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