本文整理汇总了PHP中Minify::addFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Minify::addFile方法的具体用法?PHP Minify::addFile怎么用?PHP Minify::addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Minify
的用法示例。
在下文中一共展示了Minify::addFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
/**
* Combines, minifies, and outputs the requested files.
*
* Inspects the $_GET array for a 'files' entry containing a comma-separated
* list and uses this as the set of files to be combined and minified.
*/
function handleRequest()
{
// 404 if no files were requested.
if (!isset($_GET['files'])) {
header('HTTP/1.0 404 Not Found');
exit;
}
$files = array_map('trim', explode(',', $_GET['files'], MINIFY_MAX_FILES));
// 404 if the $files array is empty for some weird reason.
if (!count($files)) {
header('HTTP/1.0 404 Not Found');
exit;
}
// Determine the content type based on the extension of the first file
// requested.
$type = preg_match('/\\.js$/iD', $files[0]) ? TYPE_JS : TYPE_CSS;
// Minify and spit out the result.
$minify = new Minify($type);
$minify->addFile($files);
ob_start("ob_gzhandler");
header("Content-Type: {$type};charset=" . MINIFY_ENCODING);
$minify->browserCache();
echo $minify->combine();
}
示例2: Minify
// Create new Minify objects.
$minifyCSS = new Minify(TYPE_CSS);
$minifyJS = new Minify(TYPE_JS);
// Specify the files to be minified.
$cssFiles = array('css/mediabrowser.css');
// Only load skin if $_GET["skin"] or $defaultSkin is set.
if ($skin != "") {
$cssFiles[count($cssFiles)] = 'skins/' . $skin . '/skin.css';
}
$minifyCSS->addFile($cssFiles);
$jsFiles = array('js/jquery.js', 'js/jquery.mediabrowser.js', 'js/jquery.plugins.js', 'swfupload/swfupload.min.js', 'swfupload/plugins/swfupload.queue.js', 'swfupload/fileprogress.js', 'swfupload/handlers.js');
//If editor is TinyMCE then add javascript file
if ($editor == "tinymce") {
$jsFiles[count($jsFiles)] = 'js/tiny_mce_popup.js';
}
$minifyJS->addFile($jsFiles);
// JAVASCRIPT
echo '<script type="text/javascript">';
echo '//<![CDATA[';
echo $minifyJS->combine();
echo '//]]>';
echo '</script>';
// CSS
echo '<style type="text/css">';
echo $minifyCSS->combine();
echo '</style>';
?>
<script type="text/javascript">
//<![CDATA[
var swfu;
示例3: Minify
<title>Dog and Rooster | PDW Browser</title>
<link rel="shortcut icon" href="mediabrowser.ico" />
<?php
// MINIFY JS and CSS
// Create new Minify objects.
$minifyCSS = new Minify(TYPE_CSS);
$minifyJS = new Minify(TYPE_JS);
// Specify the files to be minified.
$cssFiles = array('css/mediabrowser.css');
// Only load skin if $_GET["skin"] is set.
if (isset($_GET["skin"])) {
$cssFiles[count($cssFiles)] = 'skins/' . $_GET["skin"] . '/skin.css';
}
$minifyCSS->addFile($cssFiles);
$minifyJS->addFile(array('js/jquery.js', 'js/jquery.mediabrowser.js', 'js/jquery.plugins.js', 'swfupload/swfupload.min.js', 'swfupload/plugins/swfupload.queue.js', 'swfupload/fileprogress.js', 'swfupload/handlers.js', 'js/tiny_mce_popup.js'));
// JAVASCRIPT
echo '<script type="text/javascript">' . "\n";
echo '//<![CDATA[' . "\n";
echo $minifyJS->combine();
echo '//]]>' . "\n";
echo '</script>' . "\n";
// CSS
echo '<style type="text/css">' . "\n";
echo $minifyCSS->combine();
echo '</style>' . "\n";
?>
<script type="text/javascript">
//<![CDATA[
var swfu;
示例4: Minify
<?php
require_once 'minify/min/lib/minify.php';
// Create new Minify objects.
$minifyCSS = new Minify(TYPE_CSS);
$minifyJS = new Minify(TYPE_JS);
// Specify the files to be minified.
// Full URLs are allowed as long as they point
// to the same server running Minify.
$minifyCSS->addFile(array('/styles/fonts.css', '/styles/nifty.css', '/styles/public.css', '/styles/calendar.css', '/styles/navigation.css'));
$minifyJS->addFile(array('/scripts/jquery.js', '/scripts/nifty.js', '/scripts/public.js'));
?>
<html>
<head>
<style type="text/css"><?php
echo $minifyCSS->combine();
?>
</style>
<script type="text/javascript"><?php
echo $minifyJS->combine();
?>
</script>
</head>
<body>
</body>
</html>