public function get($caption_l = null, $caption_r = null) { if (empty($caption_l)) { $caption_l = _('In'); } if (empty($caption_r)) { $caption_r = _('Other'); } $grp_tab = new CTable(); $grp_tab->attr('name', $this->name); $grp_tab->attr('id', zbx_formatDomId($this->name)); $grp_tab->setCellSpacing(0); $grp_tab->setCellPadding(0); if (!is_null($caption_l) || !is_null($caption_r)) { $grp_tab->addRow(array($caption_l, SPACE, $caption_r)); } $add_btn = new CButton('add', ' « ', null, 'formlist'); $add_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_r . '", "' . $this->id_l . '", "add");'); $rmv_btn = new CButton('remove', ' » ', null, 'formlist'); $rmv_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_l . '", "' . $this->id_r . '", "rmv");'); $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox)); return $grp_tab; }
} $caption = OPERATION_TYPE_TEMPLATE_ADD == $this->data['new_operation']['operationtype'] ? _('Link with templates') : _('Unlink from templates'); $newOperationsTable->addRow(array($caption, new CDiv($templateList, 'objectgroup inlineblock border_dotted ui-corner-all'))); break; } // append operation conditions to form list if ($this->data['eventsource'] == 0) { if (!isset($this->data['new_operation']['opconditions'])) { $this->data['new_operation']['opconditions'] = array(); } else { zbx_rksort($this->data['new_operation']['opconditions']); } $allowed_opconditions = get_opconditions_by_eventsource($this->data['eventsource']); $grouped_opconditions = array(); $operationConditionsTable = new CTable(_('No conditions defined.'), 'formElementTable'); $operationConditionsTable->attr('style', 'min-width: 310px;'); $operationConditionsTable->setHeader(array(_('Label'), _('Name'), _('Action'))); $i = 0; foreach ($this->data['new_operation']['opconditions'] as $opcondition) { if (!isset($opcondition['conditiontype'])) { $opcondition['conditiontype'] = 0; } if (!isset($opcondition['operator'])) { $opcondition['operator'] = 0; } if (!isset($opcondition['value'])) { $opcondition['value'] = 0; } if (!str_in_array($opcondition['conditiontype'], $allowed_opconditions)) { continue; }
$linkedTemplateTable->attr('id', 'linkedTemplateTable'); $linkedTemplates = API::Template()->get(array('templateids' => $templateIds, 'output' => array('templateid', 'name'))); CArrayHelper::sort($linkedTemplates, array('name')); // templates for normal hosts if (!$isDiscovered) { $linkedTemplateTable->setHeader(array(_('Name'), _('Action'))); $ignoredTemplates = array(); foreach ($linkedTemplates as $template) { $tmplList->addVar('templates[]', $template['templateid']); $linkedTemplateTable->addRow(array($template['name'], array(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink'), null, 'link_menu'), SPACE, SPACE, isset($original_templates[$template['templateid']]) ? new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear'), null, 'link_menu') : SPACE)), null, 'conditions_' . $template['templateid']); $ignoredTemplates[$template['templateid']] = $template['name']; } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // create new linked template table $newTemplateTable = new CTable(null, 'formElementTable'); $newTemplateTable->attr('id', 'newTemplateTable'); $newTemplateTable->attr('style', 'min-width: 400px;'); $newTemplateTable->addRow(array(new CMultiSelect(array('name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates)))); $newTemplateTable->addRow(array(new CSubmit('add_template', _('Add'), null, 'link_menu'))); $tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); } else { $linkedTemplateTable->setHeader(array(_('Name'))); foreach ($linkedTemplates as $template) { $linkedTemplateTable->addRow(array($template['name']), null, 'conditions_' . $template['templateid']); } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); } $divTabs->addTab('templateTab', _('Templates'), $tmplList); /* * IPMI */
**/ require_once dirname(__FILE__) . '/js/adm.regexprs.edit.js.php'; zbx_add_post_js('zabbixRegExp.addExpressions(' . CJs::encodeJson(array_values($this->get('expressions'))) . ');'); $form = new CForm(); $form->attr('id', 'zabbixRegExpForm'); $form->addVar('form', 1); $form->addVar('regexpid', $this->data['regexpid']); /* * Expressions tab */ $exprTab = new CFormList('exprTab'); $nameTextBox = new CTextBox('name', $this->get('name'), ZBX_TEXTBOX_STANDARD_SIZE, false, 128); $nameTextBox->attr('autofocus', 'autofocus'); $exprTab->addRow(_('Name'), $nameTextBox); $exprTable = new CTable(null, 'formElementTable formWideTable'); $exprTable->attr('id', 'exprTable'); $exprTable->setHeader(array(_('Expression'), new CCol(_('Expression type'), 'nowrap'), new CCol(_('Case sensitive'), 'nowrap'), SPACE)); $exprTable->setFooter(new CButton('add', _('Add'), null, 'link_menu exprAdd')); $exprTab->addRow(_('Expressions'), new CDiv($exprTable, 'inlineblock border_dotted objectgroup')); $exprForm = new CTable(null, 'formElementTable'); $exprForm->addRow(array(_('Expression'), new CTextBox('expressionNew', null, ZBX_TEXTBOX_STANDARD_SIZE))); $exprForm->addRow(array(_('Expression type'), new CComboBox('typeNew', null, null, expression_type2str()))); $exprForm->addRow(array(_('Delimiter'), new CComboBox('delimiterNew', null, null, expressionDelimiters())), null, 'delimiterNewRow'); $exprForm->addRow(array(_('Case sensitive'), new CCheckBox('case_sensitiveNew'))); $exprFormFooter = array(new CButton('saveExpression', _('Add'), null, 'link_menu'), SPACE, new CButton('cancelExpression', _('Cancel'), null, 'link_menu')); $exprTab->addRow(null, new CDiv(array($exprForm, $exprFormFooter), 'objectgroup inlineblock border_dotted'), true, 'exprForm'); /* * Test tab */ $testTab = new CFormList('testTab'); $testTab->addRow(_('Test string'), new CTextArea('test_string', $this->get('test_string')));
$yaxisMaxData[] = new CTextBox('ymax_name', $ymax_name, 36, true); $yaxisMaxData[] = new CButton('yaxis_max', _('Select'), 'javascript: ' . 'return PopUp("popup.php?dstfrm=' . $graphForm->getName() . '&dstfld1=ymax_itemid' . '&dstfld2=ymax_name' . '&srctbl=items' . '&srcfld1=itemid' . '&srcfld2=name' . '&numeric=1' . '&writeonly=1" + getOnlyHostParam(), 0, 0, "zbx_popup_item");', 'formlist'); // select prototype button if (!empty($this->data['parent_discoveryid'])) { $yaxisMaxData[] = new CButton('yaxis_max_prototype', _('Select prototype'), 'javascript: ' . 'return PopUp("popup.php?dstfrm=' . $graphForm->getName() . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&dstfld1=ymax_itemid' . '&dstfld2=ymax_name' . '&srctbl=item_prototypes' . '&srcfld1=itemid' . '&srcfld2=name' . '&numeric=1", 0, 0, "zbx_popup_item");', 'formlist'); } } else { $graphForm->addVar('yaxismax', $this->data['yaxismax']); } $graphFormList->addRow(_('Y axis MAX value'), $yaxisMaxData); } else { $graphFormList->addRow(_('3D view'), new CCheckBox('show_3d', $this->data['show_3d'], null, 1)); } // append items to form list $itemsTable = new CTable(null, 'formElementTable'); $itemsTable->attr('style', 'min-width: 700px;'); $itemsTable->attr('id', 'itemsTable'); $itemsTable->setHeader(array(new CCol(SPACE, null, null, 15), new CCol(SPACE, null, null, 15), new CCol(_('Name'), null, null, $this->data['graphtype'] == GRAPH_TYPE_NORMAL ? 280 : 360), $this->data['graphtype'] == GRAPH_TYPE_PIE || $this->data['graphtype'] == GRAPH_TYPE_EXPLODED ? new CCol(_('Type'), null, null, 80) : null, new CCol(_('Function'), null, null, 80), $this->data['graphtype'] == GRAPH_TYPE_NORMAL ? new CCol(_('Draw style'), 'nowrap', null, 80) : null, $this->data['graphtype'] == GRAPH_TYPE_NORMAL || $this->data['graphtype'] == GRAPH_TYPE_STACKED ? new CCol(_('Y axis side'), 'nowrap', null, 80) : null, new CCol(_('Colour'), null, null, 100), new CCol(_('Action'), null, null, 50))); $addButton = new CButton('add_item', _('Add'), 'return PopUp("popup.php?writeonly=1&multiselect=1&dstfrm=' . $graphForm->getName() . ($this->data['normal_only'] ? '&normal_only=1' : '') . '&srctbl=items&srcfld1=itemid&srcfld2=name&numeric=1" + getOnlyHostParam(), 800, 600);', 'link_menu'); $addPrototypeButton = null; if ($this->data['parent_discoveryid']) { $addPrototypeButton = new CButton('add_protoitem', _('Add prototype'), 'return PopUp("popup.php?writeonly=1&multiselect=1&dstfrm=' . $graphForm->getName() . url_param($this->data['graphtype'], false, 'graphtype') . url_param('parent_discoveryid') . ($this->data['normal_only'] ? '&normal_only=1' : '') . '&srctbl=item_prototypes&srcfld1=itemid&srcfld2=name&numeric=1", 800, 600);', 'link_menu'); } $itemsTable->addRow(new CRow(new CCol(array($addButton, SPACE, SPACE, SPACE, $addPrototypeButton), null, 8), null, 'itemButtonsRow')); foreach ($this->data['items'] as $n => $item) { $name = $item['host'] . NAME_DELIMITER . $item['name_expanded']; if (zbx_empty($item['drawtype'])) { $item['drawtype'] = 0; } if (zbx_empty($item['yaxisside'])) { $item['yaxisside'] = 0;
$itemFormList->addRow(_('Enabled'), $enabledCheckBox); /* * Condition tab */ $conditionFormList = new CFormList('conditionlist'); // type of calculation $formula = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_STANDARD_SIZE); $formula->attr('id', 'formula'); $formula->attr('placeholder', 'A or (B and C) …'); if ($this->data['evaltype'] != CONDITION_EVAL_TYPE_EXPRESSION) { $formula->addClass('hidden'); } $conditionFormList->addRow(_('Type of calculation'), array(new CComboBox('evaltype', $this->data['evaltype'], null, array(CONDITION_EVAL_TYPE_AND_OR => _('And/Or'), CONDITION_EVAL_TYPE_AND => _('And'), CONDITION_EVAL_TYPE_OR => _('Or'), CONDITION_EVAL_TYPE_EXPRESSION => _('Custom expression'))), new CSpan('', $this->data['evaltype'] == CONDITION_EVAL_TYPE_EXPRESSION ? 'hidden' : '', 'expression'), $formula), count($this->data['conditions']) < 2, 'conditionRow'); // macros $conditionTable = new CTable('', 'formElementTable'); $conditionTable->attr('id', 'conditions'); $conditionTable->addRow(array(_('Label'), _('Macro'), SPACE, _('Regular expression'), SPACE)); $conditions = $this->data['conditions']; if (!$conditions) { $conditions = array(array('macro' => '', 'value' => '', 'formulaid' => num2letter(0))); } else { $conditions = CConditionHelper::sortConditionsByFormulaId($conditions); } // fields foreach ($conditions as $i => $condition) { // formula id $formulaId = array(new CSpan($condition['formulaid']), new CVar('conditions[' . $i . '][formulaid]', $condition['formulaid'])); // macro $macro = new CTextBox('conditions[' . $i . '][macro]', $condition['macro'], 30, false, 64); $macro->addClass('macro'); $macro->setAttribute('placeholder', '{#MACRO}');
CArrayHelper::sort($linkedTemplates, array('name')); // templates for normal hosts if (!$isDiscovered) { $linkedTemplateTable->setHeader(array(_('Name'), _('Action'))); $ignoredTemplates = array(); foreach ($linkedTemplates as $template) { $tmplList->addVar('templates[]', $template['templateid']); $templateLink = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid']); $templateLink->setTarget('_blank'); $linkedTemplateTable->addRow(array($templateLink, array(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink'), null, 'link_menu'), SPACE, SPACE, isset($originalTemplates[$template['templateid']]) ? new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear'), null, 'link_menu') : SPACE)), null, 'conditions_' . $template['templateid']); $ignoredTemplates[$template['templateid']] = $template['name']; } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all')); // create new linked template table $newTemplateTable = new CTable(null, 'formElementTable'); $newTemplateTable->attr('id', 'newTemplateTable'); $newTemplateTable->addRow(array(new CMultiSelect(array('name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates, 'popup' => array('parameters' => 'srctbl=templates&srcfld1=hostid&srcfld2=host&dstfrm=' . $frmHost->getName() . '&dstfld1=add_templates_&templated_hosts=1&multiselect=1', 'width' => 450, 'height' => 450))))); $newTemplateTable->addRow(array(new CSubmit('add_template', _('Add'), null, 'link_menu'))); $tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all')); } else { $linkedTemplateTable->setHeader(array(_('Name'))); foreach ($linkedTemplates as $template) { $templateLink = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid']); $templateLink->setTarget('_blank'); $linkedTemplateTable->addRow($templateLink, null, 'conditions_' . $template['templateid']); } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all')); } $divTabs->addTab('templateTab', _('Templates'), $tmplList); /* * IPMI
foreach (graph_item_drawtypes() as $dt) { $cmbDrawType->addItem($dt, graph_item_drawtype2str($dt)); } // Yaxisside selector $cmbYaxisside = new CComboBox('yaxisside', $yaxisside); foreach (array(0, 1) as $side) { $cmbYaxisside->addItem($side, $side == 0 ? _('Left') : _('Right')); } $graph_params_w = new CWidget(); $graph_params_w->setClass('header'); $graph_params_w->addHeader(_('Graphs')); $graph_params_div = new CDiv(); $graph_params_div->setAttribute("id", "graphparams"); $graph_params_div->addStyle("width: {$right_widget_width};"); $graph_params_tbl = new CTable(); $graph_params_tbl->attr('class', 'formtable'); $graph_params_tbl->addStyle("width: 100%; align: left; border-width: 0 0 0 0;"); $graph_params_tbl->setCellPadding(0); $graph_params_tbl->setCellSpacing(0); $graph_params_tbl1 = new CTable(); $graph_params_tbl1->attr('class', 'formtable'); $graph_params_tbl1->addStyle("width: 100%; align: left; border-width: 0 0 0 0;"); $graph_params_tbl1->addRow(array(_('Create graph'), $graphCreate, _('Name') . ':', $graphName, _('Width') . ':', $graphWidth, _('Height') . ':', $graphHeight, _('Graph type') . ':', $cmbGraphType)); $graph_params_tbl2 = new CTable(); $graph_params_tbl2->attr('class', 'formtable'); $graph_params_tbl2->addStyle("width: 100%; align: left; border-width: 0 0 0 0;"); $graph_params_tbl2->addRow(array(_('Function') . ':', $cmbGraphFunc, _('Draw style') . ':', $cmbDrawType, _('Y axis side') . ':', $cmbYaxisside)); $graph_params_tbl->addRow($graph_params_tbl1); $graph_params_tbl->addRow($graph_params_tbl2); $graph_params_div->addItem($graph_params_tbl); $graph_params_w->addItem($graph_params_div);