'', 'ID' => 0, 'UF_NAME' => '', 'UF_LINK' => '', 'UF_SORT' => 100, 'UF_FILE' => 0, 'MULTIPLE' => 'N', 'UF_DEF' => 'N', 'UF_DESCRIPTION' => '', 'UF_FULL_DESCRIPTION' => '' ); if ($USER->IsAuthorized() && check_bitrix_sessid() && isset($_REQUEST['IBLOCK_ID'])) { if (!Loader::includeModule('highloadblock') || !Loader::includeModule('iblock')) { echo Bitrix\Main\Web\Json::encode(array('ERROR' => 'SS_MODULE_NOT_INSTALLED')); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin_after.php'); die(); } $iblockID = (int)$_REQUEST['IBLOCK_ID']; if ($iblockID < 0) { echo Bitrix\Main\Web\Json::encode(array('ERROR' => 'SS_IBLOCK_ID_ABSENT')); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin_after.php'); die(); } elseif ($iblockID === 0) { if (!$USER->IsAdmin()) { echo Bitrix\Main\Web\Json::encode(array('ERROR' => 'SS_NO_ADMIN')); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin_after.php'); die(); } } else { $rsIBlocks = CIBlock::GetList( array(), array( 'ID' => $iblockID, 'CHECK_PERMISSIONS' => 'N' ) ); $arIBlock = $rsIBlocks->Fetch(); if ($arIBlock) { if (!CIBlockRights::UserHasRightTo($iblockID, $iblockID, "iblock_edit")) { echo Bitrix\Main\Web\Json::encode(array('ERROR' => 'SS_ACCESS_DENIED')); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin_after.php'); die(); } } else { echo Bitrix\Main\Web\Json::encode(array('ERROR' => 'SS_IBLOCK_ABSENT')); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin_after.php'); die(); } } CUtil::JSPostUnescape(); $multiple = 'N'; if (isset($_REQUEST['multiple']) && $_REQUEST['multiple'] === 'Y') $multiple = 'Y'; $defaultValues['MULTIPLE'] = $multiple; function addTableXmlIDCell($intPropID, $arPropInfo) { return ''; } function addTableIdCell($intPropID, $arPropInfo) { return ''; } function addTableNameCell($intPropID, $arPropInfo) { return ''; } function addTableLinkCell($intPropID, $arPropInfo) { return ''; } function addTableSortCell($intPropID, $arPropInfo) { $sort = (isset($arPropInfo['UF_SORT']) && intval($arPropInfo['UF_SORT']) > 0) ? intval($arPropInfo['UF_SORT']) : 100; return ''; } function addTableFileCell($intPropID, $arPropInfo) { static $maxImageSize = null; static $filemanIncluded = null; if (null === $maxImageSize) { $maxImageSize = array( "W" => COption::GetOptionString("iblock", "list_image_size"), "H" => COption::GetOptionString("iblock", "list_image_size"), ); } $arPropInfo["UF_FILE"] = intval($arPropInfo["UF_FILE"]); if ($filemanIncluded === null) { $filemanIncluded = Loader::includeModule('fileman'); } if (!$filemanIncluded) return ''; $strShowFile = ''; if (0 < $arPropInfo["UF_FILE"]) { $strShowFile = CFile::ShowFile( $arPropInfo["UF_FILE"], 0, $maxImageSize['W'], $maxImageSize['H'], false ); if ('' !== $strShowFile) $strShowFile .= '
'; } return $strShowFile.CFile::InputFile( "PROPERTY_DIRECTORY_VALUES[$intPropID][FILE]", 20, $arPropInfo["UF_FILE"], false, 0, "IMAGE", "", 0, "class=typeinput", "", true, false); } function addTableDefCell($intPropID, $arPropInfo) { return ''; } function addTableDescriptionCell($intPropID, $arPropInfo) { return ''; } function addTableFullDescriptionCell($intPropID, $arPropInfo) { return ''; } function addTableDelField($intPropID) { return '
'; } function addTableRow($intPropID, $arPropInfo, $fields, $json = false) { if (empty($fields)) return ''; if ($json) { $result = array(); $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableDelField($intPropID).addTableIdCell($intPropID, $arPropInfo) ); if (isset($fields['UF_NAME'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableNameCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_SORT'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableSortCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_XML_ID'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableXmlIDCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_FILE'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableFileCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_LINK'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableLinkCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_DEF'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top', 'textAlign' => 'center' ), 'html' => addTableDefCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_DESCRIPTION'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableDescriptionCell($intPropID, $arPropInfo) ); } if (isset($fields['UF_FULL_DESCRIPTION'])) { $result[] = array( 'style' => array( 'verticalAlign' => 'top' ), 'html' => addTableFullDescriptionCell($intPropID, $arPropInfo) ); } } else { $result = ''; $result .= ''.addTableDelField($intPropID).addTableIdCell($intPropID, $arPropInfo).''; if (isset($fields['UF_NAME'])) { $result .= ''.addTableNameCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_SORT'])) { $result .= ''.addTableSortCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_XML_ID'])) { $result .= ''.addTableXmlIDCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_FILE'])) { $result .= ''.addTableFileCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_LINK'])) { $result .= ''.addTableLinkCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_DEF'])) { $result .= ''.addTableDefCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_DESCRIPTION'])) { $result .= ''.addTableDescriptionCell($intPropID, $arPropInfo).''; } if (isset($fields['UF_FULL_DESCRIPTION'])) { $result .= ''.addTableFullDescriptionCell($intPropID, $arPropInfo).''; } $result .= ''; } return $result; } function addHeadRow($fields, &$colCount) { $result = ''; if (isset($fields['UF_NAME'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_NAME').''; $colCount++; } if (isset($fields['UF_SORT'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_SORT').''; $colCount++; } if (isset($fields['UF_XML_ID'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_XML_ID').''; $colCount++; } if (isset($fields['UF_FILE'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_FILE').''; $colCount++; } if (isset($fields['UF_LINK'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_LINK').''; $colCount++; } if (isset($fields['UF_DEF'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_DEF').''; $colCount++; } if (isset($fields['UF_DESCRIPTION'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_DECSRIPTION').''; $colCount++; } if (isset($fields['UF_FULL_DESCRIPTION'])) { $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_FULL_DESCRIPTION').''; $colCount++; } $result .= ''; return $result; } function addEmptyDefaultRow($property, $fields) { if (empty($fields) || !isset($fields['UF_DEF'])) return ''; if ($property['MULTIPLE'] != 'N') return ''; $result = ''; $leftSide = [ 'UF_NAME' => true, 'UF_SORT' => true, 'UF_XML_ID' => true, 'UF_FILE' => true, 'UF_LINK' => true ]; $rightSide = [ 'UF_DESCRIPTION' => true, 'UF_FULL_DESCRIPTION' => true ]; $countLeft = count(array_intersect_key($fields, $leftSide)) + 1; $result .= ''.Loc::getMessage('HIBLOCK_PROP_DIRECTORY_EMPTY_DEFAULT_VALUE').''; $result .= ''. ''. ''; $countRight = count(array_intersect_key($fields, $rightSide)); if ($countRight > 0) $result .= ' '; $result .= ''; return $result; } $rowNumber = (int)(isset($_REQUEST['rowNumber']) ? $_REQUEST['rowNumber'] : 0); $currentRowNumber = 0; $colCount = 1; $hlBlockID = (string)(isset($_REQUEST['hlBlock']) ? $_REQUEST['hlBlock'] : ''); $result = ''; $entityDataClass = null; $hlblockFields = $defaultValues; $orderFields = array(); if ($hlBlockID !== '' && $hlBlockID !== '-1') { $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $hlBlockID)))->fetch(); $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock); $entityDataClass = $entity->getDataClass(); $hlblockFields = $entityDataClass::getEntity()->getFields(); if (isset($hlblockFields['UF_SORT'])) $orderFields['UF_SORT'] = 'ASC'; if (isset($hlblockFields['UF_NAME'])) $orderFields['UF_NAME'] = 'ASC'; } if (isset($_REQUEST['addEmptyRow']) && $_REQUEST['addEmptyRow'] === 'Y') { $APPLICATION->RestartBuffer(); echo Bitrix\Main\Web\Json::encode(addTableRow('n'.$rowNumber, $defaultValues, $hlblockFields, true)); } else { if ($hlBlockID !== '') { if (isset($_REQUEST['getTitle']) && $_REQUEST['getTitle'] === 'Y') { $result .= addHeadRow($hlblockFields, $colCount); } $existDefault = false; $rowsList = ''; $rsData = $entityDataClass::getList(array( 'order' => $orderFields )); while ($arData = $rsData->fetch()) { if (isset($hlblockFields['UF_DEF']) && $arData['UF_DEF'] == '1') $existDefault = true; $arData['MULTIPLE'] = $multiple; $rowsList .= addTableRow($arData['ID'], $arData, $hlblockFields, false); } unset($arData, $rsData); $result .= addEmptyDefaultRow( ['MULTIPLE' => $multiple, 'UF_DEF' => ($existDefault ? '0' : '1')], $hlblockFields ); $result .= $rowsList; if ($rowsList == '') $result .= addTableRow('n'.$rowNumber, $defaultValues, $hlblockFields, false); unset($rowsList); } $result .= ''; echo $result; } } require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin_after.php');