field = $field; } public function getView(): CTag { $columns = $this->field->getValue(); $header = [ '', (new CColHeader(_('Name')))->addStyle('width: 39%'), (new CColHeader(_('Data')))->addStyle('width: 59%'), _('Action') ]; $row_actions = [ (new CButton('edit', _('Edit'))) ->addClass(ZBX_STYLE_BTN_LINK) ->removeId(), (new CButton('remove', _('Remove'))) ->addClass(ZBX_STYLE_BTN_LINK) ->removeId() ]; $view = (new CTable()) ->setId('list_'.$this->field->getName()) ->setHeader($header); foreach ($columns as $column_index => $column) { $column_data = [new CVar('sortorder['.$this->field->getName().'][]', $column_index)]; foreach ($column as $key => $value) { $column_data[] = new CVar($this->field->getName().'['.$column_index.']['.$key.']', $value); } if ($column['data'] == CWidgetFieldColumnsList::DATA_HOST_NAME) { $label = new CTag('em', true, _('Host name')); } else if ($column['data'] == CWidgetFieldColumnsList::DATA_TEXT) { $label = new CTag('em', true, $column['text']); } elseif (array_key_exists('item', $column)) { $label = $column['item']; } else { $label = ''; } $view->addRow( (new CRow([ (new CCol((new CDiv)->addClass(ZBX_STYLE_DRAG_ICON)))->addClass(ZBX_STYLE_TD_DRAG_ICON), (new CDiv($column['name']))->addClass('text'), (new CDiv($label))->addClass('text'), (new CList(array_merge($row_actions, [$column_data])))->addClass(ZBX_STYLE_HOR_LIST) ]))->addClass('sortable') ); } $view->addRow( (new CCol( (new CButton('add', _('Add'))) ->addClass(ZBX_STYLE_BTN_LINK) ->setEnabled(!$this->isDisabled()) ))->setColSpan(count($header)) ); return $view; } }