• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/import/import.php
  • Класс: BitrixSaleLocationImportis
  • Вызов: is::readBlockFromCurrentFile2
protected function readBlockFromCurrentFile2()
{
	$fIndex = 		$this->data['current']['fIndex'];
	$fName = 		self::getFileNameByIndex($fIndex);
	$onlyThese =& 	$this->data['files'][$fIndex]['onlyThese'];

	//$this->logMessage('READ FROM File: '.$fName.' seek to '.$this->data['current']['bytesRead']);

	if(!isset($this->hitData['csv']))
	{
		$file = $_SERVER['DOCUMENT_ROOT'].self::LOCAL_PATH.$fName;

		if(!file_exists($file) || !is_readable($file))
			throw new MainSystemException('Cannot open file '.$file.' for reading');

		$this->logMessage('Charging File: '.$fName);

		$this->hitData['csv'] = new CSVReader();
		$this->hitData['csv']->LoadFile($file);
	}

	$block = $this->hitData['csv']->ReadBlockLowLevel($this->data['current']['bytesRead'], 100);

	$this->data['current']['linesRead'] += count($block);

	if(empty($block))
		return array();

	if($this->hitData['csv']->CheckFileIsLegacy())
		$block = self::convertBlock($block);

	if(is_array($onlyThese))
	{
		foreach($block as $i => $line)
		{
			if(is_array($onlyThese) && !isset($onlyThese[$line['CODE']]))
				unset($block[$i]);
		}
	}

	//$this->logMessage('Bytes read: '.$this->data['current']['bytesRead']);

	return $block;
}