- Модуль: lists
- Путь к файлу: ~/bitrix/modules/lists/lib/bizprocdocument.php
- Класс: BizprocDocument
- Вызов: BizprocDocument::GetFieldInputControl
static function GetFieldInputControl($documentType, $fieldType, $fieldName, $fieldValue, $allowSelection = false, $publicMode = false)
{
$iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
if ($iblockId <= 0)
throw new CBPArgumentOutOfRangeException("documentType", $documentType);
static $documentFieldTypes = array();
if (!array_key_exists($documentType, $documentFieldTypes))
$documentFieldTypes[$documentType] = self::getDocumentFieldTypes($documentType);
$fieldType["BaseType"] = "string";
$fieldType["Complex"] = false;
if (array_key_exists($fieldType["Type"], $documentFieldTypes[$documentType]))
{
$fieldType["BaseType"] = $documentFieldTypes[$documentType][$fieldType["Type"]]["BaseType"];
$fieldType["Complex"] = $documentFieldTypes[$documentType][$fieldType["Type"]]["Complex"];
}
if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::isAssociativeArray($fieldValue))
$fieldValue = array($fieldValue);
$customMethodName = "";
$customMethodNameMulty = "";
if (mb_strpos($fieldType["Type"], ":") !== false)
{
$ar = CIBlockProperty::getUserType(mb_substr($fieldType["Type"], 2));
if (array_key_exists("GetPublicEditHTML", $ar))
$customMethodName = $ar["GetPublicEditHTML"];
if (array_key_exists("GetPublicEditHTMLMulty", $ar))
$customMethodNameMulty = $ar["GetPublicEditHTMLMulty"];
}
ob_start();
if ($fieldType["Type"] == "select")
{
$fieldValueTmp = $fieldValue;
?>
if ($allowSelection)
{
?>
_text" name="= htmlspecialcharsbx($fieldName["Field"]) ?>_text" value="
if (count($fieldValueTmp) > 0)
{
$a = array_values($fieldValueTmp);
echo htmlspecialcharsbx($a[0]);
}
?>">
_text', 'select');">
}
}
elseif ($fieldType["Type"] == "user")
{
$fieldValue = CBPHelper::usersArrayToString($fieldValue, null, array("lists", get_called_class(), $documentType));
?>" name="= htmlspecialcharsbx($fieldName["Field"]) ?>" value="= htmlspecialcharsbx($fieldValue) ?>">', 'user');">
}
elseif ((mb_strpos($fieldType["Type"], ":") !== false)
&& $fieldType["Multiple"]
&& (
is_array($customMethodNameMulty) && count($customMethodNameMulty) > 0
|| !is_array($customMethodNameMulty) && $customMethodNameMulty <> ''
)
)
{
if (!is_array($fieldValue))
$fieldValue = array();
if ($allowSelection)
{
$fieldValueTmp1 = array();
$fieldValueTmp2 = array();
foreach ($fieldValue as $v)
{
$vTrim = trim($v);
if (CBPDocument::IsExpression($vTrim))
$fieldValueTmp1[] = $vTrim;
else
$fieldValueTmp2[] = $v;
}
}
else
{
$fieldValueTmp1 = array();
$fieldValueTmp2 = $fieldValue;
}
if (($fieldType["Type"] == "S:employee") && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y")
$fieldValueTmp2 = CBPHelper::stripUserPrefix($fieldValueTmp2);
foreach ($fieldValueTmp2 as &$fld)
if (!isset($fld['VALUE']))
$fld = array("VALUE" => $fld);
if ($fieldType["Type"] == "E:EList")
{
static $fl = true;
if ($fl)
{
if (!empty($_SERVER['HTTP_BX_AJAX']))
$GLOBALS["APPLICATION"]->showAjaxHead();
$GLOBALS["APPLICATION"]->addHeadScript('/bitrix/js/iblock/iblock_edit.js');
}
$fl = false;
}
echo call_user_func_array(
$customMethodNameMulty,
array(
array("LINK_IBLOCK_ID" => $fieldType["Options"]),
$fieldValueTmp2,
array(
"FORM_NAME" => $fieldName["Form"],
"VALUE" => htmlspecialcharsbx($fieldName["Field"])
),
true
)
);
if ($allowSelection)
{
?>
_text" name="= htmlspecialcharsbx($fieldName["Field"]) ?>_text" value="
if (count($fieldValueTmp1) > 0)
{
$a = array_values($fieldValueTmp1);
echo htmlspecialcharsbx($a[0]);
}
?>">
_text', 'user', '= $fieldType["Type"] == 'S:employee'? 'employee' : '' ?>');">
}
}
else
{
if (!array_key_exists("CBPVirtualDocumentCloneRowPrinted", $GLOBALS) && $fieldType["Multiple"])
{
$GLOBALS["CBPVirtualDocumentCloneRowPrinted"] = 1;
?>
}
if ($fieldType["Multiple"])
echo '| '; if (is_array($customMethodName) && count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <> '') { if($fieldType["Type"] == "S:HTML") { if (Loader::includeModule("fileman")) { $editor = new CHTMLEditor; $res = array_merge( array( 'useFileDialogs' => false, 'height' => 200, 'useFileDialogs' => false, 'minBodyWidth' => 350, 'normalBodyWidth' => 555, 'bAllowPhp' => false, 'limitPhpAccess' => false, 'showTaskbars' => false, 'showNodeNavi' => false, 'askBeforeUnloadPage' => true, 'bbCode' => false, 'siteId' => SITE_ID, 'autoResize' => true, 'autoResizeOffset' => 40, 'saveOnBlur' => true, 'actionUrl' => '/bitrix/tools/html_editor_action.php', 'controlsMap' => array( array('id' => 'Bold', 'compact' => true, 'sort' => 80), array('id' => 'Italic', 'compact' => true, 'sort' => 90), array('id' => 'Underline', 'compact' => true, 'sort' => 100), array('id' => 'Strikeout', 'compact' => true, 'sort' => 110), array('id' => 'RemoveFormat', 'compact' => true, 'sort' => 120), array('id' => 'Color', 'compact' => true, 'sort' => 130), array('id' => 'FontSelector', 'compact' => false, 'sort' => 135), array('id' => 'FontSize', 'compact' => false, 'sort' => 140), array('separator' => true, 'compact' => false, 'sort' => 145), array('id' => 'OrderedList', 'compact' => true, 'sort' => 150), array('id' => 'UnorderedList', 'compact' => true, 'sort' => 160), array('id' => 'AlignList', 'compact' => false, 'sort' => 190), array('separator' => true, 'compact' => false, 'sort' => 200), array('id' => 'InsertLink', 'compact' => true, 'sort' => 210, 'wrap' => 'bx-b-link-'.$fieldNameId), array('id' => 'InsertImage', 'compact' => false, 'sort' => 220), array('id' => 'InsertVideo', 'compact' => true, 'sort' => 230, 'wrap' => 'bx-b-video-'.$fieldNameId), array('id' => 'InsertTable', 'compact' => false, 'sort' => 250), array('id' => 'Code', 'compact' => true, 'sort' => 260), array('id' => 'Quote', 'compact' => true, 'sort' => 270, 'wrap' => 'bx-b-quote-'.$fieldNameId), array('id' => 'Smile', 'compact' => false, 'sort' => 280), array('separator' => true, 'compact' => false, 'sort' => 290), array('id' => 'Fullscreen', 'compact' => false, 'sort' => 310), array('id' => 'BbCode', 'compact' => true, 'sort' => 340), array('id' => 'More', 'compact' => true, 'sort' => 400) ) ), array( 'name' => $fieldNameName, 'inputName' => $fieldNameName, 'id' => $fieldNameId, 'width' => '100%', 'content' => htmlspecialcharsBack($value), ) ); $editor->show($res); } else { ?> } } else { $value1 = $value; if ($allowSelection && CBPDocument::IsExpression(trim($value1))) $value1 = null; else unset($fieldValueTmp[$key]); if (($fieldType["Type"] == "S:employee") && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y") $value1 = CBPHelper::stripUserPrefix($value1); echo call_user_func_array( $customMethodName, array( array("LINK_IBLOCK_ID" => $fieldType["Options"]), array("VALUE" => $value1), array( "FORM_NAME" => $fieldName["Form"], "VALUE" => $fieldNameName ), true ) ); } } else { switch ($fieldType["Type"]) { case "int": case "double": unset($fieldValueTmp[$key]); ?> break; case "file": if ($publicMode) { //unset($fieldValueTmp[$key]); ?> } break; case "bool": if (in_array($value, array("Y", "N"))) unset($fieldValueTmp[$key]); ?> break; case "text": unset($fieldValueTmp[$key]); ?> break; case "date": case "datetime": if (defined("ADMIN_SECTION") && ADMIN_SECTION) { $v = ""; if (!CBPDocument::IsExpression(trim($value))) { $v = $value; unset($fieldValueTmp[$key]); } require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/interface/init_admin.php"); echo CAdminCalendar::calendarDate($fieldNameName, $v, 19, ($fieldType["Type"] != "date")); } else { $value1 = $value; if ($allowSelection && CBPDocument::IsExpression(trim($value1))) $value1 = null; else unset($fieldValueTmp[$key]); if($fieldType["Type"] == "date") $type = "Date"; else $type = "DateTime"; $ar = CIBlockProperty::getUserType($type); echo call_user_func_array( $ar["GetPublicEditHTML"], array( array("LINK_IBLOCK_ID" => $fieldType["Options"]), array("VALUE" => $value1), array( "FORM_NAME" => $fieldName["Form"], "VALUE" => $fieldNameName ), true ) ); } break; default: unset($fieldValueTmp[$key]); ?> } } if ($allowSelection) { if (!in_array($fieldType["Type"], array("file", "bool", "date", "datetime")) && (is_array($customMethodName) && count($customMethodName) <= 0 || !is_array($customMethodName) && $customMethodName == '')) { ?>');"> } } if ($fieldType["Multiple"]) echo ' |
'; } elseif($fieldType["Multiple"] && $fieldType["Type"] == "S:HTML") { $functionOnclick = 'CBPVirtualDocumentCloneRow('CBPVirtualDocument_'.$fieldName["Field"].'_Table');createAdditionalHtmlEditor('CBPVirtualDocument_'.$fieldName["Field"].'_Table');'; echo '
'; } if ($allowSelection) { if (in_array($fieldType["Type"], array("file", "bool", "date", "datetime")) || (is_array($customMethodName) && count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <> '')) { ?> _text" name="= htmlspecialcharsbx($fieldName["Field"]) ?>_text" value=" if (count($fieldValueTmp) > 0) { $a = array_values($fieldValueTmp); echo htmlspecialcharsbx($a[0]); } ?>"> _text', '= htmlspecialcharsbx($fieldType["BaseType"]) ?>', '= $fieldType["Type"] == 'S:employee'? 'employee' : '' ?>');"> } } } $s = ob_get_contents(); ob_end_clean(); return $s; }