本文整理汇总了PHP中CJs::encodeJson方法的典型用法代码示例。如果您正苦于以下问题:PHP CJs::encodeJson方法的具体用法?PHP CJs::encodeJson怎么用?PHP CJs::encodeJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CJs
的用法示例。
在下文中一共展示了CJs::encodeJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @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) . ');');
}
示例2: __construct
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');
}
示例3: doAction
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));
}
示例4: __construct
/**
* @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) . ')');
}
示例5: get
/**
* 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);
}
}
示例6: toString
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);
}
示例7: CPassBox
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;
示例8: CCol
$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
示例9: CScreenBuilder
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;
}
示例10: function
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() {
示例11: getRequest
// if ($_REQUEST['favobj'] == 'sysmap' && getRequest('action') == 'update') {
if (getRequest('favobj') == 'sysmap' && hasRequest('action') && getRequest('action') == 'update') {
$sysmapid = getRequest('sysmapid', 0);
@ob_start();
try {
DBstart();
$sysmap = API::Map()->get(array('sysmapids' => $sysmapid, 'editable' => true, 'output' => array('sysmapid')));
$sysmap = reset($sysmap);
if ($sysmap === false) {
throw new Exception(_('Access denied!') . "\n\r");
}
$sysmapUpdate = $json->decode($_REQUEST['sysmap'], true);
$sysmapUpdate['sysmapid'] = $sysmapid;
$result = API::Map()->update($sysmapUpdate);
if ($result !== false) {
echo 'if (confirm(' . CJs::encodeJson(_('Map is updated! Return?')) . ')) { location.href = "sysmaps.php"; }';
} else {
throw new Exception(_('Map update failed.') . "\n\r");
}
DBend(true);
} catch (Exception $e) {
DBend(false);
$msg = array($e->getMessage());
foreach (clear_messages() as $errMsg) {
$msg[] = $errMsg['type'] . ': ' . $errMsg['message'];
}
ob_clean();
echo 'alert(' . zbx_jsvalue(implode("\n\r", $msg)) . ');';
}
@ob_flush();
exit;
示例12: preload
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');
}
示例13: get
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());
}
示例14: dirname
** 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'));
示例15: removeDependentChild
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');
}