1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
tag.php
См. документацию.
1<?php
2
4
7
8class Tag
9{
10 public static function getTagsFromPostData(array $params = []): array
11 {
12 $result = [];
13
14 $blogId = (int)($params['blogId'] ?? 0);
15 $inputTags = (string) ($params['tags'] ?? '');
16
17 $inputTags = !empty($_POST['TAGS']) ? $_POST['TAGS'] : $inputTags;
18
19 if ($inputTags)
20 {
21 $blogCategoryList = [];
22
23 $res = \CBlogCategory::getList([], [ 'BLOG_ID' => $blogId ]);
24 while ($blogCategoryFields = $res->fetch())
25 {
26 $blogCategoryList[mb_strtolower($blogCategoryFields['NAME'])] = (int)$blogCategoryFields['ID'];
27 }
28
29 $tags = explode(',', $inputTags);
30 foreach ($tags as $tg)
31 {
32 $tg = trim($tg);
33 if (
34 $tg !== ''
35 && !in_array($blogCategoryList[mb_strtolower($tg)] ?? null, $result, true)
36 )
37 {
38 $result[] = (int) (
39 ((int) ($blogCategoryList[mb_strtolower($tg)] ?? null) > 0)
40 ? $blogCategoryList[mb_strtolower($tg)]
41 : \CBlogCategory::add([
42 'BLOG_ID' => $blogId,
43 'NAME' => $tg,
44 ])
45 );
46 }
47 }
48 }
49 elseif (!empty($_POST['CATEGORY_ID']))
50 {
51 foreach ($_POST['CATEGORY_ID'] as $v)
52 {
53 $result[] = (int)(
54 mb_strpos($v, 'new_') === 0
55 ? \CBlogCategory::add([
56 'BLOG_ID' => $blogId,
57 'NAME' => mb_substr($v, 4),
58 ])
59 : $v
60 );
61 }
62 }
63
64 return $result;
65 }
66
67 public static function parseTagsFromFields(array $params = []): array
68 {
69 $result = [];
70
71 $blogCategoryIdList = ($params['blogCategoryIdList'] ?? []);
72 $postFields = ($params['postFields'] ?? []);
73 $blogId = (int)($params['blogId'] ?? 0);
74
75 $existingTagList = [];
76
77 if (!empty($blogCategoryIdList))
78 {
79 $res = \CBlogCategory::getList(
80 [],
81 [
82 '@ID' => $blogCategoryIdList,
83 ],
84 false,
85 false,
86 [ 'NAME' ]
87 );
88 while ($blogCategoryFields = $res->fetch())
89 {
90 $existingTagList[] = $blogCategoryFields['NAME'];
91 }
92 }
93
94 $codeList = [ 'DETAIL_TEXT' ];
95 if (
96 !isset($postFields['MICRO'])
97 || $postFields['MICRO'] !== 'Y'
98 )
99 {
100 $codeList[] = 'TITLE';
101 }
102
103 $inlineTagList = Util::detectTags($postFields, $codeList);
104
105 $tagList = array_merge($existingTagList, $inlineTagList);
106 $tagList = array_intersect_key($tagList, array_unique(array_map('ToLower', $tagList)));
107
108 if (count($tagList) > count($existingTagList))
109 {
110 $lowerExistingTagList = array_unique(array_map('ToLower', $existingTagList));
111 $newTagList = [];
112
113 foreach ($inlineTagList as $inlineTag)
114 {
115 if (!in_array(mb_strtolower($inlineTag), $lowerExistingTagList, true))
116 {
117 $newTagList[] = $inlineTag;
118 }
119 }
120
121 if (!empty($newTagList))
122 {
123 $newTagList = array_unique($newTagList);
124
125 $existingCategoriesList = [];
126 $res = \CBlogCategory::getList(
127 [],
128 [
129 '@NAME' => $newTagList,
130 'BLOG_ID' => $blogId,
131 ],
132 false,
133 false,
134 [ 'ID', 'NAME' ]
135 );
136 while ($blogCategoryFields = $res->fetch())
137 {
138 $existingCategoriesList[$blogCategoryFields['NAME']] = (int)$blogCategoryFields['ID'];
139 }
140
141 foreach ($newTagList as $newTag)
142 {
143 if (isset($existingCategoriesList[$newTag]))
144 {
145 $result[] = $existingCategoriesList[$newTag];
146 }
147 else
148 {
149 $result[] = (int)\CBlogCategory::add([
150 'BLOG_ID' => $blogId,
151 'NAME' => $newTag,
152 ]);
153 }
154 }
155 }
156 }
157
158 return $result;
159 }
160}
Определения post.php:20
Определения tag.php:9
static parseTagsFromFields(array $params=[])
Определения tag.php:67
static getTagsFromPostData(array $params=[])
Определения tag.php:10
static detectTags($fieldList, $codeList=array())
Определения util.php:251
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
Определения tag.php:3
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799