Passed
Push — main ( c8d2e9...ebe3be )
by Dimitri
03:29 queued 13s
created
src/Helpers/assets.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
      */
22 22
     function css_url(string $name) : string
23 23
     {
24
-		$name = explode('?', $name)[0];
25
-		$name = str_replace(site_url() . 'css/', '', htmlspecialchars($name));
24
+        $name = explode('?', $name)[0];
25
+        $name = str_replace(site_url() . 'css/', '', htmlspecialchars($name));
26 26
 
27 27
         if (is_localfile($name)) {
28 28
             $name .=  (!preg_match('#\.css$#i', $name) ? '.css' : '');
29 29
             $filename = WEBROOT.'css'.DS.$name;
30 30
 
31
-			return site_url() . 'css/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
31
+            return site_url() . 'css/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
32 32
         }
33 33
 
34 34
         return $name . (!preg_match('#\.css$#i', $name) ? '.css' : '');
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
     function js_url(string $name) : string
51 51
     {
52 52
         $name = explode('?', $name)[0];
53
-		$name = str_replace(site_url() . 'js/', '', htmlspecialchars($name));
53
+        $name = str_replace(site_url() . 'js/', '', htmlspecialchars($name));
54 54
 
55 55
         if (is_localfile($name))
56 56
         {
57 57
             $name .=  (!preg_match('#\.js$#i', $name) ? '.js' : '');
58 58
             $filename = WEBROOT.'js'.DS.$name;
59 59
 
60
-			return site_url() . 'js/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
60
+            return site_url() . 'js/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
61 61
         }
62 62
 
63 63
         return $name . (!preg_match('#\.js$#i', $name) ? '.js' : '');
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
     function lib_css_url(string $name) : string
80 80
     {
81 81
         $name = explode('?', $name)[0];
82
-		$name = str_replace(site_url() . 'lib/', '', htmlspecialchars($name));
82
+        $name = str_replace(site_url() . 'lib/', '', htmlspecialchars($name));
83 83
 
84 84
         if (is_localfile($name))
85 85
         {
86 86
             $name .=  (!preg_match('#\.css$#i', $name) ? '.css' : '');
87 87
             $filename = WEBROOT.'lib'.DS.$name;
88 88
 
89
-			return site_url() . 'lib/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
89
+            return site_url() . 'lib/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
90 90
         }
91 91
 
92 92
         return $name . (!preg_match('#\.css$#i', $name) ? '.css' : '');
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
     function lib_js_url(string $name) : string
109 109
     {
110 110
         $name = explode('?', $name)[0];
111
-		$name = str_replace(site_url() . 'lib/', '', htmlspecialchars($name));
111
+        $name = str_replace(site_url() . 'lib/', '', htmlspecialchars($name));
112 112
 
113 113
         if (is_localfile($name))
114 114
         {
115 115
             $name .=  (!preg_match('#\.js$#i', $name) ? '.js' : '');
116 116
             $filename = WEBROOT.'lib'.DS.$name;
117 117
 
118
-			return site_url() . 'lib/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
118
+            return site_url() . 'lib/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
119 119
         }
120 120
 
121 121
         return $name . (!preg_match('#\.js$#i', $name) ? '.js' : '');
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
      * inclu une ou plusieurs feuilles de style css
133 133
      *
134 134
      * @param	string|string[]	$name nom du fichier dont on veut inserer
135
-	 * @param	bool $print Specifie si on affiche directement la sortie ou si on la retourne
135
+     * @param	bool $print Specifie si on affiche directement la sortie ou si on la retourne
136 136
      * @return	void|string
137 137
      */
138 138
     function lib_styles($name, bool $print = true)
139 139
     {
140 140
         $name = (array) $name;
141
-		$return = [];
141
+        $return = [];
142 142
 
143 143
         foreach ($name As $style)
144 144
         {
@@ -152,25 +152,25 @@  discard block
 block discarded – undo
152 152
                 }
153 153
                 else if (is_localfile($style))
154 154
                 {
155
-					$return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
155
+                    $return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
156 156
                     $return[] = '<link rel="stylesheet" type="text/css" href="'.lib_css_url($style).'" /> -->';
157 157
                 }
158
-				else
159
-				{
160
-					$return[] = '<link rel="preload" type="text/css" href="'.lib_css_url($style).'" as="style">
158
+                else
159
+                {
160
+                    $return[] = '<link rel="preload" type="text/css" href="'.lib_css_url($style).'" as="style">
161 161
 						<link rel="stylesheet" type="text/css" href="'.lib_css_url($style).'" />';
162
-				}
162
+                }
163 163
             }
164 164
         }
165 165
 
166
-		$output = join("\n", $return);
166
+        $output = join("\n", $return);
167 167
 
168
-		if (false === $print)
169
-		{
170
-			return $output;
171
-		}
168
+        if (false === $print)
169
+        {
170
+            return $output;
171
+        }
172 172
 
173
-		echo $output;
173
+        echo $output;
174 174
     }
175 175
 }
176 176
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     function lib_scripts($name, bool $print = true)
191 191
     {
192 192
         $name = (array) $name;
193
-		$return = [];
193
+        $return = [];
194 194
 
195 195
         foreach ($name As $script)
196 196
         {
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
                 }
204 204
                 else if (is_localfile($script))
205 205
                 {
206
-					$return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
206
+                    $return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
207 207
                     $return[] = '<script type="text/javascript" src="'.lib_js_url($script).'"></script> -->';
208 208
                 }
209
-				else
210
-				{
211
-					$return[] = '<script type="text/javascript" src="'.lib_js_url($script).'"></script>';
212
-				}
209
+                else
210
+                {
211
+                    $return[] = '<script type="text/javascript" src="'.lib_js_url($script).'"></script>';
212
+                }
213 213
             }
214 214
         }
