本文整理汇总了PHP中Minify_HTML类的典型用法代码示例。如果您正苦于以下问题:PHP Minify_HTML类的具体用法?PHP Minify_HTML怎么用?PHP Minify_HTML使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Minify_HTML类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: compresshtml
function compresshtml($data)
{
/* remove comments */
$data = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $data);
/* remove tabs, spaces, new lines, etc. */
$data = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), ' ', $data);
$compress = new Minify_HTML($data);
$data = $compress->minify($data);
return $data;
}
开发者ID:johngrange,项目名称:wookeyholeweb,代码行数:10,代码来源:yt-minify.php
示例2: output
public function output()
{
if ($this->output) {
if (defined('JOURNAL_INSTALLED')) {
global $registry;
$is_ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
$is_get = !empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) === 'get';
$ignored_routes = array('journal2/assets/css', 'journal2/assets/js', 'feed/google_sitemap');
$request = $registry->get('request');
$current_route = isset($request->get['route']) ? $request->get['route'] : null;
$ignored_route = $current_route !== null && in_array($current_route, $ignored_routes);
$journal2 = $registry->get('journal2');
if (!$ignored_route && !$is_ajax && $is_get && !$journal2->settings->get('config_system_settings.developer_mode') && $journal2->settings->get('config_system_settings.minify_html')) {
$this->output = Minify_HTML::minify($this->output, array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
if (Journal2Cache::$page_cache_file) {
file_put_contents(Journal2Cache::$page_cache_file, $this->output);
}
}
}
if ($this->level) {
$output = $this->compress($this->output, $this->level);
} else {
$output = $this->output;
}
if (!headers_sent()) {
foreach ($this->headers as $header) {
header($header, true);
}
}
echo $output;
}
}
开发者ID:nabeelkausari,项目名称:beelzak,代码行数:32,代码来源:response.php
示例3: minimize_html
function minimize_html($html)
{
$options = array('xhtml' => true);
$html = Minify_HTML::minify($html, $options);
$html = str_replace('<a
', '<a ', $html);
$html = str_replace('<ul
', '<ul ', $html);
$html = str_replace('<li
', '<li ', $html);
$html = str_replace('<div
', '<div ', $html);
$html = str_replace('<body
', '<body ', $html);
$html = str_replace('<header
', '<header ', $html);
$html = str_replace('<footer
', '<footer ', $html);
$html = str_replace('<link
', '<link ', $html);
$html = str_replace('<article
', '<article ', $html);
$html = str_replace('<span
', '<span ', $html);
$html = str_replace('<p
', '<p ', $html);
$html = str_replace('
itemprop="', ' itemprop="', $html);
return $html;
}
开发者ID:wpmu,项目名称:maera-compressor,代码行数:30,代码来源:maera-compressor.php
示例4: minifyHTML
public static function minifyHTML($html_content)
{
if (strlen($html_content) > 0) {
//set an alphabetical order for args
$html_content = preg_replace_callback('/(<[a-zA-Z0-9]+)((\\s?[a-zA-Z0-9]+=[\\"\\\'][^\\"\\\']*[\\"\\\']\\s?)*)>/', array('Media', 'minifyHTMLpregCallback'), $html_content);
require_once _PS_TOOL_DIR_ . 'minify_html/minify_html.class.php';
$html_content = str_replace(chr(194) . chr(160), ' ', $html_content);
$html_content = Minify_HTML::minify($html_content, array('xhtml', 'cssMinifier', 'jsMinifier'));
if (Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION')) {
//$html_content = preg_replace('/"([^\>\s"]*)"/i', '$1', $html_content);//FIXME create a js bug
$html_content = preg_replace('/<!DOCTYPE \\w[^\\>]*dtd\\">/is', '', $html_content);
$html_content = preg_replace('/\\s\\>/is', '>', $html_content);
$html_content = str_replace('</li>', '', $html_content);
$html_content = str_replace('</dt>', '', $html_content);
$html_content = str_replace('</dd>', '', $html_content);
$html_content = str_replace('</head>', '', $html_content);
$html_content = str_replace('<head>', '', $html_content);
$html_content = str_replace('</html>', '', $html_content);
$html_content = str_replace('</body>', '', $html_content);
//$html_content = str_replace('</p>', '', $html_content);//FIXME doesnt work...
$html_content = str_replace("</option>\n", '', $html_content);
//TODO with bellow
$html_content = str_replace('</option>', '', $html_content);
$html_content = str_replace('<script type=text/javascript>', '<script>', $html_content);
//Do a better expreg
$html_content = str_replace("<script>\n", '<script>', $html_content);
//Do a better expreg
}
return $html_content;
}
return false;
}
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:32,代码来源:Media.php
示例5: test_HTML
function test_HTML()
{
global $thisDir;
$src = file_get_contents($thisDir . '/_test_files/html/before.html');
$minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html');
$time = microtime(true);
$minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
$time = microtime(true) - $time;
$passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
if ($passed) {
echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
} else {
echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
}
}
$src = file_get_contents($thisDir . '/_test_files/html/before2.html');
$minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html');
$time = microtime(true);
$minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
$time = microtime(true) - $time;
$passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
if ($passed) {
echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
} else {
echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
}
}
}
开发者ID:Bhaavya,项目名称:OpenLorenz,代码行数:30,代码来源:test_Minify_HTML.php
示例6: template_post_parse
/**
* Hook for processing template output.
* @param string $template_string The template markup
* @param bool $is_embed Is the template an embed?
* @param int $site_id Site ID
* @return string The final template string
*/
public function template_post_parse($template_string, $is_embed, $site_id)
{
$final_string = $template_string;
// AutoMin model
$this->EE->load->model('automin_model');
// Prior output?
if (isset($this->EE->extensions->last_call) && $this->EE->extensions->last_call) {
$final_string = $this->EE->extensions->last_call;
}
// Is HTML minifcation disabled?
if (!$this->EE->automin_model->should_compress_markup()) {
return $final_string;
}
// Minify
if (!$is_embed) {
// Minify
$data_length_before = strlen($final_string) / 1024;
require_once 'libraries/class.html.min.php';
$final_string = Minify_HTML::minify($final_string);
$data_length_after = strlen($final_string) / 1024;
// Log results
$data_savings_kb = $data_length_before - $data_length_after;
$data_savings_percent = $data_savings_kb / $data_length_before;
$data_savings_message = sprintf('AutoMin Module HTML Compression: Before: %1.0fkb / After: %1.0fkb / Data reduced by %1.2fkb or %1.2f%%', $data_length_before, $data_length_after, $data_savings_kb, $data_savings_percent);
$this->EE->TMPL->log_item($data_savings_message);
}
return $final_string;
}
开发者ID:sjk8990,项目名称:AutoMin,代码行数:35,代码来源:ext.automin.php
示例7: htmlMin
public function htmlMin($htmlText = "")
{
if ($this->shouldMinify) {
$htmlText = \Minify_HTML::minify($htmlText);
}
return $htmlText;
}
开发者ID:johnwbaxter,项目名称:minify,代码行数:7,代码来源:MinifyService.php
示例8: minify
/**
* Minifies the passed HTML source.
*/
public function minify($pageContent)
{
Loader::library("3rdparty/minify-2.1.5/min/lib/Minify/HTML", "mainio_minco");
Loader::library("3rdparty/minify-2.1.5/min/lib/Minify/CSS", "mainio_minco");
Loader::library("3rdparty/minify-2.1.5/min/lib/JSMin", "mainio_minco");
$opts = array('cssMinifier' => "Minify_CSS::minify", 'jsMinifier' => "JSMin::minify");
return Minify_HTML::minify($pageContent, $opts);
}
开发者ID:noxstyle,项目名称:c5_mainio_minco,代码行数:11,代码来源:minco.php
示例9: initial_output
function initial_output($buffer)
{
require_once 'Minify/HTML.php';
require_once 'Minify/CSS.php';
require_once 'JSMin.php';
$buffer = Minify_HTML::minify($buffer, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
return $buffer;
}
开发者ID:kangza,项目名称:hagtag,代码行数:8,代码来源:index.php
示例10: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
$response = $this->getResponse();
if ($response->isException() || $response->isRedirect() || !$response->getBody()) {
return;
}
require_once APPLICATION_PATH . '/../library/Garp/3rdParty/minify/lib/Minify/HTML.php';
$response->setBody(Minify_HTML::minify($response->getBody()));
}
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:9,代码来源:Minify.php
示例11: onKernelResponse
/**
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
*/
public function onKernelResponse(FilterResponseEvent $event)
{
if ($this->enableListener) {
$response = $event->getResponse();
$content = \Minify_HTML::minify($response->getContent(), array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMinPlus', 'minify'), 'xhtml' => false));
$response->setContent($content);
}
return;
}
开发者ID:eab-dev,项目名称:SemaMinifierBundle,代码行数:12,代码来源:MinifyResponseListener.php
示例12: index
public function index($setting)
{
if (!defined('JOURNAL_INSTALLED')) {
return;
}
Journal2::startTimer(get_class($this));
/* get module data from db */
$module_data = $this->model_journal2_module->getModule($setting['module_id']);
if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
return;
}
if (Journal2Utils::getProperty($module_data, 'module_data.disable_mobile') && (Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet())) {
return;
}
$cache_property = "module_journal_fullscreen_slider_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
$cache = $this->journal2->cache->get($cache_property);
if ($cache === null || self::$CACHEABLE !== true) {
$module = mt_rand();
$this->data['module'] = $module;
$this->data['transition'] = Journal2Utils::getProperty($module_data, 'module_data.transition', 'fade');
$this->data['transition_speed'] = Journal2Utils::getProperty($module_data, 'module_data.transition_speed', '700');
$this->data['transition_delay'] = Journal2Utils::getProperty($module_data, 'module_data.transition_delay', '3000');
if (Journal2Utils::getProperty($module_data, 'module_data.transparent_overlay', '')) {
$this->data['transparent_overlay'] = Journal2Utils::resizeImage($this->model_tool_image, Journal2Utils::getProperty($module_data, 'module_data.transparent_overlay', ''));
} else {
$this->data['transparent_overlay'] = '';
}
$this->data['images'] = array();
$images = Journal2Utils::getProperty($module_data, 'module_data.images', array());
$images = Journal2Utils::sortArray($images);
foreach ($images as $image) {
if (!$image['status']) {
continue;
}
$image = Journal2Utils::getProperty($image, 'image');
if (is_array($image)) {
$image = Journal2Utils::getProperty($image, $this->config->get('config_language_id'));
}
$this->data['images'][] = array('image' => Journal2Utils::resizeImage($this->model_tool_image, $image), 'title' => '');
}
$this->template = $this->config->get('config_template') . '/template/journal2/module/fullscreen_slider.tpl';
if (self::$CACHEABLE === true) {
$html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
$this->journal2->cache->set($cache_property, $html);
}
} else {
$this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
$this->data['cache'] = $cache;
}
$this->document->addStyle('catalog/view/theme/journal2/lib/supersized/css/supersized.css');
$this->document->addScript('catalog/view/theme/journal2/lib/supersized/js/jquery.easing.min.js');
$this->document->addScript('catalog/view/theme/journal2/lib/supersized/js/supersized.3.2.7.min.js');
$output = $this->render();
Journal2::stopTimer(get_class($this));
return $output;
}
开发者ID:deepakdesai,项目名称:CressoyoWebApp,代码行数:56,代码来源:journal2_fullscreen_slider.php
示例13: process
/**
* Remove whitespaces from HTML code
*
* @param string $html
* @param boolean $compress_all Compress embedded css and js code
*
* @return string
*/
public static function process($html, array $settings = array())
{
require_once dirname(__FILE__) . '/min-html.php';
$settings = self::$_settings = $settings + array('compress_all' => true, 'css' => array(), 'js' => array(), 'markers' => array('<?'), 'external_services' => true);
if ($settings['compress_all']) {
return Minify_HTML::minify($html, array('cssMinifier' => array(__CLASS__, '_compress_inline_css'), 'jsMinifier' => array(__CLASS__, '_compress_inline_js')));
} else {
return Minify_HTML::minify($html);
}
}
开发者ID:saviobosco,项目名称:lobby,代码行数:18,代码来源:html-compress.php
示例14: filter_final_output
public function filter_final_output($buffer)
{
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';
return Minify_HTML::minify($buffer);
}
开发者ID:stenehall,项目名称:habari-plugins,代码行数:11,代码来源:mini.plugin.php
示例15: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
return;
}
if ($this->enabled) {
$body = $this->getResponse()->getBody();
$body = Minify_HTML::minify($body);
$this->getResponse()->setBody($body);
}
}
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:11,代码来源:HtmlMinify.php
示例16: minifyHTML
public static function minifyHTML($html_content)
{
if (strlen($html_content) > 0) {
//set an alphabetical order for args
$html_content = preg_replace_callback('/(<[a-zA-Z0-9]+)((\\s?[a-zA-Z0-9]+=[\\"\\\'][^\\"\\\']*[\\"\\\']\\s?)*)>/', array('Media', 'minifyHTMLpregCallback'), $html_content);
require_once _PS_TOOL_DIR_ . 'minify_html/minify_html.class.php';
$html_content = str_replace(chr(194) . chr(160), ' ', $html_content);
$html_content = Minify_HTML::minify($html_content, array('xhtml', 'cssMinifier', 'jsMinifier'));
return $html_content;
}
return false;
}
开发者ID:jicheng17,项目名称:pengwine,代码行数:12,代码来源:Media.php
示例17: htmlia_js_css_compress
function htmlia_js_css_compress($html)
{
/**
* some minify codes here ...
*/
require_once 'min/lib/Minify/Loader.php';
// Reuired to minify CSS
require_once 'min/lib/Minify/HTML.php';
require_once 'min/lib/Minify/CSS.php';
require_once 'min/lib/JSMin.php';
// return Minify_HTML::minify( $html );
Minify_Loader::register();
// Requeired by CSS
return Minify_HTML::minify($html, array('jsMinifier' => array('JSMin', 'minify'), 'cssMinifier' => array('Minify_CSS', 'minify')));
}
开发者ID:sunaryohadi,项目名称:primabase,代码行数:15,代码来源:minify.php
示例18: minify
public function minify()
{
if (class_exists('Minify_HTML')) {
// noptimize me
$this->content = $this->hide_noptimize($this->content);
// Minify html
$options = array('keepComments' => $this->keepcomments);
$this->content = Minify_HTML::minify($this->content, $options);
// restore noptimize
$this->content = $this->restore_noptimize($this->content);
return true;
}
//Didn't minify :(
return false;
}
开发者ID:SSRezhepa,项目名称:prodvizhenie.ru,代码行数:15,代码来源:autoptimizeHTML.php
示例19: save
public function save($content)
{
if (!$this->enable) {
return;
}
$identify = $this->getIdentify();
$file = $this->root_dir . 'cache/' . $identify;
if (!is_dir(dirname($file))) {
mkdir(dirname($file));
}
if (file_exists($file)) {
unlink($file);
}
$content = Minify_HTML::minify($content);
file_put_contents($file, $content);
}
开发者ID:wwxgitcat,项目名称:zencart_v1.0,代码行数:16,代码来源:super_cache.php
示例20: minifyHTML
/**
* Minify HTML
*
* @param string $htmlContent
*
* @return bool|mixed|string
*/
public static function minifyHTML($htmlContent)
{
if (strlen($htmlContent) > 0) {
//set an alphabetical order for args
// $html_content = preg_replace_callback(
// '/(<[a-zA-Z0-9]+)((\s*[a-zA-Z0-9]+=[\"\\\'][^\"\\\']*[\"\\\']\s*)*)>/',
// array('Media', 'minifyHTMLpregCallback'),
// $html_content,
// Media::getBackTrackLimit());
$htmlContent = str_replace(chr(194) . chr(160), ' ', $htmlContent);
if (trim($minified_content = \Minify_HTML::minify($htmlContent, array('cssMinifier', 'jsMinifier'))) != '') {
$htmlContent = $minified_content;
}
return $htmlContent;
}
return false;
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:24,代码来源:Media.php
注:本文中的Minify_HTML类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论