diff --git a/include/class_templateHandling.inc b/include/class_templateHandling.inc index d1072a28bf0ec518c58be51bf0db8e87a7b898c0..4b2084d3e7a5c74b86817fbb7fab88778ced26c6 100644 --- a/include/class_templateHandling.inc +++ b/include/class_templateHandling.inc @@ -431,6 +431,28 @@ class templateHandling return array($dateObject->format($args[1])); } + private static function modifierNumber(array $args) + { + if (count($args) < 1) { + $args[] = FALSE; + } + if (count($args) < 2) { + $args[] = 1; + } + if (count($args) < 3) { + $args[] = 1; + } + $numberGenerator = function ($mandatory, $start, $step) { + $i = $start; + while (TRUE) { + yield $i; + $i += $step; + } + }; + + return $numberGenerator($args[0], $args[1], $args[2]); + } + /*! \brief Apply a modifier * * \param string $m the modifier @@ -533,6 +555,10 @@ class templateHandling // date $result = array(static::modifierDate($args)); break; + case 'n': + // number + $result = static::modifierNumber($args); + break; default: trigger_error("Unkown modifier '$m'"); $result = array($str);