Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/burlakastudio.realcommenter/lib/ |
Upload File : |
<?php /** * ����� "��������� ����������� D7" ��� ������� * �������� ���� �����: www.realcommenter.com * �������� ���� �����������: burlaka.studio * ����� � ����������: ������� ������� (AlexeyGfi) -> alexeygfi@gmail.com */ namespace Burlakastudio\Realcommenter; use Bitrix\Main\Localization\Loc; use Bitrix\Main\Type\Collection; class AdditionalFields extends OrmHelper { protected static $hlApiCode = 'RealcommenterWideFields'; protected static $fieldsByGroups = []; /** * Sync with group settings. * Extra must be clear, necessary should create (woth empty) * @param null $groupId * @param array $additionalFields * @return bool */ public static function allRequiredSet($groupId = null, &$additionalFields = []) { $requiredButNotFound = []; if ($groupId && !empty($additionalFields)) { $addiInfo = self::getFieldsByGroup($groupId); foreach ($addiInfo as $id => $info) { if (!$additionalFields[$id] && (int)$info['UF_REQUIRED'] === 1) { $requiredButNotFound[] = $id; } } $additionalFields = array_filter( $additionalFields, static function ($key) use ($addiInfo) { return isset($addiInfo[$key]); }, ARRAY_FILTER_USE_KEY ); if (!empty($requiredButNotFound)) { foreach ($requiredButNotFound as $id) { $additionalFields[$id] = null; } } } return empty($requiredButNotFound); } public static function getFieldsByGroup($groupId = null, $onlyActive = true) { if (!$groupId) { return false; } self::$fieldsByGroups[$groupId] = self::$fieldsByGroups[$groupId] ?? []; if (!self::$fieldsByGroups[$groupId]) { $result = []; $groupInfo = TalkGroups::getInfo($groupId); $groupsFields = ($groupInfo['UF_FIELDS_MODE'] === 'AF') ? $groupInfo['UF_ADDI_FIELDS'] : null; if (!empty($groupsFields)) { if (!is_array($groupsFields)) { $groupsFields = @unserialize( $groupsFields, ['allow_clases' => false] ); } $result = self::getInfo($groupsFields, false); if ($onlyActive) { $result = array_filter( $result, static function ($value) { return (bool)$value['UF_ACTIVE']; } ); } } self::$fieldsByGroups[$groupId] = $result; } return self::$fieldsByGroups[$groupId]; } public static function getInfo($idList = null, $simplifySingle = true) { $result = parent::getInfo($idList, $simplifySingle); Collection::sortByColumn( $result, [ 'UF_SORT' => SORT_ASC ], '', 10, true ); return $result; } public static function getModerableFields($groupId = null) { $result = []; $fieldsToCheck = self::getFieldsByGroup($groupId); if (!empty($fieldsToCheck)) { $result = array_filter( $fieldsToCheck, static function ($value) { return $value['UF_MODERABLE']; } ); } return $result; } public static function getDefaultFieldTypes() { return [ 'text' => [ 'label' => Loc::getMessage('FIELD_TYPE_TEXT'), ], 'rating' => [ 'label' => Loc::getMessage('FIELD_TYPE_RATING'), // 'options' => [ // // ����� � ����������� ��-������� // 'mark_default' => 5, // // ����� ����� // 'shape_of_piece' => 'star', // // ������ // 'show_label_text' => true, // // ������������ ����� // 'rating_block_position' => 'after_title' // ] 'options' => [ // ����� � ����������� ��-������� 'mark_default' => [ 'lang' => Loc::getMessage('OPTION_mark_default_LANG'), 'type' => 'list', 'values' => [0, 1, 2, 3, 4, 5], 'default' => 5 ], // ����� ����� 'shape_of_piece' => [ 'lang' => Loc::getMessage('OPTION_shape_of_piece_LANG'), 'type' => 'list', 'values' => [ Loc::getMessage('OPTION_shape_of_piece_VAR_star') => 'star', Loc::getMessage('OPTION_shape_of_piece_VAR_circle') => 'circle', Loc::getMessage('OPTION_shape_of_piece_VAR_rectangle') => 'rectangle', Loc::getMessage('OPTION_shape_of_piece_VAR_heart') => 'heart', ], 'default' => 'star' ], // ������ 'show_label_text' => [ 'lang' => Loc::getMessage('OPTION_show_label_text_LANG'), 'type' => 'list', 'values' => [ Loc::getMessage('OPTION_show_label_text_VAR_yes') => 'yes', Loc::getMessage('OPTION_show_label_text_VAR_no') => 'no' ], 'default' => 'yes' ], // ������������ ����� 'rating_block_position' => [ 'lang' => Loc::getMessage('OPTION_rating_block_position_LANG'), 'type' => 'list', 'values' => [ Loc::getMessage('OPTION_rating_block_position_VAR_before_title') => 'before_title', Loc::getMessage('OPTION_rating_block_position_VAR_after_title') => 'after_title' ], 'default' => 'after_title' ], ] ], ]; } }