1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Iblock.php
См. документацию.
1<?php
2
3namespace Bitrix\Seo\Sitemap\Source;
4
5use Bitrix\Main\SiteTable;
6use Bitrix\Seo\Sitemap\File;
7use Bitrix\Seo\Sitemap\Internals\IblockTable;
8use Bitrix\Seo\RobotsFile;
9use Bitrix\Seo\Sitemap\Internals\SitemapTable;
10use Bitrix\Seo\Sitemap\Job;
11
12class Iblock
13{
17 public static function __callStatic($name, $arguments)
18 {
19 $name = mb_strtoupper($name);
20 switch ($name)
21 {
22 case 'ADDELEMENT':
23 case 'ADDSECTION':
24
25 $fields = $arguments[0];
26 if (
27 $fields["ID"] > 0
28 && $fields['IBLOCK_ID'] > 0
29 && (
30 !isset($fields['ACTIVE']) || $fields['ACTIVE'] == 'Y'
31 )
32 )
33 {
34 self::processIblock($fields['IBLOCK_ID']);
35 }
36 break;
37
38 case 'DELETEELEMENT':
39 case 'DELETESECTION':
40 case 'UPDATEELEMENT':
41 case 'UPDATESECTION':
42
43 $fields = $arguments[0];
44 if (is_array($fields) && $fields['ID'] > 0 && $fields['IBLOCK_ID'] > 0)
45 {
46 if (!isset($fields['RESULT']) || $fields['RESULT'] !== false)
47 {
48 self::processIblock($fields['IBLOCK_ID']);
49 }
50 }
51
52 break;
53 }
54 }
55
56 protected static function processIblock(int $iblockId): void
57 {
58 $iblocksForSitemap = IblockTable::query()
59 ->setSelect(['SITEMAP_ID'])
60 ->where('IBLOCK_ID', $iblockId)
61 ->exec()
62 ;
63
64 foreach ($iblocksForSitemap as $iblock)
65 {
66 Job::markToRegenerate($iblock['SITEMAP_ID']);
67 }
68 }
69
77 public static function prepareUrlToReplace($url, $siteId = null)
78 {
79 // REMOVE PROTOCOL - we put them later, based on user settings
80 $url = str_replace(['http://', 'https://'], '', $url);
81
82 // REMOVE SERVER_NAME from start position, because we put server_url later
83 if (mb_substr($url, 0, mb_strlen('#SERVER_NAME#')) == '#SERVER_NAME#')
84 {
85 $url = mb_substr($url, mb_strlen('#SERVER_NAME#'));
86 }
87
88 // get correct SERVER_URL
89 if ($siteId)
90 {
91 $filter = ['=LID' => $siteId];
92 $dbSite = SiteTable::getList([
93 'filter' => $filter,
94 'select' => ['LID', 'DIR', 'SERVER_NAME'],
95 'cache' => [
96 'ttl' => 60,
97 ],
98 ]);
99 $currentSite = $dbSite->fetch();
100 $serverName = $currentSite['SERVER_NAME'];
101 $url = str_replace('#SERVER_NAME#', $serverName, $url);
102 }
103
104 return $url;
105 }
106}
static markToRegenerate(int $sitemapId)
Определения Job.php:199
static processIblock(int $iblockId)
Определения Iblock.php:56
static __callStatic($name, $arguments)
Определения Iblock.php:17
static prepareUrlToReplace($url, $siteId=null)
Определения Iblock.php:77
$iblockId
Определения iblock_catalog_edit.php:30
if(! $catalogEdit->isSuccess()) $iblock
Определения iblock_catalog_edit.php:38
$filter
Определения iblock_catalog_list.php:54
$siteId
Определения ajax.php:8
$name
Определения menu_edit.php:35
$url
Определения iframe.php:7
$fields
Определения yandex_run.php:501