public function addTab($id, $header, $body) { $this->headers[$id] = $header; $this->tabs[$id] = new CDiv($body); $this->tabs[$id]->setId(zbx_formatDomId($id)); return $this; }
/** * @param array $options['objectOptions'] an array of parameters to be added to the request URL * * @see jQuery.multiSelect() */ public function __construct(array $options = []) { parent::__construct('div', true); $this->addClass('multiselect'); $this->setId(zbx_formatDomId($options['name'])); // url $url = new CUrl('jsrpc.php'); $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON); $url->setArgument('method', 'multiselect.get'); $url->setArgument('objectName', $options['objectName']); if (!empty($options['objectOptions'])) { foreach ($options['objectOptions'] as $optionName => $optionvalue) { $url->setArgument($optionName, $optionvalue); } } $params = ['url' => $url->getUrl(), 'name' => $options['name'], 'labels' => ['No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')]]; if (array_key_exists('data', $options)) { $params['data'] = zbx_cleanHashes($options['data']); } foreach (['ignored', 'defaultValue', 'disabled', 'selectedLimit', 'addNew'] as $option) { if (array_key_exists($option, $options)) { $params[$option] = $options[$option]; } } if (array_key_exists('popup', $options)) { foreach (['parameters', 'width', 'height'] as $option) { if (array_key_exists($option, $options['popup'])) { $params['popup'][$option] = $options['popup'][$option]; } } } zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ');'); }
public function __construct($label, $for = null) { parent::__construct('label', true, $label); if ($for !== null) { $this->setAttribute('for', zbx_formatDomId($for)); } }
public function __construct($id = null) { parent::__construct(); $this->addClass('table-forms'); if ($id) { $this->setId(zbx_formatDomId($id)); } }
public function __construct($id, $class = null, $editable = true) { $this->editable = $editable; $this->formList = new CList(null, 'formlist'); parent::__construct(); $this->attr('id', zbx_formatDomId($id)); $this->attr('class', $class); }
public function __construct($name, $value, $insert_color_picker = true) { parent::__construct([(new CColorCell('lbl_' . $name, $value))->setTitle('#' . $value)->onClick('javascript: show_color_picker("' . zbx_formatDomId($name) . '")'), (new CTextBox($name, $value))->setWidth(ZBX_TEXTAREA_COLOR_WIDTH)->setAttribute('maxlength', 6)->onChange('set_color_by_name("' . zbx_formatDomId($name) . '", this.value)')]); $this->addClass(ZBX_STYLE_INPUT_COLOR_PICKER); if ($insert_color_picker) { insert_show_color_picker_javascript(); } }
public function __construct($name = 'button', $caption = '') { parent::__construct('button', true, $caption); $this->setAttribute('type', 'button'); if ($name !== null) { $this->setId(zbx_formatDomId($name)); $this->setAttribute('name', $name); } }
public function __construct($name, $value, $action = null) { parent::__construct(SPACE . SPACE . SPACE, 'pointer'); $this->setName($name); $this->attr('id', zbx_formatDomId($name)); $this->attr('title', '#' . $value); $this->attr('style', 'display: inline; width: 10px; height: 10px; text-decoration: none; border: 1px solid black; background-color: #' . $value); $this->attr('onclick', $action); }
public function __construct($name = null, $color) { parent::__construct(); if ($name !== null) { $this->setName($name); $this->setId(zbx_formatDomId($name)); } $this->setAttribute('style', 'background: #' . $color); }
public function __construct($label, $for = null, $id = null) { parent::__construct('label', 'yes', $label); if (!is_null($id)) { $this->attr('id', zbx_formatDomId($id)); } if (!is_null($for)) { $this->attr('for', zbx_formatDomId($for)); } }
public function __construct($type = 'text', $name = 'textbox', $value = '') { parent::__construct('input'); $this->setType($type); // if id is not passed, it will be the same as element name $this->setId(zbx_formatDomId($name)); $this->setAttribute('name', $name); $this->setAttribute('value', $value); return $this; }
/** * @param string $options['id'] * @param string $options['name'] * @param int $options['value'] */ public function __construct(array $options = array()) { parent::__construct('div', 'yes'); $this->attr('id', isset($options['id']) ? $options['id'] : zbx_formatDomId($options['name'])); $this->addClass('jqueryinputset control-severity'); if (!isset($options['value'])) { $options['value'] = TRIGGER_SEVERITY_NOT_CLASSIFIED; } $items = array(); $jsIds = ''; $jsLabels = ''; foreach (getSeverityCaption() as $severity => $caption) { $items[] = new CRadioButton($options['name'], $severity, null, $options['name'] . '_' . $severity, $options['value'] == $severity); $css = getSeverityStyle($severity); $label = new CLabel($caption, $options['name'] . '_' . $severity, $options['name'] . '_label_' . $severity); $label->attr('data-severity', $severity); $label->attr('data-severity-style', $css); if ($options['value'] == $severity) { $label->attr('aria-pressed', 'true'); $label->addClass($css); } else { $label->attr('aria-pressed', 'false'); } $items[] = $label; $jsIds .= ', #' . $options['name'] . '_' . $severity; $jsLabels .= ', #' . $options['name'] . '_label_' . $severity; } if ($jsIds) { $jsIds = substr($jsIds, 2); $jsLabels = substr($jsLabels, 2); } $this->addItem($items); insert_js(' jQuery("' . $jsLabels . '").mouseenter(function() { jQuery("' . $jsLabels . '").each(function() { var obj = jQuery(this); if (obj.attr("aria-pressed") == "false") { obj.removeClass("ui-state-hover " + obj.data("severityStyle")); } }); var obj = jQuery(this); obj.addClass(obj.data("severityStyle")); }) .mouseleave(function() { jQuery("#' . $this->getAttribute('id') . ' [aria-pressed=\\"true\\"]").trigger("mouseenter"); }); jQuery("' . $jsIds . '").change(function() { jQuery("#' . $this->getAttribute('id') . ' [aria-pressed=\\"true\\"]").trigger("mouseenter"); });', true); }
public function __construct($name, $value) { parent::__construct(); $txt = new CTextBox($name, $value); $txt->addStyle('width: 6em;'); $txt->attr('maxlength', 6); $txt->attr('id', zbx_formatDomId($name)); $txt->addAction('onchange', 'set_color_by_name("' . $name . '", this.value)'); $txt->addStyle('style', 'margin-top: 0px; margin-bottom: 0px;'); $lbl = new CColorCell('lbl_' . $name, $value, 'javascript: show_color_picker("' . $name . '")'); $this->addItem(array($txt, $lbl)); insert_show_color_picker_javascript(); }
public function __construct($name = 'combobox', $value = null, $action = null, array $items = []) { parent::__construct('select', true); $this->setId(zbx_formatDomId($name)); $this->setAttribute('name', $name); $this->value = $value; if ($action !== null) { $this->onChange($action); } $this->addItems($items); // Prevent Firefox remembering selected option on page refresh. $this->setAttribute('autocomplete', 'off'); }
public function __construct($name = 'combobox', $value = null, $action = null, $items = null) { parent::__construct('select', 'yes'); $this->tag_end = ''; $this->attr('id', zbx_formatDomId($name)); $this->attr('name', $name); $this->attr('class', 'input select'); $this->attr('size', 1); $this->value = $value; $this->attr('onchange', $action); if (is_array($items)) { $this->addItems($items); } }
public function __construct($items = null, $class = null, $id = null) { parent::__construct('div', 'yes'); $this->attr('class', $class); if (!empty($id)) { $this->attr('id', zbx_formatDomId($id)); } $this->addItem($items); $this->tag_body_start = ''; $this->tag_start = ''; $this->tag_end = ''; $this->tag_body_start = ''; $this->tag_body_end = ''; return $this; }
/** * Init textarea. * * @param string $name * @param string $value * @param array $options * @param int $options['rows'] * @param int $options['maxlength'] * @param boolean $options['readonly'] */ public function __construct($name = 'textarea', $value = '', $options = []) { parent::__construct('textarea', true); $this->setId(zbx_formatDomId($name)); $this->setAttribute('name', $name); $this->setAttribute('rows', !empty($options['rows']) ? $options['rows'] : ZBX_TEXTAREA_STANDARD_ROWS); if (isset($options['readonly'])) { $this->setReadonly($options['readonly']); } $this->addItem($value); // set maxlength if (!empty($options['maxlength'])) { $this->setMaxlength($options['maxlength']); } }
public function addValue($name, $value, $checked = null) { $this->count++; $id = str_replace(array('[', ']'), array('_'), $this->name) . '_' . $this->count; $radio = new CInput('radio', $this->name, $value); $radio->attr('id', zbx_formatDomId($id)); if (strcmp($value, $this->value) == 0 || !is_null($checked) || $checked) { $radio->attr('checked', 'checked'); } $label = new CLabel($name, $id); $outerDiv = new CDiv(array($radio, $label)); if ($this->orientation == self::ORIENTATION_HORIZONTAL) { $outerDiv->addClass('inlineblock'); } parent::addItem($outerDiv); }
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())->addClass('tweenBoxTable')->setAttribute('name', $this->name)->setId('id', zbx_formatDomId($this->name))->setCellSpacing(0)->setCellPadding(0); if (!is_null($caption_l) || !is_null($caption_r)) { $grp_tab->addRow([$caption_l, '', $caption_r]); } $add_btn = (new CButton('add', (new CSpan())->addClass('arrow-left')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('moveListBoxSelectedItem("' . $this->varname . '", "' . $this->id_r . '", "' . $this->id_l . '", "add");'); $rmv_btn = (new CButton('remove', (new CSpan())->addClass('arrow-right')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('moveListBoxSelectedItem("' . $this->varname . '", "' . $this->id_l . '", "' . $this->id_r . '", "rmv");'); $grp_tab->addRow([$this->lbox, (new CCol([$add_btn, BR(), $rmv_btn]))->addClass(ZBX_STYLE_CENTER), $this->rbox]); return $grp_tab; }
/** * @param array $options['objectOptions'] an array of parameters to be added to the request URL * * @see jQuery.multiSelect() */ public function __construct(array $options = array()) { parent::__construct('div', 'yes'); $this->addClass('multiselect'); $this->attr('id', zbx_formatDomId($options['name'])); // url $url = new Curl('jsrpc.php'); $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON); $url->setArgument('method', 'multiselect.get'); $url->setArgument('objectName', $options['objectName']); if (!empty($options['objectOptions'])) { foreach ($options['objectOptions'] as $optionName => $optionvalue) { $url->setArgument($optionName, $optionvalue); } } $params = array('id' => $this->getAttribute('id'), 'url' => $url->getUrl(), 'name' => $options['name'], 'labels' => array('No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')), 'data' => empty($options['data']) ? array() : zbx_cleanHashes($options['data']), 'ignored' => isset($options['ignored']) ? $options['ignored'] : null, 'defaultValue' => isset($options['defaultValue']) ? $options['defaultValue'] : null, 'disabled' => isset($options['disabled']) ? $options['disabled'] : false, 'selectedLimit' => isset($options['selectedLimit']) ? $options['selectedLimit'] : null, 'addNew' => isset($options['addNew']) ? $options['addNew'] : false, 'popup' => array('parameters' => isset($options['popup']['parameters']) ? $options['popup']['parameters'] : null, 'width' => isset($options['popup']['width']) ? $options['popup']['width'] : null, 'height' => isset($options['popup']['height']) ? $options['popup']['height'] : null, 'buttonClass' => isset($options['popup']['buttonClass']) ? $options['popup']['buttonClass'] : null)); zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ')'); }
public function __construct($type = 'text', $name = 'textbox', $value = '', $class = null, $id = null) { parent::__construct('input', 'no'); $this->setType($type); // if id is not passed, it will be the same as element name if (is_null($id)) { $this->attr('id', zbx_formatDomId($name)); } else { $this->attr('id', zbx_formatDomId($id)); } $this->attr('name', $name); $this->attr('value', $value); $class = !is_null($class) ? $class : $type; if ($class == 'button' || $class == 'submit') { $class .= ' shadow ui-corner-all'; } $this->addClass('input ' . $class); return $this; }
/** * @param string $options['name'] * @param int $options['value'] (optional) Default: TRIGGER_SEVERITY_NOT_CLASSIFIED * @param bool $options['all'] (optional) */ public function __construct(array $options = []) { parent::__construct(); $id = zbx_formatDomId($options['name']); $this->addClass(ZBX_STYLE_RADIO_SEGMENTED); $this->setId($id); if (!array_key_exists('value', $options)) { $options['value'] = TRIGGER_SEVERITY_NOT_CLASSIFIED; } $severity_from = array_key_exists('all', $options) && $options['all'] ? -1 : TRIGGER_SEVERITY_NOT_CLASSIFIED; $config = select_config(); for ($severity = $severity_from; $severity < TRIGGER_SEVERITY_COUNT; $severity++) { $name = $severity == -1 ? _('all') : getSeverityName($severity, $config); $class = $severity == -1 ? null : getSeverityStyle($severity); $radio = (new CInput('radio', $options['name'], $severity))->setId(zbx_formatDomId($options['name'] . '_' . $severity)); if ($severity === $options['value']) { $radio->setAttribute('checked', 'checked'); } parent::addItem((new CListItem([$radio, new CLabel($name, $options['name'] . '_' . $severity)]))->addClass($class)); } }
/** * Init textarea. * * @param string $name * @param string $value * @param array $options * @param int $options['rows'] * @param int $options['width'] * @param int $options['maxlength'] * @param boolean $options['readonly'] */ public function __construct($name = 'textarea', $value = '', $options = array()) { parent::__construct('textarea', 'yes'); $this->attr('class', 'input'); $this->attr('id', zbx_formatDomId($name)); $this->attr('name', $name); $this->attr('rows', !empty($options['rows']) ? $options['rows'] : ZBX_TEXTAREA_STANDARD_ROWS); $this->setReadonly(!empty($options['readonly'])); $this->addItem($value); // set width if (empty($options['width']) || $options['width'] == ZBX_TEXTAREA_STANDARD_WIDTH) { $this->addClass('textarea_standard'); } elseif ($options['width'] == ZBX_TEXTAREA_BIG_WIDTH) { $this->addClass('textarea_big'); } else { $this->attr('style', 'width: ' . $options['width'] . 'px;'); } // set maxlength if (!empty($options['maxlength'])) { $this->setMaxlength($options['maxlength']); } }
public function toString($destroy = true) { if ($this->modern) { $this->addClass(ZBX_STYLE_RADIO_SEGMENTED); } else { $this->addClass($this->orientation == self::ORIENTATION_HORIZONTAL ? ZBX_STYLE_LIST_HOR_CHECK_RADIO : ZBX_STYLE_LIST_CHECK_RADIO); } foreach ($this->values as $key => $value) { if ($value['id'] === null) { $value['id'] = zbx_formatDomId($this->name) . '_' . $key; } $radio = (new CInput('radio', $this->name, $value['value']))->setEnabled($this->enabled)->onChange($value['on_change'])->setId($value['id']); if ($value['value'] === $this->value) { $radio->setAttribute('checked', 'checked'); } if ($this->modern) { parent::addItem([$radio, new CLabel($value['name'], $value['id'])]); } else { parent::addItem(new CLabel([$radio, $value['name']], $value['id'])); } } return parent::toString($destroy); }
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; }
public function addTab($id, $header, $body) { $this->headers[$id] = $header; $this->tabs[$id] = new CDiv($body); $this->tabs[$id]->attr('id', zbx_formatDomId($id)); }
public function addRow($item1, $item2 = null, $class = null, $id = null) { if (is_object($item1) && zbx_strtolower(get_class($item1)) == 'crow') { } elseif (is_object($item1) && zbx_strtolower(get_class($item1)) == 'ctable') { $td = new CCol($item1, 'form_row_c'); $td->setColSpan(2); $item1 = new CRow($td); } else { if (is_string($item1)) { $item1 = nbsp($item1); } if (empty($item1)) { $item1 = SPACE; } if (empty($item2)) { $item2 = SPACE; } $item1 = new CRow(array(new CCol($item1, 'form_row_l'), new CCol($item2, 'form_row_r')), $class); } if (!is_null($id)) { $item1->attr('id', zbx_formatDomId($id)); } array_push($this->center_items, $item1); return $item1; }
// append proxy to form list $proxyComboBox = new CComboBox('proxy_hostid', $this->data['drule']['proxy_hostid']); $proxyComboBox->addItem(0, _('No proxy')); foreach ($this->data['proxies'] as $proxy) { $proxyComboBox->addItem($proxy['proxyid'], $proxy['host']); } $discoveryFormList->addRow(_('Discovery by proxy'), $proxyComboBox); $discoveryFormList->addRow(_('IP range'), new CTextBox('iprange', $this->data['drule']['iprange'], ZBX_TEXTBOX_SMALL_SIZE)); $discoveryFormList->addRow(_('Delay (in sec)'), new CNumericBox('delay', $this->data['drule']['delay'], 8)); // append checks to form list $checkTable = new CTable(null, 'formElementTable'); $checkTable->addRow(new CRow(new CCol(new CButton('newCheck', _('New'), null, 'link_menu'), null, 2), null, 'dcheckListFooter')); $discoveryFormList->addRow(_('Checks'), new CDiv($checkTable, 'objectgroup inlineblock border_dotted ui-corner-all', 'dcheckList')); // append uniqueness criteria to form list $uniquenessCriteriaRadio = new CRadioButtonList('uniqueness_criteria', $this->data['drule']['uniqueness_criteria']); $uniquenessCriteriaRadio->addValue(SPACE . _('IP address'), -1, true, zbx_formatDomId('uniqueness_criteria_ip')); $discoveryFormList->addRow(_('Device uniqueness criteria'), new CDiv($uniquenessCriteriaRadio, 'objectgroup inlineblock border_dotted ui-corner-all', 'uniqList')); // append status to form list $status = empty($this->data['druleid']) && empty($this->data['form_refresh']) ? true : $this->data['drule']['status'] == DRULE_STATUS_ACTIVE; $discoveryFormList->addRow(_('Enabled'), new CCheckBox('status', $status, null, 1)); // append tabs to form $discoveryTabs = new CTabView(); $discoveryTabs->addTab('druleTab', _('Discovery rule'), $discoveryFormList); $discoveryForm->addItem($discoveryTabs); // append buttons to form $deleteButton = new CButtonDelete(_('Delete discovery rule?'), url_param('form') . url_param('druleid')); if (empty($this->data['druleid'])) { $deleteButton->setAttribute('disabled', 'disabled'); } $discoveryForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel()))); $discoveryWidget->addItem($discoveryForm);
$widget = (new CWidget())->setTitle(_('Discovery rules')); // create form $discoveryForm = (new CForm())->setName('discoveryForm')->addVar('form', $this->data['form']); if (!empty($this->data['druleid'])) { $discoveryForm->addVar('druleid', $this->data['druleid']); } // create form list $discoveryFormList = (new CFormList())->addRow(_('Name'), (new CTextBox('name', $this->data['drule']['name']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus')); // append proxy to form list $proxyComboBox = (new CComboBox('proxy_hostid', $this->data['drule']['proxy_hostid']))->addItem(0, _('No proxy')); foreach ($this->data['proxies'] as $proxy) { $proxyComboBox->addItem($proxy['proxyid'], $proxy['host']); } $discoveryFormList->addRow(_('Discovery by proxy'), $proxyComboBox)->addRow(_('IP range'), (new CTextArea('iprange', $this->data['drule']['iprange'], ['maxlength' => 2048]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Delay (in sec)'), (new CNumericBox('delay', $this->data['drule']['delay'], 6))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH)); $discoveryFormList->addRow(_('Checks'), (new CDiv((new CTable())->setAttribute('style', 'width: 100%;')->setFooter((new CRow((new CCol((new CButton('newCheck', _('New')))->addClass(ZBX_STYLE_BTN_LINK)))->setColSpan(2)))->setId('dcheckListFooter'))))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')->setId('dcheckList')); // append uniqueness criteria to form list $discoveryFormList->addRow(_('Device uniqueness criteria'), (new CDiv((new CRadioButtonList('uniqueness_criteria', (int) $this->data['drule']['uniqueness_criteria']))->makeVertical()->addValue(_('IP address'), -1, zbx_formatDomId('uniqueness_criteria_ip'))))->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)); // append status to form list $status = empty($this->data['druleid']) && empty($this->data['form_refresh']) ? true : $this->data['drule']['status'] == DRULE_STATUS_ACTIVE; $discoveryFormList->addRow(_('Enabled'), (new CCheckBox('status'))->setChecked($status)); // append tabs to form $discoveryTabs = (new CTabView())->addTab('druleTab', _('Discovery rule'), $discoveryFormList); // append buttons to form if (isset($this->data['druleid'])) { $discoveryTabs->setFooter(makeFormFooter(new CSubmit('update', _('Update')), [new CButton('clone', _('Clone')), new CButtonDelete(_('Delete discovery rule?'), url_param('form') . url_param('druleid')), new CButtonCancel()])); } else { $discoveryTabs->setFooter(makeFormFooter(new CSubmit('add', _('Add')), [new CButtonCancel()])); } $discoveryForm->addItem($discoveryTabs); $widget->addItem($discoveryForm); return $widget;