1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Runtime.php
См. документацию.
1<?php
2
3namespace Bitrix\Seo\Sitemap\File;
4
5use Bitrix\Main\Text\Converter;
6use Bitrix\Main\IO\File;
7use Bitrix\Main\IO\Path;
8
9class 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
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}
getContents()
Определения file.php:61
putContents($data, $flags=self::REWRITE)
Определения file.php:71
isExists()
Определения file.php:50
getPath()
Определения filesystementry.php:80
getDirectoryName()
Определения filesystementry.php:75
rename($newPath)
Определения filesystementry.php:152
static normalize($path)
Определения path.php:22
static combine(... $args)
Определения path.php:254
addIBlockEntry($url, $modifiedDate)
Определения Base.php:364
addFooter()
Определения Base.php:414
addHeader()
Определения Base.php:105
appendEntry($entry)
Определения Base.php:245
isCurrentPartNotEmpty()
Определения Base.php:223
putSitemapContent(Base $sitemapFile)
Определения Runtime.php:49
setOriginalFile(Base $sitemapFile)
Определения Runtime.php:68
__construct($PID, $fileName, $arSettings)
Определения Runtime.php:16
appendIBlockEntry($url, $modifiedDate)
Определения Runtime.php:85
reInit($fileName)
Определения Runtime.php:44
const PROGRESS_WIDTH
Определения Runtime.php:11
$f
Определения component_props.php:52
$filename
Определения file_edit.php:47
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения Image.php:9
$fileName
Определения quickway.php:305
if(empty($signedUserToken)) $key
Определения quickway.php:257
$url
Определения iframe.php:7