本文整理汇总了PHP中CIBlockSection::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockSection::getByID方法的具体用法?PHP CIBlockSection::getByID怎么用?PHP CIBlockSection::getByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockSection
的用法示例。
在下文中一共展示了CIBlockSection::getByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __callStatic
public static function __callStatic($name, $arguments)
{
$name = ToUpper($name);
switch ($name) {
case 'ADDELEMENT':
case 'ADDSECTION':
if ($arguments[0]["ID"] > 0 && $arguments[0]['IBLOCK_ID'] > 0 && (!isset($arguments[0]['ACTIVE']) || $arguments[0]['ACTIVE'] == 'Y')) {
// we recieve array reference here
$arFields = array();
foreach ($arguments[0] as $key => $value) {
$arFields[$key] = $value;
}
self::actionAdd($name, $arFields);
}
break;
case 'BEFOREDELETEELEMENT':
case 'BEFOREDELETESECTION':
case 'BEFOREUPDATEELEMENT':
case 'BEFOREUPDATESECTION':
$ID = $arguments[0];
if (is_array($ID)) {
$ID = $ID['ID'];
}
if ($ID > 0) {
$bElement = $name == 'BEFOREDELETEELEMENT' || $name == 'BEFOREUPDATEELEMENT';
$dbFields = $bElement ? \CIBlockElement::getByID($ID) : \CIBlockSection::getByID($ID);
$arFields = $dbFields->getNext();
if ($arFields) {
if ($bElement && !self::checkElement($arFields)) {
return;
}
$arSitemaps = SitemapIblockTable::getByIblock($arFields, $bElement ? SitemapIblockTable::TYPE_ELEMENT : SitemapIblockTable::TYPE_SECTION);
if (count($arSitemaps) > 0) {
self::$arBeforeActions[$name][intval($bElement)][$ID] = array('URL' => $bElement ? $arFields['~DETAIL_PAGE_URL'] : $arFields['~SECTION_PAGE_URL'], 'FIELDS' => $arFields, 'SITEMAPS' => $arSitemaps);
}
}
}
break;
case 'DELETEELEMENT':
case 'DELETESECTION':
case 'UPDATEELEMENT':
case 'UPDATESECTION':
$arFields = $arguments[0];
$bElement = $name == 'DELETEELEMENT' || $name == 'UPDATEELEMENT';
if (is_array($arFields) && $arFields['ID'] > 0 && isset(self::$arBeforeActions['BEFORE' . $name][intval($bElement)][$arFields['ID']])) {
if ($name == 'DELETEELEMENT' || $name == 'DELETESECTION') {
self::actionDelete(self::$arBeforeActions['BEFORE' . $name][intval($bElement)][$arFields['ID']]);
} else {
self::actionUpdate(self::$arBeforeActions['BEFORE' . $name][intval($bElement)][$arFields['ID']], $bElement);
}
}
break;
}
}
示例2: actionUpdate
/**
* Processes actions on IBlock element or section update
*
* @param array $data Data got from SitemapIblockTable::getByIblock() + element/section data + prev link data got from event handler.
* @param bool $element Element or section.
*/
protected static function actionUpdate($data, $element)
{
$fields = $data['FIELDS'];
foreach ($data['SITEMAPS'] as $sitemap) {
$fileName = str_replace(array('#IBLOCK_ID#', '#IBLOCK_CODE#', '#IBLOCK_XML_ID#'), array($fields['IBLOCK_ID'], $sitemap['IBLOCK_CODE'], $sitemap['IBLOCK_XML_ID']), $sitemap['SITEMAP_FILE_IBLOCK']);
if ($element) {
$dbRes = \CIBlockElement::getByID($fields["ID"]);
} else {
$dbRes = \CIBlockSection::getByID($fields["ID"]);
}
$newFields = $dbRes->fetch();
$rule = array('url' => $element ? \CIBlock::replaceDetailUrl($sitemap['DETAIL_PAGE_URL'], $newFields, false, "E") : \CIBlock::replaceDetailUrl($sitemap['SECTION_PAGE_URL'], $newFields, false, "S"), 'lastmod' => MakeTimeStamp($fields['TIMESTAMP_X']));
$sitemapFile = new SitemapFile($fileName, $sitemap);
$sitemapFile->removeEntry($data['URL']);
if ($newFields["ACTIVE"] !== "N") {
$sitemapFile->appendIblockEntry($rule['url'], $rule['lastmod']);
}
$sitemapIndex = new SitemapIndex($sitemap['SITEMAP_FILE'], $sitemap);
$sitemapIndex->appendIndexEntry($sitemapFile);
if ($sitemap['ROBOTS'] == 'Y') {
$robotsFile = new RobotsFile($sitemap['SITE_ID']);
$robotsFile->addRule(array(RobotsFile::SITEMAP_RULE, $sitemapIndex->getUrl()));
}
unset($sitemapFile);
unset($sitemapIndex);
unset($robotsFile);
}
}