Commit 39acb6af authored by zaufi's avatar zaufi

{compact} Smarty plugin is a my response to buggy (at least in 2.6.5 - 2.6.8) {strip}

parent 4f1e86d2
......@@ -3240,6 +3240,7 @@ tiki/lib/sheet/panel.js -text
tiki/lib/sheet/style.css -text
tiki/lib/shoutbox/index.php -text
tiki/lib/shoutbox/shoutboxlib.php -text
tiki/lib/smarty_tiki/block.compact.php -text
tiki/lib/smarty_tiki/block.repeat.php -text
tiki/lib/smarty_tiki/block.sortlinks.php -text
tiki/lib/smarty_tiki/block.strip.php -text
......
<?php
/*
* $Header: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/block.compact.php,v 1.1 2005-04-17 13:46:43 zaufi Exp $
*
* Smarty plugin to make result HTML code smaller
* In opposite to {strip} this plugin can be used ONCE at top level template
* to strip all HTML at once... And it have no nasty BUG which is incorrectly
* join some words together...
*/
function smarty_block_compact($params, $content, &$smarty)
{
// Tags with uncompactable content...
$nct = array('textarea', 'pre');
// Replace uncompactable content with unique marks
$ncc = array();
$num = 0;
foreach ($nct as $tag)
{
if (preg_match('/<\s*'.$tag.'.*>(.*)<\/\s*'.$tag.'\s*>/Usi', $content, $ucb) != 0)
{
$mark = md5($ucb[1].$num++.microtime());
$ncc[$mark] = $ucb[1];
$content = str_replace($ucb[1], $mark, $content);
}
}
// Compact the text
$content = str_replace('> <', '><', preg_replace('/\s+/', ' ', $content));
// Insert back all saved tags content
$ncc = array_reverse($ncc);
foreach ($ncc as $mark => $text)
$content = str_replace($mark, $text, $content);
//
return $content;
}
?>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment