Repository navigation
Expand file tree
/
Copy pathcssjs_helper.php
More file actions
65 lines (61 loc) · 1.58 KB
/
Copy pathcssjs_helper.php
File metadata and controls
65 lines (61 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Ruta: /application/helpers/cssjs_helper.php
*/
if(!function_exists('add_css')) {
function add_css($Arch = null) {
if(empty($Arch)) {
return;
}
$CI = &get_instance();
$CSS = $CI->config->item('header_css');
$CI->config->set_item('header_css', array_merge($CSS, (array)$Arch));
}
}
if(!function_exists('add_js')) {
function add_js($Arch = null, $Header = false) {
if(empty($Arch)) {
return;
}
$CI = &get_instance();
if($Header) {
$JS = $CI->config->item('header_js');
$CI->config->set_item('header_js', array_merge($JS, (array)$Arch));
}
else {
$JS = $CI->config->item('footer_js');
$CI->config->set_item('footer_js', array_merge($JS, (array)$Arch));
}
}
}
if(!function_exists('render_arch_header')) {
function render_arch_header() {
$CI = &get_instance();
$CSS = $CI->config->item('header_css');
$JS = $CI->config->item('header_js');
foreach($CSS as $V) {
if(!in_array(parse_url($V, PHP_URL_SCHEME), ['http', 'https', 'ftp'])) {
$V = base_url($V);
}
echo '<link rel="stylesheet" href="'.$V.'">'.PHP_EOL;
}
foreach($JS as $V) {
if(!in_array(parse_url($V, PHP_URL_SCHEME), ['http', 'https', 'ftp'])) {
$V = base_url($V);
}
echo '<script src="'.$V.'"></script>'.PHP_EOL;
}
}
}
if(!function_exists('render_arch_footer')) {
function render_arch_footer() {
$CI = &get_instance();
$JS = $CI->config->item('footer_js');
foreach($JS as $V) {
if(!in_array(parse_url($V, PHP_URL_SCHEME), ['http', 'https', 'ftp'])) {
$V = base_url($V);
}
echo '<script src="'.$V.'"></script>'.PHP_EOL;
}
}
}