1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Runtime.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Seo\Sitemap\File;
4
5
use Bitrix\Main\Text\Converter;
6
use Bitrix\Main\IO\File;
7
use Bitrix\Main\IO\Path;
8
9
class
Runtime
extends
Base
10
{
11
const
PROGRESS_WIDTH
= 500;
12
13
protected
$PID
= 0;
14
private
$originalFile = NULL;
15
16
public
function
__construct
(
$PID
,
$fileName
, $arSettings)
17
{
18
$this->PID =
$PID
;
19
20
if
($this->partFile ==
''
)
21
{
22
$this->partFile =
$fileName
;
23
}
24
25
// normalize slashes
26
$fileName
=
Path::normalize
(
$fileName
);
27
// divide directory and path tp correctly add prefix
28
$lastSlashPosition = mb_strrpos(
$fileName
,
"/"
);
29
$fileDirectory =
''
;
30
if
($lastSlashPosition !==
false
)
31
{
32
$fileDirectory = mb_substr(
$fileName
, 0, $lastSlashPosition + 1);
33
$fileName
= mb_substr(
$fileName
, $lastSlashPosition + 1);
34
}
35
36
parent::__construct($fileDirectory . $this->
getPrefix
() .
$fileName
, $arSettings);
37
}
38
44
protected
function
reInit
(
$fileName
)
45
{
46
$this->
__construct
($this->PID,
$fileName
, $this->settings);
47
}
48
49
public
function
putSitemapContent
(
Base
$sitemapFile)
50
{
51
// always write in new empty file - this is necessary
52
if
($this->
isExists
())
53
$this->
delete
();
54
55
if
($sitemapFile->
isExists
())
56
{
57
$this->
putContents
($sitemapFile->
getContents
());
58
$this->partChanged =
true
;
59
$this->footerClosed =
true
;
60
}
61
else
62
{
63
$this->
addHeader
();
64
}
65
}
66
67
68
public
function
setOriginalFile
(
Base
$sitemapFile)
69
{
70
if
(isset($sitemapFile))
71
{
72
$this->originalFile = $sitemapFile;
73
}
74
}
75
85
public
function
appendIBlockEntry
(
$url
, $modifiedDate)
86
{
87
// if not set original file - to use as common sitemap file
88
if
(!$this->originalFile)
89
{
90
parent::appendIBlockEntry(
$url
, $modifiedDate);
91
return
;
92
}
93
94
if
($this->originalFile->isExists())
95
{
96
// move sitemapfile to end, find name of last part
97
while
($this->originalFile->isSplitNeeded())
98
{
99
$filename
= $this->originalFile->split();
100
}
101
102
// if part was changed - create new runtime part file
103
if
(isset(
$filename
) &&
$filename
)
104
$this->
reInit
(
$filename
);
105
106
$this->
putSitemapContent
($this->originalFile);
107
$e = [];
108
$this->
appendEntry
(
array
(
109
'XML_LOC'
=> $this->settings[
'PROTOCOL'
] .
'://'
. \CBXPunycode::toASCII($this->settings[
'DOMAIN'
], $e) .
$url
,
110
'XML_LASTMOD'
=> date(
'c'
, $modifiedDate - \CTimeZone::getOffset()),
111
));
112
}
113
else
114
{
115
$this->
addHeader
();
116
$this->
addIBlockEntry
(
$url
, $modifiedDate);
117
$this->
addFooter
();
118
}
119
}
120
124
public
function
finish
()
125
{
126
foreach
($this->partList as
$key
=> $partName)
127
{
128
$f
=
new
File
(
Path::combine
($this->
getDirectoryName
(), $partName));
129
$f
->rename(str_replace($this->
getPrefix
(),
''
,
$f
->getPath()));
130
$this->partList[
$key
] =
$f
->getName();
131
}
132
133
if
($this->
isCurrentPartNotEmpty
())
134
{
135
if
(!$this->footerClosed)
136
{
137
$this->
addFooter
();
138
}
139
$this->
rename
(str_replace($this->
getPrefix
(),
''
, $this->
getPath
()));
140
}
141
}
142
143
protected
function
getPrefix
()
144
{
145
return
'~'
.
$this->PID
;
146
}
147
}
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\IO\FileSystemEntry\getPath
getPath()
Определения
filesystementry.php:80
Bitrix\Main\IO\FileSystemEntry\getDirectoryName
getDirectoryName()
Определения
filesystementry.php:75
Bitrix\Main\IO\FileSystemEntry\rename
rename($newPath)
Определения
filesystementry.php:152
Bitrix\Main\IO\Path\normalize
static normalize($path)
Определения
path.php:22
Bitrix\Main\IO\Path\combine
static combine(... $args)
Определения
path.php:254
Bitrix\Seo\Sitemap\File\Base
Определения
Base.php:20
Bitrix\Seo\Sitemap\File\Base\addIBlockEntry
addIBlockEntry($url, $modifiedDate)
Определения
Base.php:364
Bitrix\Seo\Sitemap\File\Base\addFooter
addFooter()
Определения
Base.php:414
Bitrix\Seo\Sitemap\File\Base\addHeader
addHeader()
Определения
Base.php:105
Bitrix\Seo\Sitemap\File\Base\appendEntry
appendEntry($entry)
Определения
Base.php:245
Bitrix\Seo\Sitemap\File\Base\isCurrentPartNotEmpty
isCurrentPartNotEmpty()
Определения
Base.php:223
Bitrix\Seo\Sitemap\File\Runtime
Определения
Runtime.php:10
Bitrix\Seo\Sitemap\File\Runtime\putSitemapContent
putSitemapContent(Base $sitemapFile)
Определения
Runtime.php:49
Bitrix\Seo\Sitemap\File\Runtime\setOriginalFile
setOriginalFile(Base $sitemapFile)
Определения
Runtime.php:68
Bitrix\Seo\Sitemap\File\Runtime\__construct
__construct($PID, $fileName, $arSettings)
Определения
Runtime.php:16
Bitrix\Seo\Sitemap\File\Runtime\appendIBlockEntry
appendIBlockEntry($url, $modifiedDate)
Определения
Runtime.php:85
Bitrix\Seo\Sitemap\File\Runtime\getPrefix
getPrefix()
Определения
Runtime.php:143
Bitrix\Seo\Sitemap\File\Runtime\$PID
$PID
Определения
Runtime.php:13
Bitrix\Seo\Sitemap\File\Runtime\finish
finish()
Определения
Runtime.php:124
Bitrix\Seo\Sitemap\File\Runtime\reInit
reInit($fileName)
Определения
Runtime.php:44
Bitrix\Seo\Sitemap\File\Runtime\PROGRESS_WIDTH
const PROGRESS_WIDTH
Определения
Runtime.php:11
$f
$f
Определения
component_props.php:52
$filename
$filename
Определения
file_edit.php:47
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\Main\File
Определения
Image.php:9
$fileName
$fileName
Определения
quickway.php:305
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$url
$url
Определения
iframe.php:7
bitrix
modules
seo
lib
Sitemap
File
Runtime.php
Создано системой
1.14.0