403Webshell
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/ilovecveti.ru/bitrix/modules/iblock/lib/grid/helpers/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/iblock/lib/grid/helpers/codetranslator.php
<?php

namespace Bitrix\Iblock\Grid\Helpers;

use Bitrix\Main\SystemException;
use CIBlock;

trait CodeTranslator
{
	/**
	 * @var array
	 * @psalm-var array<string, mixed>
	 */
	private array $iblockFields;

	/**
	 * Iblock
	 *
	 * @return int
	 */
	abstract protected function getIblockId(): int;

	/**
	 * @return array
	 * @throws \Bitrix\Main\SystemException if iblock not found.
	 */
	private function getIblockFields(): array
	{
		if (!isset($this->iblockFields))
		{
			$result = CIBlock::GetArrayByID($this->getIblockId());
			if (!is_array($result))
			{
				throw new SystemException('Iblock not found');
			}

			$this->iblockFields = $result;
		}

		return $this->iblockFields;
	}

	/**
	 * Transliteration settings of element.
	 *
	 * @return array|null
	 */
	protected function getElementTranslitSettings(): ?array
	{
		$iblock = $this->getIblockFields();

		$elementTranslit = $iblock['FIELDS']['CODE']['DEFAULT_VALUE'] ?? null;
		if (empty($elementTranslit))
		{
			return null;
		}

		$useElementTranslit =
			isset($elementTranslit['TRANSLITERATION'], $elementTranslit['USE_GOOGLE'])
			&& $elementTranslit['TRANSLITERATION'] === 'Y'
			&& $elementTranslit['USE_GOOGLE'] !== 'Y'
		;
		if ($useElementTranslit)
		{
			return [
				'max_len' => $elementTranslit['TRANS_LEN'],
				'change_case' => $elementTranslit['TRANS_CASE'],
				'replace_space' => $elementTranslit['TRANS_SPACE'],
				'replace_other' => $elementTranslit['TRANS_OTHER'],
				'delete_repeat_replace' => ($elementTranslit['TRANS_EAT'] === 'Y')
			];
		}

		return null;
	}

	/**
	 * Transliteration settings of section.
	 *
	 * @return array|null
	 */
	protected function getSectionTranslitSettings(): ?array
	{
		$iblock = $this->getIblockFields();

		$sectionTranslit = $iblock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE'] ?? null;
		if (empty($sectionTranslit))
		{
			return null;
		}

		$useSectionTranslit =
			isset($sectionTranslit['TRANSLITERATION'], $sectionTranslit['USE_GOOGLE'])
			&& $sectionTranslit['TRANSLITERATION'] === 'Y'
			&& $sectionTranslit['USE_GOOGLE'] !== 'Y'
		;
		if ($useSectionTranslit)
		{
			return [
				'max_len' => $sectionTranslit['TRANS_LEN'],
				'change_case' => $sectionTranslit['TRANS_CASE'],
				'replace_space' => $sectionTranslit['TRANS_SPACE'],
				'replace_other' => $sectionTranslit['TRANS_OTHER'],
				'delete_repeat_replace' => ($sectionTranslit['TRANS_EAT'] === 'Y')
			];
		}

		return null;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit