/** * Decodes JSON sting. * * @static * * @param string $data * @param bool $asArray get result as array instead of object * * @return mixed */ public static function decodeJson($data, $asArray = true) { if (self::$json === null) { self::$json = new CJson(); } return self::$json->decode($data, $asArray); }
/** * Encodes the data as a JSON string to be used in JavaScript code. * * @static * * @param mixed $data * * @param bool $forceObject force all arrays to objects * * @return mixed */ public static function encodeJson($data, $forceObject = false) { if (self::$json === null) { self::$json = new CJSON(); } return self::$json->encode($data, array(), $forceObject); }
/** * @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($name = 'editablecombobox', $value = null, $size = null, $action = null) { insert_javascript_for_editable_combobox(); parent::__construct($name, $value, $action); parent::addAction('onfocus', 'CEditableComboBoxInit(this);'); $width = $size == ZBX_TEXTBOX_STANDARD_SIZE ? ZBX_TEXTAREA_STANDARD_WIDTH : null; parent::addAction('onchange', 'CEditableComboBoxOnChange(this, ' . CJs::encodeJson($size) . ', ' . CJs::encodeJson($width) . ');'); // prevent Firefox remembering selected option on page refresh $this->setAttribute('autocomplete', 'off'); }
protected function doAction() { foreach (CJs::decodeJson($this->getInput('grid')) as $col => $column) { foreach ($column as $row => $widgetName) { $widgetName = str_replace('_widget', '', $widgetName); CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT); CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT); } } $data = ['main_block' => '']; $response = new CControllerResponseData($data); $this->setResponse($response); }
protected function doAction() { $widget = $this->getInput('widget'); $data = ['main_block' => '']; // refresh rate if ($this->hasInput('refreshrate')) { $refreshrate = $this->getInput('refreshrate'); CProfile::update('web.dashboard.widget.' . $widget . '.rf_rate', $refreshrate, PROFILE_TYPE_INT); $data['main_block'] = 'PMasters["dashboard"].dolls["' . $widget . '"].frequency(' . CJs::encodeJson($refreshrate) . ');' . "\n" . 'PMasters["dashboard"].dolls["' . $widget . '"].restartDoll();'; } // widget state if ($this->hasInput('state')) { CProfile::update('web.dashboard.widget.' . $widget . '.state', $this->getInput('state'), PROFILE_TYPE_INT); } $this->setResponse(new CControllerResponseData($data)); }
/** * @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) . ')'); }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid']; $resourceid = !empty($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid']; $containerid = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid']; $graphDims = getGraphDims(); $graphDims['graphHeight'] = $this->screenitem['height']; $graphDims['width'] = $this->screenitem['width']; // get time control $timeControlData = array('id' => $this->getDataId(), 'containerid' => $containerid, 'objDims' => $graphDims, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); // host feature if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) { $newitemid = get_same_item_for_host($resourceid, $this->hostid); $resourceid = !empty($newitemid) ? $newitemid : ''; } if ($this->mode == SCREEN_MODE_PREVIEW && !empty($resourceid)) { $this->action = 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams(); } if ($resourceid && $this->mode != SCREEN_MODE_EDIT) { if ($this->mode == SCREEN_MODE_PREVIEW) { $timeControlData['loadSBox'] = 1; } } $timeControlData['src'] = $resourceid ? 'chart.php?itemids[]=' . $resourceid . '&' . $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] : 'chart3.php?'; $timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']; $timeControlData['src'] .= $this->getProfileUrlParams(); // output if ($this->mode == SCREEN_MODE_JS) { return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ')'; } else { if ($this->mode == SCREEN_MODE_SLIDESHOW) { insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');'); } else { zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');'); } if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW) { $item = new CDiv(); } elseif ($this->mode == SCREEN_MODE_PREVIEW) { $item = new CLink(null, 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']); } $item->setAttribute('id', $containerid); return $this->getOutput($item); } }
public function toString($destroy = true) { $url = $this->url; if ($this->use_sid) { if (array_key_exists('zbx_sessionid', $_COOKIE)) { $url .= strpos($url, '&') !== false || strpos($url, '?') !== false ? '&' : '?'; $url .= 'sid=' . substr($_COOKIE['zbx_sessionid'], 16, 16); } $confirm_script = $this->confirm_message !== '' ? 'Confirm(' . CJs::encodeJson($this->confirm_message) . ') && ' : ''; $this->onClick("javascript: return " . $confirm_script . "redirect('" . $url . "', 'post', 'sid', true)"); $this->setAttribute('href', 'javascript:void(0)'); } else { $this->setAttribute('href', $url); if ($this->confirm_message !== '') { $this->onClick('javascript: return Confirm(' . CJs::encodeJson($this->confirm_message) . ');'); } } return parent::toString($destroy); }
public function get() { $widget = array(); if (!empty($this->pageHeaders)) { $widget[] = $this->createPageHeader(); } if (!empty($this->headers)) { $widget[] = $this->createHeader(); } if (!empty($this->flicker)) { $flicker_domid = 'flicker_' . $this->bodyId; $flicker_tab = new CTable(); $flicker_tab->setAttribute('width', '100%'); $flicker_tab->setCellPadding(0); $flicker_tab->setCellSpacing(0); $div = new CDiv($this->flicker, null, $flicker_domid); if (!$this->flicker_state) { $div->setAttribute('style', 'display: none;'); } $icon_l = new CDiv(SPACE . SPACE, $this->flicker_state ? 'dbl_arrow_up' : 'dbl_arrow_down', 'flicker_icon_l'); $icon_l->setAttribute('title', _('Maximize') . '/' . _('Minimize')); $icon_r = new CDiv(SPACE . SPACE, $this->flicker_state ? 'dbl_arrow_up' : 'dbl_arrow_down', 'flicker_icon_r'); $icon_r->setAttribute('title', _('Maximize') . '/' . _('Minimize')); $icons_row = new CTable(null, 'textwhite'); $flickerTitleWhenVisible = _('Hide filter'); $flickerTitleWhenHidden = _('Show filter'); $flickerTitle = $this->flicker_state ? $flickerTitleWhenVisible : $flickerTitleWhenHidden; $icons_row->addRow(array($icon_l, new CSpan(SPACE . $flickerTitle . SPACE, null, 'flicker_title'), $icon_r)); $thin_tab = $this->createFlicker($icons_row); $thin_tab->attr('id', 'filter_icon'); $thin_tab->addAction('onclick', "javascript: changeFlickerState(" . "'" . $flicker_domid . "', " . CJs::encodeJson($flickerTitleWhenVisible) . ", " . CJs::encodeJson($flickerTitleWhenHidden) . ");"); $flicker_tab->addRow($thin_tab, 'textcolorstyles pointer'); $flicker_tab->addRow($div); $widget[] = $flicker_tab; } $div = new CDiv($this->body, 'w'); $div->setAttribute('id', $this->bodyId); $widget[] = $div; return new CDiv($widget, $this->getRootClass()); }
/** * Encodes the data as a JSON string with HTML entities escaped. * * @static * * @param array $data * * @return string */ public static function serialize(array $data) { return self::encode(CJs::encodeJson($data)); }
function prepareSubfilterOutput($data, $subfilter, $subfilterName) { order_result($data, 'name'); $output = array(); foreach ($data as $id => $element) { $element['name'] = nbsp(CHtml::encode($element['name'])); // is activated if (str_in_array($id, $subfilter)) { $span = new CSpan($element['name'] . SPACE . '(' . $element['count'] . ')', 'subfilter_enabled'); $span->onClick(CHtml::encode('javascript: create_var("zbx_filter", "subfilter_set", "1", false);' . 'create_var("zbx_filter", ' . CJs::encodeJson($subfilterName . '[' . $id . ']') . ', null, true);')); $output[] = $span; } else { // subfilter has 0 items if ($element['count'] == 0) { $span = new CSpan($element['name'] . SPACE . '(' . $element['count'] . ')', 'subfilter_inactive'); $output[] = $span; } else { // this level has no active subfilters $nspan = $subfilter ? new CSpan(SPACE . '(+' . $element['count'] . ')', 'subfilter_active') : new CSpan(SPACE . '(' . $element['count'] . ')', 'subfilter_active'); $span = new CSpan($element['name'], 'subfilter_disabled'); $span->onClick(CHtml::encode('javascript: create_var("zbx_filter", "subfilter_set", "1", false);' . 'create_var("zbx_filter", ' . CJs::encodeJson($subfilterName . '[' . $id . ']') . ', ' . CJs::encodeJson($id) . ', ' . 'true' . ');')); $output[] = $span; $output[] = $nspan; } } $output[] = ', '; } array_pop($output); return $output; }
} } $errorImg = makeErrorIcon($errors); } // templated trigger if ($this->data['limited']) { // make all links inside inactive foreach ($e['list'] as &$obj) { if (gettype($obj) == 'object' && get_class($obj) == 'CSpan' && $obj->getAttribute('class') == ZBX_STYLE_LINK_ACTION) { $obj->removeAttribute('class'); $obj->onClick(null); } } unset($obj); } $expressionTable->addRow(new CRow([!$this->data['limited'] ? (new CCheckBox('expr_target_single', $e['id']))->setChecked($i == 0)->onClick('check_target(this);') : null, $e['list'], !$this->data['limited'] ? (new CCol((new CButton(null, _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)->onClick('javascript:' . ' if (confirm(' . CJs::encodeJson(_('Delete expression?')) . ')) {' . ' delete_expression("' . $e['id'] . '");' . ' document.forms["' . $triggersForm->getName() . '"].submit();' . ' }')))->addClass(ZBX_STYLE_NOWRAP) : null, $errorImg])); } } else { $allowedTesting = false; $this->data['outline'] = ''; } $testButton = (new CButton('test_expression', _('Test')))->onClick('openWinCentered("tr_testexpr.php?expression=" + encodeURIComponent(this.form.elements["expression"].value),' . '"ExpressionTest", 950, 650, "titlebar=no, resizable=yes, scrollbars=yes"); return false;')->addClass(ZBX_STYLE_BTN_LINK); if (!$allowedTesting) { $testButton->setAttribute('disabled', 'disabled'); } if (empty($this->data['outline'])) { $testButton->setAttribute('disabled', 'disabled'); } $wrapOutline = new CSpan([$this->data['outline']]); $triggersFormList->addRow(null, [$wrapOutline, BR(), BR(), (new CDiv([$expressionTable, $testButton]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')]); $inputMethodToggle = (new CButton(null, _('Close expression constructor')))->addClass(ZBX_STYLE_BTN_LINK)->onClick('javascript: ' . 'document.getElementById("toggle_input_method").value=1;' . 'document.getElementById("input_method").value=' . IM_ESTABLISHED . ';' . 'document.forms["' . $triggersForm->getName() . '"].submit();');
$buttonCol = new CCol(new CButton('addIPMIInterface', _('Add'), null, 'link_menu'), 'interface-add-control'); $col = new CCol($helpTextWhenDragInterfaceIPMI); $col->setAttribute('colspan', 6); $buttonRow = new CRow(array($buttonCol, $col)); $buttonRow->setAttribute('id', 'IPMIIterfacesFooter'); $ifTab->addRow($buttonRow); $hostList->addRow(_('IPMI interfaces'), new CDiv($ifTab, 'border_dotted objectgroup inlineblock interface-group'), false, null, 'interface-row'); } else { $interfaces = array(); $existingInterfaceTypes = array(); foreach ($dbHost['interfaces'] as $interface) { $interface['locked'] = true; $existingInterfaceTypes[$interface['type']] = true; $interfaces[$interface['interfaceid']] = $interface; } zbx_add_post_js('hostInterfacesManager.add(' . CJs::encodeJson($interfaces) . ');'); zbx_add_post_js('hostInterfacesManager.disable()'); // table for agent interfaces with footer $ifTab = new CTable(null, 'formElementTable'); $ifTab->setAttribute('id', 'agentInterfaces'); $ifTab->setAttribute('data-type', 'agent'); // header $ifTab->addRow(array(new CCol(SPACE, 'interface-drag-control'), new CCol(_('IP address'), 'interface-ip'), new CCol(_('DNS name'), 'interface-dns'), new CCol(_('Connect to'), 'interface-connect-to'), new CCol(_('Port'), 'interface-port'), new CCol(_('Default'), 'interface-default'), new CCol(SPACE, 'interface-control'))); $row = new CRow(null, null, 'agentIterfacesFooter'); if (!isset($existingInterfaceTypes[INTERFACE_TYPE_AGENT])) { $row->addItem(new CCol(null, 'interface-drag-control')); $row->addItem(new CCol(_('No agent interfaces found.'), null, 5)); } $ifTab->addRow($row); $hostList->addRow(_('Agent interfaces'), new CDiv($ifTab, 'border_dotted objectgroup interface-group'), false, null, 'interface-row interface-row-first'); // table for SNMP interfaces with footer
if (isset($this->data['change_bind_password']) || zbx_empty($this->data['config']['ldap_bind_password'])) { $authenticationForm->addVar('change_bind_password', 1); $authenticationFormList->addRow(_('Bind password'), (new CPassBox('ldap_bind_password'))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); } else { $authenticationFormList->addRow(_('Bind password'), (new CSubmit('change_bind_password', _('Change password')))->addClass(ZBX_STYLE_BTN_GREY)); } $authenticationFormList->addRow(_('Test authentication'), ' [' . _('must be a valid LDAP user') . ']'); $authenticationFormList->addRow(_('Login'), $userComboBox); $authenticationFormList->addRow(_('User password'), (new CPassBox('user_password'))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)); } // append form list to tab $authenticationTab = new CTabView(); $authenticationTab->addTab('authenticationTab', $this->data['title'], $authenticationFormList); // create save button $saveButton = new CSubmit('update', _('Update')); if ($this->data['is_authentication_type_changed']) { $saveButton->onClick('javascript: if (confirm(' . CJs::encodeJson(_('Switching authentication method will reset all except this session! Continue?')) . ')) {' . 'jQuery("#authenticationForm").submit(); return true; } else { return false; }'); } elseif ($this->data['config']['authentication_type'] != ZBX_AUTH_LDAP) { $saveButton->setAttribute('disabled', 'true'); } // append buttons to form if ($this->data['config']['authentication_type'] == ZBX_AUTH_LDAP) { $authenticationTab->setFooter(makeFormFooter($saveButton, [new CSubmit('test', _('Test'))])); } else { $authenticationTab->setFooter(makeFormFooter($saveButton)); } // append tab to form $authenticationForm->addItem($authenticationTab); // append form to widget $widget->addItem($authenticationForm); return $widget;
macroInput = $(macroInput); macroInput.val(macroInput.val().toUpperCase()); conditions.push({ id: macroInput.data('formulaid'), type: macroInput.val() }); }); $('#expression').html(getConditionFormula(conditions, +$('#evaltype').val())); } $('#conditions') .dynamicRows({ template: '#condition-row', counter: <?php echo CJs::encodeJson($counter); ?> , dataCallback: function(data) { data.formulaId = num2letter(data.rowNum); return data; } }) .bind('tableupdate.dynamicRows', function(event, options) { $('#conditionRow').toggle($(options.row, $(this)).length > 1); }) .bind('rowremove.dynamicRows', function() { updateExpression(); }) .on('change', '.macro', function() {
** 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. **/ 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'));
} }); } jQuery.when(jqxhr).done(function() { jQuery('#add_new_dcheck').prop('disabled', false); if (validationErrors.length) { showModalWindow( t(<?php echo CJs::encodeJson(_('Discovery check error')); ?> ), validationErrors.join('\n'), [{text: t(<?php echo CJs::encodeJson(_('Close')); ?> ), click: function() { jQuery(this).dialog('destroy'); }}] ); } else { dCheck.name = jQuery('#type :selected').text(); if (typeof dCheck.ports !== 'undefined' && dCheck.ports != discoveryCheckDefaultPort(dCheck.type)) { dCheck.name += ' (' + dCheck.ports + ')'; } if (dCheck.key_) { dCheck.name += ' "' + dCheck.key_ + '"'; }
handle: 'span.ui-icon-arrowthick-2-n-s', revert: 'invalid', stop: function(event, ui) { var hostInterfaceId = jQuery(this).data('interfaceid'); resetMainInterfaces(); resetUseipInterface(hostInterfaceId) } }); } function addNotDraggableIcon(domElement) { domElement.children().first().append('<span class="ui-icon ui-icon-arrowthick-2-n-s state-disabled"></span>'); jQuery('.ui-icon', domElement).hover( function (event) { jQuery('<div>' + <?php echo CJs::encodeJson(_('Interface is used by items that require this type of the interface.')); ?> + '</div>') .css({position: 'absolute', opacity: 1, padding: '2px'}) .addClass('ui-state-highlight') .appendTo(event.target.parentNode); }, function (event) { jQuery(event.target).next().remove(); } ) } function getDomElementsAttrsForInterface(hostInterface) { var attrs = { disabled: '',
$icon = (new CButton(null))->addClass(ZBX_STYLE_BTN_WIDGET_ACTION)->setTitle(_('Action'))->setMenuPopup(CMenuPopupHelper::getRefresh($widgetid, $rate)); $dashboardGrid[$col][$row] = (new CCollapsibleUiWidget($widgetid, (new CDiv())->addClass('preloader')))->setExpanded($expanded)->setHeader($widget['header'], [$icon], true, 'zabbix.php?action=dashboard.widget')->setFooter((new CList())->setId($widgetid . '_footer')); $widgetRefreshParams[$widgetid] = ['frequency' => $rate, 'url' => 'zabbix.php?action=' . $widget['action'], 'counter' => 0, 'darken' => 0, 'params' => ['widgetRefresh' => $widgetid]]; } // sort dashboard grid foreach ($dashboardGrid as $key => $val) { ksort($dashboardGrid[$key]); } $dashboardRow = (new CDiv([(new CDiv($dashboardGrid[0]))->addClass('cell'), (new CDiv($dashboardGrid[1]))->addClass('cell'), (new CDiv($dashboardGrid[2]))->addClass('cell')]))->addClass('row'); $dashboardTable = (new CDiv($dashboardRow))->addClass('table')->addClass('widget-placeholder'); $dashboard->addItem($dashboardTable)->show(); /* * Javascript */ // start refresh process $this->addPostJS('initPMaster("dashboard", ' . CJs::encodeJson($widgetRefreshParams) . ');'); // activating blinking $this->addPostJS('jqBlink.blink();'); ?> <script type="text/javascript"> /** * @see init.js add.popup event */ function addPopupValues(list) { var favourites = {graphid: 1, itemid: 1, screenid: 1, slideshowid: 1, sysmapid: 1}; if (isset(list.object, favourites)) { var favouriteIds = []; for (var i = 0; i < list.values.length; i++) {
$dashconf['severity'] = zbx_empty($severity) ? null : explode(';', $severity); $dashconf['severity'] = zbx_toHash($dashconf['severity']); $config = select_config(); $dashconf['extAck'] = $config['event_ack_enable'] ? CProfile::get('web.dashconf.events.extAck', 0) : 0; } /* * Actions */ if (isset($_REQUEST['favobj'])) { $_REQUEST['pmasterid'] = get_request('pmasterid', 'mainpage'); if ($_REQUEST['favobj'] == 'hat') { if ($_REQUEST['favaction'] == 'flop') { $widgetName = substr($_REQUEST['favref'], 4); CProfile::update('web.dashboard.widget.' . $widgetName . '.state', $_REQUEST['favstate'], PROFILE_TYPE_INT); } elseif (getRequest('favaction') == 'sort') { $favdata = CJs::decodeJson(getRequest('favdata')); foreach ($favdata as $col => $column) { foreach ($column as $row => $widgetName) { $widgetName = substr($widgetName, 4, -7); CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT); CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT); } } } elseif ($_REQUEST['favaction'] == 'refresh') { switch ($_REQUEST['favref']) { case 'hat_syssum': $syssum = make_system_status($dashconf); $syssum->show(); break; case 'hat_hoststat': $hoststat = make_hoststat_summary($dashconf);
echo MAP_LABEL_TYPE_CUSTOM; ?> '); } jQuery(document).ready(function() { jQuery('#label_format').click(function() { toggleAdvancedLabels(jQuery('#label_format:checked').length != 0); }); var inputs = ['label_type_hostgroup', 'label_type_host', 'label_type_trigger', 'label_type_map', 'label_type_image']; jQuery.each(inputs, function() { jQuery('#' + this).change(toggleCustomLabel); }); toggleAdvancedLabels(jQuery('#label_format:checked').length != 0); // clone button jQuery('#clone').click(function() { jQuery('#sysmapid, #delete, #clone').remove(); jQuery('#update').val(<?php echo CJs::encodeJson(_('Add')); ?> ).attr({id: 'add', name: 'add'}); jQuery('#cancel').addClass('ui-corner-left'); jQuery('#name').focus(); }); }); </script>
public function preload() { $id = $this->getAttribute('id'); if (empty($id)) { $id = 'img' . uniqid(); $this->setAttribute('id', $id); } insert_js('jQuery(' . CJs::encodeJson($this->toString()) . ').load(function() { var parent = jQuery("#' . $id . 'preloader").parent(); jQuery("#' . $id . 'preloader").remove(); jQuery(parent).append(jQuery(this)); });', true); $this->addClass('preloader'); $this->setAttribute('id', $id . 'preloader'); $this->setAttribute('src', 'styles/themes/' . getUserTheme(CWebUser::$data) . '/images/preloader.gif'); }
if (hasRequest('widgetRefresh')) { $screenBuilder = new CScreenBuilder(['screen' => $dbScreen, 'mode' => SCREEN_MODE_PREVIEW, 'profileIdx' => 'web.slides', 'profileIdx2' => $elementId, 'hostid' => getRequest('hostid'), 'period' => getRequest('period'), 'stime' => getRequest('stime')]); CScreenBuilder::insertScreenCleanJs(); echo (new CDiv($screenBuilder->show()))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)->toString(); CScreenBuilder::insertScreenStandardJs(['timeline' => $screenBuilder->timeline, 'profileIdx' => $screenBuilder->profileIdx]); insertPagePostJs(); } // refresh rate if (hasRequest('widgetRefreshRate')) { $widgetRefreshRate = substr(getRequest('widgetRefreshRate'), 1); CProfile::update('web.slides.rf_rate.' . WIDGET_SLIDESHOW, $widgetRefreshRate, PROFILE_TYPE_STR, $elementId); } else { $widgetRefreshRate = CProfile::get('web.slides.rf_rate.' . WIDGET_SLIDESHOW, 1, getRequest('elementid', CProfile::get('web.slides.elementid'))); } $delay = $screen['delay'] > 0 ? $screen['delay'] : $data['screen']['delay']; insert_js('PMasters["slideshows"].dolls["' . WIDGET_SLIDESHOW . '"].frequency(' . CJs::encodeJson($delay * $widgetRefreshRate) . ');' . "\n" . 'PMasters["slideshows"].dolls["' . WIDGET_SLIDESHOW . '"].restartDoll();'); } } // filter state if (hasRequest('favobj') && hasRequest('favid')) { $favouriteObject = getRequest('favobj'); $favouriteId = getRequest('favid'); // saving fixed/dynamic setting to profile if ($favouriteObject === 'timelinefixedperiod') { CProfile::update('web.slides.timelinefixed', $favouriteId, PROFILE_TYPE_INT); } } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; }
** 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. **/ require_once dirname(__FILE__) . '/include/func.inc.php'; require_once dirname(__FILE__) . '/include/classes/class.chttp_request.php'; $allowed_content = array('application/json-rpc' => 'json-rpc', 'application/json' => 'json-rpc', 'application/jsonrequest' => 'json-rpc'); $http_request = new CHTTP_request(); $content_type = $http_request->header('Content-Type'); $content_type = explode(';', $content_type); $content_type = $content_type[0]; if (!isset($allowed_content[$content_type])) { header('HTTP/1.0 412 Precondition Failed'); exit; } require_once dirname(__FILE__) . '/include/classes/core/Z.php'; header('Content-Type: application/json'); $data = $http_request->body(); try { Z::getInstance()->run(ZBase::EXEC_MODE_API); $jsonRpc = new CJSONrpc($data); echo $jsonRpc->execute(); } catch (Exception $e) { // decode input json request to get request's id $jsonData = CJs::decodeJson($data); $response = array('jsonrpc' => '2.0', 'error' => array('code' => 1, 'message' => $e->getMessage()), 'id' => isset($jsonData['id']) ? $jsonData['id'] : null); echo CJs::encodeJson($response); }
tr.appendChild(td); // column "action" var td = document.createElement('td'); td.setAttribute('class', '<?php echo ZBX_STYLE_NOWRAP; ?> '); var inputRemove = document.createElement('button'); inputRemove.setAttribute('class', '<?php echo ZBX_STYLE_BTN_LINK; ?> '); inputRemove.setAttribute('onclick', 'javascript: removeDependentChild(\'' + serviceid + '\');'); inputRemove.appendChild(document.createTextNode(<?php echo CJs::encodeJson(_('Remove')); ?> )); td.appendChild(inputRemove); tr.appendChild(td); document.getElementById('service_children').firstChild.appendChild(tr); } } function removeDependentChild(serviceid) { removeObjectById('children_' + serviceid); removeObjectById('children_' + serviceid + '_name'); removeObjectById('children_' + serviceid + '_serviceid'); removeObjectById('children_' + serviceid + '_trigger'); }
}); // Convert macro names to uppercase. $('#tbl_macros').on('blur', 'input.macro', function() { macroToUpperCase(this); }); $('#update').click(function() { var removedCount = $(this).data('removedCount'); if (removedCount) { return confirm(<?php echo CJs::encodeJson(_('Are you sure you want to delete')); ?> + ' ' + removedCount + ' ' + <?php echo CJs::encodeJson(_('macro(s)')); ?> + '?'); } }); $('#tbl_macros').dynamicRows({ template: '#macroRow' }); $('form[name="macrosForm"]').submit(function() { $('input.macro').each(function() { macroToUpperCase(this); }); });
; organizeInterfaces(itemIntefaceTypes[<?php echo CJs::encodeJson($data['initial_item_type']); ?> ]); } else { jQuery('#type').trigger('change'); } }); jQuery('#type') .change(function() { // update the interface select with each item type change var itemIntefaceTypes = <?php echo CJs::encodeJson(itemTypeInterface()); ?> ; organizeInterfaces(itemIntefaceTypes[parseInt(jQuery(this).val())]); }) .trigger('change'); if (jQuery('#visible_delay_flex').length != 0) { displayNewDeleyFlexInterval(); jQuery('#visible_delay_flex').click(function() { displayNewDeleyFlexInterval(); }); } // create jquery buttonset object when authprotocol visible box is switched on
?> "); jQuery(this).dialog("destroy"); } }, {text: <?php echo CJs::encodeJson(_('Cancel')); ?> , click: function(){ jQuery(this).dialog("destroy"); }} ], draggable: true, modal: true, width: (w > 600 ? 600 : 'inherit'), resizable: false, minWidth: 200, minHeight: 100, title: <?php echo CJs::encodeJson(_('Reset confirmation')); ?> , close: function(){ jQuery(this).dialog('destroy'); } }); jQuery('#dialog').dialog('widget').find('button:first').addClass('main'); }); }); </script>
<script type="text/javascript"> jQuery(document).ready(function() { 'use strict'; jQuery('#edit').click(function() { jQuery('#comments') .val(<?php echo CJs::encodeJson($this->data['trigger']['comments']); ?> ) .removeAttr('readonly') .focus(); jQuery('#edit').prop('disabled', true); jQuery('#update').prop('disabled', false); }); }); </script>