} else { $fieldLength = $hostInventoryTable['fields'][$inventoryInfo['db_field']]['length']; $input = new CTextBox('host_inventory[' . $inventoryInfo['db_field'] . ']', $host_inventory[$inventoryInfo['db_field']]); $input->setAttribute('maxlength', $fieldLength); $input->addStyle('width: ' . ($fieldLength > 64 ? 64 : $fieldLength) . 'em;'); } if ($inventory_mode == HOST_INVENTORY_DISABLED) { $input->setAttribute('disabled', 'disabled'); } // link to populating item at the right side (if any) if (isset($hostItemsToInventory[$inventoryNo])) { $itemName = itemName($hostItemsToInventory[$inventoryNo]); $populatingLink = new CLink($itemName, 'items.php?form=update&itemid=' . $hostItemsToInventory[$inventoryNo]['itemid']); $populatingLink->setAttribute('title', _s('This field is automatically populated by item "%s".', $itemName)); $populatingItemCell = array(' ← ', $populatingLink); $input->addClass('linked_to_item'); // this will be used for disabling fields via jquery if ($inventory_mode == HOST_INVENTORY_AUTOMATIC) { $input->setAttribute('disabled', 'disabled'); } } else { $populatingItemCell = ''; } $input->addStyle('float: left;'); $populatingItem = new CSpan($populatingItemCell, 'populating_item'); if ($inventory_mode != HOST_INVENTORY_AUTOMATIC) { // those links are visible only in automatic mode $populatingItem->addStyle('display: none'); } $inventoryFormList->addRow($inventoryInfo['title'], array($input, $populatingItem)); }
$macros = array_values($this->data['macros']); if ($readonly && !$macros) { $macrosFormList = new CFormList('macrosFormList'); $macrosFormList->addRow(_('No macros found.')); return $macrosFormList; } if (!$readonly) { include dirname(__FILE__) . '/js/common.macros.js.php'; } $macrosTable = new CTable(SPACE, 'formElementTable'); $macrosTable->setAttribute('id', 'tbl_macros'); $macrosTable->addRow(array(_('Macro'), SPACE, _('Value'), SPACE)); // fields foreach ($macros as $i => $macro) { $text1 = new CTextBox('macros[' . $i . '][macro]', $macro['macro'], 30, $readonly, 64); $text1->addClass('macro'); $text1->setAttribute('placeholder', '{$MACRO}'); $text2 = new CTextBox('macros[' . $i . '][value]', $macro['value'], 40, $readonly, 255); $text2->setAttribute('placeholder', _('value')); $span = new CSpan('⇒'); $span->addStyle('vertical-align:top;'); $deleteButtonCell = null; if (!$readonly) { $deleteButtonCell = array(new CButton('macros_' . $i . '_remove', _('Remove'), null, 'link_menu element-table-remove')); if (isset($macro['globalmacroid'])) { $deleteButtonCell[] = new CVar('macros[' . $i . '][globalmacroid]', $macro['globalmacroid'], 'macros_' . $i . '_id'); } if (isset($macro['hostmacroid'])) { $deleteButtonCell[] = new CVar('macros[' . $i . '][hostmacroid]', $macro['hostmacroid'], 'macros_' . $i . '_id'); } }
<?php /* ** Zabbix ** Copyright (C) 2001-2013 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. **/ $searchForm = new CForm('get', 'search.php'); $searchBox = new CTextBox('search', get_request('search')); $searchBox->setAttribute('autocomplete', 'off'); $searchBox->addClass('search'); $searchForm->addItem($searchBox); $searchBtn = new CSubmit('searchbttn', _('Search'), null, 'input button ui-button ui-widget ui-state-default ui-corner-all'); $searchForm->addItem($searchBtn); return new CDiv($searchForm, 'zbx_search', 'zbx_search');
} if (!str_in_array($condition['conditiontype'], $this->data['allowedConditions'])) { continue; } $label = isset($condition['formulaid']) ? $condition['formulaid'] : num2letter($i); $labelSpan = new CSpan($label, 'label'); $labelSpan->setAttribute('data-conditiontype', $condition['conditiontype']); $labelSpan->setAttribute('data-formulaid', $label); $conditionTable->addRow(array($labelSpan, get_condition_desc($condition['conditiontype'], $condition['operator'], $condition['value']), array(new CButton('remove', _('Remove'), 'javascript: removeCondition(' . $i . ');', 'link_menu'), new CVar('conditions[' . $i . ']', $condition)), new CVar('conditions[' . $i . '][formulaid]', $label)), null, 'conditions_' . $i); $i++; } $formula = new CTextBox('formula', $this->data['action']['filter']['formula'], ZBX_TEXTBOX_STANDARD_SIZE); $formula->attr('id', 'formula'); $formula->attr('placeholder', 'A or (B and C) …'); if ($this->data['action']['filter']['evaltype'] != CONDITION_EVAL_TYPE_EXPRESSION) { $formula->addClass('hidden'); } $calculationTypeComboBox = new CComboBox('evaltype', $this->data['action']['filter']['evaltype'], 'processTypeOfCalculation()'); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_AND_OR, _('And/Or')); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_AND, _('And')); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_OR, _('Or')); $calculationTypeComboBox->addItem(CONDITION_EVAL_TYPE_EXPRESSION, _('Custom expression')); $calculationTypeComboBox->setAttribute('id', 'evaltype'); $conditionFormList->addRow(_('Type of calculation'), array($calculationTypeComboBox, new CSpan('', $this->data['action']['filter']['evaltype'] == CONDITION_EVAL_TYPE_EXPRESSION ? 'hidden' : '', 'conditionLabel'), $formula), false, 'conditionRow'); $conditionFormList->addRow(_('Conditions'), new CDiv($conditionTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append new condition to form list $conditionTypeComboBox = new CComboBox('new_condition[conditiontype]', $this->data['new_condition']['conditiontype'], 'submit()'); foreach ($this->data['allowedConditions'] as $key => $condition) { $this->data['allowedConditions'][$key] = array('name' => condition_type2str($condition), 'type' => $condition); } order_result($this->data['allowedConditions'], 'name');
$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}'); $macro->setAttribute('data-formulaid', $condition['formulaid']); // value $value = new CTextBox('conditions[' . $i . '][value]', $condition['value'], 40, false, 255); $value->setAttribute('placeholder', _('regular expression')); // delete button $deleteButtonCell = array(new CButton('conditions_' . $i . '_remove', _('Remove'), null, 'link_menu element-table-remove')); $row = array($formulaId, $macro, new CSpan(_('matches')), $value, $deleteButtonCell); $conditionTable->addRow($row, 'form_row'); } $addButton = new CButton('macro_add', _('Add'), null, 'link_menu element-table-add'); $buttonColumn = new CCol($addButton); $buttonColumn->setAttribute('colspan', 5); $buttonRow = new CRow(); $buttonRow->setAttribute('id', 'row_new_macro');