1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Index.php
См. документацию.
1
<?php
8
namespace
Bitrix\Seo\Sitemap\File;
9
10
use Bitrix\Main\Text\Converter;
11
15
class
Index
extends
Base
16
{
17
const
FILE_HEADER
=
'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
;
18
const
FILE_FOOTER
=
'</sitemapindex>'
;
19
20
const
ENTRY_TPL
=
'<sitemap><loc>%s</loc><lastmod>%s</lastmod></sitemap>'
;
21
22
public
function
createIndex
(
array
$arIndex)
23
{
24
$str
= self::XML_HEADER.self::FILE_HEADER;
25
26
foreach
($arIndex as $file)
27
{
28
if
(!$file->isSystem() && $file->isExists())
29
{
30
$e = [];
31
$str
.= sprintf(
32
self::ENTRY_TPL,
33
Converter::getXmlConverter
()->encode($this->settings[
'PROTOCOL'
].
'://'
.\CBXPunycode::toASCII($this->settings[
'DOMAIN'
], $e).$this->
getFileUrl
($file)),
34
date(
'c'
, $file->getModificationTime())
35
);
36
}
37
}
38
39
$str
.= self::FILE_FOOTER;
40
41
$this->
putContents
(
$str
);
42
}
43
44
public
function
appendIndexEntry
($file)
45
{
46
if
($this->
isExists
() && $file->isExists())
47
{
48
$e = [];
49
$fileUrlEnc =
Converter::getXmlConverter
()->encode($this->settings[
'PROTOCOL'
].
'://'
.\CBXPunycode::toASCII($this->settings[
'DOMAIN'
], $e).$this->
getFileUrl
($file));
50
51
$contents
= $this->
getContents
();
52
53
$reg =
"/"
.sprintf(preg_quote(self::ENTRY_TPL,
"/"
), preg_quote($fileUrlEnc,
"/"
),
"[^<]*"
).
"/"
;
54
55
$newEntry = sprintf(
56
self::ENTRY_TPL,
57
$fileUrlEnc,
58
date(
'c'
, $file->getModificationTime($file))
59
);
60
61
$count
= 0;
62
$contents
= preg_replace($reg, $newEntry,
$contents
, 1,
$count
);
63
64
if
(
$count
<= 0)
65
{
66
$contents
= mb_substr(
$contents
, 0, -mb_strlen(self::FILE_FOOTER))
67
.$newEntry.self::FILE_FOOTER;
68
}
69
70
$this->
putContents
(
$contents
);
71
}
72
else
73
{
74
$this->
createIndex
(
array
($file));
75
}
76
}
77
}
$count
$count
Определения
admin_tab.php:4
Bitrix\Main\IO\File\getContents
getContents()
Определения
file.php:61
Bitrix\Main\IO\File\putContents
putContents($data, $flags=self::REWRITE)
Определения
file.php:71
Bitrix\Main\IO\File\isExists
isExists()
Определения
file.php:50
Bitrix\Main\Text\Converter\getXmlConverter
static getXmlConverter()
Определения
converter.php:20
Bitrix\Seo\Sitemap\File\Base
Определения
Base.php:20
Bitrix\Seo\Sitemap\File\Base\getFileUrl
getFileUrl(File $f)
Определения
Base.php:468
Bitrix\Seo\Sitemap\File\Index
Определения
Index.php:16
Bitrix\Seo\Sitemap\File\Index\FILE_FOOTER
const FILE_FOOTER
Определения
Index.php:18
Bitrix\Seo\Sitemap\File\Index\FILE_HEADER
const FILE_HEADER
Определения
Index.php:17
Bitrix\Seo\Sitemap\File\Index\ENTRY_TPL
const ENTRY_TPL
Определения
Index.php:20
Bitrix\Seo\Sitemap\File\Index\createIndex
createIndex(array $arIndex)
Определения
Index.php:22
Bitrix\Seo\Sitemap\File\Index\appendIndexEntry
appendIndexEntry($file)
Определения
Index.php:44
$str
$str
Определения
commerceml2.php:63
$contents
$contents
Определения
commerceml2.php:57
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
bitrix
modules
seo
lib
Sitemap
File
Index.php
Создано системой
1.14.0