1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Manage Asset |
5
|
|
|
* |
6
|
|
|
* @category lib |
7
|
|
|
* @author Judicaël Paquet <[email protected]> |
8
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
9
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
10
|
|
|
* @version Release: 1.0.0 |
11
|
|
|
* @filesource https://github.com/las93/venus2 |
12
|
|
|
* @link https://github.com/las93 |
13
|
|
|
* @since 1.0 |
14
|
|
|
*/ |
15
|
|
|
namespace Venus\lib; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* This class manage the Asset |
19
|
|
|
* |
20
|
|
|
* @category lib |
21
|
|
|
* @author Judicaël Paquet <[email protected]> |
22
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
23
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
24
|
|
|
* @version Release: 1.0.0 |
25
|
|
|
* @filesource https://github.com/las93/venus2 |
26
|
|
|
* @link https://github.com/las93 |
27
|
|
|
* @since 1.0 |
28
|
|
|
* |
29
|
|
|
* @tutorial $oAsset = new \Venus\lib\Asset; |
30
|
|
|
* $oAsset->stylesheets(array('css/style.css')); |
31
|
|
|
*/ |
32
|
|
|
class Asset |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* get URL of your javascripts |
36
|
|
|
* |
37
|
|
|
* @access public |
38
|
|
|
* @return array |
39
|
|
|
* @internal param array $aJavascript [many can be passed] |
40
|
|
|
*/ |
41
|
|
|
public function javascripts() : array { |
42
|
|
|
|
43
|
|
|
$sDefaultPath = 'http://'.$_SERVER['HTTP_HOST'].'/getJs?'; |
44
|
|
|
$aJavascript = func_get_args(); |
45
|
|
|
$aReturns = array(); |
46
|
|
|
|
47
|
|
|
foreach($aJavascript as $aJsCombination) { |
48
|
|
|
|
49
|
|
|
$sJsPath = $sDefaultPath; |
50
|
|
|
|
51
|
|
|
foreach ($aJsCombination as $sJsToAdd) { |
52
|
|
|
|
53
|
|
|
$sJsPath = $sJsToAdd.'&'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
if (defined('ASSET_VERSION') && ASSET_VERSION) { |
57
|
|
|
|
58
|
|
|
$sJsPath = ASSET_VERSION; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$aReturns[] = $sJsPath; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $aReturns; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* get URL of your javascripts |
69
|
|
|
* |
70
|
|
|
* @access public |
71
|
|
|
* @return array |
72
|
|
|
* @internal param array $aCss [many can be passed] |
73
|
|
|
* |
74
|
|
|
* @tutoriel |
75
|
|
|
*/ |
76
|
|
|
public function stylesheets() : array { |
77
|
|
|
|
78
|
|
|
$sDefaultPath = 'http://'.$_SERVER['HTTP_HOST'].'/getCss?'; |
79
|
|
|
$aCss = func_get_args(); |
80
|
|
|
$aReturns = array(); |
81
|
|
|
|
82
|
|
|
foreach($aCss as $aCssCombination) { |
83
|
|
|
|
84
|
|
|
$sCssPath = $sDefaultPath; |
85
|
|
|
|
86
|
|
|
foreach ($aCssCombination as $sCssToAdd) { |
87
|
|
|
|
88
|
|
|
$sCssPath = $sCssToAdd.'&'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
if (defined('ASSET_VERSION') && ASSET_VERSION) { |
92
|
|
|
|
93
|
|
|
$sCssPath = ASSET_VERSION; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$aReturns[] = $sCssPath; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $aReturns; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|