9 public function connect($connectionString =
'')
12 $DB = CDatabase::GetModuleConnection(
'search');
14 if (!
$DB->TableExists(
'b_search_content_text'))
20 if (!
$DB->IndexExists(
'b_search_content_text', [
'SEARCHABLE_CONTENT']))
22 $r =
$DB->Query(
'create fulltext index fti on b_search_content_text(SEARCHABLE_CONTENT)',
true);
35 $DB = CDatabase::GetModuleConnection(
'search');
36 $DB->Query(
'TRUNCATE TABLE b_search_content_text');
41 $DB = CDatabase::GetModuleConnection(
'search');
42 $DB->Query(
'DELETE FROM b_search_content_text WHERE SEARCH_CONTENT_ID = ' .
$ID);
52 $DB = CDatabase::GetModuleConnection(
'search');
54 if (array_key_exists(
'SEARCHABLE_CONTENT',
$arFields))
56 $text_md5 = md5(
$arFields[
'SEARCHABLE_CONTENT']);
57 $rsText =
$DB->Query(
'SELECT SEARCH_CONTENT_MD5 FROM b_search_content_text WHERE SEARCH_CONTENT_ID = ' .
$ID);
58 $arText = $rsText->Fetch();
59 if (!$arText || $arText[
'SEARCH_CONTENT_MD5'] !== $text_md5)
62 REPLACE INTO b_search_content_text
63 (SEARCH_CONTENT_ID, SEARCH_CONTENT_MD5, SEARCHABLE_CONTENT)
65 (' .
$ID .
", '" .
$DB->ForSql($text_md5) .
"', '" .
$DB->ForSql(
$arFields[
'SEARCHABLE_CONTENT']) .
"')
73 $DB = CDatabase::GetModuleConnection(
'search');
75 $queryObject = $aParamsEx[
'QUERY_OBJECT'];
76 if ($queryObject->m_parsed_query ==
'( )' || $queryObject->m_parsed_query ==
'')
83 $strQuery = $this->
PrepareQuery($queryObject, $queryObject->m_parsed_query);
84 if ($strQuery ==
'(())' || $queryObject->m_parsed_query ==
'')
95 $arTags = explode(
',',
$arParams[
'TAGS']);
96 foreach ($arTags as
$i => $strTag)
98 $arTags[
$i] = trim($strTag,
'"');
103 $strTags =
'+(+"' . implode(
'" +"', $arTags) .
'")';
107 if (($strQuery ==
'') && ($strTags <>
''))
109 $strQuery = $strTags;
114 $strQuery = preg_replace_callback(
'/&#(\\d+);/',
'chr', $strQuery);
115 $bTagsSearch =
false;
118 $query =
"match sct.SEARCHABLE_CONTENT against('" .
$DB->ForSql($strQuery) .
"' in boolean mode)";
121 if (is_array($aParamsEx) && !empty($aParamsEx))
123 foreach ($aParamsEx as $aParamEx)
126 if ($strSqlWhere !=
'')
128 $arSqlWhere[] = $strSqlWhere;
132 if (!empty($arSqlWhere))
135 "\n\t\t\t\t(" . implode(
")\n\t\t\t\t\tOR(", $arSqlWhere) .
"\n\t\t\t\t)",
140 if ($strSqlWhere !=
'')
142 array_unshift($arSqlWhere, $strSqlWhere);
145 $strSqlOrder = $this->
__PrepareSort($aSort,
'sc.', $bTagsCloud);
147 if (!empty($arSqlWhere))
149 $strSqlWhere =
"\n\t\t\t\tAND (\n\t\t\t\t\t(" . implode(
")\n\t\t\t\t\tAND(", $arSqlWhere) .
")\n\t\t\t\t)";
157 ,COUNT(DISTINCT stags.SEARCH_CONTENT_ID) as CNT
158 ,MAX(sc.DATE_CHANGE) DC_TMP
159 ,' .
$DB->DateToCharFunction(
'MAX(sc.DATE_CHANGE)') .
' as FULL_DATE_CHANGE
160 ,' .
$DB->DateToCharFunction(
'MAX(sc.DATE_CHANGE)',
'SHORT') .
' as DATE_CHANGE
161 FROM b_search_tags stags
162 INNER JOIN b_search_content sc ON (stags.SEARCH_CONTENT_ID=sc.ID)
163 INNER JOIN b_search_content_text sct ON sct.SEARCH_CONTENT_ID = sc.ID
164 INNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID
168 AND stags.SITE_ID = scsite.SITE_ID
179 sct.SEARCH_CONTENT_ID
183 b_search_content_text sct
184 INNER JOIN b_search_content sc ON sc.ID = sct.SEARCH_CONTENT_ID
185 INNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID
193 $r =
$DB->Query($strSql);
195 while (
$a = $r->Fetch())
223 function __PrepareSort($aSort = [], $strSearchContentAlias =
'sc.', $bTagsCloud =
false)
226 if (!is_array($aSort))
228 $aSort = [$aSort =>
'ASC'];
233 foreach ($aSort as
$key => $ord)
235 $ord = mb_strtoupper($ord) <>
'ASC' ?
'DESC' :
'ASC';
240 $arOrder[] =
'DC_TMP ' . $ord;
244 $arOrder[] =
$key .
' ' . $ord;
250 $arOrder[] =
'NAME ASC';
255 $this->flagsUseRatingSort = 0;
256 foreach ($aSort as
$key => $ord)
258 $ord = mb_strtoupper($ord) <>
'ASC' ?
'DESC' :
'ASC';
263 if (!($this->flagsUseRatingSort & 0x01))
265 $this->flagsUseRatingSort = 0x02;
267 $arOrder[] = $strSearchContentAlias .
$key .
' ' . $ord;
270 if (!($this->flagsUseRatingSort & 0x02))
272 $this->flagsUseRatingSort = 0x01;
274 $arOrder[] =
'`RANK` ' . $ord;
277 $arOrder[] =
'`RANK` ' . $ord;
280 $arOrder[] = $strSearchContentAlias .
$key .
' ' . $ord;
292 if (!($this->flagsUseRatingSort & 0x01))
294 $this->flagsUseRatingSort = 0x02;
296 $arOrder[] = $strSearchContentAlias .
$key .
' ' . $ord;
303 $arOrder[] =
'CUSTOM_RANK DESC';
304 $arOrder[] =
'`RANK` DESC';
305 $arOrder[] = $strSearchContentAlias .
'DATE_CHANGE DESC';
306 $this->flagsUseRatingSort = 0x01;
310 return ' ORDER BY ' . implode(
', ', $arOrder);
321 foreach (preg_split(
'/ +/', $q) as $t)
325 if (($t ===
'||') || ($t ===
'&&') || ($t ===
')'))
327 $this->error =
GetMessage(
'SEARCH_ERROR2') .
' ' . $t;
335 if (isset($qu[
$p]) && $qu[
$p] ===
' +')
344 if (isset($qu[
$p]) && $qu[
$p] ===
'(')
353 if (isset($queryObject->m_kav[$t]))
355 $t =
'"' . $queryObject->m_kav[$t] .
'"';
359 if (preg_match(
'/[^\w\d]/u', $t))
361 $t = preg_replace(
'/[^\w\d]+$/u',
'', $t);
362 $t = preg_replace(
'/^[^\w\d]+/u',
'', $t);
367 $t =
'(+' . preg_replace(
'/[^\w\d]+/u',
' +', $t) . ($queryObject->bStemming ?
'*' :
'') .
')';
369 elseif ($queryObject->bStemming)
375 if (!isset($qu[
$p]) || $qu[
$p] !==
' -')
384 if (($t ===
'||') || ($t ===
'&&'))
395 while (isset($qu[
$p]) && $qu[
$p] !==
')')
400 while (isset($qu[
$p]) && $nn)
412 if (isset($qu[
$p - 1]) && $qu[
$p - 1] ===
'')
425 $this->error =
GetMessage(
'SEARCH_ERROR2') .
' ' . $t;
432 if (($this->error ===
'') && (
$n !== 0))
438 if ($this->error !=
'')
453 if (array_key_exists(
'CNT', $r))
457 elseif (array_key_exists(
'SEARCH_CONTENT_ID', $r))
466 $DB = CDatabase::GetModuleConnection(
'search');
483 ,' .
$DB->DateToCharFunction(
'sc.DATE_CHANGE') .
' as FULL_DATE_CHANGE
484 ,' .
$DB->DateToCharFunction(
'sc.DATE_CHANGE',
'SHORT') .
' as DATE_CHANGE
488 from b_search_content sc
489 INNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID
490 where ID = ' . $r[
'SEARCH_CONTENT_ID'] .
"
491 and scsite.SITE_ID = '" . $r[
'SITE_ID'] .
"'
static __PrepareFilter($arFilter, &$bIncSites, $strSearchContentAlias='sc.')
static CheckPermissions($FIELD='sc.ID')
searchTitle($phrase='', $arPhrase=[], $nTopCount=5, $arParams=[], $bNotFilter=false, $order='')
PrepareQuery($queryObject, $q)
connect($connectionString='')
__PrepareSort($aSort=[], $strSearchContentAlias='sc.', $bTagsCloud=false)
search($arParams, $aSort, $aParamsEx, $bTagsCloud)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</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."%"