/code/web/private_php/ams/smarty/libs/plugins/modifiercompiler.count_sentences.php
PHP | 27 lines | 5 code | 1 blank | 21 comment | 0 complexity | 20707d9e923ca450a90cef9f07b73457 MD5 | raw file
Possible License(s): Apache-2.0, AGPL-3.0, GPL-3.0, LGPL-2.1
- <?php
- /**
- * Smarty plugin
- *
- * @package Smarty
- * @subpackage PluginsModifierCompiler
- */
- /**
- * Smarty count_sentences modifier plugin
- * Type: modifier<br>
- * Name: count_sentences
- * Purpose: count the number of sentences in a text
- *
- * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
- * count_sentences (Smarty online manual)
- * @author Uwe Tews
- *
- * @param array $params parameters
- *
- * @return string with compiled code
- */
- function smarty_modifiercompiler_count_sentences($params)
- {
- // find periods, question marks, exclamation marks with a word before but not after.
- return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
- }