215 215
 
216
-		$output = join("\n", $return);
216
+        $output = join("\n", $return);
217 217
 
218
-		if (false === $print)
219
-		{
220
-			return $output;
221
-		}
218
+        if (false === $print)
219
+        {
220
+            return $output;
221
+        }
222 222
 
223
-		echo $output;
223
+        echo $output;
224 224
     }
225 225
 }
226 226
 
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
      * inclu une ou plusieurs feuilles de style css
235 235
      *
236 236
      * @param	string|string[]	$name nom du fichier dont on veut inserer
237
-	 * @param	bool $print Specifie si on affiche directement la sortie ou si on la retourne
237
+     * @param	bool $print Specifie si on affiche directement la sortie ou si on la retourne
238 238
      * @return	void|string
239 239
      */
240 240
     function styles($name, bool $print = true)
241 241
     {
242 242
         $name = (array) $name;
243
-		$return = [];
243
+        $return = [];
244 244
 
245 245
         foreach ($name As $style)
246 246
         {
@@ -249,30 +249,30 @@  discard block
 block discarded – undo
249 249
                 $style = (!preg_match('#\.css$#i', $style) ? $style.'.css' : $style);
250 250
                 if (is_file(WEBROOT.'css'.DS.str_replace('/', DS, $style)))
251 251
                 {
252
-					$return[] = '<link rel="preload" type="text/css" href="'.css_url($style).'" as="style">
252
+                    $return[] = '<link rel="preload" type="text/css" href="'.css_url($style).'" as="style">
253 253
 						<link rel="stylesheet" type="text/css" href="'.css_url($style).'" />';
254 254
                 }
255 255
                 else if (is_localfile($style))
256 256
                 {
257
-					$return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
257
+                    $return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
258 258
                     $return[] = '<link rel="stylesheet" type="text/css" href="'.css_url($style).'" /> -->';
259 259
                 }
260
-				else
261
-				{
262
-					$return[] = '<link rel="preload" type="text/css" href="'.css_url($style).'" as="style">
260
+                else
261
+                {
262
+                    $return[] = '<link rel="preload" type="text/css" href="'.css_url($style).'" as="style">
263 263
 						<link rel="stylesheet" type="text/css" href="'.css_url($style).'" />';
264
-				}
264
+                }
265 265
             }
266 266
         }
267 267
 
268
-		$output = join("\n", $return);
268
+        $output = join("\n", $return);
269 269
 
270
-		if (false === $print)
271
-		{
272
-			return $output;
273
-		}
270
+        if (false === $print)
271
+        {
272
+            return $output;
273
+        }
274 274
 
275
-		echo $output;
275
+        echo $output;
276 276
     }
277 277
 }
278 278
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     function scripts($name, bool $print = true)
293 293
     {
294 294
         $name = (array) $name;
295
-		$return = [];
295
+        $return = [];
296 296
 
297 297
         foreach ($name As $script)
298 298
         {
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
                     $return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
309 309
                     $return[] = '<script type="text/javascript" src="'.js_url($script).'"></script> -->';
310 310
                 }
311
-				else
312
-				{
313
-					$return[] = '<script type="text/javascript" src="'.js_url($script).'"></script>';
314
-				}
311
+                else
312
+                {
313
+                    $return[] = '<script type="text/javascript" src="'.js_url($script).'"></script>';
314
+                }
315 315
             }
316 316
         }
317 317
 
318
-		$output = join("\n", $return);
318
+        $output = join("\n", $return);
319 319
 
320
-		if (false === $print)
321
-		{
322
-			return $output;
323
-		}
320
+        if (false === $print)
321
+        {
322
+            return $output;
323
+        }
324 324
 
