|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* KNUT7 K7F (https://marciozebedeu.com/) |
|
5
|
|
|
* KNUT7 K7F (tm) : Rapid Development Framework (https://marciozebedeu.com/) |
|
6
|
|
|
* |
|
7
|
|
|
* Licensed under The MIT License |
|
8
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
|
9
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
10
|
|
|
* |
|
11
|
|
|
* @link https://github.com/knut7/framework/ for the canonical source repository |
|
12
|
|
|
* @copyright (c) 2015. KNUT7 Software Technologies AO Inc. (https://marciozebedeu.com/) |
|
13
|
|
|
* @license https://marciozebedeu.com/license/new-bsd New BSD License |
|
14
|
|
|
* @author Marcio Zebedeu - [email protected] |
|
15
|
|
|
* @version 1.0.2 |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace Ballybran\Helpers\Utility; |
|
19
|
|
|
/** |
|
20
|
|
|
* Class Assets |
|
21
|
|
|
* @package Ballybran\Helpers\Utility |
|
22
|
|
|
*/ |
|
23
|
|
|
class Assets |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
protected static $templates = array( |
|
30
|
|
|
'js' => '<script src="%s" type="text/javascript"></script>', |
|
31
|
|
|
'css' => '<link href="%s" rel="stylesheet" type="text/css">' |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param $files |
|
36
|
|
|
* @param $template |
|
37
|
|
|
*/ |
|
38
|
|
|
protected static function resource($files, $template) |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
$template = self::$templates[$template]; |
|
42
|
|
|
|
|
43
|
|
|
if (is_array($files)) { |
|
44
|
|
|
foreach ($files as $file) { |
|
45
|
|
|
return sprintf($template, $file) . "\n"; |
|
46
|
|
|
} |
|
47
|
|
|
} else { |
|
48
|
|
|
return sprintf($template, $files) . "\n"; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public static function js(Array $files) |
|
53
|
|
|
{ |
|
54
|
|
|
if (is_array($files)) { |
|
|
|
|
|
|
55
|
|
|
foreach ($files as $key => $value) { |
|
56
|
|
|
echo static::resource($value, 'js'); |
|
57
|
|
|
} |
|
58
|
|
|
} else { |
|
59
|
|
|
echo static::resource($files, 'js'); |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
public static function css(Array $files) |
|
66
|
|
|
{ |
|
67
|
|
|
if (is_array($files)) { |
|
|
|
|
|
|
68
|
|
|
foreach ($files as $key => $value) { |
|
69
|
|
|
echo static::resource($value, 'css'); |
|
70
|
|
|
} |
|
71
|
|
|
} else { |
|
72
|
|
|
echo static::resource($files, 'css'); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|