...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
- Класс: \CCrmInstantEditorHelper
- Вызов: CCrmInstantEditorHelper::CreateField
static function CreateField($fieldID, $fieldName, $fieldTemplateName, $fieldValues, &$formFields, $fieldParams = array(), $ignoreIfEmpty = true) { $fieldID = strval($fieldID); $fieldName = strval($fieldName); $fieldTemplateName = strval($fieldTemplateName); if(!isset(self::$TEMPLATES[$fieldTemplateName])) { return false; } $field = array( 'id' => $fieldID, 'name' => $fieldName ); if($fieldTemplateName === 'FULL_NAME') { $field['type'] = 'custom'; $field['value'] = str_replace( array( '#VALUE_1#', '#NAME_1#', '#VALUE_2#', '#NAME_2#', '#VALUE_3#', '#NAME_3#', ), array( isset($fieldValues['LAST_NAME']) ? htmlspecialcharsbx($fieldValues['LAST_NAME']) : '', 'LAST_NAME', isset($fieldValues['NAME']) ? htmlspecialcharsbx($fieldValues['NAME']) : '', 'NAME', isset($fieldValues['SECOND_NAME']) ? htmlspecialcharsbx($fieldValues['SECOND_NAME']) : '', 'SECOND_NAME' ), self::$TEMPLATES[$fieldTemplateName] ); } elseif($fieldTemplateName === 'INPUT' || $fieldTemplateName === 'TEXT_AREA') { $value = isset($fieldValues['VALUE']) ? htmlspecialcharsbx($fieldValues['VALUE']) : ''; if($value === '' && $ignoreIfEmpty) { // IGNORE EMPTY VALUES (INSERT STUB ONLY) $field['type'] = 'label'; $field['value'] = ''; } else { if($fieldTemplateName === 'TEXT_AREA') { //Convert NL, CR chars to BR tags $value = str_replace(array("\r", "\n"), '', nl2br($value)); } $field['type'] = 'custom'; $field['value'] = str_replace( array( '#VALUE#', '#NAME#' ), array( $value, $fieldID ), self::$TEMPLATES[$fieldTemplateName] ); } } elseif($fieldTemplateName === 'SELECT') { $value = isset($fieldValues['VALUE']) ? $fieldValues['VALUE'] : ''; $text = isset($fieldValues['TEXT']) ? $fieldValues['TEXT'] : ''; $class = isset($fieldValues['CLASS']) ? $fieldValues['CLASS'] : ''; $options = isset($fieldValues['OPTIONS']) && is_array($fieldValues['OPTIONS']) ? $fieldValues['OPTIONS'] : array(); $optionHtml = ''; if(!empty($options)) { foreach($options as $k => &$v) { $optionHtml .= ''; } unset($v); } if($class !== '') { $class = ' '.$class; } $field['type'] = 'custom'; $field['value'] = str_replace( array( '#NAME#', '#VALUE#', '#TEXT#', '#CLASS#', '#OPTIONS_HTML#' ), array( $fieldID, htmlspecialcharsbx($value), htmlspecialcharsbx($text), htmlspecialcharsbx($class), $optionHtml ), self::$TEMPLATES[$fieldTemplateName] ); } elseif($fieldTemplateName === 'LHE') { $value = isset($fieldValues['VALUE']) ? $fieldValues['VALUE'] : ''; if($value === '' && $ignoreIfEmpty) { // IGNORE EMPTY VALUES (INSERT STUB ONLY) $field['type'] = 'label'; $field['value'] = ''; } else { $editorID = isset($fieldValues['EDITOR_ID']) ? $fieldValues['EDITOR_ID'] : ''; if($editorID ==='') { $editorID = uniqid('LHE_'); } $editorJsName = isset($fieldValues['EDITOR_JS_NAME']) ? $fieldValues['EDITOR_JS_NAME'] : ''; if($editorJsName ==='') { $editorJsName = $editorID; } if(!self::$IS_FILEMAN_INCLUDED) { CModule::IncludeModule('fileman'); self::$IS_FILEMAN_INCLUDED = true; } ob_start(); $editor = new CLightHTMLEditor; $editor->Show( array( 'id' => $editorID, 'height' => '150', 'bUseFileDialogs' => false, 'bFloatingToolbar' => false, 'bArisingToolbar' => false, 'bResizable' => false, 'jsObjName' => $editorJsName, 'bInitByJS' => false, // TODO: Lazy initialization 'bSaveOnBlur' => true, 'bHandleOnPaste'=> false, 'toolbarConfig' => array( 'Bold', 'Italic', 'Underline', 'Strike', 'BackColor', 'ForeColor', 'CreateLink', 'DeleteLink', 'InsertOrderedList', 'InsertUnorderedList', 'Outdent', 'Indent' ) ) ); $lheHtml = ob_get_contents(); ob_end_clean(); $wrapperID = isset($fieldValues['WRAPPER_ID']) ? $fieldValues['WRAPPER_ID'] : ''; if($wrapperID ==='') { $wrapperID = $editorID.'_WRAPPER'; } $field['type'] = 'custom'; $field['value'] = str_replace( array( '#TEXT#', '#VALUE#', '#NAME#', '#SETTINGS#', '#WRAPPER_ID#', '#HTML#' ), array( $value, htmlspecialcharsbx($value), $fieldID, htmlspecialcharsbx('{ "id":"'.CUtil::JSEscape($editorID).'", "wrapperId":"'.CUtil::JSEscape($wrapperID).'", "jsName":"'.CUtil::JSEscape($editorJsName).'" }'), $wrapperID, $lheHtml ), self::$TEMPLATES[$fieldTemplateName] ); } } $formFields[] = !empty($fieldParams) ? array_merge($field, $fieldParams) : $field; return true; }