function Dwoo_Plugin_jsmin(Dwoo_Core $dwoo, $files, $root = array('site-root', 'js'), $embed = false) { if (is_array($files)) { $files = implode('+', $files); } // analyze tree to obtain hash and file map $sourceReport = MinifiedRequestHandler::getSourceReport($files, $root, 'application/javascript'); if (!empty($_GET['js-debug']) || !empty($_GET['jsdebug'])) { $html = ''; foreach ($sourceReport['files'] as $filename => $fileData) { $html .= "<script src='" . preg_replace('/^site-root/', '', $filename) . "?_sha1={$fileData['SHA1']}'></script>\n"; } return $html; } if ($embed) { return '<script>' . MinifiedRequestHandler::getSourceCode('JSMin', $sourceReport) . '</script>'; } else { return "<script src='/min/js/{$files}?_sha1={$sourceReport['hash']}'></script>"; } }
function Dwoo_Plugin_cssmin(Dwoo_Core $dwoo, $files, $root = array('site-root', 'css'), $embed = false) { if (is_array($files)) { $files = implode('+', $files); } // analyze tree to obtain hash and file map $sourceReport = MinifiedRequestHandler::getSourceReport($files, $root, 'text/css'); if (!empty($_GET['css-debug']) || !empty($_GET['cssdebug'])) { $html = ''; foreach ($sourceReport['files'] as $filename => $fileData) { $html .= "<link rel='stylesheet' type='text/css' href='" . preg_replace('/^site-root/', '', $filename) . "?_sha1={$fileData['SHA1']}'>\n"; } return $html; } if ($embed) { return '<style>' . MinifiedRequestHandler::getSourceCode('CssMin', $sourceReport) . '</style>'; } else { return "<link rel='stylesheet' type='text/css' href='/min/css/{$files}?_sha1={$sourceReport['hash']}'>"; } }
<?php MinifiedRequestHandler::handleRequest();