4use \Bitrix\Landing\Landing;
5use \Bitrix\Landing\Site;
6use \Bitrix\Landing\Hook;
7use \Bitrix\Landing\File;
8use \Bitrix\Landing\Manager;
9use \Bitrix\Main\Loader;
22 if (array_key_exists($landingId, $cached))
24 return $cached[$landingId];
33 'SITE_TYPE' =>
'SITE.TYPE'
39 if ($row = $res->fetch())
41 $landing = Landing::createInstance(0);
42 $row[
'URL'] = $landing->getPublicUrl($landingId);
43 $row[
'DESCRIPTION'] =
'';
47 $hookData = Hook::getForLandingRow($row[
'ID']);
48 if (isset($hookData[
'METAOG'][
'TITLE']))
50 $row[
'TITLE'] = $hookData[
'METAOG'][
'TITLE'];
51 if (isset($hookData[
'METAOG'][
'DESCRIPTION']))
53 $row[
'DESCRIPTION'] = $hookData[
'METAOG'][
'DESCRIPTION'];
56 else if (isset($hookData[
'METAMAIN'][
'TITLE']))
58 $row[
'TITLE'] = $hookData[
'METAMAIN'][
'TITLE'];
59 if (isset($hookData[
'METAMAIN'][
'DESCRIPTION']))
61 $row[
'DESCRIPTION'] = $hookData[
'METAMAIN'][
'DESCRIPTION'];
64 if (isset($hookData[
'METAOG'][
'IMAGE']))
66 $row[
'PICTURE'] = $hookData[
'METAOG'][
'IMAGE'];
67 if (intval($row[
'PICTURE']) > 0)
69 $row[
'PICTURE'] = File::getFilePath($row[
'PICTURE']);
76 $cached[$landingId] = $result;
78 return $cached[$landingId];
88 if (isset($params[
'scope']))
90 \Bitrix\Landing\Site\Type::setScope(
95 if (!isset($params[
'URL']))
97 $params[
'URL'] = Manager::getPublicationPath() . $params[
'URL'];
100 $landingId = self::resolveLandingId($params[
'URL']);
104 Manager::getApplication()->includeComponent(
105 'bitrix:landing.socialnetwork.preview',
108 'LANDING_ID' => $landingId
111 return ob_get_clean();
129 if (isset($params[
'scope']))
131 \Bitrix\Landing\Site\Type::setScope(
136 if (!isset($params[
'URL']))
138 $params[
'URL'] = Manager::getPublicationPath() . ($params[
'knowledgeCode'] ??
'');
141 $landingId = self::resolveLandingId($params[
'URL']);
145 $preview = self::getPreview($landingId);
148 $attach = new \CIMMessageParamAttach(1,
'#E30000');
150 'NAME' => $preview[
'TITLE'],
151 'DESC' => $preview[
'DESCRIPTION'],
152 'LINK' => $preview[
'URL'],
153 'PREVIEW' => $preview[
'PICTURE']
169 if (!class_exists(
'\Bitrix\Im\V2\Entity\Url\RichData'))
174 if (isset($params[
'scope']))
176 \Bitrix\Landing\Site\Type::setScope(
181 if (!isset($params[
'URL']))
183 $params[
'URL'] = Manager::getPublicationPath() . ($params[
'knowledgeCode'] ??
'');
186 $landingId = self::resolveLandingId($params[
'URL']);
190 $preview = self::getPreview($landingId);
193 $rich = new \Bitrix\Im\V2\Entity\Url\RichData();
195 ->setName($preview[
'TITLE'])
196 ->setDescription($preview[
'DESCRIPTION'])
197 ->setLink($preview[
'URL'])
198 ->setPreviewUrl($preview[
'PICTURE'])
199 ->setType(\
Bitrix\Im\V2\
Entity\Url\RichData::LANDING_TYPE)
216 if (isset($params[
'scope']))
218 \Bitrix\Landing\Site\Type::setScope(
223 if (!isset($params[
'URL']))
225 $params[
'URL'] = Manager::getPublicationPath() . ($params[
'knowledgeCode'] ??
'');
228 return self::resolveLandingId($params[
'URL']) !==
null;
238 $publicPath = Manager::getPublicationPath();
240 if ($landingPath[0] !==
'/')
242 $urlParts = parse_url($landingPath);
243 $landingPath = $urlParts[
'path'] ??
'';
246 if (mb_strpos($landingPath, $publicPath) === 0)
248 $landingPath = mb_substr($landingPath, mb_strlen($publicPath));
249 $pathChunks = explode(
'/', $landingPath);
250 if (!empty($pathChunks[0]))
252 $res = Site::getList([
257 '=CODE' =>
'/' . $pathChunks[0] .
'/'
260 if ($row = $res->fetch())
279 if ($landingPath[0] !==
'/')
281 $urlParts = parse_url($landingPath);
282 $landingPath = $urlParts[
'path'] ??
'';
287 $siteId = self::resolveSiteId($landingPath);
290 $landingId = Landing::resolveIdByPublicUrl($landingPath, $siteId);
static getList(array $params=array())
static getPreview(int $landingId)
static resolveLandingId(string $landingPath)
static resolveSiteId(string $landingPath)
static buildPreview(array $params)
static getImRich(array $params)
static getImAttach(array $params)
static checkUserReadAccess(array $params, int $userId)
static includeModule($moduleName)