-
Notifications
You must be signed in to change notification settings - Fork 0
/
minifier.php
95 lines (82 loc) · 2.46 KB
/
minifier.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Inventory Plugin
*
* Fetch specific types of inventory
*
* @package MDV_CMS
* @author MDV.com Dev Team
* @copyright Copyright (c) 2010 - 2011, MDV.com
*
* Usage: {pyro:minifier:local_theme_files js_files="file.js,files2.js"}
*
*/
class Plugin_minifier extends Plugin
{
/**
* Private Variables
*/
private $base_url;
private $curr_theme;
/**
* Plugin Constructor
*/
public function Plugin_minifier()
{
// Fetch base url
$this->base_url = parseStr( '{pyro:url:site}' );
// Fetch current theme
$this->curr_theme = parseStr( '{pyro:settings:default_theme}' );
}
/**
* Local theme files
*/
public function local_theme_files()
{
// Fetch attributes
$css_files = $this->attribute( 'css_files', false );
$js_files = $this->attribute( 'js_files', false );
// Tags to return
$tags_to_return = "";
// Prepare minified for css
if( $css_files != false )
{
$tags_to_return .= '<link type="text/css" rel="stylesheet" href="'.$this->base_url."min/?b=addons/default/themes/".$this->curr_theme."/css&f=".$css_files.'" />';
}
// Prepare minified for js
if( $js_files != false )
{
$tags_to_return .= '<script type="text/javascript" src="'.$this->base_url."min/?b=addons/default/themes/".$this->curr_theme."/js&f=".$js_files.'"></script>';
}
// Return
if( strlen( $tags_to_return ) > 0 )
return $tags_to_return;
}
/**
* Remote theme files
*/
public function remote_theme_files()
{
// Fetch attributes
$css_files = $this->attribute( 'css_files', false );
$js_files = $this->attribute( 'js_files', false );
$alt_js_dir = $this->attribute( 'alt_js_dir', false );
$alt_css_dir = $this->attribute( 'alt_css_dir', false );
// Tags to return
$tags_to_return = "";
// Prepare minified for css
if( $css_files != false )
{
$tags_to_return .= '<link type="text/css" rel="stylesheet" href="'.$this->config->item( 'perm_base_url' )."min/?b=mdvcms_library/css".( ( $alt_css_dir != false ) ? "/".$alt_css_dir : "" )."&f=".$css_files.'" />';
}
// Prepare minified for js
if( $js_files != false )
{
$tags_to_return .= '<script type="text/javascript" src="'.$this->config->item( 'perm_base_url' )."min/?b=mdvcms_library/js".( ( $alt_js_dir != false ) ? "/".$alt_js_dir : "" )."&f=".$js_files.'"></script>';
}
// Return
if( strlen( $tags_to_return ) > 0 )
return $tags_to_return;
}
}
/* End of file minifier.php */