...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
- Класс: \CCrmInstantEditorHelper
- Вызов: CCrmInstantEditorHelper::CreateMultiFields
static function CreateMultiFields($fieldTypeID, &$fieldValues, &$formFields, $fieldParams = array(), $readOnlyMode = true) { $fieldTypeID = mb_strtoupper(strval($fieldTypeID)); if($fieldTypeID === '' || !is_array($fieldValues) || count($fieldValues) === 0 || !is_array($formFields)) { return false; } if(!is_array($fieldParams)) { $fieldParams = array(); } foreach($fieldValues as $ID => &$data) { $valueType = isset($data['VALUE_TYPE'])? mb_strtoupper($data['VALUE_TYPE']) : ''; $value = isset($data['VALUE']) ? $data['VALUE'] : ''; $fieldID = "FM.{$fieldTypeID}.{$valueType}"; $field = array( 'id' => $fieldID, 'name' => CCrmFieldMulti::GetEntityName($fieldTypeID, $valueType, true) ); if($readOnlyMode) { $field['type'] = 'label'; $field['value'] = CCrmFieldMulti::GetTemplate($fieldTypeID, $valueType, $value); } else { $templateType = 'INPUT'; $editorFieldType = mb_strtolower($fieldTypeID); if($fieldTypeID === 'PHONE' || $fieldTypeID === 'EMAIL' || $fieldTypeID === 'WEB') { $templateType = '_LINK_'; if($fieldTypeID === 'WEB') { if($valueType !== 'WORK' && $valueType !== 'HOME' && $valueType !== 'OTHER') { $editorFieldType .= '-'.mb_strtolower($valueType); } } } elseif($fieldTypeID === 'IM') { $templateType = $valueType === 'SKYPE' || $valueType === 'ICQ' || $valueType === 'MSN' ? '_LINK_' : 'INPUT'; $editorFieldType .= '-'.mb_strtolower($valueType); } $template = isset(self::$TEMPLATES[$templateType]) ? self::$TEMPLATES[$templateType] : ''; if($template === '') { $field['type'] = 'label'; $field['value'] = CCrmFieldMulti::GetTemplate($fieldTypeID, $valueType, $value); } else { $viewValue = $value; if($fieldTypeID === 'PHONE') { $viewValue = CCrmCallToUrl::Format($value); } elseif($fieldTypeID === 'EMAIL') { $viewValue = "mailto:{$value}"; } elseif($fieldTypeID === 'WEB') { if($valueType === 'OTHER' || $valueType === 'WORK' || $valueType === 'HOME') { $hasProto = preg_match('/^http(?:s)?:\/\/(.+)/', $value, $urlMatches) > 0; if($hasProto) { $value = $urlMatches[1]; } else { $viewValue = "http://{$value}"; } } elseif($valueType === 'FACEBOOK') { $viewValue = "http://www.facebook.com/{$value}/"; } elseif($valueType === 'TWITTER') { $viewValue = "http://twitter.com/{$value}/"; } elseif($valueType === 'LIVEJOURNAL') { $viewValue = "http://{$value}.livejournal.com/"; } } elseif($fieldTypeID === 'IM') { if($valueType === 'SKYPE') { $viewValue = "skype:{$value}?chat"; } elseif($valueType === 'ICQ') { $viewValue = "http://www.icq.com/people/{$value}/"; } elseif($valueType === 'MSN') { $viewValue = "msn:{$value}"; } } $field['type'] = 'custom'; $field['value'] = str_replace( array('#NAME#', '#FIELD_TYPE#', '#VALUE#', '#VIEW_VALUE#'), array($fieldID, htmlspecialcharsbx($editorFieldType), htmlspecialcharsbx($value), htmlspecialcharsbx($viewValue)), $template ); } } $formFields[] = !empty($fieldParams) ? array_merge($field, $fieldParams) : $field; } unset($data); return true; }