本文整理汇总了PHP中Minify类的典型用法代码示例。如果您正苦于以下问题:PHP Minify类的具体用法?PHP Minify怎么用?PHP Minify使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Minify类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _showSource
/**
* 处理单条数据
*
* @param string $path 路径
* @param array $files 文件列表
*/
protected function _showSource($path, $files)
{
$extension = pathinfo($path, PATHINFO_EXTENSION);
$type_constant = 'Minify::TYPE_' . strtoupper($extension);
if (defined($type_constant)) {
$content_type = constant($type_constant);
} else {
$content_type = Minify::TYPE_HTML;
}
$sources = array();
foreach ($files as $value) {
$source_path = str_replace('//', ROOT_PATH, $value);
if (!is_file($source_path)) {
echo "[Not Found] {$source_path}<br />\r\n";
continue;
}
$content = file_get_contents($source_path);
$sources[] = new Minify_Source(array('id' => $value, 'contentType' => $content_type, 'filepath' => $source_path));
}
$minify = new Minify(new Minify_Cache_Null());
$combined = $minify->combine($sources, $this->_minify_config);
$to_file_path = ROOT_PATH . "static/{$extension}/{$path}";
$to_dir = dirname($to_file_path);
if (!is_dir($to_dir)) {
mkdir($to_dir, 0775, true);
}
file_put_contents($to_file_path, $combined);
chmod($to_file_path, 0777);
}
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:35,代码来源:Compile.php
示例2: filter
/**
* @param $sources
* @param $extension
* @param $use_cache
* @param $options
* @return array
*/
public function filter($sources, $extension, $use_cache, $options)
{
$files = array();
// handle request
if (!$options['combine']) {
foreach ($sources as $file) {
$cache_filename = basename($file) . '.' . md5($file) . '.' . $extension;
$destination_file = $this->cache_path . $cache_filename;
if (!file_exists($destination_file) || !$use_cache) {
$this->cache->write($destination_file, \Minify::combine($file, array('minifiers' => array('application/x-javascript' => ''))));
}
if (file_exists($destination_file)) {
$files[] = $this->host . $this->fileUtility->getRelativePath($this->storeRootDir, $destination_file);
}
}
} else {
$cache_filename = md5(serialize($sources)) . '.' . $extension;
$destination_file = $this->cache_path . $cache_filename;
if (($cache_file = $this->cache->exists($destination_file)) === false || !$use_cache) {
// Todo: what to do if we do not turn on the minify?
$cache_file = $this->cache->write($destination_file, \Minify::combine($sources, $options));
}
if (file_exists($destination_file)) {
$files[] = $this->fileUtility->getRelativePath($this->storeRootDir, $destination_file);
}
}
return $files;
}
开发者ID:zepluf,项目名称:plugin-ricjloader,代码行数:35,代码来源:MinifyFilter.php
示例3: handleStatic
private function handleStatic($filenames, $type)
{
/* Fix to prevent debug bar from rendering on this page */
$config = Kohana::config('debug_toolbar');
if ($config) {
$config->set('auto_render', false);
}
/* end fix */
if ($filenames === null) {
$this->response = "/* No {$type} TO BE FOUND */";
return;
}
if (Kohana_Core::$environment != Kohana::DEVELOPMENT && self::check(300) === FALSE) {
self::set(300);
}
$this->response->headers('Content-Type', File::mime_by_ext($type));
$body = "";
$filenames = preg_replace("/\\.{$type}\$/", '', $filenames);
foreach (explode(',', $filenames) as $key) {
$key = basename($key, ".{$type}");
$file = Kohana::find_file('views/' . $type, $key, $type);
if (!$file) {
$body .= "/* No such file or directory ({$key}.{$type}) */\n";
continue;
}
$body .= implode('', array('/* (', str_replace(DOCROOT, '', $file), ") */\n"));
$body .= file_get_contents($file);
}
/* Play nice with minify module if its enabled */
if (Kohana::config('minify.enabled', false) && class_exists('Minify')) {
$body = Minify::factory($type)->set($body)->min();
}
$this->response->body($body);
}
开发者ID:halkeye,项目名称:kohana-static,代码行数:34,代码来源:static.php
示例4: actionIndex
public function actionIndex()
{
$incPath = get_include_path();
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$_SERVER['DOCUMENT_ROOT'] = dirname(Yii::app()->request->getScriptFile());
set_include_path(Yii::app()->getExtensionPath()."/minify" . PATH_SEPARATOR . $incPath);
require 'Minify.php';
$option['debug'] = $this->_debug;
$option['maxAge'] = $this->_maxAge;
$option['bubbleCssImports'] = $this->_bubbleCssImports;
$option['encodeOutput'] = $this->_encodeOutput;
$option['encodeMethod'] = $this->_encodeMethod;
foreach ($this->_symlinks as $link => $target) {
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT'])."/", $link);
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
$option['minifierOptions']['text/css']['symlinks'][$link] = realpath($target);
}
Minify::setCache(Yii::app()->getRuntimePath(), $this->_cacheFileLocking);
if ($this->_errorLogger) {
require_once 'Minify/Logger.php';
require_once 'FirePHP.php';
Minify_Logger::setLogger(FirePHP::getInstance(true));
}
$mgv = Yii::app()->getRuntimePath()."/minifyGroups.var";
$minifyGroups = unserialize(file_get_contents($mgv));
$option['files'] = $minifyGroups[$_GET['group']];
Minify::serve('Files', $option);
set_include_path($incPath);
$_SERVER['DOCUMENT_ROOT'] = $docRoot;
}
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:30,代码来源:MinifyController.php
示例5: test_Lines
function test_Lines()
{
global $thisDir;
$exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js");
$env = new Minify_Env();
$sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null());
$controller = new Minify_Controller_Files($env, $sourceFactory);
$minify = new Minify(new Minify_Cache_Null());
$ret = $minify->serve($controller, array('debug' => true, 'quiet' => true, 'encodeOutput' => false, 'files' => array("{$thisDir}/_test_files/js/before.js")));
$passed = assertTrue($exp === $ret['content'], 'Minify_Lines');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($ret['content']) . " bytes\n\n{$ret['content']}\n\n";
if (!$passed) {
echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n";
}
}
}
开发者ID:chaoyanjie,项目名称:HiBlog,代码行数:17,代码来源:test_Minify_Lines.php
示例6: getLastModified
/**
* Get last modified
*
* @return string
*/
public function getLastModified()
{
if (0 === stripos(PHP_OS, 'win')) {
Minify::setDocRoot();
// we may be on IIS
}
return $this->lastModified;
}
开发者ID:pratiknikam,项目名称:speedster,代码行数:13,代码来源:BuildSpeedster.php
示例7: initialize
public function initialize()
{
$assets = $this->request->getQuery('r');
if ($assets != null) {
$this->assetsList = explode(',', $assets);
}
set_include_path(LIB_PATH . 'Minify/' . PATH_SEPARATOR . get_include_path());
\Minify::setCache(new \Minify_Cache_APC());
}
开发者ID:ozc,项目名称:phalcon_micro_controllers,代码行数:9,代码来源:assets.php
示例8: action_minify
public function action_minify()
{
// load config
$config = Kohana::config('minify');
//require MINIFY_MIN_DIR.'/Minify.php';
Minify::$uploaderHoursBehind = $config['uploaderHoursBehind'];
Minify::setCache(isset($config['cachePath']) ? $config['cachePath'] : '', $config['cacheFileLocking']);
if ($config['documentRoot']) {
$_SERVER['DOCUMENT_ROOT'] = $config['documentRoot'];
} elseif (0 === stripos(PHP_OS, 'win')) {
Minify::setDocRoot();
// IIS may need help
}
$config['serveOptions']['minifierOptions']['text/css']['symlinks'] = $config['symlinks'];
// auto-add targets to allowDirs
foreach ($config['symlinks'] as $uri => $target) {
$config['serveOptions']['minApp']['allowDirs'][] = $target;
}
if ($config['allowDebugFlag']) {
if (!empty($_COOKIE['minDebug'])) {
foreach (preg_split('/\\s+/', $_COOKIE['minDebug']) as $debugUri) {
if (false !== strpos($_SERVER['REQUEST_URI'], $debugUri)) {
$config['serveOptions']['debug'] = true;
break;
}
}
}
// allow GET to override
if (isset($_GET['debug'])) {
$config['serveOptions']['debug'] = true;
}
}
if ($config['errorLogger']) {
//require _once MINIFY_MIN_DIR . '/Minify/Logger.php';
if (true === $config['errorLogger']) {
//require _once MINIFY_MIN_DIR . '/FirePHP.php';
Minify_Logger::setLogger(FirePHP::getInstance(true));
} else {
Minify_Logger::setLogger($config['errorLogger']);
}
}
// check for URI versioning
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
$config['serveOptions']['maxAge'] = 31536000;
}
if (isset($_GET['g'])) {
// well need groups config
$config['serveOptions']['minApp']['groups'] = $config['groupsConfig'];
}
if (isset($_GET['f']) || isset($_GET['g'])) {
// serve!
Minify::serve('MinApp', $config['serveOptions']);
exit;
}
}
开发者ID:nickschot,项目名称:minify-kohana,代码行数:55,代码来源:index.php
示例9: serve_css
public function serve_css($files)
{
$opt = array('files' => $this->get_css_files($files), 'contentTypeCharset' => $this->charset);
/*
* Bazı sunucularda fpassthru engelli olduğundan problem çıkarabiliyor.
* Bu durumda fonksiyonun kullanıldığı filelocking seçeneğini FALSE gönderiyoruz.
* Bu işlemi de function_exists(fpassthru) ile otomatik yapıyoruz.
*/
Minify::setCache($this->cache_path, function_exists('fpassthru'));
Minify::serve('Files', $opt);
}
开发者ID:navruzm,项目名称:navruz.net,代码行数:11,代码来源:index.php
示例10: setupSources
/**
* Set up groups of files as sources
*
* @param array $options controller and Minify options
* @return array Minify options
*
*/
public function setupSources($options)
{
// PHP insecure by default: realpath() and other FS functions can't handle null bytes.
if (isset($_GET['files'])) {
$_GET['files'] = str_replace("", '', (string) $_GET['files']);
}
self::_setupDefines();
if (MINIFY_USE_CACHE) {
$cacheDir = defined('MINIFY_CACHE_DIR') ? MINIFY_CACHE_DIR : '';
Minify::setCache($cacheDir);
}
$options['badRequestHeader'] = 'HTTP/1.0 404 Not Found';
$options['contentTypeCharset'] = MINIFY_ENCODING;
// The following restrictions are to limit the URLs that minify will
// respond to. Ideally there should be only one way to reference a file.
if (!isset($_GET['files']) || !preg_match('/^[^,]+\\.(css|js)(,[^,]+\\.\\1)*$/', $_GET['files'], $m) || strpos($_GET['files'], '//') !== false || strpos($_GET['files'], '\\') !== false || preg_match('/(?:^|[^\\.])\\.\\//', $_GET['files'])) {
return $options;
}
$extension = $m[1];
$files = explode(',', $_GET['files']);
if (count($files) > MINIFY_MAX_FILES) {
return $options;
}
// strings for prepending to relative/absolute paths
$prependRelPaths = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR;
$prependAbsPaths = $_SERVER['DOCUMENT_ROOT'];
$sources = array();
$goodFiles = array();
$hasBadSource = false;
$allowDirs = isset($options['allowDirs']) ? $options['allowDirs'] : MINIFY_BASE_DIR;
foreach ($files as $file) {
// prepend appropriate string for abs/rel paths
$file = ($file[0] === '/' ? $prependAbsPaths : $prependRelPaths) . $file;
// make sure a real file!
$file = realpath($file);
// don't allow unsafe or duplicate files
if (parent::_fileIsSafe($file, $allowDirs) && !in_array($file, $goodFiles)) {
$goodFiles[] = $file;
$srcOptions = array('filepath' => $file);
$this->sources[] = new Minify_Source($srcOptions);
} else {
$hasBadSource = true;
break;
}
}
if ($hasBadSource) {
$this->sources = array();
}
if (!MINIFY_REWRITE_CSS_URLS) {
$options['rewriteCssUris'] = false;
}
return $options;
}
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:60,代码来源:Version1.php
示例11: after
public function after()
{
if ($this->auto_render) {
$styles = array('base.css', 'master.css');
$scripts = array('jquery-1.4.1.js');
$this->template->styles = array_merge($styles, $this->template->styles);
$this->template->scripts = array_merge($scripts, $this->template->scripts);
$this->template->styles = Minify::factory('css')->minify($this->template->styles);
$this->template->scripts = Minify::factory('js')->minify($this->template->scripts);
}
parent::after();
}
开发者ID:ryross,项目名称:kobase,代码行数:12,代码来源:base.php
示例12: process
/**
* Runs minify
*/
function process()
{
require_once W3TC_LIB_MINIFY_DIR . '/Minify.php';
require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
HTTP_Encoder::$encodeToIe6 = $this->_config->get_boolean('minify.comprss.ie6');
Minify::$uploaderHoursBehind = $this->_config->get_integer('minify.fixtime');
Minify::setCache($this->_get_cache());
$serve_options = $this->_config->get_array('minify.options');
$serve_options['maxAge'] = $this->_config->get_integer('minify.maxage');
$serve_options['encodeOutput'] = $this->_config->get_boolean('minify.compress');
$serve_options['postprocessor'] = array(&$this, 'postprocessor');
if (stripos(PHP_OS, 'win') === 0) {
Minify::setDocRoot();
}
foreach ($this->_config->get_array('minify.symlinks') as $link => $target) {
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
$serve_options['minifierOptions']['text/css']['symlinks'][$link] = realpath($target);
}
if ($this->_config->get_boolean('minify.debug')) {
$serve_options['debug'] = true;
}
if ($this->_config->get('minify.debug')) {
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php';
Minify_Logger::setLogger($this);
}
if (isset($_GET['f']) || isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
if (isset($_GET['gg']) && isset($_GET['g']) && isset($_GET['t'])) {
$serve_options['minApp']['groups'] = $this->get_groups($_GET['gg'], $_GET['t']);
if ($_GET['t'] == 'js' && (in_array($_GET['g'], array('include', 'include-nb')) && $this->_config->get_boolean('minify.js.combine.header') || in_array($_GET['g'], array('include-footer', 'include-footer-nb')) && $this->_config->get_boolean('minify.js.combine.footer'))) {
$serve_options['minifiers']['application/x-javascript'] = array($this, 'minify_stub');
}
/**
* Setup user-friendly cache ID for disk cache
*/
if ($this->_config->get_string('minify.engine') == 'file') {
$cacheId = sprintf('%s.%s.%s', $_GET['gg'], $_GET['g'], $_GET['t']);
Minify::setCacheId($cacheId);
}
}
@header('Pragma: public');
try {
Minify::serve('MinApp', $serve_options);
} catch (Exception $exception) {
printf('<strong>W3 Total Cache Error:</strong> Minify error: %s', $exception->getMessage());
}
} else {
die('This file cannot be accessed directly');
}
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:53,代码来源:Minify.php
示例13: minify
/**
* Generate minified HTML code
*
* @param string $content
* @param array $options
*
* - `html` - boolean - Minify HTML code
* - `js` - boolean - Minify JS
* - `css` - boolean - Minify CSS
*
* @return string modified content if avaible, otherwise origin content
*/
public static function minify($content, $options = array())
{
$options += array('html' => true, 'js' => true, 'css' => true);
$minifyOptions = array();
if ($options['html'] === true) {
App::uses('Minify', 'Tidy.Vendor/Minify');
$minifyOptions['xhtml'] = false;
if ($options['js'] === true) {
App::uses('JSMin', 'Tidy.Vendor/Minify');
$minifyOptions['jsMinifier'] = array("JSMin", "minify");
}
if ($options['css'] === true) {
App::uses('Minify_CSS', 'Tidy.Vendor/Minify');
$minifyOptions['cssMinifier'] = array("Minify_CSS", "minify");
}
$Minify = new Minify();
$minified = $Minify->process($content, $minifyOptions);
if (!empty($minified)) {
return $minified;
}
}
return $content;
}
开发者ID:cikorka,项目名称:cakephp-html-tidy-plugin,代码行数:35,代码来源:LibTidy.php
示例14: test_Lines
function test_Lines()
{
global $thisDir;
$exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js");
Minify::setCache(null);
// no cache
$ret = Minify::serve('Files', array('debug' => true, 'quiet' => true, 'encodeOutput' => false, 'files' => array("{$thisDir}/_test_files/minify/email.js", "{$thisDir}/_test_files/minify/lines_bugs.js", "{$thisDir}/_test_files/minify/QueryString.js", "{$thisDir}/_test_files/js/before.js")));
$passed = assertTrue($exp === $ret['content'], 'Minify_Lines');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($ret['content']) . " bytes\n\n{$ret['content']}\n\n";
if (!$passed) {
echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n";
}
}
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:15,代码来源:test_Minify_Lines.php
示例15: get
public function get()
{
$_assetsList = array();
for ($i = 0; $i < count($this->assetsList); $i++) {
if (file_exists(PUBLIC_PATH . 'css/' . $this->assetsList[$i])) {
$_assetsList[] = '//css/' . $this->assetsList[$i];
}
}
unset($this->assetsList);
if (count($_assetsList) > 0) {
$options = array('files' => $_assetsList, 'maxAge' => \Application::$config['assets']['maxAge'], 'debug' => \Application::$config['assets']['debug']);
\Minify::serve('Files', $options);
unset($options);
}
}
开发者ID:ozc,项目名称:phalcon_micro_controllers,代码行数:15,代码来源:css.php
示例16: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$assetHelper = $container->get('mautic.helper.assetgeneration');
$factory = $container->get('mautic.factory');
// Combine and minify bundle assets
$assetHelper->getAssets(true);
// Minify Mautic Form SDK
file_put_contents($factory->getSystemPath('assets') . '/js/mautic-form.js', \Minify::combine(array($factory->getSystemPath('assets') . '/js/mautic-form-src.js')));
/** @var \Symfony\Bundle\FrameworkBundle\Translation\Translator $translator */
$translator = $this->getContainer()->get('translator');
$translator->setLocale($this->getContainer()->get('mautic.factory')->getParameter('locale'));
// Update successful
$output->writeln('<info>' . $translator->trans('mautic.core.command.asset_generate_success') . '</info>');
return 0;
}
开发者ID:Jandersolutions,项目名称:mautic,代码行数:19,代码来源:GenerateProductionAssetsCommand.php
示例17: serve
public function serve()
{
// Adapted from index.php and config.php in the Minify distribution
$min_serveOptions = array();
$min_uploaderHoursBehind = isset($this->_config['min_uploaderHoursBehind']) ? $this->_config['min_uploaderHoursBehind'] : 0;
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
$min_cacheFileLocking = isset($this->_config['min_cacheFileLocking']) ? $this->_config['min_cacheFileLocking'] : true;
$min_cachePath = $this->_config['cache_dir'];
Minify::setCache($min_cachePath, $min_cacheFileLocking);
$min_symlinks = isset($this->_config['min_symlinks']) ? $this->_config['min_symlinks'] : array();
foreach ($min_symlinks as $link => $target) {
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
$min_serveOptions['minifierOptions']['text/css']['symlinks'][$link] = realpath($target);
}
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
if (isset($this->_config['debug_minify_logger'])) {
require_once 'Minify/Logger.php';
if (true === $this->_config['debug_minify_logger']) {
require_once 'FirePHP.php';
Minify_Logger::setLogger(FirePHP::getInstance(true));
} else {
Minify_Logger::setLogger($this->_config['debug_minify_logger']);
}
}
// check for URI versioning
if (!empty($this->_version)) {
$min_serveOptions['maxAge'] = 31536000;
} else {
# don't cache if we are not using a version number
$min_serveOptions['maxAge'] = 0;
}
$min_serveOptions['swift']['files'] = array();
foreach ($this->_current_modules as $module) {
if (!empty($this->_config['debug_use_alt_resources']) && !empty($this->_config['modules'][$module]['debug_path'])) {
$min_serveOptions['swift']['files'][] = $this->_config['modules'][$module]['debug_path'];
} else {
$min_serveOptions['swift']['files'][] = $this->_config['modules'][$module]['path'];
}
}
# check what format we're working on by looking at the extension on the first file
# if we are in debug mode for the current type of files use Minify's debug mode
if (!empty($this->_config['debug_minify_js_off']) && pathinfo($min_serveOptions['swift']['files'][0], PATHINFO_EXTENSION) == 'js' || !empty($this->_config['debug_minify_css_off']) && pathinfo($min_serveOptions['swift']['files'][0], PATHINFO_EXTENSION) == 'css') {
$min_serveOptions['debug'] = true;
}
Minify::serve('Swift', $min_serveOptions);
}
开发者ID:jos3000,项目名称:swift,代码行数:47,代码来源:Server.php
示例18: serve
public static function serve()
{
// try to disable output_compression (may not have an effect)
ini_set('zlib.output_compression', '0');
Minify::setCache(OX_PATH . '/var/cache', true);
if (isset($_GET['g'])) {
// serve!
$options = array();
$options['minApp']['groupsOnly'] = true;
$options['rewriteCssUris'] = false;
$options['minApp']['groups'] = self::prepareGroups();
Minify::serve('MinApp', $options);
} else {
header("Location: /");
exit;
}
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:17,代码来源:Server.php
示例19: action_template_header
public function action_template_header()
{
$modified = Stack::get_sorted_stack('template_header_javascript');
foreach ($modified as $key => $value) {
Stack::remove('template_header_javascript', $key);
}
Stack::add('template_header_javascript', Site::get_url('user') . "/files/minified.js", 'Minified');
if (!Cache::has(self::$cache_name . '_js') || !Cache::has(self::$cache_name . '_css')) {
set_include_path(dirname(__FILE__) . '/min/lib' . PATH_SEPARATOR . get_include_path());
require_once 'Minify/Source.php';
require_once 'Minify/HTML.php';
require_once 'Minify/CSS.php';
require_once 'Minify/HTML.php';
require_once 'Minify.php';
require_once 'Minify/Cache/File.php';
}
if (!Cache::has(self::$cache_name . '_js')) {
$js_stack = array();
foreach ($modified as $js) {
$js_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $js);
}
$options = array('files' => $js_stack, 'encodeOutput' => false, 'quiet' => true, 'maxAge' => 86400);
$result = Minify::serve('Files', $options);
file_put_contents(site::get_dir('user') . '/files/minified.js', $result['content']);
Cache::set(self::$cache_name . '_js', 'true');
}
/* CSS */
$modified = Stack::get_sorted_stack('template_stylesheet');
$tmp = array();
foreach ($modified as $key => $value) {
$tmp[] = $value[0];
Stack::remove('template_stylesheet', $key);
}
Stack::add('template_stylesheet', array(Site::get_url('user') . "/files/minified.css", 'screen'), 'style');
if (!Cache::has(self::$cache_name . '_css')) {
$css_stack = array();
foreach ($tmp as $css) {
$css_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $css);
}
$options = array('files' => $css_stack, 'encodeOutput' => false, 'quiet' => true, 'maxAge' => 86400);
// handle request
$result = Minify::serve('Files', $options);
file_put_contents(site::get_dir('user') . '/files/minified.css', $result['content']);
Cache::set(self::$cache_name . '_css', 'true');
}
}
开发者ID:stenehall,项目名称:habari-plugins,代码行数:46,代码来源:mini.plugin.php
示例20: minify
function minify($files)
{
global $CFG;
$cachedir = $CFG->cachedir . '/js';
// make sure the cache dir exist
if (!file_exists($cachedir)) {
@mkdir($cachedir, $CFG->directorypermissions, true);
}
if (0 === stripos(PHP_OS, 'win')) {
Minify::setDocRoot();
// IIS may need help
}
Minify::setCache($cachedir, true);
$options = array('maxAge' => 60 * 60 * 24 * 20, 'files' => $files);
Minify::serve('Files', $options);
die;
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:17,代码来源:javascript.php
注:本文中的Minify类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论