public function GetFieldInputValuePrintable($documentType, $fieldType, $fieldValue) { $result = $fieldValue; switch ($fieldType['Type']) { case "user": if (!is_array($fieldValue)) { $fieldValue = array($fieldValue); } $result = CBPHelper::usersArrayToString($fieldValue, null, array("lists", get_called_class(), $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); $imgQuery = CFile::getByID($r); if ($img = $imgQuery->fetch()) { $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($img["FILE_NAME"]) . "&i=" . $r . "&h=" . md5($img["SUBDIR"]) . "]" . htmlspecialcharsbx($img["ORIGINAL_NAME"]) . "[/url]"; } } } else { $fieldValue = intval($fieldValue); $imgQuery = CFile::getByID($fieldValue); if ($img = $imgQuery->fetch()) { $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($img["FILE_NAME"]) . "&i=" . $fieldValue . "&h=" . md5($img["SUBDIR"]) . "]" . htmlspecialcharsbx($img["ORIGINAL_NAME"]) . "[/url]"; } } break; case "select": if (is_array($fieldType["Options"])) { if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { if (array_key_exists($r, $fieldType["Options"])) { $result[] = $fieldType["Options"][$r]; } } } else { if (array_key_exists($fieldValue, $fieldType["Options"])) { $result = $fieldType["Options"][$fieldValue]; } } } break; } if (strpos($fieldType['Type'], ":") !== false) { if ($fieldType["Type"] == "S:employee") { $fieldValue = CBPHelper::stripUserPrefix($fieldValue); } $customType = CIBlockProperty::getUserType(substr($fieldType['Type'], 2)); if (array_key_exists("GetPublicViewHTML", $customType)) { if (is_array($fieldValue) && !CBPHelper::isAssociativeArray($fieldValue)) { $result = array(); foreach ($fieldValue as $value) { $r = call_user_func_array($customType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $fieldType["Options"]), array("VALUE" => $value), "")); $result[] = HTMLToTxt($r); } } else { $result = call_user_func_array($customType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $fieldType["Options"]), array("VALUE" => $fieldValue), "")); $result = HTMLToTxt($result); } } } return $result; }
protected function getPropsList($iblockId, $skuPropertyId = 0) { $arResult = array(); $dbrFProps = \CIBlockProperty::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "!XML_ID" => "CML2_LINK", "CHECK_PERMISSIONS" => "N")); while ($arProp = $dbrFProps->getNext()) { if ($skuPropertyId == $arProp['ID']) { continue; } $arProp["PROPERTY_USER_TYPE"] = !empty($arProp["USER_TYPE"]) ? \CIBlockProperty::getUserType($arProp["USER_TYPE"]) : array(); $arResult[] = $arProp; } return $arResult; }
public static function getFieldInputControl($documentType, $fieldType, $fieldName, $fieldValue, $allowSelection = false, $publicMode = false) { global $USER_FIELD_MANAGER, $APPLICATION; $storageId = self::getStorageIdByType($documentType); if (!$storageId) { throw new CBPArgumentNullException('documentType'); } if (!$publicMode) { $APPLICATION->showAjaxHead(); } 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 (strpos($fieldType["Type"], ":") !== false) { $ar = \CIBlockProperty::getUserType(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; ?> <select id="id_<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> " style="width:280px" name="<?php echo htmlspecialcharsbx($fieldName["Field"]) . ($fieldType["Multiple"] ? "[]" : ""); ?> "<?php echo $fieldType["Multiple"] ? ' size="5" multiple' : ''; ?> > <?php if (!$fieldType['Required']) { echo '<option value="">[' . Loc::getMessage('DISK_FILED_NOT_SET') . ']</option>'; } foreach ($fieldType['Options'] as $k => $v) { $ind = array_search($k, $fieldValueTmp); echo '<option value="' . htmlspecialcharsbx($k) . '"' . ($ind !== false ? ' selected' : '') . '>' . htmlspecialcharsbx($v) . '</option>'; if ($ind !== false) { unset($fieldValueTmp[$ind]); } } ?> </select> <?php if ($allowSelection) { ?> <br /><input type="text" id="id_<?php echo htmlspecialcharsbx($fieldName['Field']); ?> _text" name="<?php echo htmlspecialcharsbx($fieldName['Field']); ?> _text" value="<?php if (count($fieldValueTmp) > 0) { $a = array_values($fieldValueTmp); echo htmlspecialcharsbx($a[0]); } ?> "> <input type="button" value="..." onclick="BPAShowSelector('id_<?php echo htmlspecialcharsbx($fieldName['Field']); ?> _text', 'select');"> <?php } } elseif ($fieldType['Type'] == 'user' || $fieldType['Type'] == static::getPrefixForCustomType() . 'employee') { $fieldValue = CBPHelper::usersArrayToString($fieldValue, null, self::generateDocumentComplexType($storageId)); ?> <input type="text" size="40" id="id_<?php echo htmlspecialcharsbx($fieldName['Field']); ?> " name="<?php echo htmlspecialcharsbx($fieldName['Field']); ?> " value="<?php echo htmlspecialcharsbx($fieldValue); ?> "> <input type="button" value="..." onclick="BPAShowSelector('id_<?php echo htmlspecialcharsbx($fieldName['Field']); ?> ', 'user');"><?php } elseif (strpos($fieldType["Type"], ":") !== false && $fieldType["Multiple"] && (is_array($customMethodNameMulty) && count($customMethodNameMulty) > 0 || !is_array($customMethodNameMulty) && strlen($customMethodNameMulty) > 0)) { if (!is_array($fieldValue)) { $fieldValue = array(); } if ($allowSelection) { $fieldValueTmp1 = array(); $fieldValueTmp2 = array(); foreach ($fieldValue as $v) { $vTrim = trim($v); if (preg_match("#^\\{=[a-z0-9_]+:[a-z0-9_]+\\}\$#i", $vTrim) || substr($vTrim, 0, 1) == "=") { $fieldValueTmp1[] = $vTrim; } else { $fieldValueTmp2[] = $v; } } } else { $fieldValueTmp1 = array(); $fieldValueTmp2 = $fieldValue; } if ($fieldType["Type"] == "E:EList") { static $fl = true; if ($fl) { $GLOBALS["APPLICATION"]->addHeadScript('/bitrix/js/iblock/iblock_edit.js'); } $fl = false; } $fieldValueTmp21 = array(); foreach ($fieldValueTmp2 as $k => $fld) { if ($fld === null || $fld === "") { continue; } if (is_array($fld) && isset($fld["VALUE"])) { $fieldValueTmp21[$k] = $fld; } else { $fieldValueTmp21[$k] = array("VALUE" => $fld); } } $fieldValueTmp2 = $fieldValueTmp21; 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) { ?> <br /><input type="text" id="id_<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> _text" name="<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> _text" value="<?php if (count($fieldValueTmp1) > 0) { $a = array_values($fieldValueTmp1); echo htmlspecialcharsbx($a[0]); } ?> "> <input type="button" value="..." onclick="BPAShowSelector('id_<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> _text', 'user');"> <?php } } else { if (!array_key_exists('CBPVirtualDocumentCloneRowPrinted_' . $documentType, $GLOBALS) && $fieldType['Multiple']) { $GLOBALS['CBPVirtualDocumentCloneRowPrinted_' . $documentType] = 1; ?> <script language="JavaScript"> function CBPVirtualDocumentCloneRow(tableId) { var tbl = document.getElementById(tableId); var cnt = tbl.rows.length; var oRow = tbl.insertRow(cnt); var oCell = oRow.insertCell(0); var sHTML = tbl.rows[cnt - 1].cells[0].innerHTML; var p = 0; while (true) { var s = sHTML.indexOf('[n', p); if (s < 0) break; var e = sHTML.indexOf(']', s); if (e < 0) break; var n = parseInt(sHTML.substr(s + 2, e - s)); sHTML = sHTML.substr(0, s) + '[n' + (++n) + ']' + sHTML.substr(e + 1); p = s + 1; } var p = 0; while (true) { var s = sHTML.indexOf('__n', p); if (s < 0) break; var e = sHTML.indexOf('_', s + 2); if (e < 0) break; var n = parseInt(sHTML.substr(s + 3, e - s)); sHTML = sHTML.substr(0, s) + '__n' + (++n) + '_' + sHTML.substr(e + 1); p = e + 1; } oCell.innerHTML = sHTML; var patt = new RegExp('<' + 'script' + '>[^\000]*?<' + '\/' + 'script' + '>', 'ig'); var code = sHTML.match(patt); if (code) { for (var i = 0; i < code.length; i++) { if (code[i] != '') { var s = code[i].substring(8, code[i].length - 9); BX.evalGlobal(s); } } } } function CBPVirtualDocumentCloneRowHtml(tableId) { CBPVirtualDocumentCloneRow(tableId); var htmlEditor = BX.findChildrenByClassName(BX(tableId), 'bx-html-editor'); for(var k in htmlEditor) { var editorId = htmlEditor[k].getAttribute('id'); var frameArray = BX.findChildrenByClassName(BX(editorId), 'bx-editor-iframe'); if(frameArray.length > 1) { for(var i = 0; i < frameArray.length - 1; i++) { frameArray[i].parentNode.removeChild(frameArray[i]); } } } } function createAdditionalHtmlEditor(tableId) { var tbl = document.getElementById(tableId); var cnt = tbl.rows.length-1; var name = tableId.replace(/(?:CBPVirtualDocument_)(.*)(?:_Table)/, '$1') var idEditor = 'id_'+name+'__n'+cnt+'_'; var inputNameEditor = name+'[n'+cnt+']'; window.BXHtmlEditor.Show( { 'id':idEditor, 'inputName':inputNameEditor, 'content':'', 'width':'100%', 'height':'200', 'allowPhp':false, 'limitPhpAccess':false, 'templates':[], 'templateId':'', 'templateParams':[], 'componentFilter':'', 'snippets':[], 'placeholder':'Text here...', 'actionUrl':'/bitrix/tools/html_editor_action.php', 'cssIframePath':'/bitrix/js/fileman/html_editor/iframe-style.css?1412693817', 'bodyClass':'', 'bodyId':'', 'spellcheck_path':'/bitrix/js/fileman/html_editor/html-spell.js?v=1412693817', 'usePspell':'N', 'useCustomSpell':'Y', 'bbCode':true, 'askBeforeUnloadPage':true, 'settingsKey':'user_settings_1', 'showComponents':true, 'showSnippets':true, 'view':'wysiwyg', 'splitVertical':false, 'splitRatio':'1', 'taskbarShown':false, 'taskbarWidth':'250', 'lastSpecialchars':false, 'cleanEmptySpans':true, 'lazyLoad':false, 'showTaskbars':false, 'showNodeNavi':false, 'controlsMap':[ {'id':'Bold','compact':true,'sort':'80'}, {'id':'Italic','compact':true,'sort':'90'}, {'id':'Underline','compact':true,'sort':'100'}, {'id':'Strikeout','compact':true,'sort':'110'}, {'id':'RemoveFormat','compact':true,'sort':'120'}, {'id':'Color','compact':true,'sort':'130'}, {'id':'FontSelector','compact':false,'sort':'135'}, {'id':'FontSize','compact':false,'sort':'140'}, {'separator':true,'compact':false,'sort':'145'}, {'id':'OrderedList','compact':true,'sort':'150'}, {'id':'UnorderedList','compact':true,'sort':'160'}, {'id':'AlignList','compact':false,'sort':'190'}, {'separator':true,'compact':false,'sort':'200'}, {'id':'InsertLink','compact':true,'sort':'210','wrap':'bx-b-link-'+idEditor}, {'id':'InsertImage','compact':false,'sort':'220'}, {'id':'InsertVideo','compact':true,'sort':'230','wrap':'bx-b-video-'+idEditor}, {'id':'InsertTable','compact':false,'sort':'250'}, {'id':'Code','compact':true,'sort':'260'}, {'id':'Quote','compact':true,'sort':'270','wrap':'bx-b-quote-'+idEditor}, {'id':'Smile','compact':false,'sort':'280'}, {'separator':true,'compact':false,'sort':'290'}, {'id':'Fullscreen','compact':false,'sort':'310'}, {'id':'BbCode','compact':true,'sort':'340'}, {'id':'More','compact':true,'sort':'400'}], 'autoResize':true, 'autoResizeOffset':'40', 'minBodyWidth':'350', 'normalBodyWidth':'555' }); var htmlEditor = BX.findChildrenByClassName(BX(tableId), 'bx-html-editor'); for(var k in htmlEditor) { var editorId = htmlEditor[k].getAttribute('id'); var frameArray = BX.findChildrenByClassName(BX(editorId), 'bx-editor-iframe'); if(frameArray.length > 1) { for(var i = 0; i < frameArray.length - 1; i++) { frameArray[i].parentNode.removeChild(frameArray[i]); } } } } </script> <?php } if ($fieldType['Multiple']) { echo '<table width="100%" border="0" cellpadding="2" cellspacing="2" id="CBPVirtualDocument_' . htmlspecialcharsbx($fieldName["Field"]) . '_Table">'; } $fieldValueTmp = $fieldValue; $ind = -1; foreach ($fieldValue as $key => $value) { $ind++; $fieldNameId = 'id_' . htmlspecialcharsbx($fieldName['Field']) . '__n' . $ind . '_'; $fieldNameName = htmlspecialcharsbx($fieldName['Field']) . ($fieldType['Multiple'] ? '[n' . $ind . ']' : ''); if ($fieldType['Multiple']) { echo '<tr><td>'; } if (strpos($fieldType['Type'], static::getPrefixForCustomType()) === 0) { $value1 = $value; if ($allowSelection && (preg_match("#^\\{=[a-z0-9_]+:[a-z0-9_]+\\}\$#i", trim($value1)) || substr(trim($value1), 0, 1) == "=")) { $value1 = null; } else { unset($fieldValueTmp[$key]); } $type = str_replace(static::getPrefixForCustomType(), '', $fieldType['Type']); $_REQUEST[$fieldName['Field']] = $value1; $userFieldType = $USER_FIELD_MANAGER->getUserType($type); $userField = array('ENTITY_ID' => 'DISK_FILE_' . $storageId, 'FIELD_NAME' => $fieldName['Field'], 'USER_TYPE_ID' => $type, 'SORT' => 100, 'MULTIPLE' => $fieldType['Multiple'] ? 'Y' : 'N', 'MANDATORY' => $fieldType['Required'] ? 'Y' : 'N', 'EDIT_IN_LIST' => 'Y', 'EDIT_FORM_LABEL' => $userFieldType['DESCRIPTION'], 'VALUE' => $value1, 'USER_TYPE' => $userFieldType, 'SETTINGS' => array()); if ($fieldType['Type'] == static::getPrefixForCustomType() . 'iblock_element' || $fieldType['Type'] == static::getPrefixForCustomType() . 'iblock_section' || $fieldType['Type'] == static::getPrefixForCustomType() . 'boolean') { $options = $fieldType['Options']; if (is_string($options)) { $userField['SETTINGS']['IBLOCK_ID'] = $options; } elseif (is_array($options)) { $userField['SETTINGS'] = $options; } } $APPLICATION->includeComponent('bitrix:system.field.edit', $type, array('arUserField' => $userField, 'bVarsFromForm' => true, 'form_name' => $fieldName['Form'], 'FILE_MAX_HEIGHT' => 400, 'FILE_MAX_WIDTH' => 400, 'FILE_SHOW_POPUP' => true), false, array('HIDE_ICONS' => 'Y')); } elseif (is_array($customMethodName) && count($customMethodName) > 0 || !is_array($customMethodName) && strlen($customMethodName) > 0) { if ($fieldType['Type'] == static::getPrefixForCustomType() . 'HTML') { if (Loader::includeModule("fileman")) { $editor = new \CHTMLEditor(); $res = array_merge(array('height' => 200, 'minBodyWidth' => 350, 'normalBodyWidth' => 555, 'bAllowPhp' => false, 'limitPhpAccess' => false, 'showTaskbars' => false, 'showNodeNavi' => false, 'askBeforeUnloadPage' => true, 'bbCode' => true, 'siteId' => SITE_ID, 'autoResize' => true, 'autoResizeOffset' => 40, 'saveOnBlur' => true, '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 { ?> <textarea rows="5" cols="40" id="<?php echo $fieldNameId; ?> " name="<?php echo $fieldNameName; ?> "><?php echo htmlspecialcharsbx($value); ?> </textarea><?php } } else { $value1 = $value; if ($allowSelection && (preg_match("#^\\{=[a-z0-9_]+:[a-z0-9_]+\\}\$#i", trim($value1)) || substr(trim($value1), 0, 1) == "=")) { $value1 = null; } else { unset($fieldValueTmp[$key]); } 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': unset($fieldValueTmp[$key]); ?> <input type='text' size='10' id='<?php echo $fieldNameId; ?> ' name='<?php echo $fieldNameName; ?> ' value='<?php echo htmlspecialcharsbx($value); ?> '><?php break; case 'file': if ($publicMode) { //unset($fieldValueTmp[$key]); ?> <input type="file" id="<?php echo $fieldNameId; ?> " name="<?php echo $fieldNameName; ?> "><?php } break; case 'bool': if (in_array($value, array('Y', 'N'))) { unset($fieldValueTmp[$key]); } ?> <select id='<?php echo $fieldNameId; ?> ' name='<?php echo $fieldNameName; ?> '> <?php if (!$fieldType['Required']) { echo '<option value="">[' . Loc::getMessage("DISK_FILED_NOT_SET") . ']</option>'; } ?> <option value="Y"<?php echo in_array("Y", $fieldValue) ? ' selected' : ''; ?> ><?php echo Loc::getMessage("DISK_YES"); ?> </option> <option value="N"<?php echo in_array("N", $fieldValue) ? ' selected' : ''; ?> ><?php echo Loc::getMessage("DISK_NO"); ?> </option> </select> <?php break; case "date": case "datetime": $v = ""; if (!preg_match("#^\\{=[a-z0-9_]+:[a-z0-9_]+\\}\$#i", trim($value)) && substr(trim($value), 0, 1) != "=") { $v = $value; unset($fieldValueTmp[$key]); } $APPLICATION->includeComponent('bitrix:main.calendar', '', array('SHOW_INPUT' => 'Y', 'FORM_NAME' => $fieldName['Form'], 'INPUT_NAME' => $fieldNameName, 'INPUT_VALUE' => $v, 'SHOW_TIME' => 'Y'), false, array('HIDE_ICONS' => 'Y')); break; case 'text': unset($fieldValueTmp[$key]); ?> <textarea rows="5" cols="40" id="<?php echo $fieldNameId; ?> " name="<?php echo $fieldNameName; ?> "><?php echo htmlspecialcharsbx($value); ?> </textarea><?php break; default: unset($fieldValueTmp[$key]); ?> <input type="text" size="40" id="<?php echo $fieldNameId; ?> " name="<?php echo $fieldNameName; ?> " value="<?php echo htmlspecialcharsbx($value); ?> "><?php } } if ($allowSelection) { if (!in_array($fieldType["Type"], array("file", "bool", "date", "datetime", static::getPrefixForCustomType() . "HTML")) && strpos($fieldType['Type'], static::getPrefixForCustomType()) !== 0) { ?> <input type="button" value="..." onclick="BPAShowSelector('<?php echo $fieldNameId; ?> ', '<?php echo $fieldType["BaseType"]; ?> ');"><?php } } if ($fieldType['Multiple']) { echo '</td></tr>'; } } if ($fieldType['Multiple']) { echo '</table>'; } if ($fieldType["Multiple"] && $fieldType['Type'] != static::getPrefixForCustomType() . 'HTML' && ($fieldType["Type"] != "file" || $publicMode)) { echo '<input type="button" value="' . Loc::getMessage("DISK_ADD") . '" onclick="CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_' . $fieldName["Field"] . '_Table\');"/><br />'; } elseif ($fieldType["Multiple"] && $fieldType['Type'] == static::getPrefixForCustomType() . 'HTML') { $functionOnclick = 'CBPVirtualDocumentCloneRowHtml(\'CBPVirtualDocument_' . $fieldName["Field"] . '_Table\');'; if (!$publicMode) { $functionOnclick = 'CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_' . $fieldName["Field"] . '_Table\');createAdditionalHtmlEditor(\'CBPVirtualDocument_' . $fieldName["Field"] . '_Table\');'; } echo '<input type="button" value="' . Loc::getMessage("DISK_ADD") . '" onclick="' . $functionOnclick . '"/><br />'; } if ($allowSelection) { if (in_array($fieldType['Type'], array('file', 'bool', "date", "datetime")) || strpos($fieldType['Type'], static::getPrefixForCustomType()) === 0) { ?> <input type="text" id="id_<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> _text" name="<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> _text" value="<?php if (count($fieldValueTmp) > 0) { $a = array_values($fieldValueTmp); echo htmlspecialcharsbx($a[0]); } ?> "> <input type="button" value="..." onclick="BPAShowSelector('id_<?php echo htmlspecialcharsbx($fieldName["Field"]); ?> _text', '<?php echo htmlspecialcharsbx($fieldType["BaseType"]); ?> ');"> <?php } } } $s = ob_get_contents(); ob_end_clean(); return $s; }
/** * Retruns GetPublicViewHTML handler function for $this->property. * Returns false if no handler defined. * * @return callable|false */ protected function getFormatFunction() { static $propertyFormatFunction = null; if (!isset($propertyFormatFunction)) { $propertyFormatFunction = false; if ($this->property && strlen($this->property["USER_TYPE"])) { $propertyUserType = \CIBlockProperty::getUserType($this->property["USER_TYPE"]); if (array_key_exists("GetPublicViewHTML", $propertyUserType) && is_callable($propertyUserType["GetPublicViewHTML"])) { $propertyFormatFunction = $propertyUserType["GetPublicViewHTML"]; } } } return $propertyFormatFunction; }
protected static function getUserType(FieldType $fieldType) { return \CIBlockProperty::getUserType(substr($fieldType->getType(), 2)); }
/** * @param integer $key Iblock element identifier. * @param array|mixed $property Iblock property array. */ function __construct($key, $property) { parent::__construct($key); if (is_array($property)) { $this->property = $property; if (strlen($property["USER_TYPE"])) { $propertyUserType = \CIBlockProperty::getUserType($property["USER_TYPE"]); if (array_key_exists("GetPublicViewHTML", $propertyUserType) && is_callable($propertyUserType["GetPublicViewHTML"])) { $this->propertyFormatFunction = $propertyUserType["GetPublicViewHTML"]; } } } }
public function OnAfterIBlockElementDelete($fields) { if (CModule::includeModule('bizproc')) { $errors = array(); $iblockType = COption::getOptionString("lists", "livefeed_iblock_type_id"); $iblockQuery = CIBlock::getList(array(), array('ID' => $fields['IBLOCK_ID'])); if ($iblock = $iblockQuery->fetch()) { $iblockType = $iblock["IBLOCK_TYPE_ID"]; } $states = CBPStateService::getDocumentStates(BizprocDocument::getDocumentComplexId($iblockType, $fields['ID'])); $listWorkflowId = array(); foreach ($states as $workflowId => $state) { $listWorkflowId[] = $workflowId; } self::deleteSocnetLog($listWorkflowId); CBPDocument::onDocumentDelete(BizprocDocument::getDocumentComplexId($iblockType, $fields['ID']), $errors); } $propertyQuery = CIBlockElement::getProperty($fields['IBLOCK_ID'], $fields['ID'], 'sort', 'asc', array('ACTIVE' => 'Y')); while ($property = $propertyQuery->fetch()) { $userType = \CIBlockProperty::getUserType($property['USER_TYPE']); if (array_key_exists('DeleteAllAttachedFiles', $userType)) { call_user_func_array($userType['DeleteAllAttachedFiles'], array($fields['ID'])); } } }
/** * @param string $documentId - document id. * @return array - document fields array. */ public function GetDocument($documentId) { $documentId = intval($documentId); if ($documentId <= 0) { throw new CBPArgumentNullException("documentId"); } $arResult = null; $dbDocumentList = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y")); if ($objDocument = $dbDocumentList->GetNextElement(false, true)) { $arDocumentFields = $objDocument->GetFields(); $arDocumentProperties = $objDocument->GetProperties(); foreach ($arDocumentFields as $fieldKey => $fieldValue) { if (substr($fieldKey, 0, 1) == "~") { continue; } $arResult[$fieldKey] = $fieldValue; if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) { $arResult[$fieldKey] = "user_" . $fieldValue; $arResult[$fieldKey . "_PRINTABLE"] = $arDocumentFields[$fieldKey == "MODIFIED_BY" ? "USER_NAME" : "CREATED_USER_NAME"]; } elseif (in_array($fieldKey, array("PREVIEW_TEXT", "DETAIL_TEXT"))) { if ($arDocumentFields[$fieldKey . "_TYPE"] == "html") { $arResult[$fieldKey] = HTMLToTxt($arDocumentFields["~" . $fieldKey]); } } } foreach ($arDocumentProperties as $propertyKey => $propertyValue) { if (strlen($propertyValue["USER_TYPE"]) > 0) { if ($propertyValue["USER_TYPE"] == "UserID" || $propertyValue["USER_TYPE"] == "employee" && COption::GetOptionString("bizproc", "employee_compatible_mode", "N") != "Y") { if (!is_array($propertyValue["VALUE"])) { $propertyValue["VALUE"] = array($propertyValue["VALUE"]); } $listUsers = implode(' | ', $propertyValue["VALUE"]); $userQuery = CUser::getList($by = 'ID', $order = 'ASC', array('ID' => $listUsers), array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME'))); while ($user = $userQuery->fetch()) { $arResult["PROPERTY_" . $propertyKey][$user['ID']] = "user_" . intval($user['ID']); $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$user['ID']] = "(" . $user["LOGIN"] . ")" . (strlen($user["NAME"]) > 0 || strlen($user["LAST_NAME"]) > 0 ? " " : "") . $user["NAME"] . (strlen($user["NAME"]) > 0 && strlen($user["LAST_NAME"]) > 0 ? " " : "") . $user["LAST_NAME"]; } } elseif ($propertyValue["USER_TYPE"] == "DiskFile") { if (is_array($propertyValue["VALUE"])) { if ($propertyValue["MULTIPLE"] == "Y") { $propertyValue["VALUE"] = current($propertyValue["VALUE"]); } if (!is_array($propertyValue["VALUE"])) { continue; } foreach ($propertyValue["VALUE"] as $attachedId) { $userType = \CIBlockProperty::getUserType($propertyValue['USER_TYPE']); $fileId = null; if (array_key_exists('GetObjectId', $userType)) { $fileId = call_user_func_array($userType['GetObjectId'], array($attachedId)); } if (!$fileId) { continue; } $printableUrl = ''; if (array_key_exists('GetUrlAttachedFileElement', $userType)) { $printableUrl = call_user_func_array($userType['GetUrlAttachedFileElement'], array($documentId, $fileId)); } $arResult["PROPERTY_" . $propertyKey][$attachedId] = $fileId; $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$attachedId] = $printableUrl; } } else { continue; } } else { $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"]; } } elseif ($propertyValue["PROPERTY_TYPE"] == "L") { $arPropertyValue = $propertyValue["VALUE"]; $arPropertyKey = self::GetVersion() > 1 ? $propertyValue["VALUE_XML_ID"] : $propertyValue["VALUE_ENUM_ID"]; if (!is_array($arPropertyValue)) { $arPropertyValue = array($arPropertyValue); $arPropertyKey = array($arPropertyKey); } for ($i = 0, $cnt = count($arPropertyValue); $i < $cnt; $i++) { $arResult["PROPERTY_" . $propertyKey][$arPropertyKey[$i]] = $arPropertyValue[$i]; } } elseif ($propertyValue["PROPERTY_TYPE"] == "F") { $arPropertyValue = $propertyValue["VALUE"]; if (!is_array($arPropertyValue)) { $arPropertyValue = array($arPropertyValue); } foreach ($arPropertyValue as $v) { $ar = CFile::GetFileArray($v); if ($ar) { $arResult["PROPERTY_" . $propertyKey][intval($v)] = $ar["SRC"]; $arResult["PROPERTY_" . $propertyKey . "_printable"][intval($v)] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($ar["FILE_NAME"]) . "&i=" . $v . "&h=" . md5($ar["SUBDIR"]) . "]" . htmlspecialcharsbx($ar["ORIGINAL_NAME"]) . "[/url]"; } } } else { $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"]; } } $documentFields = static::GetDocumentFields(static::GetDocumentType($documentId)); foreach ($documentFields as $fieldKey => $field) { if (!array_key_exists($fieldKey, $arResult)) { $arResult[$fieldKey] = null; } } } return $arResult; }