Update
This commit is contained in:
@@ -5,6 +5,7 @@ use Bitrix\Landing\Field;
|
||||
use Bitrix\Landing\Manager;
|
||||
use Bitrix\Main\Loader;
|
||||
use Bitrix\Main\Localization\Loc;
|
||||
use Bitrix\Main\Page\Asset;
|
||||
use Bitrix\UI;
|
||||
|
||||
class Fonts extends \Bitrix\Landing\Hook\Page
|
||||
@@ -65,6 +66,11 @@ class Fonts extends \Bitrix\Landing\Hook\Page
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Default domain for Google Fonts.
|
||||
*/
|
||||
public const DEFAULT_DOMAIN = 'fonts.googleapis.com';
|
||||
|
||||
/**
|
||||
* Set fonts on the page.
|
||||
* @var array
|
||||
@@ -164,10 +170,7 @@ class Fonts extends \Bitrix\Landing\Hook\Page
|
||||
|
||||
if ($setFonts)
|
||||
{
|
||||
Manager::setPageView(
|
||||
'BeforeHeadClose',
|
||||
implode('', $setFonts)
|
||||
);
|
||||
Asset::getInstance()->addString(implode('', $setFonts));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +214,8 @@ class Fonts extends \Bitrix\Landing\Hook\Page
|
||||
*/
|
||||
public static function generateFontTags(string $fontName): string
|
||||
{
|
||||
$fontUrl = "https://fonts.bitrix24.ru/css2?family="
|
||||
$proxyDomain = self::getProxyDomain();
|
||||
$fontUrl = "https://{$proxyDomain}/css2?family="
|
||||
. str_replace(' ', '+', $fontName)
|
||||
. ":wght@100;200;300;400;500;600;700;800;900";
|
||||
$fontClass = strtolower(str_replace(' ', '-', $fontName));
|
||||
@@ -221,7 +225,7 @@ class Fonts extends \Bitrix\Landing\Hook\Page
|
||||
<link rel="preload" href="$fontUrl" data-font="g-font-$fontClass" onload="this.removeAttribute('onload');this.rel='stylesheet'" as="style">
|
||||
<style data-id="g-font-$fontClass">.g-font-$fontClass { font-family: "$fontName", sans-serif; }</style>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy font url to bitrix servers
|
||||
@@ -230,16 +234,28 @@ class Fonts extends \Bitrix\Landing\Hook\Page
|
||||
*/
|
||||
protected static function proxyFontUrl(string $fontString): string
|
||||
{
|
||||
$defaultDomain = 'fonts.googleapis.com';
|
||||
$proxyDomain = $defaultDomain;
|
||||
if (Loader::includeModule('ui'))
|
||||
{
|
||||
$proxyDomain = UI\Fonts\Proxy::resolveDomain(Manager::getZone());
|
||||
}
|
||||
$defaultDomain = self::DEFAULT_DOMAIN;
|
||||
$proxyDomain = self::getProxyDomain();
|
||||
|
||||
return ($defaultDomain !== $proxyDomain)
|
||||
? str_replace($defaultDomain, $proxyDomain, $fontString)
|
||||
: $fontString
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the proxy domain for fonts, depending on the current zone and UI module.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getProxyDomain(): string
|
||||
{
|
||||
$proxyDomain = self::DEFAULT_DOMAIN;
|
||||
if (Loader::includeModule('ui'))
|
||||
{
|
||||
$proxyDomain = UI\Fonts\Proxy::resolveDomain(Manager::getZone());
|
||||
}
|
||||
|
||||
return $proxyDomain;
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class PixelVk extends \Bitrix\Landing\Hook\Page
|
||||
var t=document.createElement("script");
|
||||
t.type="text/javascript",
|
||||
t.async=!0,
|
||||
t.src="https://vk.com/js/api/openapi.js?160",
|
||||
t.src="https://vk.ru/js/api/openapi.js?160",
|
||||
t.onload=function(){VK.Retargeting.Init("' . $counter . '"),
|
||||
VK.Retargeting.Hit()},document.head.appendChild(t)
|
||||
}();'
|
||||
@@ -84,7 +84,7 @@ class PixelVk extends \Bitrix\Landing\Hook\Page
|
||||
Manager::setPageView(
|
||||
'Noscript',
|
||||
'<noscript>
|
||||
<img src="https://vk.com/rtrg?p=' . $counter . '" style="position:fixed; left:-999px;" alt=""/>
|
||||
<img src="https://vk.ru/rtrg?p=' . $counter . '" style="position:fixed; left:-999px;" alt=""/>
|
||||
</noscript>'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class Settings extends \Bitrix\Landing\Hook\Page
|
||||
'BRAND_PROPERTY' => 'BRAND_REF',
|
||||
'CART_POSITION' => 'BL',
|
||||
'AGREEMENT_ID' => 0,
|
||||
'AGREEMENTS' => null,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -156,9 +157,8 @@ class Settings extends \Bitrix\Landing\Hook\Page
|
||||
default:
|
||||
{
|
||||
$field = new Field\Text($code, array(
|
||||
'title' => isset($params['NAME'])
|
||||
? $params['NAME']
|
||||
: ''
|
||||
'title' => $params['NAME'] ?? '',
|
||||
'fetch_data_modification' => $params['FETCH_DATA_MODIFICATION'] ?? null,
|
||||
));
|
||||
break;
|
||||
}
|
||||
@@ -322,6 +322,40 @@ class Settings extends \Bitrix\Landing\Hook\Page
|
||||
$fields['AGREEMENT_ID'] = self::getFieldByType(
|
||||
null, 'AGREEMENT_ID'
|
||||
);
|
||||
$fields['AGREEMENTS'] = self::getFieldByType(
|
||||
null,
|
||||
'AGREEMENTS',
|
||||
[
|
||||
'FETCH_DATA_MODIFICATION' => function ($agreements) {
|
||||
if (!is_array($agreements))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$resultAgreements = [];
|
||||
$existAgreementIds = [];
|
||||
foreach ($agreements as $agreement)
|
||||
{
|
||||
$agreement['ID'] = (int)$agreement['ID'];
|
||||
if (
|
||||
empty($agreement['ID'])
|
||||
|| isset($existAgreementIds[$agreement['ID']])
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$existAgreementIds[$agreement['ID']] = true;
|
||||
$resultAgreements[] = [
|
||||
'ID' => $agreement['ID'],
|
||||
'CHECKED' => $agreement['CHECKED'] === 'Y' ? 'Y' : 'N',
|
||||
'REQUIRED' => $agreement['REQUIRED'] === 'Y' ? 'Y' : 'N',
|
||||
];
|
||||
}
|
||||
|
||||
return $resultAgreements;
|
||||
}
|
||||
],
|
||||
);
|
||||
|
||||
// cart position
|
||||
$positions = array_fill_keys(
|
||||
@@ -423,11 +457,19 @@ class Settings extends \Bitrix\Landing\Hook\Page
|
||||
if($hooks['SETTINGS']['AGREEMENT_USE'] === 'N')
|
||||
{
|
||||
$settings[$id]['AGREEMENT_ID'] = 0;
|
||||
$settings[$id]['AGREEMENTS'] = [];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings[$id]['AGREEMENT_USE'] = $settings[$id]['AGREEMENT_ID'] ? 'Y' : 'N';
|
||||
if ($settings[$id]['AGREEMENTS'] === null)
|
||||
{
|
||||
$settings[$id]['AGREEMENT_USE'] = $settings[$id]['AGREEMENT_ID'] ? 'Y' : 'N';
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings[$id]['AGREEMENT_USE'] = $settings[$id]['AGREEMENTS'] ? 'Y' : 'N';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($hooks['SETTINGS']['CART_POSITION']))
|
||||
|
||||
Reference in New Issue
Block a user