} $map_tab->addRow(_('Minimum trigger severity'), new CSeverity(['name' => 'severity_min', 'value' => (int) $data['sysmap']['severity_min']])); // Create url table. $url_table = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Name'), _('URL'), _('Element'), _('Action')]); if (empty($data['sysmap']['urls'])) { $data['sysmap']['urls'][] = ['name' => '', 'url' => '', 'elementtype' => 0]; } $i = 0; foreach ($data['sysmap']['urls'] as $url) { $url_table->addRow((new CRow([(new CTextBox('urls[' . $i . '][name]', $url['name']))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH), (new CTextBox('urls[' . $i . '][url]', $url['url']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), new CComboBox('urls[' . $i . '][elementtype]', $url['elementtype'], null, sysmap_element_types()), (new CCol((new CButton(null, _('Remove')))->onClick('$("urlEntry_' . $i . '").remove();')->addClass(ZBX_STYLE_BTN_LINK)))->addClass(ZBX_STYLE_NOWRAP)]))->setId('urlEntry_' . $i)); $i++; } // Append empty template row to url table. $template_url_label = (new CTextBox('urls[#{id}][name]', ''))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)->setAttribute('disabled', 'disabled'); $template_url_link = (new CTextBox('urls[#{id}][url]', ''))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('disabled', 'disabled'); $template_url_etype = new CComboBox('urls[#{id}][elementtype]', null, null, sysmap_element_types()); $template_url_etype->setAttribute('disabled', 'disabled'); $template_remove_button = (new CButton(null, _('Remove')))->onClick('$("entry_#{id}").remove();')->addClass(ZBX_STYLE_BTN_LINK); $template_url_row = (new CRow([$template_url_label, $template_url_link, $template_url_etype, (new CCol($template_remove_button))->addClass(ZBX_STYLE_NOWRAP)]))->addStyle('display: none')->setId('urlEntryTpl'); $url_table->addRow($template_url_row); // Append "add" button to url table. $add_button = (new CButton(null, _('Add')))->onClick('cloneRow("urlEntryTpl", ' . $i . ')')->addClass(ZBX_STYLE_BTN_LINK); $add_button_column = (new CCol($add_button))->setColSpan(4); $url_table->addRow($add_button_column); // Append url table to form list. $map_tab->addRow(_('URLs'), (new CDiv($url_table))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); $tabs->addTab('sysmap_tab', _('Map'), $map_tab); // User group sharing table. $user_group_shares_table = (new CTable())->setHeader([_('User groups'), _('Permissions'), _('Action')])->setAttribute('style', 'width: 100%;'); $add_user_group_btn = [(new CButton(null, _('Add')))->onClick('return PopUp("popup.php?dstfrm=' . $form->getName() . '&srctbl=usrgrp&srcfld1=usrgrpid&srcfld2=name&multiselect=1")')->addClass(ZBX_STYLE_BTN_LINK)]; $user_group_shares_table->addRow((new CRow((new CCol($add_user_group_btn))->setColSpan(3)))->setId('user_group_list_footer'));
$urlEtype->addItems(sysmap_element_types()); $removeButton = new CSpan(_('Remove'), 'link_menu'); $removeButton->addAction('onclick', '$("urlEntry_' . $i . '").remove();'); $urlRow = new CRow(array($urlLabel, $urlLink, $urlEtype, $removeButton)); $urlRow->setAttribute('id', 'urlEntry_' . $i); $urlTable->addRow($urlRow); $i++; } // append empty template row to url table $templateUrlLabel = new CTextBox('urls[#{id}][name]', '', 32); $templateUrlLabel->setAttribute('disabled', 'disabled'); $templateUrlLink = new CTextBox('urls[#{id}][url]', '', 32); $templateUrlLink->setAttribute('disabled', 'disabled'); $templateUrlEtype = new CComboBox('urls[#{id}][elementtype]'); $templateUrlEtype->setAttribute('disabled', 'disabled'); $templateUrlEtype->addItems(sysmap_element_types()); $templateRemoveButton = new CSpan(_('Remove'), 'link_menu'); $templateRemoveButton->addAction('onclick', '$("entry_#{id}").remove();'); $templateUrlRow = new CRow(array($templateUrlLabel, $templateUrlLink, $templateUrlEtype, $templateRemoveButton)); $templateUrlRow->addStyle('display: none'); $templateUrlRow->setAttribute('id', 'urlEntryTpl'); $urlTable->addRow($templateUrlRow); // append "add" button to url table $addButton = new CSpan(_('Add'), 'link_menu'); $addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')'); $addButtonColumn = new CCol($addButton); $addButtonColumn->setColSpan(4); $urlTable->addRow($addButtonColumn); // append url table to form list $sysmapList->addRow(_('URLs'), new CDiv($urlTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append sysmap to form
$urlEtype->addItems(sysmap_element_types()); $removeButton = new CSpan(_('Remove'), 'link_menu'); $removeButton->addAction('onclick', '$("urlEntry_' . $i . '").remove();'); $urlRow = new CRow(array($urlLabel, $urlLink, $urlEtype, $removeButton)); $urlRow->setAttribute('id', 'urlEntry_' . $i); $urlTable->addRow($urlRow); $i++; } // append empty template row to url table $tplUrlLabel = new CTextBox('urls[#{id}][name]', '', 32); $tplUrlLabel->setAttribute('disabled', 'disabled'); $tplUrlLink = new CTextBox('urls[#{id}][url]', '', 32); $tplUrlLink->setAttribute('disabled', 'disabled'); $tplUrlEtype = new CCombobox('urls[#{id}][elementtype]'); $tplUrlEtype->setAttribute('disabled', 'disabled'); $tplUrlEtype->addItems(sysmap_element_types()); $tplRemoveButton = new CSpan(_('Remove'), 'link_menu'); $tplRemoveButton->addAction('onclick', '$("entry_#{id}").remove();'); $tplUrlRow = new CRow(array($tplUrlLabel, $tplUrlLink, $tplUrlEtype, $tplRemoveButton)); $tplUrlRow->addStyle('display: none'); $tplUrlRow->setAttribute('id', 'urlEntryTpl'); $urlTable->addRow($tplUrlRow); // append "add" button to url table $addButton = new CSpan(_('Add'), 'link_menu'); $addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')'); $addButtonColumn = new CCol($addButton); $addButtonColumn->setColSpan(4); $urlTable->addRow($addButtonColumn); // append url table to sysmap $sysmapList->addRow(_('URLs'), new CDiv($urlTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append sysmap to form