"form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; } $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { case RecordModel::PARENT: // 기존 작성하던 값 old($field)가 있으면 그 값을 넣고 없으면 부모 값이 있으면 넣고 없으면 entity가 있으면 그 값을 넣고 없으면 디폴트 값을 넣는다. $value = $value ?: (isset($viewDatas[$field]) ? $viewDatas[$field] : (isset($viewDatas['entity']) ? $viewDatas['entity']->getParent() : DEFAULTS['EMPTY'])); $extra_class = isset($extras['class']) ? 'select-field ' . $extras['class'] : 'select-field'; $form = form_dropdown($field, [ "" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택', ] + $viewDatas['field_options'][$field], $value, [ 'class' => $extra_class, ...array_diff_key($extras, ['class' => '']) ]); break; case RecordModel::TITLE: // host $form = form_input($field, $value, $extras); break; case 'hosts': $form = form_textarea($field, html_entity_decode($value), [ 'rows' => '5', ...$extras ]); break; case 'content': $form = form_input($field, $value, ["placeholder" => "예)123.123.123.123", ...$extras]); break; case "type": case "fixed": case "locked": case "proxied": case "proxiable": $form = form_dropdown($field, [ "" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택', ] + $viewDatas['field_options'][$field], $value, $extras); break; default: $form = parent::getFieldForm($field, $value, $viewDatas, $extras); break; } return $form; } public function getFieldView(string $field, array $viewDatas, array $extras = []): string { $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; switch ($field) { case RecordModel::PARENT: if ($this->old_parent === $viewDatas['entity']->getParent()) { $value = ""; } else { $value = anchor( current_url() . "/reload/" . $viewDatas['entity']->getParent(), ICONS["RELOAD"], [ "class" => "btn btn-sm btn-primary btn-circle", "target" => "_self", ] ) . " " . form_label( $viewDatas['field_options'][$field][$value], 'label_zones', ['class' => "label_zones", ...$extras] ); } $this->old_parent = $viewDatas['entity']->getParent(); break; case RecordModel::TITLE: $fixed = anchor( sprintf("%s/toggle/%s/fixed?fixed=%s", current_url(), $viewDatas['entity']->getPK(), $viewDatas['entity']->fixed == 'on' ? "off" : "on"), $viewDatas['entity']->fixed == 'on' ? "" . ICONS['LOCK'] . "" : ICONS['UNLOCK'], ["class" => "ext-danger", "style" => "float:right;", ...$extras] ); $value = $fixed . " " . form_label( $value, 'view', [ "data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(), "data-bs-toggle" => "modal", "data-bs-target" => "#index_action_form", 'class' => "label_hosts", "style" => "color: blue; cursor: pointer; font-weight:bold;", ...$extras, ] ); break; case 'content': // 값이 40자 이상인 경우 자르고 '...' 추가 if ($viewDatas['action'] === 'index' && mb_strlen($value) > 40) { $value = '' . htmlspecialchars(mb_substr($value, 0, 40), ENT_QUOTES) . '...'; $value .= ''; } break; case 'type': $value = $value === 'A' ? parent::getFieldView($field, $viewDatas, $extras) : $viewDatas['field_options'][$field][$value]; break; default: $value = parent::getFieldView($field, $viewDatas, $extras); break; } return $value; } public function getListRowColor($entity): string { return $entity->locked != 'on' ? 'class="table-danger"' : ""; } public function getListLabel(string $field, array $viewDatas, array $extras = []): string { $label = parent::getListLabel($field, $viewDatas, $extras); switch ($field) { case RecordModel::PARENT: $label .= ""; break; case RecordModel::TITLE: $label .= ""; break; } return $label; } public function getListButton(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'modify': $checkbox = ""; if ($viewDatas['entity']->fixed != 'on') { $pk = $viewDatas['entity']->getPK(); $oldBatchJobUids = old("batchjob_uids") ?? []; $oldBatchJobUids = is_array($oldBatchJobUids) ? $oldBatchJobUids : [$oldBatchJobUids]; $checkbox = form_checkbox([ "id" => "checkbox_uid_{$pk}", "name" => "batchjob_uids[]", "value" => $pk, "class" => "batchjobuids_checkboxs", "checked" => in_array($pk, $oldBatchJobUids) ]); } $extras = ["target" => "_self", ...$extras]; $action = $checkbox . anchor( current_url() . "/sync/" . $viewDatas['entity']->getPK(), $viewDatas['cnt'], $extras ); break; default: $action = parent::getListButton($action, $viewDatas, $extras); break; } return $action; } }