1 | <?php |
||
2 | /** |
||
3 | * KumbiaPHP web & app Framework |
||
4 | * |
||
5 | * LICENSE |
||
6 | * |
||
7 | * This source file is subject to the new BSD license that is bundled |
||
8 | * with this package in the file LICENSE. |
||
9 | * |
||
10 | * @category KumbiaPHP |
||
11 | * @package Helpers |
||
12 | * |
||
13 | * @copyright Copyright (c) 2005 - 2023 KumbiaPHP Team (http://www.kumbiaphp.com) |
||
14 | * @license https://github.com/KumbiaPHP/KumbiaPHP/blob/master/LICENSE New BSD License |
||
15 | */ |
||
16 | |||
17 | /** |
||
18 | * Helper que utiliza Css |
||
19 | * |
||
20 | * @category KumbiaPHP |
||
21 | * @package Helpers |
||
22 | */ |
||
23 | class Css |
||
24 | { |
||
25 | /** |
||
26 | * Css que son requisito de otros |
||
27 | * |
||
28 | * @var array |
||
29 | * */ |
||
30 | protected static $_dependencies = array(); |
||
31 | |||
32 | /** |
||
33 | * Css |
||
34 | * |
||
35 | * @var array |
||
36 | * */ |
||
37 | protected static $_css = array(); |
||
38 | |||
39 | /** |
||
40 | * Directorio Css |
||
41 | * |
||
42 | * @var array |
||
43 | * */ |
||
44 | protected static $css_dir = 'css/'; |
||
45 | |||
46 | /** |
||
47 | * Añade un archivo Css fuera del template para ser incluido en el template |
||
48 | * |
||
49 | * @param string $file nombre del archivo a añadir |
||
50 | * @param array $dependencies archivos que son requisito del archivo a añadir |
||
51 | */ |
||
52 | public static function add( $file, array $dependencies = [] ) |
||
53 | { |
||
54 | self::$_css[$file] = $file; |
||
55 | foreach ($dependencies as $file) self::$_dependencies [$file] = $file; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Incluye todos los archivo Css en el template añadidos con el metodo add |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public static function inc() |
||
64 | { |
||
65 | $css = self::$_dependencies + self::$_css; |
||
66 | $html = ''; |
||
67 | foreach ($css as $file) |
||
68 | { |
||
69 | $html .= '<link href="' . PUBLIC_PATH . self::$css_dir . "$file.css\" rel=\"stylesheet\" type=\"text/css\" />" . PHP_EOL; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
70 | } |
||
71 | return $html; |
||
72 | } |
||
73 | } |
||
74 |