<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */


class ExportadapterDatamoduls extends Exportadapter
{
  
  public $datamoduls;

  
  public function fillVars($str, $index = -1)
  {
    if ($index < 0) {
      throw new Exception('Ungültiger Param: $index < 0');
    }
    for ($i = 0; $i < count($this->varlist);$i++) {
      $str = str_replace(
        '{%' . $this->varlist[$i] . '%}',
        $this->datamoduls[$index]->getVarValue($this->varlist[$i]),
        $str
      );
    }

    return $str;
  }

  
  public function replaceVarNames()
  {
    $this->initiateResultlist();

    
    for ($i = 0; $i < count($this->datamoduls); $i++) {
      
      $parsedStream = $this->parseScripts($this->filestream);
      
      
      $this->getVarNames($parsedStream);
      
      array_push($this->resultlist, $this->fillVars($parsedStream, $i));


    }
  }
}