Source
$new_condition_value = (new CTextBox('value', '0-1023,1024-49151'))->setWidth(ZBX_TEXTAREA_MEDIUM_WIDTH);
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** 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.
**/
/**
* @var CView $this
*/
$inline_js = '';
$form = (new CForm())
->cleanItems()
->setId('popup.condition')
->setName('popup.condition')
->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE)
->addVar('action', $data['action'])
->addVar('type', $data['type']);
if (array_key_exists('source', $data)) {
$form->addVar('source', $data['source']);
}
$condition_type = (int) $data['last_type'];
$form_list = (new CFormList())->cleanItems();
switch ($data['type']) {
case ZBX_POPUP_CONDITION_TYPE_EVENT_CORR:
// Type select.
$form_list->addRow(new CLabel(_('Type'), 'label-condition-type'), (new CSelect('condition_type'))
->setFocusableElementId('label-condition-type')
->setValue($condition_type)
->setId('condition-type')
->addOptions(CSelect::createOptionsFromArray(CCorrelationHelper::getConditionTypes()))
);
$inline_js .= '$(() => $("#condition-type").on("change",'
.'(e) => reloadPopup($(e.target).closest("form").get(0), "popup.condition.event.corr")));';
switch ($condition_type) {
// Old|New event tag form elements.
case ZBX_CORR_CONDITION_OLD_EVENT_TAG:
case ZBX_CORR_CONDITION_NEW_EVENT_TAG:
$operator = (new CRadioButtonList('', CONDITION_OPERATOR_EQUAL))
->setModern(true)
->addValue(CCorrelationHelper::getLabelByOperator(
CCorrelationHelper::getOperatorsByConditionType(ZBX_CORR_CONDITION_OLD_EVENT_TAG)[0]
), CCorrelationHelper::getOperatorsByConditionType(ZBX_CORR_CONDITION_OLD_EVENT_TAG)[0]);
$new_condition_tag = (new CTextAreaFlexible('tag'))->setWidth(ZBX_TEXTAREA_MEDIUM_WIDTH);
$inline_js .= $new_condition_tag->getPostJS();
$form_list
->addRow(_('Operator'), [$operator, new CVar('operator', CONDITION_OPERATOR_EQUAL)])
->addRow(_('Tag'), $new_condition_tag);
break;
// New event host group form elements.
case ZBX_CORR_CONDITION_NEW_EVENT_HOSTGROUP:
$operator = (new CRadioButtonList('operator', CONDITION_OPERATOR_EQUAL))->setModern(true);
foreach (CCorrelationHelper::getOperatorsByConditionType(ZBX_CORR_CONDITION_NEW_EVENT_HOSTGROUP)
as $value) {
$operator->addValue(CCorrelationHelper::getLabelByOperator($value), $value);
}
$hostgroup_multiselect = (new CMultiSelect([
'name' => 'groupids[]',
'object_name' => 'hostGroup',
'default_value' => 0,
'popup' => [
'parameters' => [
'srctbl' => 'host_groups',
'srcfld1' => 'groupid',
'dstfrm' => $form->getName(),