См. определение в файле sitemapiblock.php строка 212
◆ __callStatic()
static __callStatic |
( |
|
$name, |
|
|
|
$arguments |
|
) |
| |
|
static |
Event handler for multiple IBlock events.
См. определение в файле sitemapiblock.php строка 224
226 $name = ToUpper($name);
233 $arguments[0][
"ID"] > 0
234 && $arguments[0][
'IBLOCK_ID'] > 0
236 !isset($arguments[0][
'ACTIVE'])
237 || $arguments[0][
'ACTIVE'] ==
'Y'
243 foreach($arguments[0] as $key => $value)
245 $fields[$key] = $value;
248 if(!isset($fields[
'EXTERNAL_ID']) && isset($fields[
'XML_ID']))
250 $fields[
'EXTERNAL_ID'] = $fields[
'XML_ID'];
257 case 'BEFOREDELETEELEMENT':
258 case 'BEFOREDELETESECTION':
259 case 'BEFOREUPDATEELEMENT':
260 case 'BEFOREUPDATESECTION':
267 $element = $name ==
'BEFOREDELETEELEMENT' || $name ==
'BEFOREUPDATEELEMENT';
270 ? \CIBlockElement::getByID($ID)
271 : \CIBlockSection::getByID($ID);
273 $fields = $dbFields->getNext();
276 if($element && !self::checkElement($fields))
286 if (count($sitemaps) > 0)
290 $dbIblock = \CIBlock::GetByID($fields[
'IBLOCK_ID']);
291 $iblock = $dbIblock->GetNext();
293 ? $iblock[
'~DETAIL_PAGE_URL']
294 : $iblock[
'~SECTION_PAGE_URL'];
296 $url = \CIBlock::replaceDetailUrl($url, $fields,
false, $element ?
'E' :
'S');
298 self::$beforeActions[$name][intval($element)][$ID] = array(
301 'SITEMAPS' => $sitemaps,
308 case 'DELETEELEMENT':
309 case 'DELETESECTION':
310 case 'UPDATEELEMENT':
311 case 'UPDATESECTION':
313 $fields = $arguments[0];
314 $element = $name ==
'DELETEELEMENT' || $name ==
'UPDATEELEMENT';
319 && isset(self::$beforeActions[
'BEFORE'.$name][intval($element)][$fields[
'ID']])
322 if($fields[
'RESULT'] !==
false)
324 if($name ==
'DELETEELEMENT' || $name ==
'DELETESECTION')
326 self::actionDelete(self::$beforeActions[
'BEFORE'.$name][intval($element)][$fields[
'ID']]);
330 self::actionUpdate(self::$beforeActions[
'BEFORE'.$name][intval($element)][$fields[
'ID']], $element);
334 unset(self::$beforeActions[
'BEFORE'.$name][intval($element)][$fields[
'ID']]);
◆ actionAdd()
static actionAdd |
( |
|
$name, |
|
|
|
$fields |
|
) |
| |
|
staticprotected |
Processes actions on IBlock element or section add.
- Аргументы
-
string | $name | Event handler name. |
array | $fields | Element/section fields. |
См. определение в файле sitemapiblock.php строка 477
479 if($name ==
'ADDELEMENT')
481 if(!self::checkElement($fields))
487 if(is_array($fields[
'IBLOCK_SECTION']) && count($fields[
'IBLOCK_SECTION']) > 0)
489 $newSections = array();
491 'ID' => $fields[
'IBLOCK_SECTION'],
492 'IBLOCK_ID' => $fields[
'IBLOCK_ID'],
493 'GLOBAL_ACTIVE' =>
'Y'
496 $dbRes = \CIBlockSection::getList(array(), $filter,
false, array(
'ID',
'IBLOCK_TYPE_ID',
'IBLOCK_CODE'));
497 while ($ar = $dbRes->fetch())
499 $newSections[] = $ar[
'ID'];
500 $iblockTypeId = $ar[
'IBLOCK_TYPE_ID'] ? $ar[
'IBLOCK_TYPE_ID'] :
null;
501 $iblockCode = $ar[
'IBLOCK_CODE'] ? $ar[
'IBLOCK_CODE'] :
null;
504 if(count($newSections) <= 0)
510 $fields[
'IBLOCK_SECTION'] = $newSections;
513 elseif($name ==
'ADDSECTION')
515 $dbRes = \CIBlockSection::getList(
517 array(
'ID' => $fields[
'ID'],
'GLOBAL_ACTIVE' =>
'Y'),
519 array(
'ID',
'IBLOCK_TYPE_ID',
'IBLOCK_CODE')
522 $inactiveBranch =
true;
523 while ($ar = $dbRes->fetch())
525 $iblockTypeId = $ar[
'IBLOCK_TYPE_ID'] ? $ar[
'IBLOCK_TYPE_ID'] :
null;
526 $iblockCode = $ar[
'IBLOCK_CODE'] ? $ar[
'IBLOCK_CODE'] :
null;
527 $inactiveBranch =
false;
537 $fields[
'IBLOCK_TYPE_ID'] = $iblockTypeId;
538 $fields[
'IBLOCK_CODE'] = $iblockCode;
545 $fields[
'TIMESTAMP_X'] = ConvertTimeStamp(
false,
"FULL");
547 if(isset($fields[
'IBLOCK_SECTION']) && is_array($fields[
'IBLOCK_SECTION']) && count($fields[
'IBLOCK_SECTION']) > 0)
549 $fields[
'IBLOCK_SECTION_ID'] = min($fields[
'IBLOCK_SECTION']);
552 if(count($sitemaps) > 0)
554 $siteDirs = self::createSiteDirs();
556 foreach ($sitemaps as $sitemap)
558 $fileName = str_replace(
559 array(
'#IBLOCK_ID#',
'#IBLOCK_CODE#',
'#IBLOCK_XML_ID#'),
560 array($fields[
'IBLOCK_ID'], $sitemap[
'IBLOCK_CODE'], $sitemap[
'IBLOCK_XML_ID']),
561 $sitemap[
'SITEMAP_FILE_IBLOCK']
564 $sitemapFile =
new SitemapFile($fileName, $sitemap);
567 $sitemapRuntimeId = $sitemap[
'SITE_ID'] .
'-' . uniqid();
568 $sitemapRuntimeId .= isset($fields[
'ID']) ?
'-' . $fields[
'ID'] .
'-' :
'';
569 $sitemapRuntimeFile =
new SitemapRuntime($sitemapRuntimeId, $fileName, $sitemap);
571 if(self::checkActivity($name ==
'ADDELEMENT' ?
true :
false, $fields))
573 $fields[
'LANG_DIR'] = $siteDirs[$sitemap[
'SITE_ID']];
575 $url = $name ==
'ADDSECTION' ? $sitemap[
'SECTION_PAGE_URL'] : $sitemap[
'DETAIL_PAGE_URL'];
576 $urlType = $name ==
'ADDSECTION' ?
'S' :
'E';
580 'url' => \CIBlock::replaceDetailUrl($url, $fields,
false, $urlType),
581 'lastmod' => MakeTimeStamp($fields[
'TIMESTAMP_X']),
584 $sitemapRuntimeFile->setOriginalFile($sitemapFile);
585 $sitemapRuntimeFile->appendIblockEntry($rule[
'url'], $rule[
'lastmod']);
589 if ($sitemapRuntimeFile->isNotEmpty() && $sitemapRuntimeFile->isCurrentPartNotEmpty())
590 $sitemapRuntimeFile->finish();
592 $sitemapRuntimeFile->delete();
594 $sitemapIndex =
new SitemapIndex($sitemap[
'SITEMAP_FILE'], $sitemap);
595 $sitemapIndex->appendIndexEntry($sitemapFile);
597 if ($sitemap[
'ROBOTS'] ==
'Y')
599 $robotsFile =
new RobotsFile($sitemap[
'SITE_ID']);
600 $robotsFile->addRule(
◆ actionDelete()
static actionDelete |
( |
|
$data | ) |
|
|
staticprotected |
Processes actions on IBlock element or section delete.
- Аргументы
-
См. определение в файле sitemapiblock.php строка 452
454 $fields = $data[
'FIELDS'];
455 foreach ($data[
'SITEMAPS'] as $sitemap)
457 $fileName = str_replace(
458 array(
'#IBLOCK_ID#',
'#IBLOCK_CODE#',
'#IBLOCK_XML_ID#'),
459 array($fields[
'IBLOCK_ID'], $sitemap[
'IBLOCK_CODE'], $sitemap[
'IBLOCK_XML_ID']),
460 $sitemap[
'SITEMAP_FILE_IBLOCK']
463 $sitemapFile =
new SitemapFile($fileName, $sitemap);
464 $sitemapFile->removeEntry($data[
'URL']);
466 $sitemapIndex =
new SitemapIndex($sitemap[
'SITEMAP_FILE'], $sitemap);
467 $sitemapIndex->appendIndexEntry($sitemapFile);
◆ actionUpdate()
static actionUpdate |
( |
|
$data, |
|
|
|
$element |
|
) |
| |
|
staticprotected |
Processes actions on IBlock element or section update.
- Аргументы
-
См. определение в файле sitemapiblock.php строка 376
378 $fields = $data[
'FIELDS'];
379 $siteDirs = self::createSiteDirs();
381 foreach ($data[
'SITEMAPS'] as $sitemap)
383 $fileName = str_replace(
384 array(
'#IBLOCK_ID#',
'#IBLOCK_CODE#',
'#IBLOCK_XML_ID#'),
385 array($fields[
'IBLOCK_ID'], $sitemap[
'IBLOCK_CODE'], $sitemap[
'IBLOCK_XML_ID']),
386 $sitemap[
'SITEMAP_FILE_IBLOCK']
390 $dbRes = \CIBlockElement::getByID($fields[
"ID"]);
392 $dbRes = \CIBlockSection::getByID($fields[
"ID"]);
394 $newFields = $dbRes->fetch();
396 $sitemapFile =
new SitemapFile($fileName, $sitemap);
399 $fileName = $sitemapFile->removeEntry($data[
'URL']);
402 $sitemapRuntimeId = $sitemap[
'SITE_ID'] .
'-' . uniqid();
403 $sitemapRuntimeId .= isset($fields[
'ID']) ?
'-' . $fields[
'ID'] .
'-' :
'';
404 $sitemapRuntimeFile =
new SitemapRuntime($sitemapRuntimeId, $fileName, $sitemap);
407 if(self::checkActivity($element, $newFields))
409 $newFields[
'LANG_DIR'] = $siteDirs[$sitemap[
'SITE_ID']];
412 $date = date(
'd.m.Y H:i:s');
414 $url = $element ? $sitemap[
'DETAIL_PAGE_URL'] : $sitemap[
'SECTION_PAGE_URL'];
415 $urlType = $element ?
'E' :
'S';
419 'url' => \CIBlock::replaceDetailUrl($url, $newFields,
false, $urlType),
420 'lastmod' => MakeTimeStamp($date),
423 $sitemapRuntimeFile->setOriginalFile($sitemapFile);
424 $sitemapRuntimeFile->appendIblockEntry($rule[
'url'], $rule[
'lastmod']);
429 if ($sitemapRuntimeFile->isNotEmpty() && $sitemapRuntimeFile->isCurrentPartNotEmpty())
430 $sitemapRuntimeFile->finish();
432 $sitemapRuntimeFile->delete();
434 $sitemapIndex =
new SitemapIndex($sitemap[
'SITEMAP_FILE'], $sitemap);
435 $sitemapIndex->appendIndexEntry($sitemapFile);
437 if ($sitemap[
'ROBOTS'] ==
'Y')
439 $robotsFile =
new RobotsFile($sitemap[
'SITE_ID']);
440 $robotsFile->addRule(
◆ checkElement()
static checkElement |
( |
& |
$fields | ) |
|
|
staticprotected |
Checks if element is a real element, not a workflow item.
- Аргументы
-
array | $fields | Element fields. |
- Возвращает
- bool
См. определение в файле sitemapiblock.php строка 349
351 if($fields[
'WF'] ===
'Y')
354 $fields[
'WF_PARENT_ELEMENT_ID'] > 0
355 && $fields[
'WF_PARENT_ELEMENT_ID'] != $fields[
'ID']
356 && $fields[
'WF_STATUS_ID'] == 1
359 $fields[
'ID'] = $fields[
'WF_PARENT_ELEMENT_ID'];
◆ prepareUrlToReplace()
static prepareUrlToReplace |
( |
|
$url, |
|
|
|
$siteId = NULL |
|
) |
| |
|
static |
Replace some parts of URL-template, then not correct processing in replaceDetailUrl.
- Аргументы
-
string | $url | - String of URL-template. |
null | $siteId | - In NULL - #SERVER_NAME# will not replaced. |
- Возвращает
- mixed|string
См. определение в файле sitemapiblock.php строка 670
673 $url = str_replace(
'http://',
'', $url);
674 $url = str_replace(
'https://',
'', $url);
677 if (substr($url, 0, strlen(
'#SERVER_NAME#')) ==
'#SERVER_NAME#')
678 $url = substr($url, strlen(
'#SERVER_NAME#'));
683 $filter = array(
'=LID' => $siteId);
686 'select' => array(
'LID',
'DIR',
'SERVER_NAME'),
688 $currentSite = $dbSite->fetch();
689 $serverName = $currentSite[
'SERVER_NAME'];
690 $url = str_replace(
'#SERVER_NAME#', $serverName, $url);
Объявления и описания членов класса находятся в файле: