本文整理汇总了PHP中CUtil::phpToJSObject方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::phpToJSObject方法的具体用法?PHP CUtil::phpToJSObject怎么用?PHP CUtil::phpToJSObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtil
的用法示例。
在下文中一共展示了CUtil::phpToJSObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getScripts
/**
* @return string
*/
public function getScripts()
{
if (!static::$jsInited) {
\Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_basket.js");
static::$jsInited = true;
}
$data = static::prepareData();
$totalPrices = OrderEdit::getTotalPrices($this->order, $this, false);
$langPhrases = array("SALE_ORDER_BASKET_TURN", "SALE_ORDER_BASKET_EXPAND", "SALE_ORDER_BASKET_UP_RATIO", "SALE_ORDER_BASKET_PROD_EDIT", "SALE_ORDER_BASKET_DOWN_RATIO", "SALE_ORDER_BASKET_PROD_COUNT", "SALE_ORDER_BASKET_NO_PICTURE", "SALE_ORDER_BASKET_PROD_CREATE", "SALE_ORDER_BASKET_ROW_SETTINGS", "SALE_ORDER_BASKET_PROD_MENU_EDIT", "SALE_ORDER_BASKET_PROD_MENU_DELETE", "SALE_ORDER_BASKET_BASE_CATALOG_PRICE", "SALE_ORDER_BASKET_PROD_EDIT_ITEM_SAVE", "SALE_ORDER_BASKET_KG", "SALE_ORDER_BASKET_COUPON", "SALE_ORDER_BASKET_COUPON_STATUS", "SALE_ORDER_BASKET_COUPON_APPLY", "SALE_ORDER_BASKET_COUPON_DELETE", "SALE_ORDER_BASKET_POSITION_EXISTS");
$result = '<script type="text/javascript">';
foreach ($langPhrases as $phrase) {
$result .= ' BX.message({' . $phrase . ': "' . \CUtil::jsEscape(Loc::getMessage($phrase)) . '"});';
}
if ($this->mode == self::EDIT_MODE) {
$result .= '
BX.ready(function(){
' . $this->jsObjName . '= new BX.Sale.Admin.OrderBasketEdit({
tableId: "' . $this->idPrefix . 'sale_order_edit_product_table",
idPrefix: "' . $this->idPrefix . '",
productsOrder: ' . \CUtil::phpToJSObject($data["ITEMS_ORDER"]) . ',
products: ' . \CUtil::phpToJSObject($data["ITEMS"]) . ',
visibleColumns: ' . \CUtil::phpToJSObject($this->visibleColumns) . ',
objName: "' . $this->jsObjName . '",
createProductBasement: ' . ($this->createProductBasement ? 'true' : 'false') . ',
columnsCount: ' . count($this->visibleColumns) . ',
createBasketBottom: true,
iblocksSkuParams: ' . \CUtil::phpToJSObject($data["IBLOCKS_SKU_PARAMS"]) . ',
productsOffersSkuParams: ' . \CUtil::phpToJSObject($data["PRODUCTS_OFFERS_SKU"]) . ',
isShowXmlId: ' . ($this->isShowXmlId ? 'true' : 'false') . ',
discounts: ' . \CUtil::phpToJSObject(OrderEdit::getOrderedDiscounts($this->order, false)) . ',
mode: "edit",
unRemovableFields: ["PRICE", "QUANTITY"],
' . $this->getTotalBlockFieldsJs($totalPrices, $data) . '
});
BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( ' . $this->jsObjName . '.getFieldsUpdaters() );
BX.Sale.Admin.OrderBasketCoupons.statusCouponApplyed = ' . DiscountCouponsManager::STATUS_APPLYED . ';
BX.Sale.Admin.OrderBasketCoupons.mode = BX.Sale.Admin.OrderBasketCoupons.MODES_LIST.' . ($this->order->getId() > 0 ? 'EDIT' : 'CREATE') . ';
BX.Sale.Admin.OrderBasketCoupons.setCoupons(' . \CUtil::phpToJSObject(OrderEdit::getCouponList($this->order, false)) . ');
});';
$result .= $this->settingsDialog->getScripts();
} else {
$result .= '
BX.ready(function(){
' . $this->jsObjName . '= new BX.Sale.Admin.OrderBasket({
tableId: "' . $this->idPrefix . 'sale_order_view_product_table",
idPrefix: "' . $this->idPrefix . '",
productsOrder: ' . \CUtil::phpToJSObject($data["ITEMS_ORDER"]) . ',
products: ' . \CUtil::phpToJSObject($data["ITEMS"]) . ',
visibleColumns: ' . \CUtil::phpToJSObject($this->visibleColumns) . ',
objName: "' . $this->jsObjName . '",
createProductBasement: ' . ($this->createProductBasement ? 'true' : 'false') . ',
iblocksSkuParams: ' . \CUtil::phpToJSObject($data["IBLOCKS_SKU_PARAMS"]) . ',
columnsCount: ' . count($this->visibleColumns) . ',
isShowXmlId: ' . ($this->isShowXmlId ? 'true' : 'false') . ',
discounts: ' . \CUtil::phpToJSObject(OrderEdit::getOrderedDiscounts($this->order, false)) . ',
createBasketBottom: true,
mode: "view",
' . $this->getTotalBlockFieldsJs($totalPrices, $data) . '
});
BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( ' . $this->jsObjName . '.getFieldsUpdaters() );
BX.Sale.Admin.OrderBasketCoupons.mode = BX.Sale.Admin.OrderBasketCoupons.MODES_LIST.VIEW;
BX.Sale.Admin.OrderBasketCoupons.setCoupons(' . \CUtil::phpToJSObject(OrderEdit::getCouponList($this->order, false)) . ');
});';
$result .= $this->settingsDialog->getScripts();
}
$result .= '</script>';
return $result;
}
示例2: processActionOpenDialog
protected function processActionOpenDialog()
{
$selectedService = '';
$fakeMove = $this->request->getQuery('wish') === 'fakemove';
$enabledMultiSelect = $this->request->getQuery('multiselect') !== 'N';
if ($this->request->getQuery('cloudImport')) {
$list = $this->listCloudStorages();
$types = array('cloud' => array('id' => 'cloud', 'order' => 4));
$selectedService = $this->request->getQuery('service');
} else {
$list = $this->listStorages();
if (!$list) {
$this->sendJsonErrorResponse();
}
$types = array('recently_used' => array('id' => 'recently_used', 'order' => 1, 'searchable' => false), 'user' => array('id' => 'user', 'order' => 2, 'searchable' => false), 'common' => array('id' => 'common', 'name' => Loc::getMessage('DISK_UF_CONTROLLER_SHARED_DOCUMENTS'), 'order' => 3, 'searchable' => false), 'group' => array('id' => 'group', 'name' => Loc::getMessage('DISK_UF_CONTROLLER_MY_GROUPS'), 'order' => 4, 'searchable' => false));
if ($fakeMove) {
unset($types['recently_used']);
}
}
$dialogName = $this->request->getQuery('dialogName');
if (strlen($dialogName) <= 0) {
$dialogName = 'DiskFileDialog';
}
$dialogTitle = Loc::getMessage($fakeMove ? 'DISK_UF_CONTROLLER_SAVE_DOCUMENT_TITLE' : 'DISK_UF_CONTROLLER_SELECT_DOCUMENT_TITLE');
if (!$fakeMove && !$enabledMultiSelect) {
$dialogTitle = Loc::getMessage('DISK_UF_CONTROLLER_SELECT_ONE_DOCUMENT_TITLE');
}
$js = "\n\t\t\t<script>\n\t\t\t\tBX.DiskFileDialog.init({\n\t\t\t\t\t'currentTabId': '" . \CUtil::jSEscape($selectedService) . "',\n\t\t\t\t\t'name' : '" . \CUtil::jSEscape($dialogName) . "',\n\n\t\t\t\t\t'bindPopup' : { 'node' : null, 'offsetTop' : 0, 'offsetLeft': 0},\n\n\t\t\t\t\t'localize' : {\n\t\t\t\t\t\t'title' : '" . \CUtil::jSEscape($dialogTitle) . "',\n\t\t\t\t\t\t'saveButton' : '" . \CUtil::jSEscape(Loc::getMessage($fakeMove ? 'DISK_UF_CONTROLLER_SELECT_FOLDER' : 'DISK_UF_CONTROLLER_SELECT_DOCUMENT')) . "',\n\t\t\t\t\t\t'cancelButton' : '" . \CUtil::jSEscape(Loc::getMessage('DISK_UF_CONTROLLER_CANCEL')) . "'\n\t\t\t\t\t},\n\n\t\t\t\t\t'callback' : {\n\t\t\t\t\t\t'saveButton' : function(tab, path, selected) {},\n\t\t\t\t\t\t'cancelButton' : function(tab, path, selected) {}\n\t\t\t\t\t},\n\n\t\t\t\t\t'type' : " . \CUtil::phpToJSObject($types) . ",\n\t\t\t\t\t'typeItems' : " . \CUtil::phpToJSObject($list) . ",\n\t\t\t\t\t'items' : {},\n\n\t\t\t\t\t'itemsDisabled' : {},\n\t\t\t\t\t'itemsSelected' : {},\n\t\t\t\t\t'itemsSelectEnabled' : " . ($fakeMove ? '{folder: true}' : "{'onlyFiles' : true}") . ", // all, onlyFiles, folder, archive, image, file, video, txt, word, excel, ppt\n\t\t\t\t\t'itemsSelectMulti' : " . ($fakeMove || !$enabledMultiSelect ? 'false' : 'true') . ",\n\n\t\t\t\t\t'gridColumn' : {\n\t\t\t\t\t\t'name' : {'id' : 'name', 'name' : '" . \CUtil::jSEscape(Loc::getMessage('DISK_UF_CONTROLLER_TITLE_NAME')) . "', 'sort' : 'name', 'style': 'width: 310px', 'order': 1},\n\t\t\t\t\t\t'size' : {'id' : 'size', 'name' : '" . \CUtil::jSEscape(Loc::getMessage('DISK_UF_CONTROLLER_FILE_SIZE')) . "', 'sort' : 'sizeInt', 'style': 'width: 79px', 'order': 2},\n\t\t\t\t\t\t'modifyBy' : {'id' : 'modifyBy', 'name' : '" . \CUtil::jSEscape(Loc::getMessage('DISK_UF_CONTROLLER_TITLE_MODIFIED_BY')) . "', 'sort' : 'modifyBy', 'style': 'width: 122px', 'order': 3},\n\t\t\t\t\t\t'modifyDate' : {'id' : 'modifyDate', 'name' : '" . \CUtil::jSEscape(Loc::getMessage('DISK_UF_CONTROLLER_TITLE_TIMESTAMP')) . "', 'sort' : 'modifyDateInt', 'style': 'width: 90px', 'order': 4}\n\t\t\t\t\t},\n\t\t\t\t\t'gridOrder' : {'column': 'modifyDateInt', 'order':'desc'}\n\t\t\t\t});\n\t\t\t</script>\n\t\t\t\t";
$this->sendResponse($js);
}
示例3:
?>
'];<?php
?>
services['<?php
echo $service['id'];
?>
'] = ['<?php
echo $service['server'];
?>
'];<?php
?>
domainUsers['<?php
echo $service['id'];
?>
'] = <?php
echo CUtil::phpToJSObject($service['users']);
?>
;<?php
}
}
?>
var mb = {
'dialog': (function() {
var dlg = new BX.CDialog({
'content': '',
'title': '',
'width': 420,
'resizable': false
});
dlg.PARTS.CONTENT_DATA.style.height = 'auto';
示例4: function
<script type="text/javascript">
var initialSite = '<?php
echo CUtil::jsEscape($abtest['SITE_ID']);
?>
';
var siteDirs = <?php
echo CUtil::phpToJSObject(array_map(function ($site) {
return $site['DIR'];
}, $arSites));
?>
;
var estDays = <?php
echo CUtil::phpToJSObject($arEstDays);
?>
;
var fileDialogTarget = null;
var fileDialogCallback = function(filename, path)
{
fileDialogTarget.value = (path+'/'+filename).replace(/\/+/, '/');
fileDialogTarget.style.color = '';
ABTestList.Item.handle(fileDialogTarget, true);
fileDialogTarget = null;
}
var ABTestParams = {