%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.22.240.164 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/web/webpacker/ |
Upload File : |
<?php namespace Bitrix\Main\Web\WebPacker; /** * Class Loader * * @package Bitrix\Main\Web\WebPacker */ class Loader { /** @var Output\File */ protected $file; protected $cacheTtl = 60; protected $skipMoving = false; protected $tagAttributes = []; /** * Loader constructor. * * @param Output\File $file File output instance. */ public function __construct(Output\File $file) { $this->file = $file; } /** * Set cache ttl. * * @param int $cacheTtl Ttl in seconds. * @return $this */ public function setCacheTtl($cacheTtl) { $this->cacheTtl = (int) $cacheTtl; return $this; } /** * Set skip moving. * * @param bool $skip Skip moving. * @return $this */ public function setSkipMoving($skip) { $this->skipMoving = (bool) $skip; return $this; } /** * Set tag attributes. * * @param array $tagAttributes Tag attributes. * @return $this */ public function setTagAttributes(array $tagAttributes = []) { $this->tagAttributes = $tagAttributes; return $this; } /** * Return loader file url. * * @return string */ public function getFileUrl() { return $this->file->getUri(); } /** * Return loader string. * * @return string */ public function getString() { $content = $this->getStringJs(); $attributes = $this->tagAttributes; if ($this->skipMoving) { $attributes['data-skip-moving'] = 'true'; } $attrs = ''; foreach ($attributes as $key => $value) { $attrs .= " " . htmlspecialcharsbx($key) . '="' . htmlspecialcharsbx($value) . '"'; } return <<<EOD <script{$attrs}> $content </script> EOD; } /** * Return loader js string. * * @return string */ public function getStringJs() { $path = $this->file->getUri(); if (!$path) { return ''; } $ttl = ($this->cacheTtl ?: 1) * 1000; return <<<EOD (function(w,d,u){ var s=d.createElement('script');s.async=true;s.src=u+'?'+(Date.now()/$ttl|0); var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h); })(window,document,'$path'); EOD; } }