325
-		echo $output;
325
+        echo $output;
326 326
     }
327 327
 }
328 328
 
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
     function less_url(string $name) : string
342 342
     {
343 343
         $name = explode('?', $name)[0];
344
-		$name = str_replace(site_url() . 'less/', '', htmlspecialchars($name));
344
+        $name = str_replace(site_url() . 'less/', '', htmlspecialchars($name));
345 345
 
346 346
         if (is_localfile($name)) {
347 347
             $name .=  (!preg_match('#\.less$#i', $name) ? '.less' : '');
348 348
             $filename = WEBROOT.'less'.DS.$name;
349 349
 
350
-			return site_url() . 'less/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
350
+            return site_url() . 'less/' . $name.((file_exists($filename)) ? '?v='.filemtime($filename) : '');
351 351
         }
352 352
 
353 353
         return $name . (!preg_match('#\.less$#i', $name) ? '.less' : '');
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     function less_styles($name, bool $print = true)
371 371
     {
372 372
         $name = (array) $name;
373
-		$return = [];
373
+        $return = [];
374 374
 
375 375
         foreach ($name As $style)
376 376
         {
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
                     $return[] = "<!-- The specified file do not exist. we can not load it. \n\t";
387 387
                     $return[] = '<link rel="stylesheet" type="text/less" href="'.less_url($style).'" /> -->';
388 388
                 }
389
-				else
390
-				{
391
-					$return[] = '<link rel="stylesheet" type="text/less" href="'.less_url($style).'" />';
392
-				}
389
+                else
390
+                {
391
+                    $return[] = '<link rel="stylesheet" type="text/less" href="'.less_url($style).'" />';
392
+                }
393 393
             }
394 394
         }
395 395
 
396
-		$output = join("\n", $return);
396
+        $output = join("\n", $return);
397 397
 
398
-		if (false === $print)
399
-		{
400
-			return $output;
401
-		}
398
+        if (false === $print)
399
+        {
400
+            return $output;
401
+        }
402 402
 
403
-		echo $output;
403
+        echo $output;
404 404
     }
405 405
 }
406 406
 
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
         }
424 424
 
425 425
         $name = explode('?', $name)[0];
426
-		$name = str_replace(site_url() . 'img/', '', htmlspecialchars($name));
426
+        $name = str_replace(site_url() . 'img/', '', htmlspecialchars($name));
427 427
 
428 428
         if (is_localfile($name)) {
429 429
             $filename = WEBROOT.'img'.DS.$name;
430 430
 
431
-			return site_url() . 'img/' . $name.((file_exists($filename) && $add_version) ? '?v='.filemtime($filename) : '');
431
+            return site_url() . 'img/' . $name.((file_exists($filename) && $add_version) ? '?v='.filemtime($filename) : '');
432 432
         }
433 433
 
434 434
         return $name;
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
     {
454 454
         $return = '<img src="' . img_url($name) . '" alt="' . $alt . '"';
455 455
 
456
-		$noprint = isset($options['print']) AND $options['print'] == false;
457
-		unset($options['print']);
456
+        $noprint = isset($options['print']) AND $options['print'] == false;
457
+        unset($options['print']);
458 458
 
459 459
         foreach ($options As $key => $value)
460 460
         {
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
         }
463 463
         $return .= ' />';
464 464
 
465
-		if ($noprint === true)
466
-		{
467
-			return $return;
468
-		}
465
+        if ($noprint === true)
466
+        {
467
+            return $return;
468
+        }
469 469
 
470 470
         echo $return;
471 471
     }
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
         }
490 490
 
491 491
         $name = explode('?', $name)[0];
492
-		$name = str_replace(site_url() . 'docs/', '', htmlspecialchars($name));
492
+        $name = str_replace(site_url() . 'docs/', '', htmlspecialchars($name));
493 493
 
494 494
         if (is_localfile($name)) {
495 495
             $filename = WEBROOT.'docs'.DS.$name;
496 496
 
497
-			return site_url() . 'docs/' . $name.((file_exists($filename && $add_version)) ? '?v='.filemtime($filename) : '');
497
+            return site_url() . 'docs/' . $name.((file_exists($filename && $add_version)) ? '?v='.filemtime($filename) : '');
498 498
         }
499 499
 
500 500
         return $name;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         }
520 520
 
521 521
         $name = explode('?', $name)[0];
522
-		$name = str_replace(site_url() . 'videos/', '', htmlspecialchars($name));
522
+        $name = str_replace(site_url() . 'videos/', '', htmlspecialchars($name));
523 523
 
524 524
         if (is_localfile($name)) {
525 525
             $filename = WEBROOT.'videos'.DS.$name;
Please login to merge, or discard this patch.