1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
loader.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Web\WebPacker;
4
10class Loader
11{
13 protected $file;
14
15 protected $cacheTtl = 60;
16
17 protected $skipMoving = false;
18
19 protected $tagAttributes = [];
20
26 public function __construct(Output\File $file)
27 {
28 $this->file = $file;
29 }
30
37 public function setCacheTtl($cacheTtl)
38 {
39 $this->cacheTtl = (int) $cacheTtl;
40 return $this;
41 }
42
49 public function setSkipMoving($skip)
50 {
51 $this->skipMoving = (bool) $skip;
52 return $this;
53 }
54
62 {
63 $this->tagAttributes = $tagAttributes;
64 return $this;
65 }
66
72 public function getFileUrl()
73 {
74 return $this->file->getUri();
75 }
76
82 public function getString()
83 {
84 $content = $this->getStringJs();
85 $attributes = $this->tagAttributes;
86 if ($this->skipMoving)
87 {
88 $attributes['data-skip-moving'] = 'true';
89 }
90 $attrs = '';
91 foreach ($attributes as $key => $value)
92 {
93 $attrs .= " " . htmlspecialcharsbx($key) . '="'
94 . htmlspecialcharsbx($value) . '"';
95 }
96 return <<<EOD
97<script{$attrs}>
99</script>
100EOD;
101
102 }
103
109 public function getStringJs()
110 {
111 $path = $this->file->getUri();
112 if (!$path)
113 {
114 return '';
115 }
116
117 $ttl = ($this->cacheTtl ?: 1) * 1000;
118
119 return
120<<<EOD
121 (function(w,d,u){
122 var s=d.createElement('script');s.async=true;s.src=u+'?'+(Date.now()/$ttl|0);
123 var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
124 })(window,document,'$path');
125EOD;
126
127 }
128}
$path
Определения access_edit.php:21
Определения loader.php:13
Определения date.php:9
__construct(Output\File $file)
Определения loader.php:26
setCacheTtl($cacheTtl)
Определения loader.php:37
setSkipMoving($skip)
Определения loader.php:49
setTagAttributes(array $tagAttributes=[])
Определения loader.php:61
$content
Определения commerceml.php:144
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
Определения Image.php:9
if(empty($signedUserToken)) $key
Определения quickway.php:257