- Модуль: translate
- Путь к файлу: ~/bitrix/modules/translate/lib/io/csvfile.php
- Класс: BitrixTranslateIOCsvFile
- Вызов: CsvFile::put
public function put(array $fields): bool
{
$length = false;
$throw32KWarning = false;
if ($this->fieldsType == self::FIELDS_TYPE_WITH_DELIMITER)
{
$content = '';
for ($i = 0, $n = count($fields); $i < $n; $i++)
{
if ($i>0)
{
$content .= $this->fieldDelimiter;
}
//$pos1 = strpos($fields[$i], $this->fieldDelimiter);
//$pos2 = $pos1 || strpos($fields[$i], """);
//$pos3 = $pos2 || strpos($fields[$i], "n");
//$pos4 = $pos3 || strpos($fields[$i], "r");
//if ($pos1 !== false || $pos2 !== false || $pos3 !== false || $pos4 !== false)
if ($fields[$i] === null)
{
$fields[$i] = '';
}
elseif (preg_match("#["nr]+#".BX_UTF_PCRE_MODIFIER, $fields[$i]))
{
$fields[$i] = str_replace(""", """", $fields[$i]);
//$fields[$i] = str_replace("\", "\\", $fields[$i]);
}
$content .= """;
$content .= $fields[$i];
$content .= """;
// ms excel las limitation with total number of characters that a cell can contain 32767 characters
if ($throw32KWarning !== true && $this->getStringByteLength($fields[$i]) > 32767)
{
$throw32KWarning = true;
}
}
if ($content !== '')
{
$content .= $this->rowDelimiter;
$length = $this->write($content);
if ($length !== false)
{
$this->fileSize += $length;
}
}
}
// todo: $this->fieldsType == self::FIELDS_TYPE_FIXED_WIDTH
if ($throw32KWarning)
{
if (!$this->hasError(self::ERROR_32K_FIELD_LENGTH))
{
$this->addError(new MainError(
'Excel has limit when the total number of characters that a cell can contain is 32767 characters.',
self::ERROR_32K_FIELD_LENGTH
));
}
}
return ($length !== false);
}