39 $name = ToUpper($name);
43 if ($arguments[1][
"APPROVED"] ==
"Y")
49 if ($arguments[1][
"APPROVED"] ==
"Y")
55 if ($arguments[1][
"APPROVED"] ==
"N")
59 else if (empty($arguments[2]) || $arguments[1][
"FORUM_ID"] == $arguments[2][
"FORUM_ID"])
61 self::actionUpdate((empty($arguments[2]) ? $arguments[1] : $arguments[2]), $arguments[1]);
70 if ($arguments[1][
"APPROVED"] ==
"Y")
78 protected static function checkParams($arMessage = array(), &$arTopic, &$arForum)
80 if (\
Bitrix\Main\Loader::includeModule(
'forum'))
82 $arTopic = (!empty($arTopic) ? $arTopic : \CForumTopic::GetByID($arMessage[
"TOPIC_ID"]));
86 if (!empty($arSitemaps) && ($arForum = \CForumNew::GetByIDEx($arTopic[
"FORUM_ID"])) && $arForum)
88 $arForum[
"PATH2FORUM_MESSAGE"] = \CForumNew::GetSites($arTopic[
"FORUM_ID"]);
89 $date = MakeTimeStamp($arTopic[
'LAST_POST_DATE']);
91 foreach($arSitemaps as $arSitemap)
93 $path = $arForum[
"PATH2FORUM_MESSAGE"][$arSitemap[
"SITE_ID"]];
96 $arSitemap[
"fileName"] = str_replace(
"#FORUM_ID#", $arForum[
"ID"], $arSitemap[
'SITEMAP_FILE_FORUM']);
97 $arSitemap[
"url"] = \CForumNew::PreparePath2Message(
100 "FORUM_ID" => $arForum[
"ID"],
101 "TOPIC_ID" => $arTopic[
"ID"],
102 "TITLE_SEO" => $arTopic[
"TITLE_SEO"],
104 "SOCNET_GROUP_ID" => $arTopic[
"SOCNET_GROUP_ID"],
105 "OWNER_ID" => $arTopic[
"OWNER_ID"],
106 "PARAM1" => $arTopic[
"PARAM1"],
107 "PARAM2" => $arTopic[
"PARAM2"]
110 $arSitemap[
"date"] = $date;
111 $result[] = $arSitemap;
114 return (empty($result) ?
false : $result);
120 protected static function actionUpdate($arOldTopic, $arTopic, $arForum = array())
122 if (($arSitemaps = self::checkParams(array(), $arTopic, $arForum)) && $arSitemaps)
125 foreach($arSitemaps as $key => $arSitemap)
127 $sitemapFile =
new SitemapFile($arSitemap[
"fileName"], $arSitemap);
128 $sitemapFile->removeEntry($arSitemapsOld[$key][
'url']);
130 $sitemapFile->appendIblockEntry($arSitemap[
"url"], $arSitemap[
'date']);
132 $sitemapIndex =
new SitemapIndex($arSitemap[
'SITEMAP_FILE'], $arSitemap);
133 $sitemapIndex->appendIndexEntry($sitemapFile);
134 if($arSitemap[
'ROBOTS'] ==
'Y')
136 $robotsFile =
new RobotsFile($arSitemap[
'SITE_ID']);
137 $robotsFile->addRule(
147 if (($arSitemaps = self::checkParams(array(), $arTopic, $arForum)) && $arSitemaps)
149 foreach($arSitemaps as $arSitemap)
151 $sitemapFile =
new SitemapFile($arSitemap[
"fileName"], $arSitemap);
152 $sitemapFile->removeEntry($arSitemap[
'url']);
153 $informRobots =
false;
154 if (!$sitemapFile->isNotEmpty())
157 'url' => \CForumNew::PreparePath2Message(
158 $arForum[
"PATH2FORUM_MESSAGE"][$arSitemap[
"SITE_ID"]],
160 "FORUM_ID" => $arForum[
"ID"],
161 "TOPIC_ID" => $arForum[
"TID"],
162 "TITLE_SEO" => $arForum[
"TITLE_SEO"],
164 "SOCNET_GROUP_ID" => $arForum[
"SOCNET_GROUP_ID"],
165 "OWNER_ID" => $arForum[
"OWNER_ID"],
166 "PARAM1" => $arForum[
"PARAM1"],
167 "PARAM2" => $arForum[
"PARAM2"]
170 'date' => MakeTimeStamp($arForum[
'LAST_POST_DATE'])
172 $sitemapFile->appendIblockEntry($rule[
'url'], $rule[
'date']);
173 $informRobots =
true;
176 $sitemapIndex =
new SitemapIndex($arSitemap[
'SITEMAP_FILE'], $arSitemap);
177 $sitemapIndex->appendIndexEntry($sitemapFile);
178 if ($informRobots && $arSitemap[
'ROBOTS'] ==
'Y')
180 $robotsFile =
new RobotsFile($arSitemap[
'SITE_ID']);
181 $robotsFile->addRule(
189 protected static function actionAdd($arMessage, $arTopic, $arForum = array())
191 if (($arSitemaps = self::checkParams($arMessage, $arTopic, $arForum)) && $arSitemaps)
193 foreach($arSitemaps as $arSitemap)
195 $sitemapFile =
new SitemapFile($arSitemap[
"fileName"], $arSitemap);
196 $sitemapFile->appendIblockEntry($arSitemap[
'url'], $arSitemap[
'date']);
198 $sitemapIndex =
new SitemapIndex($arSitemap[
'SITEMAP_FILE'], $arSitemap);
199 $sitemapIndex->appendIndexEntry($sitemapFile);
201 if($arSitemap[
'ROBOTS'] ==
'Y')
203 $robotsFile =
new RobotsFile($arSitemap[
'SITE_ID']);
204 $robotsFile->addRule(