. */ /* */ /*************************************************************************************/ require_once __DIR__ . "/../../fonctions/autoload.php"; class BoucleRepeter extends PexElement{ public $nom; public $contenu; public $args; function __construct($nom) { $this->nom = $nom; } function type() { return PexToken::TYPE_BOUCLE_REPETER; } function set_args($args) { $this->args = $args; } function ajouter($data) { $this->contenu = $data; } function evaluer(&$substitutions = array()) { if (DEBUG_EVAL) { Analyse::echo_debug("Evaluation boucle repeter $this->nom. RAW args: $this->args"); } $args = $this->replace($substitutions, $this->args); $debut = lireTag($args, "debut"); $fin = lireTag($args, "fin"); $increment = lireTag($args, "increment"); if ($debut == '') $debut = 1; if ($increment == '') $increment = 1; $val = ''; if ($increment == 0) die("L'increment de la boucle REPETER_".$this->nom." doit être different de 0"); for($idx = $debut, $count = 1; $idx <= $fin; $idx += $increment, $count++) { $substitutions['#INDEX'] = $idx; $substitutions['#__COMPTEUR__'] = $count; $val .= $this->contenu->evaluer($substitutions); } return $val; } function imprimer() { Analyse::echo_debug("[DEBUT REPETER $this->nom, args: ", $this->args, "]"); $this->contenu->imprimer(); Analyse::echo_debug("[FIN REPETER $this->nom]"); } } ?>