public static function GetFieldInputControl($parameterDocumentType, $fieldType, $fieldName, $fieldValue, $bAllowSelection = false, $publicMode = false) { list($moduleId, $entity, $documentType) = CBPHelper::ParseDocumentId($parameterDocumentType); if (strlen($moduleId) > 0) { CModule::IncludeModule($moduleId); } if (is_array($fieldType)) { $arFieldType = array("Type" => null, "Multiple" => false, "Required" => false, "Options" => null); foreach ($fieldType as $key => $val) { switch (strtoupper($key)) { case "TYPE": case "0": $arFieldType["Type"] = strval($val); break; case "MULTIPLE": case "1": $arFieldType["Multiple"] = !$val || is_int($val) && $val == 0 || strtoupper($val) == "N" ? false : true; break; case "REQUIRED": case "2": $arFieldType["Required"] = !$val || is_int($val) && $val == 0 || strtoupper($val) == "N" ? false : true; break; case "OPTIONS": case "3": $arFieldType["Options"] = $val; break; } } } else { $arFieldType = array("Type" => strval($fieldType), "Multiple" => false, "Required" => false, "Options" => null); } if ((string) $arFieldType["Type"] == "") { return ""; } if (is_array($fieldName)) { $arFieldName = array("Form" => null, "Field" => null); foreach ($fieldName as $key => $val) { switch (strtoupper($key)) { case "FORM": case "0": $arFieldName["Form"] = $val; break; case "FIELD": case "1": $arFieldName["Field"] = $val; break; } } } else { $arFieldName = array("Form" => null, "Field" => $fieldName); } if ((string) $arFieldName["Field"] == "" || preg_match("#[^a-z0-9_]#i", $arFieldName["Field"])) { return ""; } if ((string) $arFieldName["Form"] != "" && preg_match("#[^a-z0-9_]#i", $arFieldName["Form"])) { return ""; } if ($publicMode && !array_key_exists("BP_AddShowParameterInit_" . $moduleId . "_" . $entity . "_" . $documentType, $GLOBALS)) { $GLOBALS["BP_AddShowParameterInit_" . $moduleId . "_" . $entity . "_" . $documentType] = 1; CBPDocument::AddShowParameterInit($moduleId, "only_users", $documentType, $entity); } if (class_exists($entity)) { if (method_exists($entity, "GetFieldInputControl")) { return call_user_func_array(array($entity, "GetFieldInputControl"), array($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection, $publicMode)); } if (method_exists($entity, "GetGUIFieldEdit")) { return call_user_func_array(array($entity, "GetGUIFieldEdit"), array($documentType, $arFieldName["Form"], $arFieldName["Field"], $fieldValue, $arFieldType, $bAllowSelection)); } } return CBPHelper::GetFieldInputControl($parameterDocumentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection); }
public function GetFieldInputControl($parameterDocumentType, $fieldType, $fieldName, $fieldValue, $bAllowSelection = false, $publicMode = false) { list($moduleId, $entity, $documentType) = CBPHelper::ParseDocumentId($parameterDocumentType); if (strlen($moduleId) > 0) { CModule::IncludeModule($moduleId); } $arFieldType = FieldType::normalizeProperty($fieldType); if ((string) $arFieldType["Type"] == "") { return ""; } if (is_array($fieldName)) { $arFieldName = array("Form" => null, "Field" => null); foreach ($fieldName as $key => $val) { switch (strtoupper($key)) { case "FORM": case "0": $arFieldName["Form"] = $val; break; case "FIELD": case "1": $arFieldName["Field"] = $val; break; } } } else { $arFieldName = array("Form" => null, "Field" => $fieldName); } if ((string) $arFieldName["Field"] == "" || preg_match("#[^a-z0-9_]#i", $arFieldName["Field"])) { return ""; } if ((string) $arFieldName["Form"] != "" && preg_match("#[^a-z0-9_]#i", $arFieldName["Form"])) { return ""; } if ($publicMode && !array_key_exists("BP_AddShowParameterInit_" . $moduleId . "_" . $entity . "_" . $documentType, $GLOBALS)) { $GLOBALS["BP_AddShowParameterInit_" . $moduleId . "_" . $entity . "_" . $documentType] = 1; CBPDocument::AddShowParameterInit($moduleId, "only_users", $documentType, $entity); } $fieldTypeObject = $this->getFieldTypeObject($parameterDocumentType, $arFieldType); if ($fieldTypeObject) { $renderMode = $publicMode ? 0 : FieldType::RENDER_MODE_DESIGNER; if (defined('ADMIN_SECTION') && ADMIN_SECTION) { $renderMode = $renderMode | FieldType::RENDER_MODE_ADMIN; } return $fieldTypeObject->renderControl($arFieldName, $fieldValue, $bAllowSelection, $renderMode); } if (class_exists($entity)) { if (method_exists($entity, "GetFieldInputControl")) { return call_user_func_array(array($entity, "GetFieldInputControl"), array($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection, $publicMode)); } if (method_exists($entity, "GetGUIFieldEdit")) { return call_user_func_array(array($entity, "GetGUIFieldEdit"), array($documentType, $arFieldName["Form"], $arFieldName["Field"], $fieldValue, $arFieldType, $bAllowSelection)); } } return CBPHelper::GetFieldInputControl($parameterDocumentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection); }