3namespace Bitrix\Landing\Assets;
5use \Bitrix\Main\Localization\Loc;
6use Bitrix\Main\UI\Extension;
9use Bitrix\Main\IO\File;
11Loc::loadMessages(__FILE__);
27 private static ?
Manager $instance =
null;
39 private bool $isSandbox =
false;
61 if (self::$instance ===
null)
63 self::$instance =
new static;
66 return self::$instance;
74 $this->mode = self::MODE_STANDART;
86 $this->isSandbox =
true;
97 $this->mode = self::MODE_WEBPACK;
107 $this->mode = self::MODE_STANDART;
127 return array_key_exists(
$code, $this->registered);
139 return $this->registered[
$code][self::REGISTERED_KEY_LOCATION];
150 $this->registered[
$code] = [
151 self::REGISTERED_KEY_CODE =>
$code,
152 self::REGISTERED_KEY_LOCATION =>
$location,
173 foreach (
$code as $item)
205 else if ($ext = Extension::getConfig(
$code))
257 if (!isset($asset[
$type]) || empty($asset[
$type]))
262 if (!is_array($asset[
$type]))
271 foreach ($asset[
$type] as $rel)
284 if (\CMain::isExternalLink(
$path))
289 else if (self::detectType(
$path))
300 foreach ($asset[
$type] as $fontFile)
303 !\CMain::isExternalLink($fontFile)
333 $externalLink =
"<link href=\"$path\" type=\"text/css\" rel=\"stylesheet\">";
339 $externalLink =
"<script src=\"$path\"></script>";
346 $externalLink =
'<link rel="preload" href="' .
$path
347 .
'" as="font" crossorigin="anonymous" type="' . $fontType .
'" crossorigin>';
355 return $externalLink;
368 $type = mb_strtolower(mb_substr(strrchr(
$path,
'.'), 1));
393 'woff2' =>
'font/woff2',
394 'woff' =>
'font/woff',
396 'eot' =>
'application/vnd.ms-fontobject',
397 'svg' =>
'image/svg+xml',
401 foreach ($available as
$type => $value)
420 $this->resources->addString(trim($string));
429 if ($this->isSandbox)
437 "You must to pass ID of current landing to the \Bitrix\Landing\Assets\Manager::setOutput",
442 $this->builder->attachToLanding($lid);
443 $this->builder->setOutput();
455 return $this->builder->getOutput();
464 return $this->resources->getStrings();
static createByType(ResourceCollection $resources, string $type)
static verifyLocation($location)
getRegisteredAssetLocation(string $code)
addString(string $string)
addAsset(string|array $code, ?int $location=null)
processAsset(array $asset, int $location)
static checkFontLinkType(string $path)
const REGISTERED_KEY_CODE
isNeedAddAsset(string $code, int $location)
markAssetRegistered($code, $location)
createStringFromPath(string $path, string $type)
static detectType(string $path)
addAssetRecursive(string $code, $location=null)
const REGISTERED_KEY_LOCATION
static rebuildWebpackForLanding($lid=[])
static markToRebuild($lid)
static markAllToRebuild()
static isExtensionLoaded($code)
static markExtensionLoaded($code)
</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