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


class ExportadapterRekursiv extends Exportadapter
{
  
  public function fillVars($str, $index = '')
  {
    for ($i = 0; $i < count($this->varlist);$i++) {
      $str = $this->replaceVar($this->varlist[$i], $this->export->getVarValue($this->varlist[$i]), $str);
    }

    $this->getVarNames($str);
    if (count($this->varlist) > 0) {
      $str = $this->fillVars($str);
    }

    return $str;
  }

  
  public function replaceVarNames()
  {
    $this->initiateResultlist();
    for ($i = 0; $i < $this->export->resultCount(); $i++) {

      if ($this->export->selectResultSet($i)) {
        
        $parsedStream = $this->parseScripts($this->filestream);
        
        
        $this->getVarNames($parsedStream);
        
        array_push($this->resultlist, $this->fillVars($parsedStream));

      }
    }
  }
}