本文整理汇总了PHP中CBPHelper::GetJSFunctionsForFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CBPHelper::GetJSFunctionsForFields方法的具体用法?PHP CBPHelper::GetJSFunctionsForFields怎么用?PHP CBPHelper::GetJSFunctionsForFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBPHelper
的用法示例。
在下文中一共展示了CBPHelper::GetJSFunctionsForFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetJSFunctionsForFields
public function GetJSFunctionsForFields($parameterDocumentType, $objectName, $arDocumentFields = array(), $arDocumentFieldTypes = array())
{
if (!is_array($arDocumentFields) || count($arDocumentFields) <= 0) {
$arDocumentFields = self::GetDocumentFields($parameterDocumentType);
}
if (!is_array($arDocumentFieldTypes) || count($arDocumentFieldTypes) <= 0) {
$arDocumentFieldTypes = self::GetDocumentFieldTypes($parameterDocumentType);
}
list($moduleId, $entity, $documentType) = CBPHelper::ParseDocumentId($parameterDocumentType);
if (strlen($moduleId) > 0) {
CModule::IncludeModule($moduleId);
}
$documentFieldsString = "";
foreach ($arDocumentFields as $fieldKey => $arFieldValue) {
if (strlen($documentFieldsString) > 0) {
$documentFieldsString .= ",";
}
$documentFieldsString .= "'" . Cutil::JSEscape($fieldKey) . "':{";
$documentFieldsString .= "'Name':'" . CUtil::JSEscape($arFieldValue["Name"]) . "',";
$documentFieldsString .= "'Type':'" . CUtil::JSEscape($arFieldValue["Type"]) . "',";
$documentFieldsString .= "'Multiple':'" . CUtil::JSEscape($arFieldValue["Multiple"] ? "Y" : "N") . "',";
$documentFieldsString .= "'Complex':'" . CUtil::JSEscape($arFieldValue["Complex"] ? "Y" : "N") . "',";
$documentFieldsString .= "'Options':";
if (array_key_exists("Options", $arFieldValue)) {
if (is_array($arFieldValue["Options"])) {
$documentFieldsString .= "{";
$flTmp = false;
foreach ($arFieldValue["Options"] as $k => $v) {
if ($flTmp) {
$documentFieldsString .= ",";
}
$documentFieldsString .= "'" . CUtil::JSEscape($k) . "':'" . CUtil::JSEscape($v) . "'";
$flTmp = true;
}
$documentFieldsString .= "}";
} else {
$documentFieldsString .= "'" . CUtil::JSEscape($arFieldValue["Options"]) . "'";
}
} else {
$documentFieldsString .= "''";
}
$documentFieldsString .= "}";
}
$fieldTypesString = "";
$ind = -1;
foreach ($arDocumentFieldTypes as $typeKey => $arTypeValue) {
$ind++;
if (strlen($fieldTypesString) > 0) {
$fieldTypesString .= ",";
}
$fieldTypesString .= "'" . CUtil::JSEscape($typeKey) . "':{";
$fieldTypesString .= "'Name':'" . CUtil::JSEscape($arTypeValue["Name"]) . "',";
$fieldTypesString .= "'BaseType':'" . CUtil::JSEscape($arTypeValue["BaseType"]) . "',";
$fieldTypesString .= "'Complex':'" . CUtil::JSEscape($arTypeValue["Complex"] ? "Y" : "N") . "',";
$fieldTypesString .= "'Index':" . $ind . "";
$fieldTypesString .= "}";
}
$documentTypeString = CUtil::PhpToJSObject($parameterDocumentType);
$bitrixSessId = bitrix_sessid();
$result = <<<EOS
<script type="text/javascript">
var {$objectName} = {};
{$objectName}.arDocumentFields = { {$documentFieldsString} };
{$objectName}.arFieldTypes = { {$fieldTypesString} };
{$objectName}.AddField = function(fldCode, fldName, fldType, fldMultiple, fldOptions)
{
\tthis.arDocumentFields[fldCode] = {};
\tthis.arDocumentFields[fldCode]["Name"] = fldName;
\tthis.arDocumentFields[fldCode]["Type"] = fldType;
\tthis.arDocumentFields[fldCode]["Multiple"] = fldMultiple;
\tthis.arDocumentFields[fldCode]["Options"] = fldOptions;
}
{$objectName}._PrepareResponse = function(v)
{
\tv = v.replace(/^\\s+|\\s+\$/g, '');
\twhile (v.length > 0 && v.charCodeAt(0) == 65279)
\t\tv = v.substring(1);
\tif (v.length <= 0)
\t\treturn undefined;
\teval("v = " + v);
\treturn v;
}
{$objectName}.GetFieldInputControl4Type = function(type, value, name, subtypeFunctionName, func)
{
\tthis.GetFieldInputControlInternal(
\t\ttype,
\t\tvalue,
\t\tname,
\t\tfunction(v)
\t\t{
\t\t\tvar p = v.indexOf('<!--__defaultOptionsValue:');
\t\t\tif (p >= 0)
\t\t\t{
//.........这里部分代码省略.........