14 $blogId = (int)($params[
'blogId'] ?? 0);
15 $inputTags = (string) ($params[
'tags'] ??
'');
17 $inputTags = !empty($_POST[
'TAGS']) ? $_POST[
'TAGS'] : $inputTags;
21 $blogCategoryList = [];
23 $res = \CBlogCategory::getList([], [
'BLOG_ID' => $blogId ]);
24 while ($blogCategoryFields = $res->fetch())
26 $blogCategoryList[ToLower($blogCategoryFields[
'NAME'])] = (int)$blogCategoryFields[
'ID'];
29 $tags = explode(
',', $inputTags);
30 foreach ($tags as $tg)
35 && !in_array($blogCategoryList[ToLower($tg)] ??
null, $result,
true)
39 ((
int) ($blogCategoryList[ToLower($tg)] ??
null) > 0)
40 ? $blogCategoryList[ToLower($tg)]
41 : \CBlogCategory::add([
49 elseif (!empty($_POST[
'CATEGORY_ID']))
51 foreach ($_POST[
'CATEGORY_ID'] as $v)
54 mb_strpos($v,
'new_') === 0
55 ? \CBlogCategory::add([
57 'NAME' => mb_substr($v, 4),
71 $blogCategoryIdList = ($params[
'blogCategoryIdList'] ?? []);
72 $postFields = ($params[
'postFields'] ?? []);
73 $blogId = (int)($params[
'blogId'] ?? 0);
75 $existingTagList = [];
77 if (!empty($blogCategoryIdList))
79 $res = \CBlogCategory::getList(
82 '@ID' => $blogCategoryIdList,
88 while ($blogCategoryFields = $res->fetch())
90 $existingTagList[] = $blogCategoryFields[
'NAME'];
94 $codeList = [
'DETAIL_TEXT' ];
96 !isset($postFields[
'MICRO'])
97 || $postFields[
'MICRO'] !==
'Y'
100 $codeList[] =
'TITLE';
105 $tagList = array_merge($existingTagList, $inlineTagList);
106 $tagList = array_intersect_key($tagList, array_unique(array_map(
'ToLower', $tagList)));
108 if (count($tagList) > count($existingTagList))
110 $lowerExistingTagList = array_unique(array_map(
'ToLower', $existingTagList));
113 foreach ($inlineTagList as $inlineTag)
115 if (!in_array(ToLower($inlineTag), $lowerExistingTagList,
true))
117 $newTagList[] = $inlineTag;
121 if (!empty($newTagList))
123 $newTagList = array_unique($newTagList);
125 $existingCategoriesList = [];
126 $res = \CBlogCategory::getList(
129 '@NAME' => $newTagList,
130 'BLOG_ID' => $blogId,
136 while ($blogCategoryFields = $res->fetch())
138 $existingCategoriesList[$blogCategoryFields[
'NAME']] = (int)$blogCategoryFields[
'ID'];
141 foreach ($newTagList as $newTag)
143 if (isset($existingCategoriesList[$newTag]))
145 $result[] = $existingCategoriesList[$newTag];
149 $result[] = (int)\CBlogCategory::add([
150 'BLOG_ID' => $blogId,