1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Blitz PHP framework. |
5
|
|
|
* |
6
|
|
|
* (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view |
9
|
|
|
* the LICENSE file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
if (! function_exists('css_url')) { |
13
|
|
|
/** |
14
|
|
|
* CSS URL |
15
|
|
|
* |
16
|
|
|
* Renvoie l'url d'un fichier css. |
17
|
|
|
* |
18
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
19
|
|
|
*/ |
20
|
|
|
function css_url(string $name): string |
21
|
|
|
{ |
22
|
2 |
|
$name = explode('?', $name)[0]; |
23
|
2 |
|
$name = str_replace(site_url() . 'css/', '', htmlspecialchars($name)); |
24
|
|
|
|
25
|
|
|
if (is_localfile($name)) { |
26
|
2 |
|
$name .= (! preg_match('#\.css$#i', $name) ? '.css' : ''); |
27
|
2 |
|
$filename = WEBROOT . 'css' . DS . $name; |
|
|
|
|
28
|
|
|
|
29
|
2 |
|
return site_url() . 'css/' . $name . ((file_exists($filename)) ? '?v=' . filemtime($filename) : ''); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
return $name . (! preg_match('#\.css$#i', $name) ? '.css' : ''); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
if (! function_exists('js_url')) { |
37
|
|
|
/** |
38
|
|
|
* JS URL |
39
|
|
|
* |
40
|
|
|
* Renvoie l'url d'un fichier js. |
41
|
|
|
* |
42
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
43
|
|
|
*/ |
44
|
|
|
function js_url(string $name): string |
45
|
|
|
{ |
46
|
2 |
|
$name = explode('?', $name)[0]; |
47
|
2 |
|
$name = str_replace(site_url() . 'js/', '', htmlspecialchars($name)); |
48
|
|
|
|
49
|
|
|
if (is_localfile($name)) { |
50
|
2 |
|
$name .= (! preg_match('#\.js$#i', $name) ? '.js' : ''); |
51
|
2 |
|
$filename = WEBROOT . 'js' . DS . $name; |
|
|
|
|
52
|
|
|
|
53
|
2 |
|
return site_url() . 'js/' . $name . ((file_exists($filename)) ? '?v=' . filemtime($filename) : ''); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return $name . (! preg_match('#\.js$#i', $name) ? '.js' : ''); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (! function_exists('lib_css_url')) { |
61
|
|
|
/** |
62
|
|
|
* LIB CSS URL |
63
|
|
|
* |
64
|
|
|
* Renvoie l'url d'un fichier css d'une librairie |
65
|
|
|
* |
66
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
67
|
|
|
*/ |
68
|
|
|
function lib_css_url(string $name): string |
69
|
|
|
{ |
70
|
2 |
|
$name = explode('?', $name)[0]; |
71
|
2 |
|
$site_url = site_url(); |
72
|
|
|
$name = str_replace( |
73
|
|
|
[$site_url . 'lib/', $site_url . 'vendor/', $site_url . 'plugins/'], |
74
|
|
|
'', |
75
|
|
|
htmlspecialchars($name) |
76
|
2 |
|
); |
77
|
|
|
|
78
|
|
|
if (is_localfile($name)) { |
79
|
2 |
|
$name .= (! preg_match('#\.css$#i', $name) ? '.css' : ''); |
80
|
2 |
|
$paths = ['lib', 'vendor', 'plugins']; |
81
|
|
|
|
82
|
|
|
foreach ($paths as $path) { |
83
|
2 |
|
$filename = WEBROOT . $path . DS . $name; |
|
|
|
|
84
|
|
|
|
85
|
|
|
if (file_exists($filename)) { |
86
|
2 |
|
return $site_url . $path . '/' . $name . '?v=' . filemtime($filename); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
2 |
|
return $site_url . 'lib/' . $name; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return $name . (! preg_match('#\.css$#i', $name) ? '.css' : ''); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
if (! function_exists('lib_js_url')) { |
98
|
|
|
/** |
99
|
|
|
* LIB JS URL |
100
|
|
|
* |
101
|
|
|
* Renvoie l'url d'un fichier js d'une librairy. |
102
|
|
|
* |
103
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
104
|
|
|
*/ |
105
|
|
|
function lib_js_url(string $name): string |
106
|
|
|
{ |
107
|
2 |
|
$name = explode('?', $name)[0]; |
108
|
2 |
|
$site_url = site_url(); |
109
|
|
|
$name = str_replace( |
110
|
|
|
[$site_url . 'lib/', $site_url . 'vendor/', $site_url . 'plugins/'], |
111
|
|
|
'', |
112
|
|
|
htmlspecialchars($name) |
113
|
2 |
|
); |
114
|
|
|
|
115
|
|
|
if (is_localfile($name)) { |
116
|
2 |
|
$name .= (! preg_match('#\.js$#i', $name) ? '.js' : ''); |
117
|
2 |
|
$paths = ['lib', 'vendor', 'plugins']; |
118
|
|
|
|
119
|
|
|
foreach ($paths as $path) { |
120
|
2 |
|
$filename = WEBROOT . $path . DS . $name; |
|
|
|
|
121
|
|
|
|
122
|
|
|
if (file_exists($filename)) { |
123
|
2 |
|
return $site_url . $path . '/' . $name . '?v=' . filemtime($filename); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
2 |
|
return $site_url . 'lib/' . $name; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
return $name . (! preg_match('#\.js$#i', $name) ? '.js' : ''); |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
if (! function_exists('lib_styles')) { |
135
|
|
|
/** |
136
|
|
|
* LIB_STYLES |
137
|
|
|
* |
138
|
|
|
* inclu une ou plusieurs feuilles de style css |
139
|
|
|
* |
140
|
|
|
* @param string|string[] $name nom du fichier dont on veut inserer |
141
|
|
|
* @param bool $print Specifie si on affiche directement la sortie ou si on la retourne |
142
|
|
|
* |
143
|
|
|
* @return string|void |
144
|
|
|
*/ |
145
|
|
|
function lib_styles($name, bool $print = true) |
146
|
|
|
{ |
147
|
2 |
|
$name = (array) $name; |
148
|
2 |
|
$return = []; |
149
|
|
|
|
150
|
|
|
foreach ($name as $style) { |
151
|
|
|
if (is_string($style)) { |
152
|
2 |
|
$style = (! preg_match('#\.css$#i', $style) ? $style . '.css' : $style); |
153
|
|
|
if (is_file(WEBROOT . 'lib' . DS . str_replace('/', DS, $style))) { |
|
|
|
|
154
|
|
|
$return[] = '<link rel="preload" type="text/css" href="' . lib_css_url($style) . '" as="style"> |
155
|
|
|
<link rel="stylesheet" type="text/css" href="' . lib_css_url($style) . '" />'; |
156
|
|
|
} elseif (is_localfile($style)) { |
157
|
2 |
|
$return[] = "<!-- The specified file do not exist. we can not load it. \n\t"; |
158
|
2 |
|
$return[] = '<link rel="stylesheet" type="text/css" href="' . lib_css_url($style) . '" /> -->'; |
159
|
|
|
} else { |
160
|
|
|
$return[] = '<link rel="preload" type="text/css" href="' . lib_css_url($style) . '" as="style"> |
161
|
|
|
<link rel="stylesheet" type="text/css" href="' . lib_css_url($style) . '" />'; |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
166
|
2 |
|
$output = implode("\n", $return); |
167
|
|
|
|
168
|
|
|
if (false === $print) { |
169
|
|
|
return $output; |
170
|
|
|
} |
171
|
|
|
|
172
|
2 |
|
echo $output; |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
if (! function_exists('lib_scripts')) { |
177
|
|
|
/** |
178
|
|
|
* LIB_SCRIPTS |
179
|
|
|
* |
180
|
|
|
* inclu un ou plusieurs scripts js |
181
|
|
|
* |
182
|
|
|
* @param string|string[] $name nom du fichier dont on veut inserer |
183
|
|
|
* @param bool $print Specifie si on affiche directement la sortie ou si on la retourne |
184
|
|
|
* |
185
|
|
|
* @return string|void |
186
|
|
|
*/ |
187
|
|
|
function lib_scripts($name, bool $print = true) |
188
|
|
|
{ |
189
|
2 |
|
$name = (array) $name; |
190
|
2 |
|
$return = []; |
191
|
|
|
|
192
|
|
|
foreach ($name as $script) { |
193
|
|
|
if (is_string($script)) { |
194
|
2 |
|
$script = (! preg_match('#\.js$#i', $script) ? $script . '.js' : $script); |
195
|
|
|
if (is_file(WEBROOT . 'lib' . DS . str_replace('/', DS, $script))) { |
|
|
|
|
196
|
|
|
$return[] = '<script type="text/javascript" src="' . lib_js_url($script) . '"></script>'; |
197
|
|
|
} elseif (is_localfile($script)) { |
198
|
2 |
|
$return[] = "<!-- The specified file do not exist. we can not load it. \n\t"; |
199
|
2 |
|
$return[] = '<script type="text/javascript" src="' . lib_js_url($script) . '"></script> -->'; |
200
|
|
|
} else { |
201
|
|
|
$return[] = '<script type="text/javascript" src="' . lib_js_url($script) . '"></script>'; |
202
|
|
|
} |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
|
206
|
2 |
|
$output = implode("\n", $return); |
207
|
|
|
|
208
|
|
|
if (false === $print) { |
209
|
|
|
return $output; |
210
|
|
|
} |
211
|
|
|
|
212
|
2 |
|
echo $output; |
213
|
|
|
} |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
if (! function_exists('styles')) { |
217
|
|
|
/** |
218
|
|
|
* STYLES |
219
|
|
|
* |
220
|
|
|
* inclu une ou plusieurs feuilles de style css |
221
|
|
|
* |
222
|
|
|
* @param string|string[] $name nom du fichier dont on veut inserer |
223
|
|
|
* @param bool $print Specifie si on affiche directement la sortie ou si on la retourne |
224
|
|
|
* |
225
|
|
|
* @return string|void |
226
|
|
|
*/ |
227
|
|
|
function styles($name, bool $print = true) |
228
|
|
|
{ |
229
|
2 |
|
$name = (array) $name; |
230
|
2 |
|
$return = []; |
231
|
|
|
|
232
|
|
|
foreach ($name as $style) { |
233
|
|
|
if (is_string($style)) { |
234
|
2 |
|
$style = (! preg_match('#\.css$#i', $style) ? $style . '.css' : $style); |
235
|
|
|
if (is_file(WEBROOT . 'css' . DS . str_replace('/', DS, $style))) { |
|
|
|
|
236
|
|
|
$return[] = '<link rel="preload" type="text/css" href="' . css_url($style) . '" as="style"> |
237
|
|
|
<link rel="stylesheet" type="text/css" href="' . css_url($style) . '" />'; |
238
|
|
|
} elseif (is_localfile($style)) { |
239
|
2 |
|
$return[] = "<!-- The specified file do not exist. we can not load it. \n\t"; |
240
|
2 |
|
$return[] = '<link rel="stylesheet" type="text/css" href="' . css_url($style) . '" /> -->'; |
241
|
|
|
} else { |
242
|
|
|
$return[] = '<link rel="preload" type="text/css" href="' . css_url($style) . '" as="style"> |
243
|
|
|
<link rel="stylesheet" type="text/css" href="' . css_url($style) . '" />'; |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
|
248
|
2 |
|
$output = implode("\n", $return); |
249
|
|
|
|
250
|
|
|
if (false === $print) { |
251
|
|
|
return $output; |
252
|
|
|
} |
253
|
|
|
|
254
|
2 |
|
echo $output; |
255
|
|
|
} |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
if (! function_exists('scripts')) { |
259
|
|
|
/** |
260
|
|
|
* SCRIPTS |
261
|
|
|
* |
262
|
|
|
* inclu un ou plusieurs scripts js |
263
|
|
|
* |
264
|
|
|
* @param string|string[] $name nom du fichier dont on veut inserer |
265
|
|
|
* @param bool $print Specifie si on affiche directement la sortie ou si on la retourne |
266
|
|
|
* |
267
|
|
|
* @return string|void |
268
|
|
|
*/ |
269
|
|
|
function scripts($name, bool $print = true) |
270
|
|
|
{ |
271
|
2 |
|
$name = (array) $name; |
272
|
2 |
|
$return = []; |
273
|
|
|
|
274
|
|
|
foreach ($name as $script) { |
275
|
|
|
if (is_string($script)) { |
276
|
2 |
|
$script = (! preg_match('#\.js$#i', $script) ? $script . '.js' : $script); |
277
|
|
|
if (is_file(WEBROOT . 'js' . DS . str_replace('/', DS, $script))) { |
|
|
|
|
278
|
|
|
$return[] = '<script type="text/javascript" src="' . js_url($script) . '"></script>'; |
279
|
|
|
} elseif (is_localfile($script)) { |
280
|
2 |
|
$return[] = "<!-- The specified file do not exist. we can not load it. \n\t"; |
281
|
2 |
|
$return[] = '<script type="text/javascript" src="' . js_url($script) . '"></script> -->'; |
282
|
|
|
} else { |
283
|
|
|
$return[] = '<script type="text/javascript" src="' . js_url($script) . '"></script>'; |
284
|
|
|
} |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
|
288
|
2 |
|
$output = implode("\n", $return); |
289
|
|
|
|
290
|
|
|
if (false === $print) { |
291
|
|
|
return $output; |
292
|
|
|
} |
293
|
|
|
|
294
|
2 |
|
echo $output; |
295
|
|
|
} |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
if (! function_exists('less_url')) { |
299
|
|
|
/** |
300
|
|
|
* LESS URL |
301
|
|
|
* |
302
|
|
|
* Renvoie l'url d'un fichier less. |
303
|
|
|
* |
304
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
305
|
|
|
*/ |
306
|
|
|
function less_url(string $name): string |
307
|
|
|
{ |
308
|
|
|
$name = explode('?', $name)[0]; |
309
|
|
|
$name = str_replace(site_url() . 'less/', '', htmlspecialchars($name)); |
310
|
|
|
|
311
|
|
|
if (is_localfile($name)) { |
312
|
|
|
$name .= (! preg_match('#\.less$#i', $name) ? '.less' : ''); |
313
|
|
|
$filename = WEBROOT . 'less' . DS . $name; |
|
|
|
|
314
|
|
|
|
315
|
|
|
return site_url() . 'less/' . $name . ((file_exists($filename)) ? '?v=' . filemtime($filename) : ''); |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
return $name . (! preg_match('#\.less$#i', $name) ? '.less' : ''); |
319
|
|
|
} |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
if (! function_exists('less_styles')) { |
323
|
|
|
/** |
324
|
|
|
* LESS_STYLES |
325
|
|
|
* |
326
|
|
|
* inclu une ou plusieurs feuilles de style less |
327
|
|
|
* |
328
|
|
|
* @param string|string[] $name nom du fichier dont on veut inserer |
329
|
|
|
* @param bool $print Specifie si on affiche directement la sortie ou si on la retourne |
330
|
|
|
* |
331
|
|
|
* @return string|void |
332
|
|
|
*/ |
333
|
|
|
function less_styles($name, bool $print = true) |
334
|
|
|
{ |
335
|
|
|
$name = (array) $name; |
336
|
|
|
$return = []; |
337
|
|
|
|
338
|
|
|
foreach ($name as $style) { |
339
|
|
|
if (is_string($style)) { |
340
|
|
|
$style = (! preg_match('#\.less$#i', $style) ? $style . '.less' : $style); |
341
|
|
|
if (is_file(WEBROOT . 'less' . DS . str_replace('/', DS, $style))) { |
|
|
|
|
342
|
|
|
$return[] = '<link rel="stylesheet" type="text/less" href="' . less_url($style) . '" />'; |
343
|
|
|
} elseif (is_localfile($style)) { |
344
|
|
|
$return[] = "<!-- The specified file do not exist. we can not load it. \n\t"; |
345
|
|
|
$return[] = '<link rel="stylesheet" type="text/less" href="' . less_url($style) . '" /> -->'; |
346
|
|
|
} else { |
347
|
|
|
$return[] = '<link rel="stylesheet" type="text/less" href="' . less_url($style) . '" />'; |
348
|
|
|
} |
349
|
|
|
} |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
$output = implode("\n", $return); |
353
|
|
|
|
354
|
|
|
if (false === $print) { |
355
|
|
|
return $output; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
echo $output; |
359
|
|
|
} |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
if (! function_exists('img_url')) { |
363
|
|
|
/** |
364
|
|
|
* IMG URL |
365
|
|
|
* |
366
|
|
|
* Renvoie l'url d'une image |
367
|
|
|
* |
368
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
369
|
|
|
*/ |
370
|
|
|
function img_url(?string $name, bool $add_version = true): string |
371
|
|
|
{ |
372
|
|
|
if ($name === null || $name === '' || $name === '0') { |
373
|
|
|
return ''; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
$name = explode('?', $name)[0]; |
377
|
|
|
$name = str_replace(site_url() . 'img/', '', htmlspecialchars($name)); |
378
|
|
|
|
379
|
|
|
if (is_localfile($name)) { |
380
|
|
|
$filename = WEBROOT . 'img' . DS . $name; |
|
|
|
|
381
|
|
|
|
382
|
|
|
return site_url() . 'img/' . $name . ((file_exists($filename) && $add_version) ? '?v=' . filemtime($filename) : ''); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
return $name; |
386
|
|
|
} |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
if (! function_exists('img')) { |
390
|
|
|
/** |
391
|
|
|
* IMG |
392
|
|
|
* |
393
|
|
|
* Cree une image |
394
|
|
|
* |
395
|
|
|
* @param string $name nom du fichier dont on veut inserer |
396
|
|
|
* @param string $alt texte alternatif |
397
|
|
|
* |
398
|
|
|
* @return string|void |
399
|
|
|
*/ |
400
|
|
|
function img(string $name, string $alt = '', array $options = []) |
401
|
|
|
{ |
402
|
|
|
$return = '<img src="' . img_url($name) . '" alt="' . $alt . '"'; |
403
|
|
|
|
404
|
|
|
$noprint = isset($options['print']) && $options['print'] === false; |
405
|
|
|
unset($options['print']); |
406
|
|
|
|
407
|
|
|
foreach ($options as $key => $value) { |
408
|
|
|
$return .= ' ' . $key . '="' . $value . '"'; |
409
|
|
|
} |
410
|
|
|
$return .= ' />'; |
411
|
|
|
|
412
|
|
|
if ($noprint === true) { |
413
|
|
|
return $return; |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
echo $return; |
417
|
|
|
} |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
if (! function_exists('docs_url')) { |
421
|
|
|
/** |
422
|
|
|
* DOCS URL |
423
|
|
|
* |
424
|
|
|
* Renvoie l'url d'un document |
425
|
|
|
* |
426
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
427
|
|
|
*/ |
428
|
|
|
function docs_url(?string $name, bool $add_version = true): string |
429
|
|
|
{ |
430
|
|
|
if ($name === null || $name === '' || $name === '0') { |
431
|
|
|
return ''; |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
$name = explode('?', $name)[0]; |
435
|
|
|
$name = str_replace(site_url() . 'docs/', '', htmlspecialchars($name)); |
436
|
|
|
|
437
|
|
|
if (is_localfile($name)) { |
438
|
|
|
$filename = WEBROOT . 'docs' . DS . $name; |
|
|
|
|
439
|
|
|
|
440
|
|
|
return site_url() . 'docs/' . $name . ((file_exists($filename && $add_version)) ? '?v=' . filemtime($filename) : ''); |
|
|
|
|
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
return $name; |
444
|
|
|
} |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
if (! function_exists('videos_url')) { |
448
|
|
|
/** |
449
|
|
|
* VIDEOS URL |
450
|
|
|
* |
451
|
|
|
* Renvoie l'url d'une vidéo |
452
|
|
|
* |
453
|
|
|
* @param string $name nom du fichier dont on veut avoir l'url |
454
|
|
|
*/ |
455
|
|
|
function videos_url(?string $name, bool $add_version = true): string |
456
|
|
|
{ |
457
|
|
|
if ($name === null || $name === '' || $name === '0') { |
458
|
|
|
return ''; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
$name = explode('?', $name)[0]; |
462
|
|
|
$name = str_replace(site_url() . 'videos/', '', htmlspecialchars($name)); |
463
|
|
|
|
464
|
|
|
if (is_localfile($name)) { |
465
|
|
|
$filename = WEBROOT . 'videos' . DS . $name; |
|
|
|
|
466
|
|
|
|
467
|
|
|
return site_url() . 'videos/' . $name . ((file_exists($filename) && $add_version) ? '?v=' . filemtime($filename) : ''); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
return $name; |
471
|
|
|
} |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
if (! function_exists('mix')) { |
475
|
|
|
/** |
476
|
|
|
* Obtenez le chemin d'accès à un fichier Mix versionné. |
477
|
|
|
* |
478
|
|
|
* @throws Exception |
479
|
|
|
*/ |
480
|
|
|
function mix(string $path, string $manifestDirectory = ''): string |
481
|
|
|
{ |
482
|
|
|
static $manifests = []; |
483
|
|
|
|
484
|
|
|
$publicPath = trim(WEBROOT, '/\\'); |
|
|
|
|
485
|
|
|
|
486
|
|
|
if ($path[0] !== '/') { |
487
|
|
|
$path = "/{$path}"; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
if ($manifestDirectory && $manifestDirectory[0] !== '/') { |
491
|
|
|
$manifestDirectory = "/{$manifestDirectory}"; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
$config = (object) config('mix'); |
495
|
|
|
|
496
|
|
|
if (is_file($publicPath . $manifestDirectory . '/hot')) { |
497
|
|
|
$url = rtrim(file_get_contents($publicPath . $manifestDirectory . '/hot')); |
498
|
|
|
|
499
|
|
|
if (! empty($customUrl = $customUrl = $config->hot_proxy_url)) { |
|
|
|
|
500
|
|
|
return $customUrl . $path; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
if (str_starts_with($url, 'http://') || str_starts_with($url, 'https://')) { |
504
|
|
|
return explode(':', $url, 2)[1] . $path; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
return "//localhost:3300{$path}"; |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
$manifestPath = $publicPath . $manifestDirectory . '/mix-manifest.json'; |
511
|
|
|
|
512
|
|
|
if (! isset($manifests[$manifestPath])) { |
513
|
|
|
if (! is_file($manifestPath)) { |
514
|
|
|
throw new Exception('Le manifeste Mix n\'existe pas.'); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
$manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
$manifest = $manifests[$manifestPath]; |
521
|
|
|
|
522
|
|
|
if (! isset($manifest[$path])) { |
523
|
|
|
$exception = new Exception("Impossible de localiser le fichier Mix: {$path}."); |
524
|
|
|
|
525
|
|
|
if (! BLITZ_DEBUG) { |
526
|
|
|
return $path; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
throw $exception; |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
return $config->url . $manifestDirectory . $manifest[$path]; |
|
|
|
|
533
|
|
|
} |
534
|
|
|
} |
535
|
|
|
|