2013-07-14 22:15:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Smarty plugin
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2013-07-14 22:15:45 +00:00
|
|
|
* @subpackage PluginsModifierCompiler
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Smarty count_paragraphs modifier plugin
|
2017-11-11 07:11:33 +01:00
|
|
|
* Type: modifier
|
|
|
|
* Name: count_paragraphs
|
2013-07-14 22:15:45 +00:00
|
|
|
* Purpose: count the number of paragraphs in a text
|
|
|
|
*
|
2021-10-13 12:15:17 +02:00
|
|
|
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
2013-07-14 22:15:45 +00:00
|
|
|
* count_paragraphs (Smarty online manual)
|
2018-06-12 09:58:15 +02:00
|
|
|
* @author Uwe Tews
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param array $params parameters
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string with compiled code
|
|
|
|
*/
|
2014-06-06 02:40:04 +00:00
|
|
|
function smarty_modifiercompiler_count_paragraphs($params)
|
2013-07-14 22:15:45 +00:00
|
|
|
{
|
|
|
|
// count \r or \n characters
|
2016-02-09 01:27:15 +01:00
|
|
|
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[ 0 ] . ', $tmp)+1)';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|