author | Markus Bröker <broeker.markus@googlemail.com> |
Sat, 14 Nov 2015 02:40:44 +0100 | |
changeset 24 | ef2914b7af78 |
parent 0 | 4869aea77e21 |
permissions | -rw-r--r-- |
0
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
1 |
<?php |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
2 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
3 |
* Smarty plugin |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
4 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
5 |
* @package Smarty |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
6 |
* @subpackage PluginsModifierCompiler |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
7 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
8 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
9 |
/** |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
10 |
* Smarty strip modifier plugin |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
11 |
* Type: modifier<br> |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
12 |
* Name: strip<br> |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
13 |
* Purpose: Replace all repeated spaces, newlines, tabs |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
14 |
* with a single space or supplied replacement string.<br> |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
15 |
* Example: {$var|strip} {$var|strip:" "}<br> |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
16 |
* Date: September 25th, 2002 |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
17 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
18 |
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual) |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
19 |
* @author Uwe Tews |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
20 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
21 |
* @param array $params parameters |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
22 |
* |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
23 |
* @return string with compiled code |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
24 |
*/ |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
25 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
26 |
function smarty_modifiercompiler_strip($params) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
27 |
if (!isset($params[1])) { |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
28 |
$params[1] = "' '"; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
29 |
} |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
30 |
|
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
31 |
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; |
4869aea77e21
Bröker-Framework BFW-1
Markus Bröker <broeker.markus@googlemail.com>
parents:
diff
changeset
|
32 |
} |