diff --git a/models/ab_htmlmin.php b/models/ab_htmlmin.php index 9883820..01d889e 100644 --- a/models/ab_htmlmin.php +++ b/models/ab_htmlmin.php @@ -13,10 +13,15 @@ */ class ab_htmlmin extends ab_htmlmin_parent { - protected function _fillCommonSmartyProperties( $oSmarty ) + protected function _fillCommonSmartyProperties($oSmarty) { parent::_fillCommonSmartyProperties($oSmarty); - include_once dirname(__FILE__).'/smarty/plugins/outputfilter.trimwhitespace.php'; - $oSmarty->load_filter ('output' , 'trimwhitespace'); + $cfg = oxRegistry::getConfig(); + + $aPluginsDir = $oSmarty->plugins_dir; + $aPluginsDir[] = $cfg->getModulesDir()."/ab_htmlmin/smarty/plugins/"; + $oSmarty->load_filter('output' , 'trimwhitespace'); + + $oSmarty->plugins_dir = $aPluginsDir; } -} \ No newline at end of file +} diff --git a/smarty/plugins/outputfilter.trimwhitespace.php b/smarty/plugins/outputfilter.trimwhitespace.php new file mode 100644 index 0000000..62ab4e7 --- /dev/null +++ b/smarty/plugins/outputfilter.trimwhitespace.php @@ -0,0 +1,90 @@ +.*?#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { + foreach ($matches as $match) { + $store[] = $match[0][0]; + $_length = strlen($match[0][0]); + $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; + $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); + + $_offset += $_length - strlen($replace); + $_store ++; + } + } + + // Strip all HTML-Comments + // yes, even the ones in