- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/lib/Sitemap/File/Index.php
- Класс: BitrixSeoSitemapFileIndex
- Вызов: Index::appendIndexEntry
public function appendIndexEntry($file)
{
if ($this->isExists() && $file->isExists())
{
$e = [];
$fileUrlEnc = Converter::getXmlConverter()->encode($this->settings['PROTOCOL'].'://'.CBXPunycode::toASCII($this->settings['DOMAIN'], $e).$this->getFileUrl($file));
$contents = $this->getContents();
$reg = "/".sprintf(preg_quote(self::ENTRY_TPL, "/"), preg_quote($fileUrlEnc, "/"), "[^<]*")."/";
$newEntry = sprintf(
self::ENTRY_TPL,
$fileUrlEnc,
date('c', $file->getModificationTime($file))
);
$count = 0;
$contents = preg_replace($reg, $newEntry, $contents, 1, $count);
if($count <= 0)
{
$contents = mb_substr($contents, 0, -mb_strlen(self::FILE_FOOTER))
.$newEntry.self::FILE_FOOTER;
}
$this->putContents($contents);
}
else
{
$this->createIndex(array($file));
}
}