mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
Merge branch 'w10_MDL-31079_m23_minifydebug' of git://github.com/skodak/moodle
This commit is contained in:
commit
55957253d2
@ -198,6 +198,10 @@ function css_send_css_not_found() {
|
||||
function css_minify_css($files) {
|
||||
global $CFG;
|
||||
|
||||
if (empty($files)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
set_include_path($CFG->libdir . '/minify/lib' . PATH_SEPARATOR . get_include_path());
|
||||
require_once('Minify.php');
|
||||
|
||||
@ -220,8 +224,31 @@ function css_minify_css($files) {
|
||||
// This returns the CSS rather than echoing it for display
|
||||
'quiet' => true
|
||||
);
|
||||
$result = Minify::serve('Files', $options);
|
||||
return $result['content'];
|
||||
|
||||
$error = 'unknown';
|
||||
try {
|
||||
$result = Minify::serve('Files', $options);
|
||||
if ($result['success']) {
|
||||
return $result['content'];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$error = str_replace("\r", ' ', $error);
|
||||
$error = str_replace("\n", ' ', $error);
|
||||
}
|
||||
|
||||
// minification failed - try to inform the theme developer and include the non-minified version
|
||||
$css = <<<EOD
|
||||
/* Error: $error */
|
||||
/* Problem detected during theme CSS minimisation, please review the following code */
|
||||
/* ================================================================================ */
|
||||
|
||||
|
||||
EOD;
|
||||
foreach ($files as $cssfile) {
|
||||
$css .= file_get_contents($cssfile)."\n";
|
||||
}
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,6 +85,27 @@ function minify($files) {
|
||||
'files' => $files
|
||||
);
|
||||
|
||||
Minify::serve('Files', $options);
|
||||
die();
|
||||
try {
|
||||
Minify::serve('Files', $options);
|
||||
die();
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$error = str_replace("\r", ' ', $error);
|
||||
$error = str_replace("\n", ' ', $error);
|
||||
}
|
||||
|
||||
// minification failed - try to inform the developer and include the non-minified version
|
||||
$js = <<<EOD
|
||||
try {console.log('Error: Minimisation of javascript failed!');} catch (e) {}
|
||||
|
||||
// Error: $error
|
||||
// Problem detected during javascript minimisation, please review the following code
|
||||
// =================================================================================
|
||||
|
||||
|
||||
EOD;
|
||||
echo $js;
|
||||
foreach ($files as $jsfile) {
|
||||
echo file_get_contents($jsfile)."\n";
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +130,10 @@ function send_uncached_js($js) {
|
||||
}
|
||||
|
||||
function minify($files) {
|
||||
if (empty($files)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (0 === stripos(PHP_OS, 'win')) {
|
||||
Minify::setDocRoot(); // IIS may need help
|
||||
}
|
||||
@ -150,6 +154,30 @@ function minify($files) {
|
||||
'quiet' => true
|
||||
);
|
||||
|
||||
$result = Minify::serve('Files', $options);
|
||||
return $result['content'];
|
||||
$error = 'unknown';
|
||||
try {
|
||||
$result = Minify::serve('Files', $options);
|
||||
if ($result['success']) {
|
||||
return $result['content'];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$error = str_replace("\r", ' ', $error);
|
||||
$error = str_replace("\n", ' ', $error);
|
||||
}
|
||||
|
||||
// minification failed - try to inform the theme developer and include the non-minified version
|
||||
$js = <<<EOD
|
||||
try {console.log('Error: Minimisation of theme javascript failed!');} catch (e) {}
|
||||
|
||||
// Error: $error
|
||||
// Problem detected during javascript minimisation, please review the following code
|
||||
// =================================================================================
|
||||
|
||||
|
||||
EOD;
|
||||
foreach ($files as $jsfile) {
|
||||
$js .= file_get_contents($jsfile)."\n";
|
||||
}
|
||||
return $js;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user