本文整理汇总了PHP中CBPHelper::IsAssociativeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CBPHelper::IsAssociativeArray方法的具体用法?PHP CBPHelper::IsAssociativeArray怎么用?PHP CBPHelper::IsAssociativeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBPHelper
的用法示例。
在下文中一共展示了CBPHelper::IsAssociativeArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExtractValuesFromVariables
private static function ExtractValuesFromVariables($ar, $variables, $constants = array())
{
if (is_string($ar) && preg_match(CBPActivity::ValuePattern, $ar, $arMatches)) {
$ar = array($arMatches['object'], $arMatches['field']);
}
if (is_array($ar)) {
if (!CBPHelper::IsAssociativeArray($ar)) {
if (count($ar) == 2 && ($ar[0] == 'Variable' || $ar[0] == 'Constant' || $ar[0] == 'Template')) {
if ($ar[0] == 'Variable' && is_array($variables) && array_key_exists($ar[1], $variables)) {
return array($variables[$ar[1]]["Default"]);
}
if ($ar[0] == 'Constant' && is_array($constants) && array_key_exists($ar[1], $constants)) {
return array($constants[$ar[1]]["Default"]);
}
return array();
}
$arResult = array();
foreach ($ar as $ar1) {
$arResult[] = self::ExtractValuesFromVariables($ar1, $variables, $constants);
}
return $arResult;
}
}
return $ar;
}
示例2: checkActivityFilterRules
private function checkActivityFilterRules($rules, $documentType, $distrName)
{
if (!is_array($rules) || CBPHelper::IsAssociativeArray($rules)) {
$rules = array($rules);
}
foreach ($rules as $rule) {
$result = false;
if (is_array($rule)) {
if (!$documentType) {
$result = true;
} else {
foreach ($documentType as $key => $value) {
if (!isset($rule[$key])) {
break;
}
$result = $rule[$key] == $value;
if (!$result) {
break;
}
}
}
} else {
$result = (string) $rule == $distrName;
}
if ($result) {
return true;
}
}
return false;
}
示例3: CheckCondition
private function CheckCondition($fieldName, $field, $operation, $value, $type = null, $rootActivity = null)
{
$result = false;
$value = $rootActivity->ParseValue($value, $type);
if ($type == "user") {
$field = CBPHelper::ExtractUsersFromUserGroups($field, $rootActivity);
$value = CBPHelper::ExtractUsersFromUserGroups($value, $rootActivity);
} elseif ($type == "select") {
if (is_array($field) && CBPHelper::IsAssociativeArray($field)) {
$field = array_keys($field);
}
}
if (!is_array($field)) {
$field = array($field);
}
if ($operation == "in") {
foreach ($field as $f) {
if (is_array($value)) {
$result = in_array($f, $value);
} else {
$result = strpos($value, $f) !== false;
}
if (!$result) {
break;
}
}
return $result;
}
if ($operation == "contain") {
if (!is_array($value)) {
$value = array($value);
}
foreach ($value as $v) {
foreach ($field as $f) {
if (is_array($f)) {
$result = in_array($v, $f);
} else {
$result = strpos($f, $v) !== false;
}
if ($result) {
break;
}
}
if (!$result) {
break;
}
}
return $result;
}
if ($operation == 'modified') {
$modified = $rootActivity->{CBPDocument::PARAM_MODIFIED_DOCUMENT_FIELDS};
if (!is_array($modified)) {
return true;
}
return in_array($fieldName, $modified);
}
if (!is_array($value)) {
$value = array($value);
}
if (CBPHelper::IsAssociativeArray($field)) {
$field = array_keys($field);
}
if (CBPHelper::IsAssociativeArray($value)) {
$value = array_keys($value);
}
$i = 0;
$fieldCount = count($field);
$valueCount = count($value);
$iMax = max($fieldCount, $valueCount);
while ($i < $iMax) {
$f1 = $fieldCount > $i ? $field[$i] : $field[$fieldCount - 1];
$v1 = $valueCount > $i ? $value[$i] : $value[$valueCount - 1];
if ($type == "datetime" || $type == "date") {
if (($f1Tmp = MakeTimeStamp($f1, FORMAT_DATETIME)) === false) {
if (($f1Tmp = MakeTimeStamp($f1, FORMAT_DATE)) === false) {
if (($f1Tmp = MakeTimeStamp($f1, "YYYY-MM-DD HH:MI:SS")) === false) {
if (($f1Tmp = MakeTimeStamp($f1, "YYYY-MM-DD")) === false) {
$f1Tmp = 0;
}
}
}
}
$f1 = $f1Tmp;
if (($v1Tmp = MakeTimeStamp($v1, FORMAT_DATETIME)) === false) {
if (($v1Tmp = MakeTimeStamp($v1, FORMAT_DATE)) === false) {
if (($v1Tmp = MakeTimeStamp($v1, "YYYY-MM-DD HH:MI:SS")) === false) {
if (($v1Tmp = MakeTimeStamp($v1, "YYYY-MM-DD")) === false) {
$v1Tmp = 0;
}
}
}
}
$v1 = $v1Tmp;
}
switch ($operation) {
case ">":
$result = $f1 > $v1;
break;
case ">=":
$result = $f1 >= $v1;
//.........这里部分代码省略.........
示例4: CreateDocument
/**
* ћетод создает новый документ с указанными свойствами (пол¤ми).
*
* @param array $arFields - массив значений свойств документа в виде array(код_свойства => значение, ...). оды свойств соответствуют кодам свойств, возвращаемым методом GetDocumentFields.
* @return int - код созданного документа.
*/
public function CreateDocument($parentDocumentId, $arFields)
{
if (!array_key_exists("IBLOCK_ID", $arFields) || intval($arFields["IBLOCK_ID"]) <= 0) {
throw new Exception("IBlock ID is not found");
}
$arFieldsPropertyValues = array();
$arDocumentFields = self::GetDocumentFields("iblock_" . $arFields["IBLOCK_ID"]);
$arKeys = array_keys($arFields);
foreach ($arKeys as $key) {
if (!array_key_exists($key, $arDocumentFields)) {
continue;
}
$arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
if ($arDocumentFields[$key]["Type"] == "user") {
$ar = array();
foreach ($arFields[$key] as $v1) {
if (substr($v1, 0, strlen("user_")) == "user_") {
$ar[] = substr($v1, strlen("user_"));
} else {
$a1 = self::GetUsersFromUserGroup($v1, $documentId);
foreach ($a1 as $a11) {
$ar[] = $a11;
}
}
}
$arFields[$key] = $ar;
} elseif ($arDocumentFields[$key]["Type"] == "select") {
$realKey = substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_" ? substr($key, strlen("PROPERTY_")) : $key;
$arV = array();
$db = CIBlockProperty::GetPropertyEnum($realKey, false, array("IBLOCK_ID" => $arFields["IBLOCK_ID"]));
while ($ar = $db->GetNext()) {
$arV[$ar["XML_ID"]] = $ar["ID"];
}
foreach ($arFields[$key] as &$value) {
if (array_key_exists($value, $arV)) {
$value = $arV[$value];
}
}
} elseif ($arDocumentFields[$key]["Type"] == "file") {
foreach ($arFields[$key] as &$value) {
$value = CFile::MakeFileArray($value);
}
} elseif ($arDocumentFields[$key]["Type"] == "S:HTML") {
foreach ($arFields[$key] as &$value) {
$value = array("VALUE" => $value);
}
}
if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
if (count($arFields[$key]) > 0) {
$a = array_values($arFields[$key]);
$arFields[$key] = $a[0];
} else {
$arFields[$key] = null;
}
}
if (substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_") {
$realKey = substr($key, strlen("PROPERTY_"));
$arFieldsPropertyValues[$realKey] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
unset($arFields[$key]);
}
}
if (count($arFieldsPropertyValues) > 0) {
$arFields["PROPERTY_VALUES"] = $arFieldsPropertyValues;
}
$iblockElement = new CIBlockElement();
$id = $iblockElement->Add($arFields, false, true, true);
if (!$id || $id <= 0) {
throw new Exception($iblockElement->LAST_ERROR);
}
return $id;
}
示例5: StripUserPrefix
public static function StripUserPrefix($value)
{
if (is_array($value) && !CBPHelper::IsAssociativeArray($value)) {
foreach ($value as &$v) {
if (substr($v, 0, 5) == "user_") {
$v = substr($v, 5);
}
}
} else {
if (substr($value, 0, 5) == "user_") {
$value = substr($value, 5);
}
}
return $value;
}
示例6: ExtractValuesFromVariables
private static function ExtractValuesFromVariables($ar, $variables, $constants = array())
{
if (is_string($ar) && preg_match('/^\\{=([A-Za-z0-9_]+)\\:([A-Za-z0-9_]+)\\}$/i', $ar, $arMatches)) {
$ar = array($arMatches[1], $arMatches[2]);
}
if (is_array($ar)) {
if (!CBPHelper::IsAssociativeArray($ar)) {
if (count($ar) == 2 && ($ar[0] == 'Variable' || $ar[0] == 'Constant')) {
if ($ar[0] == 'Variable' && is_array($variables) && array_key_exists($ar[1], $variables)) {
return array($variables[$ar[1]]["Default"]);
}
if ($ar[0] == 'Constant' && is_array($constants) && array_key_exists($ar[1], $constants)) {
return array($constants[$ar[1]]["Default"]);
}
}
$arResult = array();
foreach ($ar as $ar1) {
$arResult[] = self::ExtractValuesFromVariables($ar1, $variables, $constants);
}
return $arResult;
}
}
return $ar;
}
示例7: GetFieldInputValuePrintable
function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
{
if ($storage = self::needProxyToDiskByDocType($documentType)) {
return self::proxyToDisk(__FUNCTION__, array(\Bitrix\Disk\BizProcDocumentCompatible::generateDocumentType($storage->getId()), $arFieldType, $fieldValue));
}
$result = $fieldValue;
switch ($arFieldType['Type']) {
case "user":
if (!is_array($fieldValue)) {
$fieldValue = array($fieldValue);
}
$result = CBPHelper::UsersArrayToString($fieldValue, null, array("webdav", "CIBlockDocumentWebdavSocnet", $documentType));
break;
case "bool":
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
$result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
}
} else {
$result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
}
break;
case "file":
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
$r = intval($r);
$dbImg = CFile::GetByID($r);
if ($arImg = $dbImg->Fetch()) {
$result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
}
}
} else {
$fieldValue = intval($fieldValue);
$dbImg = CFile::GetByID($fieldValue);
if ($arImg = $dbImg->Fetch()) {
$result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
}
}
break;
case "select":
if (is_array($arFieldType["Options"])) {
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
if (array_key_exists($r, $arFieldType["Options"])) {
$result[] = $arFieldType["Options"][$r];
}
}
} else {
if (array_key_exists($fieldValue, $arFieldType["Options"])) {
$result = $arFieldType["Options"][$fieldValue];
}
}
}
break;
}
if (strpos($arFieldType['Type'], ":") !== false) {
$arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2));
if (array_key_exists("GetPublicViewHTML", $arCustomType)) {
if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
$result = array();
foreach ($fieldValue as $value) {
$r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), ""));
$result[] = HTMLToTxt($r);
}
} else {
$result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), ""));
$result = HTMLToTxt($result);
}
}
}
return $result;
}
示例8: InternalizeEnumerationField
protected static function InternalizeEnumerationField($entityTypeID, array &$fields, $name)
{
if (!isset($fields[$name])) {
return;
}
$entityResult = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => $entityTypeID, "FIELD_NAME" => $name));
$entity = $entityResult->Fetch();
if (!is_array($entity)) {
return;
}
$isMultiple = isset($entity['MULTIPLE']) && $entity['MULTIPLE'] === 'Y';
$enumXMap = array();
$enumVMap = array();
$enumResult = CUserTypeEnum::GetList($entity);
while ($enum = $enumResult->GetNext()) {
$enumXMap[$enum["XML_ID"]] = $enum["ID"];
$enumVMap[$enum["VALUE"]] = $enum["ID"];
}
$results = array();
if (is_array($fields[$name])) {
foreach ($fields[$name] as $value) {
if (CBPHelper::IsAssociativeArray($value)) {
//HACK: For IBlockDocument
$value = array_keys($value);
if (!$isMultiple) {
$value = array_shift($value);
}
}
if (is_array($value)) {
foreach ($value as $v) {
if (isset($enumXMap[$v])) {
$results[] = $enumXMap[$v];
} elseif (isset($enumVMap[$v])) {
$results[] = $enumVMap[$v];
}
}
} elseif (isset($enumXMap[$value])) {
$results[] = $enumXMap[$value];
} elseif (isset($enumVMap[$value])) {
$results[] = $enumVMap[$value];
}
}
} elseif (isset($enumXMap[$fields[$name]])) {
$results[] = $enumXMap[$fields[$name]];
} elseif (isset($enumVMap[$fields[$name]])) {
$results[] = $enumVMap[$fields[$name]];
}
if (!empty($results)) {
$fields[$name] = $isMultiple ? $results : $results[0];
} else {
unset($fields[$name]);
}
}
示例9: UpdateDocument
public static function UpdateDocument($documentId, $arFields)
{
global $DB;
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
$dbDocumentList = CCrmCompany::GetList(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), array('ID'));
$arResult = $dbDocumentList->Fetch();
if (!$arResult) {
throw new Exception(GetMessage('CRM_DOCUMENT_ELEMENT_IS_NOT_FOUND'));
}
$arDocumentFields = self::GetDocumentFields($arDocumentID['TYPE']);
$arKeys = array_keys($arFields);
foreach ($arKeys as $key) {
if (!array_key_exists($key, $arDocumentFields)) {
//Fix for issue #40374
unset($arFields[$key]);
continue;
}
$fieldType = $arDocumentFields[$key]["Type"];
if (in_array($fieldType, array("phone", "email", "im", "web"), true)) {
CCrmDocument::PrepareEntityMultiFields($arFields, strtoupper($fieldType));
continue;
}
$arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
if ($fieldType == "user") {
$ar = array();
foreach ($arFields[$key] as $v1) {
if (substr($v1, 0, strlen("user_")) == "user_") {
$ar[] = substr($v1, strlen("user_"));
} else {
$a1 = self::GetUsersFromUserGroup($v1, $documentId);
foreach ($a1 as $a11) {
$ar[] = $a11;
}
}
}
$arFields[$key] = $ar;
} elseif ($fieldType == "select" && substr($key, 0, 3) == "UF_") {
self::InternalizeEnumerationField('CRM_COMPANY', $arFields, $key);
} elseif ($fieldType == "file") {
$arFileOptions = array('ENABLE_ID' => true);
foreach ($arFields[$key] as &$value) {
//Issue #40380. Secure URLs and file IDs are allowed.
$file = false;
CCrmFileProxy::TryResolveFile($value, $file, $arFileOptions);
$value = $file;
}
unset($value);
} elseif ($fieldType == "S:HTML") {
foreach ($arFields[$key] as &$value) {
$value = array("VALUE" => $value);
}
unset($value);
}
if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
if (count($arFields[$key]) > 0) {
$a = array_values($arFields[$key]);
$arFields[$key] = $a[0];
} else {
$arFields[$key] = null;
}
}
}
if (isset($arFields['CONTACT_ID']) && !is_array($arFields['CONTACT_ID'])) {
$arFields['CONTACT_ID'] = array($arFields['CONTACT_ID']);
}
if (isset($arFields['COMMENTS']) && $arFields['COMMENTS'] !== '') {
$arFields['COMMENTS'] = preg_replace("/[\r\n]+/" . BX_UTF_PCRE_MODIFIER, "<br/>", $arFields['COMMENTS']);
}
$DB->StartTransaction();
$CCrmEntity = new CCrmCompany(false);
$res = $CCrmEntity->Update($arDocumentID['ID'], $arFields);
if (!$res) {
$DB->Rollback();
throw new Exception($CCrmEntity->LAST_ERROR);
}
if (COption::GetOptionString("crm", "start_bp_within_bp", "N") == "Y") {
$CCrmBizProc = new CCrmBizProc('COMPANY');
if (false === $CCrmBizProc->CheckFields($arDocumentID['ID'], true)) {
throw new Exception($CCrmBizProc->LAST_ERROR);
}
if ($res && !$CCrmBizProc->StartWorkflow($arDocumentID['ID'])) {
$DB->Rollback();
throw new Exception($CCrmBizProc->LAST_ERROR);
}
}
if ($res) {
$DB->Commit();
}
}
示例10: PreparePrintableValue
protected static function PreparePrintableValue($arDocumentID, $fieldName, $arFieldType, $fieldValue)
{
global $USER_FIELD_MANAGER, $APPLICATION;
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
$result = $fieldValue;
switch ($arFieldType['Type']) {
case 'date':
case 'datetime':
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $_fieldValue) {
$result[] = empty($_fieldValue) ? FormatDate('x', MakeTimeStamp($_fieldValue)) : '';
}
} else {
$result = !empty($fieldValue) ? FormatDate('x', MakeTimeStamp($fieldValue)) : '';
}
break;
case 'user':
if (!is_array($fieldValue)) {
$fieldValue = array($fieldValue);
}
$result = CBPHelper::UsersArrayToString($fieldValue, null, $arDocumentID["DOCUMENT_TYPE"]);
break;
case 'bool':
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
$result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage('BPVDX_YES') : GetMessage('BPVDX_NO');
}
} else {
$result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage('BPVDX_YES') : GetMessage('BPVDX_NO');
}
break;
case 'file':
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
$r = intval($r);
$dbImg = CFile::GetByID($r);
if ($arImg = $dbImg->Fetch()) {
$result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
}
}
} else {
$fieldValue = intval($fieldValue);
$dbImg = CFile::GetByID($fieldValue);
if ($arImg = $dbImg->Fetch()) {
$result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
}
}
break;
case 'select':
if (is_array($arFieldType["Options"])) {
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
if (array_key_exists($r, $arFieldType["Options"])) {
$result[] = $arFieldType["Options"][$r];
}
}
} else {
if (array_key_exists($fieldValue, $arFieldType["Options"])) {
$result = $arFieldType["Options"][$fieldValue];
}
}
}
break;
case 'web':
case 'im':
case 'email':
case 'phone':
$result = array();
if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
$fieldValue = $fieldValue[0];
}
if (is_array($fieldValue) && is_array($fieldValue[strtoupper($arFieldType['Type'])])) {
foreach ($fieldValue[strtoupper($arFieldType['Type'])] as $val) {
if (!empty($val)) {
$result[] = CCrmFieldMulti::GetEntityNameByComplex(strtoupper($arFieldType['Type']) . '_' . $val['VALUE_TYPE'], false) . ': ' . $val['VALUE'];
}
}
}
break;
}
if (strpos($arFieldType['Type'], 'UF:') === 0) {
$sType = str_replace('UF:', '', $arFieldType['Type']);
$arUserFieldType = $USER_FIELD_MANAGER->GetUserType($sType);
$arUserField = array('ENTITY_ID' => 'CRM_LEAD', 'FIELD_NAME' => 'UF_XXXXXXX', 'USER_TYPE_ID' => $sType, 'SORT' => 100, 'MULTIPLE' => $arFieldType['Multiple'] ? 'Y' : 'N', 'MANDATORY' => $arFieldType['Required'] ? 'Y' : 'N', 'EDIT_FORM_LABEL' => $arUserFieldType['DESCRIPTION'], 'VALUE' => $fieldValue, 'USER_TYPE' => $arUserFieldType);
if ($arFieldType['Type'] == 'UF:iblock_element' || $arFieldType['Type'] == 'UF:iblock_section') {
$arUserField['SETTINGS']['IBLOCK_ID'] = $arFieldType['Options'];
} elseif ($arFieldType['Type'] == 'UF:crm_status') {
$arUserField['SETTINGS']['ENTITY_TYPE'] = $arFieldType['Options'];
} elseif ($arFieldType['Type'] == 'UF:crm') {
$arUserField['SETTINGS'] = $arFieldType['Options'];
if (empty($arUserField['SETTINGS'])) {
$arUserField['SETTINGS'] = array('LEAD' => 'Y', 'CONTACT' => 'Y', 'COMPANY' => 'Y', 'DEAL' => 'Y');
}
//
//.........这里部分代码省略.........
示例11: GetFieldInputValuePrintable
public function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
{
$result = $fieldValue;
switch ($arFieldType['Type']) {
case "user":
if (!is_array($fieldValue)) {
$fieldValue = array($fieldValue);
}
$result = CBPHelper::UsersArrayToString($fieldValue, null, array("lists", "BizprocDocument", $documentType));
break;
case "bool":
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
$result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
}
} else {
$result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
}
break;
case "file":
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
$r = intval($r);
$dbImg = CFile::GetByID($r);
if ($arImg = $dbImg->Fetch()) {
$result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
}
}
} else {
$fieldValue = intval($fieldValue);
$dbImg = CFile::GetByID($fieldValue);
if ($arImg = $dbImg->Fetch()) {
$result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
}
}
break;
case "select":
if (is_array($arFieldType["Options"])) {
if (is_array($fieldValue)) {
$result = array();
foreach ($fieldValue as $r) {
if (array_key_exists($r, $arFieldType["Options"])) {
$result[] = $arFieldType["Options"][$r];
}
}
} else {
if (array_key_exists($fieldValue, $arFieldType["Options"])) {
$result = $arFieldType["Options"][$fieldValue];
}
}
}
break;
}
if (strpos($arFieldType['Type'], ":") !== false) {
if ($arFieldType["Type"] == "S:employee") {
$fieldValue = CBPHelper::StripUserPrefix($fieldValue);
}
$arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2));
if (array_key_exists("GetPublicViewHTML", $arCustomType)) {
if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
$result = array();
foreach ($fieldValue as $value) {
$r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), ""));
$result[] = HTMLToTxt($r);
}
} else {
$result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), ""));
$result = HTMLToTxt($result);
}
}
}
return $result;
}
示例12: ExtractValuesFromVariables
private static function ExtractValuesFromVariables($ar, $arVars)
{
if (is_string($ar) && preg_match("/^\\{=([A-Za-z0-9_]+)\\:([A-Za-z0-9_]+)\\}\$/i", $ar, $arMatches)) {
$ar = array($arMatches[1], $arMatches[2]);
}
if (is_array($ar)) {
if (!CBPHelper::IsAssociativeArray($ar)) {
if (count($ar) == 2 && $ar[0] == "Variable") {
if (is_array($arVars) && array_key_exists($ar[1], $arVars)) {
return array($arVars[$ar[1]]["Default"]);
}
}
$arResult = array();
foreach ($ar as $ar1) {
$arResult[] = self::ExtractValuesFromVariables($ar1, $arVars);
}
return $arResult;
}
}
return $ar;
}
示例13: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$arProperties = array("Fields" => array());
$arTaskPriority = array(0, 1, 2);
foreach ($arTaskPriority as $k => $v) {
$arTaskPriority[$v] = GetMessage("TASK_PRIORITY_" . $v);
}
$arGroups = array(GetMessage("TASK_EMPTY_GROUP"));
if (CModule::IncludeModule("socialnetwork")) {
$db = CSocNetGroup::GetList(array("NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME"));
while ($ar = $db->GetNext()) {
$arGroups[$ar["ID"]] = "[" . $ar["ID"] . "]" . $ar["NAME"];
}
}
$arDF = self::__GetFields();
foreach (static::$arAllowedTasksFieldNames as $field) {
$r = null;
if (in_array($field, array("CREATED_BY", "RESPONSIBLE_ID", "ACCOMPLICES", "AUDITORS"))) {
$value = $arCurrentValues[$field];
if (strlen($value) > 0) {
$arErrorsTmp = array();
$r = CBPHelper::UsersStringToArray($value, $documentType, $arErrorsTmp);
if (count($arErrorsTmp) > 0) {
$arErrors = array_merge($arErrors, $arErrorsTmp);
}
}
} elseif (array_key_exists($field, $arCurrentValues) || array_key_exists($field . "_text", $arCurrentValues)) {
$arValue = array();
if (array_key_exists($field, $arCurrentValues)) {
$arValue = $arCurrentValues[$field];
if (!is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue)) {
$arValue = array($arValue);
}
}
if (array_key_exists($field . "_text", $arCurrentValues)) {
$arValue[] = $arCurrentValues[$field . "_text"];
}
foreach ($arValue as $value) {
$value = trim($value);
if (!preg_match("#^\\{=[a-z0-9_]+:[a-z0-9_]+\\}\$#i", $value) && substr($value, 0, 1) !== "=") {
if ($field == "PRIORITY") {
if (strlen($value) <= 0) {
$value = null;
}
if ($value != null && !array_key_exists($value, $arTaskPriority)) {
$value = null;
$arErrors[] = array("code" => "ErrorValue", "message" => "Priority is empty", "parameter" => $field);
}
} elseif ($field == "GROUP_ID") {
if (strlen($value) <= 0) {
$value = null;
}
if ($value != null && !array_key_exists($value, $arGroups)) {
$value = null;
$arErrors[] = array("code" => "ErrorValue", "message" => "Group is empty", "parameter" => $field);
}
} elseif (in_array($field, array("ALLOW_CHANGE_DEADLINE", "TASK_CONTROL", "ADD_IN_REPORT", 'ALLOW_TIME_TRACKING'))) {
if (strtoupper($value) == "Y" || $value === true || $value . "!" == "1!") {
$value = "Y";
} elseif (strtoupper($value) == "N" || $value === false || $value . "!" == "0!") {
$value = "N";
} else {
$value = null;
}
} else {
if (!is_array($value) && strlen($value) <= 0) {
$value = null;
}
}
}
if ($value != null) {
$r[] = $value;
}
}
}
$r_orig = $r;
if (!in_array($field, array("ACCOMPLICES", "AUDITORS"))) {
if (count($r) > 0) {
$r = $r[0];
} else {
$r = null;
}
}
if (in_array($field, array("TITLE", "CREATED_BY", "RESPONSIBLE_ID")) && ($r == null || is_array($r) && count($r) <= 0)) {
$arErrors[] = array("code" => "emptyRequiredField", "message" => str_replace("#FIELD#", $arDF[$field]["Name"], GetMessage("BPCDA_FIELD_REQUIED")));
}
$arProperties["Fields"][$field] = $r;
if (array_key_exists($field . "_text", $arCurrentValues) && isset($r_orig[1])) {
$arProperties["Fields"][$field . '_text'] = $r_orig[1];
}
}
$arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("TASKS_TASK", 0, LANGUAGE_ID);
foreach ($arUserFields as $field) {
$r = $arCurrentValues[$field["FIELD_NAME"]];
if ($field["MULTIPLE"] == "Y" && (!$r || is_array($r) && count($r) <= 0)) {
$arErrors[] = array("code" => "emptyRequiredField", "message" => str_replace("#FIELD#", $field["EDIT_FORM_LABEL"], GetMessage("BPCDA_FIELD_REQUIED")));
}
$arProperties["Fields"][$field["FIELD_NAME"]] = $r;
}
//.........这里部分代码省略.........
示例14: CreateDocument
/**
* ћетод создает новый документ с указанными свойствами (пол¤ми).
*
* @param array $arFields - массив значений свойств документа в виде array(код_свойства => значение, ...). оды свойств соответствуют кодам свойств, возвращаемым методом GetDocumentFields.
* @return int - код созданного документа.
*/
public function CreateDocument($parentDocumentId, $arFields)
{
if (!array_key_exists("IBLOCK_ID", $arFields) || intval($arFields["IBLOCK_ID"]) <= 0) {
throw new Exception("IBlock ID is not found");
}
$arFieldsPropertyValues = array();
$arDocumentFields = self::GetDocumentFields("iblock_" . $arFields["IBLOCK_ID"]);
$arKeys = array_keys($arFields);
$listId = array();
foreach ($arKeys as $key) {
if (!array_key_exists($key, $arDocumentFields)) {
continue;
}
$arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
$realKey = substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_" ? substr($key, strlen("PROPERTY_")) : $key;
if ($arDocumentFields[$key]["Type"] == "user") {
$ar = array();
foreach ($arFields[$key] as $v1) {
if (substr($v1, 0, strlen("user_")) == "user_") {
$ar[] = substr($v1, strlen("user_"));
} else {
$a1 = self::GetUsersFromUserGroup($v1, $parentDocumentId);
foreach ($a1 as $a11) {
$ar[] = $a11;
}
}
}
$arFields[$key] = $ar;
} elseif ($arDocumentFields[$key]["Type"] == "select") {
$arV = array();
$db = CIBlockProperty::GetPropertyEnum($realKey, false, array("IBLOCK_ID" => $arFields["IBLOCK_ID"]));
while ($ar = $db->GetNext()) {
$arV[$ar["XML_ID"]] = $ar["ID"];
}
$listValue = array();
foreach ($arFields[$key] as &$value) {
if (CBPHelper::isAssociativeArray($value)) {
$listXmlId = array_keys($value);
foreach ($listXmlId as $xmlId) {
$listValue[] = $arV[$xmlId];
}
} else {
if (array_key_exists($value, $arV)) {
$value = $arV[$value];
}
}
}
if (!empty($listValue)) {
$arFields[$key] = $listValue;
}
} elseif ($arDocumentFields[$key]["Type"] == "file") {
foreach ($arFields[$key] as &$value) {
$value = CFile::MakeFileArray($value);
}
} elseif ($arDocumentFields[$key]["Type"] == "S:DiskFile") {
foreach ($arFields[$key] as &$value) {
if (is_array($value)) {
foreach ($value as $attachId) {
$listId[$realKey][] = $attachId;
}
} else {
$listId[$realKey][] = $value;
}
}
} elseif ($arDocumentFields[$key]["Type"] == "S:HTML") {
foreach ($arFields[$key] as &$value) {
$value = array("VALUE" => $value);
}
}
if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
if (count($arFields[$key]) > 0) {
$a = array_values($arFields[$key]);
$arFields[$key] = $a[0];
} else {
$arFields[$key] = null;
}
}
if (substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_") {
$realKey = substr($key, strlen("PROPERTY_"));
$arFieldsPropertyValues[$realKey] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
unset($arFields[$key]);
}
}
if (count($arFieldsPropertyValues) > 0) {
$arFields["PROPERTY_VALUES"] = $arFieldsPropertyValues;
}
$iblockElement = new CIBlockElement();
$id = $iblockElement->Add($arFields, false, true, true);
if (!$id || $id <= 0) {
throw new Exception($iblockElement->LAST_ERROR);
}
/* Attaching files from the disk to the iblock element */
if (!empty($listId)) {
$fields = array();
//.........这里部分代码省略.........
示例15: MakeArrayFlat
public static function MakeArrayFlat($ar)
{
if (!is_array($ar)) {
return array($ar);
}
$result = array();
if (!CBPHelper::IsAssociativeArray($ar) && count($ar) == 2 && in_array($ar[0], array("Variable", "Document", "Template", "Workflow", "User", "System")) && is_string($ar[1])) {
$result[] = $ar;
return $result;
}
foreach ($ar as $val) {
if (!is_array($val)) {
if (trim($val) !== "") {
$result[] = $val;
}
} else {
foreach (self::MakeArrayFlat($val) as $val1) {
$result[] = $val1;
}
}
}
return $result;
}