2namespace Bitrix\Landing\DataLoader;
4use \Bitrix\Landing\Block;
5use \Bitrix\Landing\Hook;
6use \Bitrix\Landing\Landing as LandingCore;
7use \Bitrix\Landing\Landing\Cache;
19 $res = \Bitrix\Landing\Internals\HookDataTable::getList([
21 'VALUE',
'ENTITY_ID',
'CODE'
25 '=CODE' => [
'IMAGE',
'DESCRIPTION'],
26 '=PUBLIC' => Hook::getEditMode() ?
'N' :
'Y',
27 '=ENTITY_TYPE' => Hook::ENTITY_TYPE_LANDING,
31 while ($row =
$res->fetch())
33 if (!isset($images[$row[
'ENTITY_ID']]))
35 $images[$row[
'ENTITY_ID']] = [];
37 if ($row[
'CODE'] ==
'IMAGE')
39 if (intval($row[
'VALUE']) > 0)
44 $images[$row[
'ENTITY_ID']][$row[
'CODE']] = $row[
'VALUE'];
56 static $currentRequest =
null;
58 if ($currentRequest ===
null)
61 $currentRequest =
$context->getRequest();
64 return trim($currentRequest->get(
'q'));
75 $phrases = explode(
' ',
$query);
76 \trimArr($phrases,
true);
80 foreach ($phrases as $phrase)
82 $phrasePos = mb_strpos(mb_strtolower(
$content), mb_strtolower($phrase));
83 if ($phrasePos ===
false)
87 $newContent .= (($phrasePos > $snippetOffset) ?
' ...' :
' ') .
90 ($phrasePos > $snippetOffset) ? $phrasePos - $snippetOffset : 0,
91 $phrasePos + mb_strlen($phrase) + $snippetOffset
106 $needPreviewPicture =
false;
107 $needPreviewText =
false;
125 if (isset($contextFilter[
'SITE_ID']))
127 $filter[
'SITE_ID'] = $contextFilter[
'SITE_ID'];
129 if (isset($contextFilter[
'LANDING_ACTIVE']))
131 $filter[
'=ACTIVE'] = $contextFilter[
'LANDING_ACTIVE'];
139 if (isset($rawOrder[
'by']) && isset($rawOrder[
'order']))
141 $order[$rawOrder[
'by']] = $rawOrder[
'order'];
142 if (!in_array($rawOrder[
'by'],
$select))
149 if (
$code ==
'IMAGE')
151 $needPreviewPicture =
true;
154 else if (
$code ==
'DESCRIPTION')
156 $needPreviewText =
true;
159 else if (
$code ==
'LINK')
177 if ($cache instanceof \CPHPCache)
179 $cache->abortDataCache();
182 if (mb_strlen(
$query) < 3)
191 $blockFilter[
'LANDING.SITE_ID'] =
$filter[
'SITE_ID'];
193 $blocks = Block::search(
196 [
'LID',
'ID',
'SEARCH_CONTENT']
198 $landingBlocksIds = [];
199 foreach ($blocks as $block)
202 if (!$searchContent[$block[
'LID']])
204 unset($searchContent[$block[
'LID']]);
206 $landingBlocksIds[] = $block[
'LID'];
212 'TITLE' =>
'%' .
$query .
'%',
213 '*%SEARCH_CONTENT' =>
$query,
214 'ID' => $landingBlocksIds ? $landingBlocksIds : [-1]
226 while ($row =
$res->fetch())
228 Cache::register($row[
'ID']);
237 $needPreviewPicture ||
247 foreach (
$result as $id => &$item)
250 $needPreviewPicture &&
251 isset($metaData[$id][
'IMAGE'])
255 'src' => $metaData[$id][
'IMAGE'],
256 'alt' => $item[
'TITLE'] ??
''
259 if ($needPreviewText)
261 if (isset($searchContent[$id]))
265 else if (isset($metaData[$id][
'DESCRIPTION']))
272 $item[
'LINK'] =
'#landing' . $id;
294 $element = intval($element);
321 $row =
$res->fetch();
327 Cache::register($row[
'ID']);
328 $this->seo->setTitle($row[
'TITLE']);
getSearchSnippet(string $query, string $content)
static getFilePath($fileId)
getPreparedSelectFields()
static getList(array $parameters=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)