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 : |
<?php namespace Goodde\YandexTurbo; use Bitrix\Main, Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); /** * Class TurboStaticFileTable * * Fields: * <ul> * <li> ID int mandatory * <li> LID string(2) optional * <li> TIMESTAMP_X datetime mandatory default 'current_timestamp()' * <li> DATE_CREATE datetime optional * <li> ACTIVE bool optional default 'Y' * <li> NAME string(255) optional * <li> IN_AGENT bool optional default 'N' * </ul> * * @package Goodde\YandexTurbo **/ class TurboStaticFileTable extends Main\Entity\DataManager { const SETTINGS_DEFAULT_FILE_MASK = '*.php,*.html'; const EXPORT_FILE_PATH = '/upload/yandex_turbo/goodde_static_file_export_#id#.xml'; /** * Returns DB table name for entity. * * @return string */ public static function getTableName() { return 'goodde_yandex_turbo_file'; } /** * Returns entity map definition. * * @return array */ public static function getMap() { return array( new Main\Entity\IntegerField('ID', array( 'primary' => true, 'autocomplete' => true, 'editable' => false, 'title' => Loc::getMessage('TURBO_FILE_ENTITY_ID_FIELD'), )), new Main\Entity\DatetimeField('TIMESTAMP_X', array( 'required' => true, 'default_value' => new Main\Type\DateTime(), 'editable' => false, 'title' => Loc::getMessage('TURBO_FILE_ENTITY_TIMESTAMP_X_FIELD'), )), new Main\Entity\IntegerField('MODIFIED_BY', array( 'editable' => false, 'title' => Loc::getMessage('TURBO_FILE_ENTITY_MODIFIED_BY_FIELD'), )), new Main\Entity\DatetimeField('DATE_CREATE', array( 'default_value' => new Main\Type\DateTime(), 'editable' => false, 'title' => Loc::getMessage('TURBO_FILE_ENTITY_DATE_CREATE_FIELD'), )), new Main\Entity\IntegerField('CREATED_BY', array( 'title' => Loc::getMessage('TURBO_FILE_ENTITY_CREATED_BY_FIELD'), )), new Main\Entity\BooleanField('ACTIVE', array( 'values' => array('N', 'Y'), 'default_value' => 'Y', 'title' => Loc::getMessage('TURBO_FILE_ENTITY_ACTIVE_FIELD'), )), new Main\Entity\BooleanField('ITEM_STATUS', array( 'values' => array('N', 'Y'), 'default_value' => 'N', 'title' => Loc::getMessage('TURBO_FILE_ENTITY_ITEM_STATUS_FIELD'), )), new Main\Entity\BooleanField('IN_DEBUG', array( 'values' => array('N', 'Y'), 'default_value' => 'Y', 'title' => Loc::getMessage('TURBO_FILE_ENTITY_IN_DEBUG_FIELD'), )), new Main\Entity\StringField('NAME', array( 'validation' => array(__CLASS__, 'validateName'), 'title' => Loc::getMessage('TURBO_FILE_ENTITY_NAME_FIELD'), )), new Main\Entity\StringField('LID', array( 'validation' => array(__CLASS__, 'validateLid'), 'title' => Loc::getMessage('TURBO_FILE_ENTITY_LID_FIELD'), )), new Main\Entity\StringField('SERVER_ADDRESS', array( 'validation' => array(__CLASS__, 'validateServerAddress'), 'title' => Loc::getMessage('TURBO_FILE_ENTITY_SERVER_ADDRESS_FIELD'), )), new Main\Entity\DatetimeField('LAST_START', array( 'title' => Loc::getMessage('TURBO_FILE_ENTITY_LAST_START_FIELD'), )), new Main\Entity\DatetimeField('LAST_END', array( 'title' => Loc::getMessage('TURBO_FILE_ENTITY_LAST_END_FIELD'), )), new Main\Entity\IntegerField('TOTAL_OFFERS', array( 'title' => Loc::getMessage('TURBO_FILE_ENTITY_TOTAL_OFFERS_FIELD'), )), new Main\Entity\StringField('TOTAL_RUN_TIME', array( 'title' => Loc::getMessage('TURBO_FILE_ENTITY_TOTAL_RUN_TIME_FIELD'), )), new Main\Entity\StringField('TOTAL_MEMORY', array( 'title' => Loc::getMessage('TURBO_FILE_ENTITY_TOTAL_MEMORY_FIELD'), )), new Main\Entity\BooleanField('IN_AGENT', array( 'values' => array('N', 'Y'), 'default_value' => 'N', 'title' => Loc::getMessage('TURBO_FILE_ENTITY_IN_AGENT_FIELD'), )), new Main\Entity\TextField('SETTINGS', array( 'editable' => false, 'hidden' => true, 'serialized' => true, )), ); } protected static function compileMask($mask) { if($mask <> '') { $arMask = preg_split("/[\s,;]+/", $mask); foreach ($arMask as $key => $subMask) { if($subMask <> '') { $arMask[$key] = str_replace( array("___ALL___", "___ONE___"), array(".*?", "."), preg_quote(str_replace( array("*", "?"), array("___ALL___", "___ONE___"), $subMask )) ); } else { unset($arMask[$key]); } } return "/^(".implode('|', $arMask).")$/i".BX_UTF_PCRE_MODIFIER; } else { return "/.*/i".BX_UTF_PCRE_MODIFIER; } } /** * Gets settings from admin page and returns filtered version * @param $arSettings * @return array */ public static function prepareSettings($arSettings) { if(is_array($arSettings)) { $arSettings['FILE_MASK_REGEXP'] = self::compileMask($arSettings['FILE_MASK']); if(!isset($arSettings['DIR']) || !is_array($arSettings['DIR'])) { $arSettings['DIR'] = array(); } if(isset($arSettings['FILE']) && is_array($arSettings['FILE'])) { ksort($arSettings['FILE'], SORT_STRING); foreach($arSettings['FILE'] as $file => $value) { $pos = mb_strrpos($file, '/'); $parentDir = $pos > 0 ? mb_substr($file, 0, $pos) : '/'; if(isset($arSettings['DIR'][$parentDir]) && $arSettings['DIR'][$parentDir] == $value) { unset($arSettings['FILE'][$file]); } } } /* if(isset($arSettings['DIR']) && is_array($arSettings['DIR'])) { krsort($arSettings['DIR'], SORT_STRING); foreach($arSettings['DIR'] as $dir => $value) { if($dir != '/') { $pos = mb_strrpos($dir, '/'); $parentDir = mb_substr($dir, 0, $pos); if($parentDir == '') $parentDir = '/'; if(isset($arSettings['DIR'][$parentDir]) && $arSettings['DIR'][$parentDir] == $value) { unset($arSettings['DIR'][$dir]); } } } $arSettings['DIR'] = array_reverse($arSettings['DIR']); } */ } return $arSettings; } /** * Returns validators for LID field. * * @return array */ public static function validateLid() { return array( new Main\Entity\Validator\Length(null, 2), ); } /** * Returns validators for SERVER_ADDRESS field. * * @return array */ public static function validateServerAddress() { return array( new Main\Entity\Validator\Length(null, 255), ); } /** * Returns validators for NAME field. * * @return array */ public static function validateName() { return array( new Main\Entity\Validator\Length(null, 255), ); } } ?>