Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit ed3490f

Browse files
author
Jamie Snape
committed
Minor tweaks to smartoptimizer
1 parent 108b2c1 commit ed3490f

File tree

4 files changed

+31
-38
lines changed

4 files changed

+31
-38
lines changed

core/public/smartoptimizer/config.php

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,48 @@
1717
See the License for the specific language governing permissions and
1818
limitations under the License.
1919
=========================================================================*/
20+
2021
/*
2122
* SmartOptimizer Configuration File
2223
*/
24+
2325
if(file_exists('../../configs/application.local.ini'))
2426
{
25-
$config=parse_ini_file('../../configs/application.local.ini');
27+
$config = parse_ini_file('../../configs/application.local.ini');
2628
}
2729
else
2830
{
29-
$config=parse_ini_file('../../configs/application.ini');
31+
$config = parse_ini_file('../../configs/application.ini');
3032
}
31-
32-
if(isset($config['smartoptimizer'])&&$config['smartoptimizer']==1)
33-
{
34-
//use this to set gzip compression On or Off
35-
$settings['gzip'] = true;
3633

37-
//use this to set Minifier On or Off
38-
$settings['minify'] = true;
34+
if(isset($config['smartoptimizer']) && $config['smartoptimizer'] == 1 && is_writable('../../../tmp/cache/smartoptimizer/'))
35+
{
36+
//use this to set gzip compression On or Off
37+
$settings['gzip'] = true;
3938

40-
//use this to set file concatenation On or Off
41-
$settings['concatenate'] = true;
39+
//use this to set Minifier On or Off
40+
$settings['minify'] = true;
4241

43-
//specifies whether to emebed files included in css files using the data URI scheme or not
44-
$settings['embed'] = false;
45-
}
42+
//use this to set file concatenation On or Off
43+
$settings['concatenate'] = true;
44+
45+
//specifies whether to emebed files included in css files using the data URI scheme or not
46+
$settings['embed'] = false;
47+
}
4648
else
47-
{
48-
//use this to set gzip compression On or Off
49-
$settings['gzip'] = false;
49+
{
50+
//use this to set gzip compression On or Off
51+
$settings['gzip'] = false;
5052

51-
//use this to set Minifier On or Off
52-
$settings['minify'] = false;
53+
//use this to set Minifier On or Off
54+
$settings['minify'] = false;
5355

54-
//use this to set file concatenation On or Off
55-
$settings['concatenate'] = false;
56+
//use this to set file concatenation On or Off
57+
$settings['concatenate'] = false;
5658

57-
//specifies whether to emebed files included in css files using the data URI scheme or not
58-
$settings['embed'] = false;
59-
}
59+
//specifies whether to emebed files included in css files using the data URI scheme or not
60+
$settings['embed'] = false;
61+
}
6062

6163
//base dir (a relative path to the base directory)
6264
$settings['baseDir'] = '../';
@@ -67,15 +69,12 @@
6769
//Show error messages if any error occurs (true or false)
6870
$settings['debug'] = false;
6971

70-
7172
//use this to set gzip compression level (an integer between 1 and 9)
7273
$settings['compressionLevel'] = 9;
7374

7475
//these types of files will not be gzipped nor minified
7576
$settings['gzipExceptions'] = array('gif','jpeg','jpg','png','swf');
7677

77-
78-
7978
//separator for files to be concatenated
8079
$settings['separator'] = ',';
8180

@@ -102,5 +101,3 @@
102101

103102
//Setting this to false will force the browser to use cached files without checking for changes.
104103
$settings['clientCacheCheck'] = true;
105-
106-
?>

core/public/smartoptimizer/index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
See the License for the specific language governing permissions and
1818
limitations under the License.
1919
=========================================================================*/
20+
2021
/* SmartOptimizer v1.8
2122
* SmartOptimizer enhances your website performance using techniques
2223
* such as compression, concatenation, minifying, caching, and embedding on demand.
@@ -212,5 +213,3 @@ function_exists('gzencode'));
212213
readfile($cachedFile);
213214
}
214215
} else headerExit('304 Not Modified');
215-
216-
?>

core/public/smartoptimizer/minifiers/css.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
See the License for the specific language governing permissions and
1818
limitations under the License.
1919
=========================================================================*/
20+
2021
/*
2122
* SmartOptimizer CSS Minifier
2223
*/
23-
2424
function convertUrl($url, $count)
2525
{
2626
global $settings, $mimeTypes, $fileDir;
@@ -51,7 +51,7 @@ function convertUrl($url, $count)
5151
}
5252

5353
$contents = file_get_contents($fileDir.$url);
54-
54+
5555
if ($fileType == 'css') {
5656
$oldFileDir = $fileDir;
5757
$fileDir = rtrim(dirname($fileDir.$url), '\/').'/';
@@ -62,7 +62,7 @@ function convertUrl($url, $count)
6262
$baseUrl = $oldBaseUrl;
6363
}
6464

65-
$base64 = base64_encode($contents);
65+
$base64 = base64_encode($contents);
6666
return 'data:' . $mimeType . ';base64,' . $base64;
6767
}
6868

@@ -131,4 +131,3 @@ function minify_css($str) {
131131
if ($i<strlen($str) && preg_match('/[^\n\r\t ]/', $str[$i])) $res .= $str[$i];
132132
return $res;
133133
}
134-
?>

core/public/smartoptimizer/minifiers/js.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
See the License for the specific language governing permissions and
1818
limitations under the License.
1919
=========================================================================*/
20+
2021
/*
2122
* SmartOptimizer JavaScript Minifier
2223
*/
@@ -64,8 +65,6 @@ function minify_js($str) {
6465
while ($i<strlen($str) && $str[$i]!="\n" && $str[$i]!="\r") $i++;
6566
}
6667

67-
68-
6968
$LF_needed = false;
7069
if (preg_match('/[\n\r\t ]/', $str[$i])) {
7170
if (strlen($res) && preg_match('/[\n ]/', $res[strlen($res)-1])) {
@@ -112,4 +111,3 @@ function minify_js($str) {
112111
if ($i<strlen($str) && preg_match('/[^\n\r\t ]/', $str[$i])) $res .= $str[$i];
113112
return $res;
114113
}
115-
?>

0 commit comments

Comments
 (0)