$expressionForm->addVar('dstfld1', $this->data['dstfld1']); $expressionForm->addVar('itemid', $this->data['itemid']); if (!empty($this->data['parent_discoveryid'])) { $expressionForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); } // create form list $expressionFormList = new CFormList('expressionFormList'); // append item to form list $item = array(new CTextBox('description', $this->data['description'], ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), new CButton('select', _('Select'), 'return PopUp(\'popup.php?writeonly=1&dstfrm=' . $expressionForm->getName() . '&dstfld1=itemid&dstfld2=description&submitParent=1' . (!empty($this->data['parent_discoveryid']) ? '&normal_only=1' : '') . '&srctbl=items&srcfld1=itemid&srcfld2=name\', 0, 0, \'zbx_popup_item\');', 'formlist')); if (!empty($this->data['parent_discoveryid'])) { $item[] = new CButton('select', _('Select prototype'), 'return PopUp(\'popup.php?dstfrm=' . $expressionForm->getName() . '&dstfld1=itemid&dstfld2=description&submitParent=1' . url_param('parent_discoveryid', true) . '&srctbl=prototypes&srcfld1=itemid&srcfld2=name\', 0, 0, \'zbx_popup_item\');', 'formlist'); } $expressionFormList->addRow(_('Item'), $item); // append function to form list $functionComboBox = new CComboBox('expr_type', $this->data['expr_type'], 'submit()'); $functionComboBox->addStyle('width: 605px;'); foreach ($this->data['functions'] as $id => $f) { // if user has selected an item, we are filtering out the triggers that can't work with it if (empty($this->data['itemValueType']) || !empty($f['allowed_types'][$this->data['itemValueType']])) { $functionComboBox->addItem($id, $f['description']); } } $expressionFormList->addRow(_('Function'), $functionComboBox); if (isset($this->data['functions'][$this->data['function'] . '[' . $this->data['operator'] . ']']['params'])) { foreach ($this->data['functions'][$this->data['function'] . '[' . $this->data['operator'] . ']']['params'] as $pid => $pf) { $paramIsReadonly = 'no'; $paramTypeElement = null; $paramValue = isset($this->data['param'][$pid]) ? $this->data['param'][$pid] : null; if ($pf['T'] == T_ZBX_INT) { if ($pid == 0 || $pid == 1 && (substr($this->data['expr_type'], 0, 6) == 'regexp' || substr($this->data['expr_type'], 0, 7) == 'iregexp' || substr($this->data['expr_type'], 0, 3) == 'str' && substr($this->data['expr_type'], 0, 6) != 'strlen')) { if (isset($pf['M'])) {
** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/js/adm.regexprs.edit.js.php'; $widget = (new CWidget())->setTitle(_('Regular expressions'))->setControls((new CForm())->cleanItems()->addItem((new CList())->addItem(makeAdministrationGeneralMenu('adm.regexps.php')))); $form = (new CForm())->setId('zabbixRegExpForm')->addVar('form', 1)->addVar('regexpid', $data['regexpid']); /* * Expressions tab */ $exprTable = (new CTable())->setId('tbl_expr')->setAttribute('style', 'width: 100%;')->setHeader([_('Expression type'), _('Expression'), _('Delimiter'), _('Case sensitive'), _('Action')]); foreach ($data['expressions'] as $i => $expression) { $exp_delimiter = new CComboBox('expressions[' . $i . '][exp_delimiter]', $expression['exp_delimiter'], null, expressionDelimiters()); if ($expression['expression_type'] != EXPRESSION_TYPE_ANY_INCLUDED) { $exp_delimiter->addStyle('display: none;'); } $row = [(new CComboBox('expressions[' . $i . '][expression_type]', $expression['expression_type'], null, expression_type2str()))->onChange('onChangeExpressionType(this, ' . $i . ')'), (new CTextBox('expressions[' . $i . '][expression]', $expression['expression'], false, 255))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), $exp_delimiter, (new CCheckBox('expressions[' . $i . '][case_sensitive]', '1'))->setChecked($expression['case_sensitive'])]; $button_cell = [(new CButton('expressions[' . $i . '][remove]', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('element-table-remove')]; if (array_key_exists('expressionid', $expression)) { $button_cell[] = new CVar('expressions[' . $i . '][expressionid]', $expression['expressionid']); } $row[] = (new CCol($button_cell))->addClass(ZBX_STYLE_NOWRAP); $exprTable->addRow((new CRow($row))->addClass('form_row')->setAttribute('data-index', $i)); } $exprTable->setFooter((new CButton('expression_add', _('Add')))->addClass(ZBX_STYLE_BTN_LINK)->addClass('element-table-add')); $exprTab = (new CFormList('exprTab'))->addRow(_('Name'), (new CTextBox('name', $data['name'], false, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))->addRow(_('Expressions'), (new CDiv($exprTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); /* * Test tab */ $testTab = (new CFormList())->addRow(_('Test string'), (new CTextArea('test_string', $data['test_string']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow('', (new CButton('testExpression', _('Test expressions')))->addClass(ZBX_STYLE_BTN_ALT))->addRow(_('Result'), (new CDiv((new CTable())->setId('testResultTable')->setAttribute('style', 'width: 100%;')->setHeader([_('Expression type'), _('Expression'), _('Result')])))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;'));
* IPMI */ $ipmiList = new CFormList('ipmilist'); // normal hosts if (!$isDiscovered) { $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype); $cmbIPMIAuthtype->addItems(ipmiAuthTypes()); $cmbIPMIAuthtype->addClass('openView'); $cmbIPMIAuthtype->setAttribute('size', 7); $cmbIPMIAuthtype->addStyle('width: 170px;'); $ipmiList->addRow(_('Authentication algorithm'), $cmbIPMIAuthtype); $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege); $cmbIPMIPrivilege->addItems(ipmiPrivileges()); $cmbIPMIPrivilege->addClass('openView'); $cmbIPMIPrivilege->setAttribute('size', 5); $cmbIPMIPrivilege->addStyle('width: 170px;'); $ipmiList->addRow(_('Privilege level'), $cmbIPMIPrivilege); } else { $cmbIPMIAuthtype = new CTextBox('ipmi_authtype_name', ipmiAuthTypes($dbHost['ipmi_authtype']), ZBX_TEXTBOX_SMALL_SIZE, true); $ipmiList->addRow(_('Authentication algorithm'), $cmbIPMIAuthtype); $cmbIPMIPrivilege = new CTextBox('ipmi_privilege_name', ipmiPrivileges($dbHost['ipmi_privilege']), ZBX_TEXTBOX_SMALL_SIZE, true); $ipmiList->addRow(_('Privilege level'), $cmbIPMIPrivilege); } $ipmiList->addRow(_('Username'), new CTextBox('ipmi_username', $ipmi_username, ZBX_TEXTBOX_SMALL_SIZE, $isDiscovered)); $ipmiList->addRow(_('Password'), new CTextBox('ipmi_password', $ipmi_password, ZBX_TEXTBOX_SMALL_SIZE, $isDiscovered)); $divTabs->addTab('ipmiTab', _('IPMI'), $ipmiList); /* * Macros */ if (empty($macros)) { $macros = array(array('macro' => '', 'value' => ''));
close_window(); } } --> </script> <?php } echo SBR; $form = new CFormTable(S_CONDITION); $form->SetName('expression'); $form->addVar('dstfrm', $dstfrm); $form->addVar('dstfld1', $dstfld1); $form->addVar('itemid', $itemid); $form->addRow(S_ITEM, array(new CTextBox('description', $description, 50, 'yes'), new CButton('select', S_SELECT, "return PopUp('popup.php?dstfrm=" . $form->GetName() . "&dstfld1=itemid&dstfld2=description&submitParent=1&" . "srctbl=items&srcfld1=itemid&srcfld2=description',0,0,'zbx_popup_item');"))); $cmbFnc = new CComboBox('expr_type', $expr_type, 'submit()'); $cmbFnc->addStyle('width: auto;'); //If user has already selected an item if (isset($_REQUEST['itemid'])) { //getting type of return value for the item user selected $options = array('itemids' => array($_REQUEST['itemid']), 'output' => API_OUTPUT_EXTEND); $selectedItems = CItem::get($options); if ($selectedItem = reset($selectedItems)) { $itemValueType = $selectedItem['value_type']; } } foreach ($functions as $id => $f) { foreach ($f['operators'] as $op => $txt_op) { //if user has selected an item, we are filtering out the triggers that can't work with it if (!isset($itemValueType) || isset($f['allowed_types'][$itemValueType])) { $cmbFnc->addItem($id . '[' . $op . ']', str_replace('{OP}', $txt_op, $f['description'])); }