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/rospirotorg.ru/bitrix/modules/goodde.yandexturboapi/lib/ |
Upload File : |
<? namespace Goodde\Export; use Bitrix\Main\Type, Bitrix\Main\Config\Option, Bitrix\Main\Localization\Loc, Bitrix\Main\Text\Converter; Loc::loadMessages(__FILE__); class ProfileTools { public static function getGuid($value = '', $field = array(), $item = array(), $profile = array()) { return $profile['SHOP_URL'] . '/' . $value; } public static function getPreviewText($value = '', $field = array(), $item = array(), $profile = array()) { $text = trim($value); if($text <> '') { $text = "<![CDATA[" . static::clearSpaces($text) . "]]>"; } return $text; } public static function getDetailText($value = '', $field = array(), $item = array(), $profile = array()) { $text = trim($value); if($text <> '') { preg_match_all("/<img[\s\S]*>/U", $text, $matches); if($matches[0]) { foreach($matches[0] as $value) { $text = str_replace($value, '<figure>' . $value . '</figure>', $text); } } } if($text <> '') { $text = "<![CDATA[" . static::clearSpaces($text) . "]]>"; } return $text; } public static function getTemplatesSeoText($value = '', $field = array(), $item = array(), $profile = array()) { $text = trim($value); if($item['PARENT_ID'] > 0 && $item['ID'] > 0) { $entity = new \Bitrix\Iblock\Template\Entity\Element($item['ID']); $text = \Bitrix\Iblock\Template\Engine::process($entity, $text); $text = str_replace(['[', ']'], ['{', '}'], $text); $entity = new \Bitrix\Iblock\Template\Entity\Element($item['PARENT_ID']); $text = \Bitrix\Iblock\Template\Engine::process($entity, $text); } elseif($item['ID'] > 0) { $entity = new \Bitrix\Iblock\Template\Entity\Element($item['ID']); $text = \Bitrix\Iblock\Template\Engine::process($entity, $text); } if(in_array($profile['TYPE'], ['avito_doma_dachi']) && $field['CODE'] == 'Description') { if($text) { $text = htmlspecialchars_decode($text); $text = "<![CDATA[" . static::clearSpaces($text) . "]]>"; } } return $text; } public static function getDetailMedia($value = '', $field = array(), $item = array(), $profile = array()) { $text = trim($value); $result = array(); preg_match_all("/<img[\s\S]*>/U", $text, $matches); if($matches[0]) { foreach($matches[0] as $key => $value) { preg_match("/src=[\"'](.+)[\"']/U", $value, $matches_src); $src = $matches_src[1]; if($src <> '') { if(mb_strpos($src, "resizer2GD.php") !== false) { $src = str_replace('/yenisite.resizer2/resizer2GD.php?url=', '', strtok($src, '&')); } $url = (mb_strpos($src, "http") === false) ? $profile['SHOP_URL'] . $src : $src; $info = getimagesize($url); if(empty($info['mime'])) { $info['mime'] = 'image/' . mb_substr($url, -3); } $result[ $key ] = array( 'url' => $url, 'src' => $src, 'width' => $info[0], 'height' => $info[1], 'type' => $info['mime'], ); } } } return $result; } protected static function clearSpaces($text) { $text = preg_replace("/^\s+/im" . BX_UTF_PCRE_MODIFIER, "", $text); $text = preg_replace("/[\n\r]/im" . BX_UTF_PCRE_MODIFIER, "", $text); return $text; } public static function preGenerateExport($profileId) { $profileId = (int)$profileId; if ($profileId <= 0) return false; if(!\Bitrix\Main\Loader::includeModule('goodde.yandexturboapi')) return false; if(!\Bitrix\Main\Loader::includeModule('iblock')) return false; $strFile = '/bitrix/modules/goodde.yandexturboapi/load/xml_export_run.php'; if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile)) return false; include($_SERVER['DOCUMENT_ROOT'].$strFile); return "\Goodde\Export\ProfileTools::preGenerateExport(".$profileId.");"; } }