/** * @param FieldType $fieldType * @param array $field * @param mixed $value * @param bool $allowSelection * @param int $renderMode * @return string */ protected static function renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { if ($value !== null && !is_array($value)) { $value = array($value); } $value = \CBPHelper::usersArrayToString($value, null, $fieldType->getDocumentType()); $renderResult = parent::renderControl($fieldType, $field, $value, $allowSelection, $renderMode); $renderResult .= static::renderControlSelector($field, null, false, '', $fieldType); return $renderResult; }
/** * @param FieldType $fieldType * @return array */ private static function getDocumentSelectFields(FieldType $fieldType) { $runtime = \CBPRuntime::getRuntime(); $runtime->startRuntime(); $documentService = $runtime->getService("DocumentService"); $result = array(); $fields = $documentService->getDocumentFields($fieldType->getDocumentType()); foreach ($fields as $key => $field) { if ($field['Type'] == 'select' && substr($key, -10) != '_PRINTABLE') { $result[$key] = $field; } } return $result; }
private static function getIblockId(FieldType $fieldType) { $documentType = $fieldType->getDocumentType(); $type = explode('_', $documentType[2]); return intval($type[1]); }
public static function clearValueMultiple(FieldType $fieldType, $values) { if (!Loader::includeModule('disk')) { return; } if (!is_array($values)) { $values = array($values); } $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager(); list($connectorClass, $moduleId) = $userFieldManager->getConnectorDataByEntityType('lists_workflow'); $documentType = $fieldType->getDocumentType(); $iblockId = intval(substr($documentType[2], strlen("iblock_"))); if (!$iblockId) { return; } foreach ($values as $value) { $attachedModel = \Bitrix\Disk\AttachedObject::load(array('OBJECT_ID' => $value, '=ENTITY_TYPE' => $connectorClass, '=ENTITY_ID' => $iblockId, '=MODULE_ID' => $moduleId)); if (!$attachedModel) { continue; } if ($userFieldManager->belongsToEntity($attachedModel, "lists_workflow", $iblockId)) { \Bitrix\Disk\AttachedObject::detachByFilter(array('ID' => $attachedModel->getId())); } } }
public static function clearValueSingle(FieldType $fieldType, $value) { if (!Loader::includeModule('disk')) { return; } $value = (int) $value; if (!$value) { return; } $documentType = $fieldType->getDocumentType(); $iblockId = intval(substr($documentType[2], strlen("iblock_"))); if (!$iblockId) { return; } $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager(); list($type, $realId) = \Bitrix\Disk\Uf\FileUserType::detectType($value); if ($type == \Bitrix\Disk\Uf\FileUserType::TYPE_ALREADY_ATTACHED) { $attachedModel = \Bitrix\Disk\AttachedObject::loadById($realId); if (!$attachedModel) { return; } if ($userFieldManager->belongsToEntity($attachedModel, "iblock_workflow", $iblockId)) { \Bitrix\Disk\AttachedObject::detachByFilter(array('ID' => $realId)); } } }
/** * @param array $field * @param null|string $value * @param bool $showInput * @param string $selectorMode * @param FieldType $fieldType * @return string */ protected static function renderControlSelector(array $field, $value = null, $showInput = false, $selectorMode = '', FieldType $fieldType = null) { $html = ''; $controlId = static::generateControlId($field); if ($showInput) { $controlId = $controlId . '_text'; $name = static::generateControlName($field) . '_text'; $html = '<input type="text" id="' . htmlspecialcharsbx($controlId) . '" name="' . htmlspecialcharsbx($name) . '" value="' . htmlspecialcharsbx((string) $value) . '">'; } $html .= '<input type="button" value="..." onclick="BPAShowSelector(\'' . htmlspecialcharsbx($controlId) . '\', \'' . htmlspecialcharsbx(static::getType()) . '\', ' . ($selectorMode ? '\'' . htmlspecialcharsbx($selectorMode) . '\'' : 'null') . ', null, ' . htmlspecialcharsbx(\Bitrix\Main\Web\Json::encode($fieldType ? $fieldType->getDocumentType() : null)) . ');">'; return $html; }