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/sproduction.datasync/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/sproduction.datasync/lib/storesections.php
<?php
/**
 *    StoreSections
 *
 * @mail support@s-production.online
 * @link s-production.online
 */

namespace SProduction\Datasync;

\Bitrix\Main\Loader::includeModule("catalog");

use Bitrix\Main,
	Bitrix\Main\Entity,
	Bitrix\Main\Type,
	Bitrix\Main\Localization\Loc;

Loc::loadMessages(__FILE__);


class StoreSections {
	const SEARCH_FIELD_DEFAULT = 'CODE';
	const SEARCH_FIELD_DEFAULT_ALT = 'ID';

	/**
	 * Get section data
	 */
	public static function getById($section_id) {
		$values = false;
		if ($section = \Bitrix\Iblock\SectionTable::getByPrimary($section_id)->fetch()) {
			$values = [];
			foreach ($section as $k => $value) {
				if (gettype($value) == 'object' && get_class($value) == 'Bitrix\Main\Type\DateTime') {
					$values[$k] = $value->getTimestamp();
				}
				else {
					$values[$k] = $value;
				}
			}
		}
		return $values;
	}

	/**
	 * Get sections list
	 */
	public static function getList($iblock_id, int $after_id=0, array $select=['ID'], $limit=0) {
		$sections = [];
		$filter = [
			'IBLOCK_ID'   => $iblock_id,
		];
		$sections_db = \Bitrix\Iblock\SectionTable::getList([
			'order' => ['DEPTH_LEVEL' => 'asc', 'ID' => 'asc'],
			'filter' => $filter,
			'select' => $select,
		]);
		$run_process = false;
		$count = 0;
		while ($section = $sections_db->fetch()) {
			if (!$run_process && !$after_id) {
				$run_process = true;
			}
			if ($run_process) {
				$sections[] = $section;
				$count++;
			}
			if (!$run_process && $after_id && $section['ID'] == $after_id) {
				$run_process = true;
			}
			if ($limit && $count >= $limit) {
				break;
			}
		}
		return $sections;
	}

	/**
	 * Get sections list count
	 */
	public static function getCount($iblock_id) {
		$filter = [
			'IBLOCK_ID'   => $iblock_id,
		];
		return \Bitrix\Iblock\SectionTable::getCount($filter);
	}

	/**
	 * Find section
	 */
	public static function find($iblock_id, $search_value, $search_field=false) {
		$section_id = false;
		if ($search_field === false) {
			$search_field = self::SEARCH_FIELD_DEFAULT;
		}
		if ($section = \Bitrix\Iblock\SectionTable::getList([
			'filter' => [
				'IBLOCK_ID' => $iblock_id,
				$search_field => $search_value,
			]
		])->fetch()) {
			$section_id = $section['ID'];
		}
		return $section_id;
	}

	/**
	 * Get search value
	 */
	public static function getSearchValue($store_sect_id) {
		$store_prod = StoreSections::getById($store_sect_id);
		if ($store_prod[self::SEARCH_FIELD_DEFAULT]) {
			$search_value = $store_prod[self::SEARCH_FIELD_DEFAULT];
		}
		else {
			$search_value = $store_prod[self::SEARCH_FIELD_DEFAULT_ALT];
		}
		return $search_value;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit