0
|
1 |
<?php
|
|
2 |
/**
|
|
3 |
* Smarty plugin
|
|
4 |
*
|
|
5 |
* @package Smarty
|
|
6 |
* @subpackage PluginsModifierCompiler
|
|
7 |
*/
|
|
8 |
|
|
9 |
/**
|
|
10 |
* Smarty strip_tags modifier plugin
|
|
11 |
*
|
|
12 |
* Type: modifier<br>
|
|
13 |
* Name: strip_tags<br>
|
|
14 |
* Purpose: strip html tags from text
|
|
15 |
*
|
|
16 |
* @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
|
|
17 |
* @author Uwe Tews
|
|
18 |
* @param array $params parameters
|
|
19 |
* @return string with compiled code
|
|
20 |
*/
|
|
21 |
function smarty_modifiercompiler_strip_tags($params, $compiler)
|
|
22 |
{
|
|
23 |
if (!isset($params[1])) {
|
|
24 |
$params[1] = true;
|
|
25 |
}
|
|
26 |
if ($params[1] === true) {
|
|
27 |
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
|
28 |
} else {
|
|
29 |
return 'strip_tags(' . $params[0] . ')';
|
|
30 |
}
|
|
31 |
}
|
|
32 |
|
|
33 |
?> |