server/onyx/modules/templates/smarty/plugins/modifiercompiler.strip.php

34 lines
813 B
PHP
Raw Normal View History

2013-10-09 13:40:23 +00:00
<?php
/**
* Smarty plugin
*
2015-01-14 10:28:47 +00:00
* @package Smarty
2013-10-09 13:40:23 +00:00
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty strip modifier plugin
* Type: modifier<br>
* Name: strip<br>
* Purpose: Replace all repeated spaces, newlines, tabs
* with a single space or supplied replacement string.<br>
* Example: {$var|strip} {$var|strip:"&nbsp;"}<br>
* Date: September 25th, 2002
*
2015-01-14 10:28:47 +00:00
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
2013-10-09 13:40:23 +00:00
* @author Uwe Tews
2015-01-14 10:28:47 +00:00
*
2013-10-09 13:40:23 +00:00
* @param array $params parameters
2015-01-14 10:28:47 +00:00
*
2013-10-09 13:40:23 +00:00
* @return string with compiled code
*/
2015-01-14 10:28:47 +00:00
function smarty_modifiercompiler_strip($params)
2013-10-09 13:40:23 +00:00
{
if (!isset($params[1])) {
$params[1] = "' '";
}
2013-10-09 17:08:38 +00:00
2013-10-09 13:40:23 +00:00
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
}