<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\Classes\Export\ExportCalculation;

class ExportCalcSystem extends ExportCalc
{
  
  private $exportCalculation;

  
  private $nrOfMainBodyElements;

  
  private $blaetternInfo;

  
  private $tool0settings;

  
  private $tool4settings;

  public function __construct(\ExportCalculation $exportCalculation, int $nrOfMainBodyElements, ?\BlaetternLink $blaetternInfo)
  {
    $this->exportCalculation = $exportCalculation;
    $this->nrOfMainBodyElements = $nrOfMainBodyElements;
    $this->blaetternInfo = $blaetternInfo;
    $this->tool0settings = \ToolSettingsAPI::getToolSettings(0);
    $this->tool4settings = \ToolSettingsAPI::getToolSettings(4);
  }

  public function resolveVar(string $varname, ?\Datamodul $datamodul = null): string
  {
    $hatZweitenParam = false;
    $zweiterParam = '';
    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 8) == 'include:') {
      
      $file = \StringOperations::substr($varname, 8);
      if (file_exists($file) == false) {
        return '';
      } else {
        return implode('', file($file));
      }
    }
    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 12) == 'file_exists:') {
      $file = \StringOperations::substr($varname, 12);
      $file = str_replace('BASEDIR', BASEDIR, $file);
      $file = str_replace('TYPO3_WBPFAD', $this->resolveVar('typo3_wbpfad'), $file);

      return file_exists($file) ? '1' : '0';
    }
    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 22) == 'include_bykatid_exists') {
      $param = new \URLParameterKategorie();
      $file = BASEDIR . 'webbasys/static/kat_' . $param->katid . '.html';

      return file_exists($file) ? '1' : '0';
    }
    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 15) == 'include_bykatid') {
      
      $param = new \URLParameterKategorie();
      $file = BASEDIR . 'webbasys/static/kat_' . $param->katid . '.html';
      if (file_exists($file) === false) {
        return '';
      } else {
        return implode('', file($file));
      }
    }

    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 11) == 'sortierung_') {
      
      
      $prop = \StringOperations::substr($varname, 11);
      
      switch ($prop) {
        case 'knr':           $prop = 'nr';
          break;
        case 'datum':         $prop = 'beginn_dat';
          break;
        case 'datumzeit':     $prop = 'beginndt';
          break;
        case 'titel':         $prop = 'kurzbez';
          break;
        case 'aussenstelle':  $prop = 'aussenst';
          break;
      }

      return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getSortierungKurseLink($prop));
    }

    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 35) == 'nurausgewaehltermonatmonthsoverview') {
      return $this->tool4settings->nurAusgewaehlterMonatMonthsOverview ? '1' : '';
    }
    
    
    
    
    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 17) == 'include_htmlbody:') {
      $file = \StringOperations::substr($varname, 17);
      if ((\StringOperations::substr($file, 0, 7) != 'http://') && (file_exists($file) == false)) {
        return 'Die Datei "' . \CleanOperations::cleanStringForHtml($file) . '" wurde nicht gefunden!';
      } else {
        $content = file_get_contents($file);
        $matches = array();
        if (!preg_match_all('#</?body[^>]*>#', $content, $matches, PREG_OFFSET_CAPTURE)
            && !preg_match_all('#</?BODY[^>]*>#', $content, $matches, PREG_OFFSET_CAPTURE)) {
          return 'Es wurde kein "body" - Element gefunden! (Datei: ' . \CleanOperations::cleanStringForHtml($file) . ')';
        }
        $lenStartTag = \StringOperations::strlen($matches[0][0][0]);
        $pos1 = $matches[0][0][1];
        $pos2 = $matches[0][1][1];
        $body = \StringOperations::substr($content, $pos1 + $lenStartTag, $pos2 - ($pos1 + $lenStartTag));

        
        preg_match('#(.*)/#', $file, $matches);
        $relPath = $matches[0];
        $body = preg_replace('/(href=["\']{1}([^#])([^:@>]*)["\']{1})/', 'href="' . \CleanOperations::cleanStringForHtml($relPath) . '\\2\\3"', $body);
        
        $body = preg_replace('/<img([^>]*)src=["\']{1}(?!http:|https|\\/)([^>]*)["\']{1}([^>]*)>/', '<img\\1src="' . \CleanOperations::cleanStringForHtml($relPath) . '\\2"\\3>', $body);
        $body = preg_replace('#<IMG([^>]*)src=["\']{1}(?!http:|https|\\/)([^>]*)["\']{1}([^>]*)>#', '<img\\1src="' . \CleanOperations::cleanStringForHtml($relPath) . '\\2"\\3>', $body);
        
        preg_match('#(.*\\/\\/[^\\/]*)/(.*)#', $relPath, $matches);
        $body = preg_replace('#<img([^>]*)src=["\']{1}(\\/[^>]*)["\']{1}([^>]*)>#', '<img\\1src="' . \CleanOperations::cleanStringForHtml($matches[1]) . '\\2"\\3>', $body);
        $body = preg_replace('#<IMG([^>]*)src=["\']{1}(\\/[^>]*)["\']{1}([^>]*)>#', '<img\\1src="' . \CleanOperations::cleanStringForHtml($matches[1]) . '\\2"\\3>', $body);
        
        $body = preg_replace('/<form([^>]*)action=["\']{1}(?!http:|https|\\/)([^>]*)["\']{1}([^>]*)>/', '<form\\1action="' . \CleanOperations::cleanStringForHtml($relPath) . '\\2"\\3>', $body);
        $body = preg_replace('/<FORM([^>]*)action=["\']{1}(?!http:|https|\\/)([^>]*)["\']{1}([^>]*)>/', '<form\\1action="' . \CleanOperations::cleanStringForHtml($relPath) . '\\2"\\3>', $body);
        $body = preg_replace('#<form([^>]*)action=["\']{1}(\\/[^>]*)["\']{1}([^>]*)>#', '<form\\1action="' . \CleanOperations::cleanStringForHtml($matches[1]) . '\\2"\\3>', $body);
        $body = preg_replace('#<FORM([^>]*)action=["\']{1}(\\/[^>]*)["\']{1}([^>]*)>#', '<form\\1action="' . \CleanOperations::cleanStringForHtml($matches[1]) . '\\2"\\3>', $body);

        return $body;
      }
    }
    
    if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 13) == 'include_http:') {
      $file = \StringOperations::substr($varname, 13);
      if (\StringOperations::substr($file, 0, 7) == 'http://') {
        return \RequestOperations::getFromHTTP($file);
      } else {
        return '';
      }
    }

    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 20) == 'protectemail_simple:') {
      $email = \StringOperations::substr($varname, 20);

      return \CleanOperations::cleanStringForHtml(\StringOperations::protect_eMail_simple($email));
    } elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 20) == 'protectemail_number:') {
      $email = \StringOperations::substr($varname, 20);

      return \CleanOperations::cleanStringForHtml(\StringOperations::protect_eMail_numbers($email));
    } elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 21) == 'protectemail_numbers:') {
      $email = \StringOperations::substr($varname, 21);

      return \CleanOperations::cleanStringForHtml(\StringOperations::protect_eMail_numbers($email));
    } elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 22) == 'protectemail_complete:') {
      $email = \StringOperations::substr($varname, 22);

      return \StringOperations::protect_eMail_complete($email);
    }

    
    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 18) == 'anmschrittvisited:') {
      $schritt = \StringOperations::substr($varname, 18);
      $maxSchritt = \SessionOperations::getVarValueAnm(ANMELDEPFAD_SCHRITTMAX, 0);

      return ($schritt <= $maxSchritt && $maxSchritt < 5) ? '1' : '0';
    }
    
    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 15) == 'anmschrittlink:') {
      $schritt = \StringOperations::substr($varname, 15);

      $param = new \URLParameterAnmeldungArt();
      $param->kathaupt = 5;
      $param->schritt = $schritt;
      $param->anmart = \SessionOperations::getVarValueAnm(ANMELDEPFAD_ART, 0);
      $param->schrittback = 'true';
      $param->implodeSettings();

      return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $param->stream);
    }
    
    
    
    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 7) == 'anmcss:') {
      $schritt = \StringOperations::substr($varname, 7);
      $css = '';

      
      $maxSchritt = \SessionOperations::getVarValueAnm(ANMELDEPFAD_SCHRITTMAX, 0);
      if ($schritt <= $maxSchritt) {
        $css .= ' anmvisited';
      }

      
      $aktSchritt = \SessionOperations::getVarValueAnm(ANMELDEPFAD_SCHRITT, 0);
      if ($aktSchritt == $schritt) {
        $css .= ' anmactive';
      }

      return $css;
    } elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 10) == 'menuehigh_') {
      $kathauptApi = new \KathauptAPI();
      $param = new \URLParameterAnmeldungArt();
      if (\StringOperations::substr($varname, 10) == $param->kathaupt
          || \StringOperations::substr($varname, 10) == $kathauptApi->getParentDepth0Kathaupt($param->kathaupt)) {
        return ' hglt';
      } else {
        return '';
      }
    }
    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 12) == 't_bundesland') {
      $value = \SessionOperations::getVarValueWk('w_bundesland');
      if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 13) == 't_bundesland:') {
        $param = \StringOperations::substr($varname, 13);

        return $value == $param ? '1' : '0';
      } else {
        return \CleanOperations::cleanStringForHtml($value);
      }
    }
    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 7) == 'tw_krit') {
      $lfdnr = \StringOperations::substr($varname, 7, 1);
      $value = \SessionOperations::getVarValueWk('w_krit' . $lfdnr . '_ma');
      if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 9) == 'tw_krit' . $lfdnr . ':') {
        $param = \StringOperations::substr($varname, 9);

        return $value == $param ? '1' : '0';
      } else {
        return \CleanOperations::cleanStringForHtml($value);
      }
    }
    
    
    elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 8) == 'tw_kennz') {
      $sessionSuffix = '_ma';
      $kennz = \StringOperations::substr($varname, 8);
      for ($i = 1; $i <= 10; $i++) {
        if (\SessionOperations::getVarValueWk('w_kennz' . $i . $sessionSuffix) != '') {
          $value = trim(\SessionOperations::getVarValueWk('w_kennz' . $i . $sessionSuffix));
        } else {
          $value = '';
        }
        if ($value == $kennz) {
          return '1';
        }
      }

      return '0';
    } elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 9) == 'filteras_') {
      $lfdnr = \StringOperations::substr($varname, 9, 1);
      if (!is_numeric($lfdnr) || $lfdnr < 1) {
        return '';
      }
      $restVarname = \StringOperations::substr($varname, 11);

      $as = \AussenstellenAPI::getAussenstInWarenkorb();
      if (count($as) >= $lfdnr) {
        return \CleanOperations::cleanStringForHtml($this->exportCalculation->getVarValue4Aussenstelle($restVarname, $as[$lfdnr - 1]));
      }

      return '';
    }
    
    
    elseif ($varname == 'wk_alle_voll') {
      $kurse = \DBWorkWarenkorbKurseWB::getDefaultInstance()->getKurse();

      foreach ($kurse as $kurs) {
        if ($kurs->getVarValue('anmeldungeng_web') != 3) {
          return '0';
        }
      }

      return '1';
    }
    
    elseif ($varname == 'wk_einer_voll') {
      $kurse = \DBWorkWarenkorbKurseWB::getDefaultInstance()->getKurse();

      foreach ($kurse as $kurs) {
        if ($kurs->getVarValue('anmeldungeng_web') == 3) {
          return '1';
        }
      }

      return '0';
    } elseif (\StringOperations::strtolower($varname) == 'wk_onlinezahlung_moeglich') {
      $kurse = \DBWorkWarenkorbKurseWB::getDefaultInstance()->getKurse();
      $epayHinderungsgruende = new \EPaymentHinderungsgruende();

      return $epayHinderungsgruende->isEPaymentAllowedForKurse($kurse) ? '1' : '';
    } elseif (\StringOperations::strtolower($varname) == 'wk_onlinezahlung_moeglich_text') {
      $kurse = \DBWorkWarenkorbKurseWB::getDefaultInstance()->getKurse();

      $epayHinderungsgruende = new \EPaymentHinderungsgruende();
      $hinderungsgruendeForKurse = $epayHinderungsgruende->checkForKurse($kurse);
      $moreThanOneKurse = count($hinderungsgruendeForKurse) > 1;

      $buffer = '<span>';
      foreach ($hinderungsgruendeForKurse as $knr => $gruende) {
        if ($moreThanOneKurse) {
          $buffer .= 'Kurs-Nr: ' . $knr;
        }
        $buffer .= '<ul>';
        foreach ($gruende as $grund) {
          $buffer .= '<li>' . $grund . '</li>';
        }
        $buffer .= '</ul>';
      }
      $buffer .= '</span>';

      return $buffer;
    } elseif (\StringOperations::strtolower($varname) == 'wk_t_bemerkung') {
      
      
      $tnAry = \SessionOperations::getTeilnehmerFromSession();
      $tn = $tnAry[0];

      return \CleanOperations::cleanStringForHtml($tn->getVarValue('bemerkung'));
    } elseif (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 3) == 'wk_'
      && \StringOperations::substr_count($varname, '_') > 1
      
      && \StringOperations::substr($varname, 0, 19) !== 'wk_ohne_kennzeichen'
      && \StringOperations::substr($varname, 0, 36) !== 'wk_dublette_in_mindestens_einem_kurs'
      && \StringOperations::substr($varname, 0, 36) !== 'wk_sumkursgeberm_float'
      && \StringOperations::substr($varname, 0, 26) !== 'wk_kurs_spaeter_als_x_tage'
      && strpos($varname, 'kursinwk') === false) {
      $varname = \StringOperations::substr($varname, 3);
      $indexNext_ = \StringOperations::strpos($varname, '_');

      
      if (\StringOperations::substr(\StringOperations::strtolower($varname), 0, 2) === 't_') {
        if (\SessionOperations::isNeuesAnmeldeverfahren()) {
          $anmInfo = \SessionOperations::getVarValueAnmInfo();
          if (isset($anmInfo->hauptTn)) {
            $tn = $anmInfo->hauptTn;
          } else {
            $tn = new \TeilnehmerPflicht();
          }
        } else {
          $tnAry = \SessionOperations::getTeilnehmerFromSession();
          $tn = $tnAry[0];
        }

        return $this->exportCalculation->getVarValue4Teilnehmer(\StringOperations::substr($varname, 2), $tn);
      }

      $lfdnr = 1;
      if ($indexNext_ !== false) {
        $lfdnr = \StringOperations::substr($varname, 0, $indexNext_);

        if (!is_numeric($lfdnr)) {
          return 'Falsches Format bei sys_wk_' . $varname . ': laufende Nummer (1 .. Anzahl Kurse im Warenkorb) erwartet (sys_wk_X_' . $varname . ')';
        }

        $varname = \StringOperations::substr($varname, $indexNext_ + 1);
      } else {
        return 'Falsches Format bei sys_wk_' . $varname . ': zu wenig "_" enthalten';
      }

      $exp = new \ExportKurse();
      $exp->initiate();
      $exp->exportresults = \DBWorkWarenkorbKurseWB::getDefaultInstance()->getKurse();
      $kursCount = count($exp->exportresults);
      $exp->setNrOfMainBodyElements($kursCount);

      if ($lfdnr > $kursCount) {
        return '';
      }
      $exp->actualset = $lfdnr - 1;

      return $exp->getVarValue($varname);
    } else {
      
      
      $varparam = '';
      if (\StringOperations::strpos($varname, ':')) {
        $parts = explode(':', $varname);
        $varname = $parts[0];
        $varparam = implode(':', array_slice($parts, 1));

        $hatZweitenParam = \StringOperations::strpos($varparam, TRENNER_VORBELEGUNG) > 0;
        if ($hatZweitenParam) {
          $parts = explode(TRENNER_VORBELEGUNG, $varparam);
          $varparam = array_shift($parts);
          $zweiterParam = implode(TRENNER_VORBELEGUNG, $parts);
        } else {
          $zweiterParam = '';
        }
      }

      switch (\StringOperations::strtolower($varname)) {
        case 'edittandozvertrag':
          return '';
        case 'rel_kw_path':
          return \CmsAnb::getAnbindung()->getKuferWebUrl();
        case 'anm_js_pfade':
        case 'js_pfade':
          return \JsOperations::getAnmeldungJsPfade();
        case 'languagekey':
          return (string)\SessionOperations::getCurrentLanguageKey();
        case 'urlparam_value':
          if ($varparam === '') {
            return '';
          } else {
            $upnav = new \URLParameterNavigation();

            return ($upnav->VarExist($varparam) ? \CleanOperations::cleanStringForHtml($upnav->{$varparam}) : '');
          }
          
        case 'raise_html_error_403':
          http_response_code(403);
          break;
        case 'raise_html_error_404':
          http_response_code(404);
          break;
        case 'raise_html_error_410':
          http_response_code(410);
          break;
        case 'raise_html_error_403_and_exit':
          \RequestOperations::sendHttpStatusAndQuit(403);
          break;
        case 'raise_html_error_404_and_exit':
          \RequestOperations::sendHttpStatusAndQuit(404);
          break;
        case 'raise_html_error_410_and_exit':
          \RequestOperations::sendHttpStatusAndQuit(410);
          break;
        case 'encoding': return \CleanOperations::cleanStringForHtml(\ConstantOperations::getEncoding());
        case 'is_bestkopie': return (class_exists('\\TNBestaetigungEMailByStatus') && \TNBestaetigungEMailByStatus::checkIfIsCopy()) ? '1' : '0';
        case 'is_stammhoereraendernkopie': return \DataMenuLoginDatenAendern::checkIfIsCopy() ? '1' : '0';
        case 'is_stammhoereraendernemailerfolgreichversendet': return \DataMenuLoginDatenAendern::checkIfEmailSendSuccessful() ? '1' : '0';
        case 'is_stammhoererteilnbedingungennotaccepted':
          return \LoginApi::checkIfTeilnBedingungenAccepted() ? '0' : '1';
        case 'version': return \CleanOperations::cleanStringForHtml(VERSION);
        case 'datum_tag_monat':
          $date = \DateTimeOperations::getDateNow();

          return \CleanOperations::cleanStringForHtml(implode('.', array_slice(explode('.', $date), 0, 2)));
        case 'datum':
          $date = \DateTimeOperations::getDateNow();
          if ($varparam != '' && \CleanOperations::isInt($varparam)) {
            $date = \DateTimeOperations::addDays($date, \CleanOperations::cleanInt($varparam));
          }

          return \CleanOperations::cleanStringForHtml($date);
        case 'datum_komplettkurz':
          $date = \DateTimeOperations::getDateNow();
          if ($varparam != '' && \CleanOperations::isInt($varparam)) {
            $date = \DateTimeOperations::addDays($date, \CleanOperations::cleanInt($varparam));
          }

          $wotagkurz = \DateTimeOperations::getWeekDayShort($date);

          return \CleanOperations::cleanStringForHtml($wotagkurz . ', ' . $date);
        case 'datum_monatsanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(6));
        case 'datum_monatsende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(7));
        case 'datum_quartalsanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getQuartalerstTag());
        case 'datum_quartalsende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getQuartalletztTag());
        case 'datum_naechstquartanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_NAE_QUART_BEGINN));
        case 'datum_naechstquartende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_NAE_QUART_ENDE));
        case 'datum_morgen': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(1));
        case 'datum_diesewocheanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(2));
        case 'datum_diesewocheende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(3));
        case 'datum_naechstewocheanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(4));
        case 'datum_naechstewocheende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(5));
        case 'datum_naechstmonatanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(8));
        case 'datum_naechstmonatende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(9));
        case 'datum_2monatanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_2_MO_BEGINN));
        case 'datum_2monatende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_2_MO_ENDE));
        case 'datum_3monatanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_3_MO_BEGINN));
        case 'datum_3monatende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_3_MO_ENDE));
        case 'datum_2wochenanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_2_WO_BEGINN));
        case 'datum_2wochenende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_2_WO_ENDE));
        case 'datum_3wochenanfang': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_3_WO_BEGINN));
        case 'datum_3wochenende': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateByParam(DATE_3_WO_ENDE));
        case 'datum_letztes_jahr': return date('Y', time() - (3600 * 24 * 365));
        case 'datum_aktuelles_jahr': return date('Y', time());
        case 'datum_naechstes_jahr': return date('Y', time() + (3600 * 24 * 365));

        case 'datum_weihnachtsferien_blak':
          $dateToday = \DateObj::getNow();
          $month = intval($dateToday->getMonth());
          $day = intval($dateToday->getDay());

          return (string)(($month == 12 && $day >= 24) || ($month == 1 && $day <= 6));
        case 'uhrzeit': return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getTimeNow());
        case 'formurl':
          $tmp = new \URLParameterNavigation();
          $scriptname = \StringOperations::getHttpWithoutParams(\RequestOperations::getReferer(INDEXSCRIPT));
          $tmp->implodeSettings();

          return \CleanOperations::cleanStringForHtml($scriptname . '?urlparameter=' . $tmp->stream);
        case 'url': $tmp = new \URLParameterBasis();
          $scriptname = \StringOperations::getHttpWithoutParams(\RequestOperations::getReferer(INDEXSCRIPT));

          return \CleanOperations::cleanStringForHtml($scriptname . '?urlparameter=' . $tmp->stream);
        case 'urlself': $tmp = new \URLParameterBasis();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $tmp->stream);
        case 'urlself_ohne_blaettern':
          $urlparam = new \URLParameterNavigation();
          $urlparam->knr = '';
          $urlparam->browse = '';
          $urlparam->suchesetzen = '';
          $urlparam->implodeSettings();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparam->stream);
        case 'host_name':
          $protocol = \RequestOperations::getHttpProtocolPrefix();
          $host = \StringOperations::getHttpWithoutParams(\RequestOperations::getHostName());
          $url = $protocol . $host . DIRECTORY_SEPARATOR;

          return \CleanOperations::cleanStringForHtml($url);
        case 'anmschritt':
          $urlParam = new \URLParameterAnmeldung();

          return \CleanOperations::cleanStringForHtml($urlParam->schritt);
        case 'urlparameterstart': return 'urlparameter=';
        case 'urlparameterzuweisung': return \CleanOperations::cleanStringForHtml(URLPARAMETER_ZUWEISUNG);
        case 'urlparametertrennzeichen': return \CleanOperations::cleanStringForHtml(URLPARAMETER_TRENNZEICHEN);
        case 'currency': return \CleanOperations::cleanStringForHtml(CURRENCY);
        case 'cssfile':
          $tmpurlparam = new \URLParameterBrowse();
          if ($tmpurlparam->printmodus == 'true') {
            return 'indexprint.css';
          } else {
            return 'index.css';
          }
          
        case 'kufercssfile':
          $tmpurlparam = new \URLParameterBrowse();
          if ($tmpurlparam->printmodus == 'true') {
            return 'system_print.css';
          } else {
            return 'system.css';
          }
          
          
          
        case 'printbody': $tmpurlparam = new \URLParameterBrowse();
          if ($tmpurlparam->printmodus == 'true') {
            return "onload='printpage();'";
          }
          break;

          
          
        case 'sizecss':
          switch (\SessionOperations::getVarValueIntern(FONTSIZE_SESSION_VAR, FONTSIZE_NORMAL)) {
            case FONTSIZE_SMALL: return 'small.css';
            case FONTSIZE_BIG: return 'big.css';
            case FONTSIZE_EXTRABIG: return 'extrabig.css';
            case FONTSIZE_NORMAL:
            default: return 'normal.css';
          }
          break;
          
        case 'sizebig':
          $urlparam = new \UrlParameterFontSize();
          $urlparam->size = FONTSIZE_BIG;
          $urlparam->implodeSettings();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparam->stream);
          
        case 'sizeextrabig':
          $urlparam = new \UrlParameterFontSize();
          $urlparam->size = FONTSIZE_EXTRABIG;
          $urlparam->implodeSettings();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparam->stream);
          
        case 'sizenormal':
          $urlparam = new \UrlParameterFontSize();
          $urlparam->size = FONTSIZE_NORMAL;
          $urlparam->implodeSettings();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparam->stream);
          
        case 'sizesmall':
          $urlparam = new \UrlParameterFontSize();
          $urlparam->size = FONTSIZE_SMALL;
          $urlparam->implodeSettings();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparam->stream);
        case 'kurshighlights':
          return \DataMenuKursHighlights::getKurshighlightsSicht($varparam);
        case 'kurshighlights_bykategorie':
          $urlparam = new \URLParameterNavigation();

          return \DataMenuKursHighlights::getKurshighlightsSicht($varparam, $urlparam->katid);
        case 'artikelhighlights':
          $dbw = new \DBWorkObjektHighlights();
          $highlights = $dbw->getObjektHighlights4Date(\DateTimeOperations::getDateNow());
          $helper = new \Kufer\Web\Classes\Api\Helpers\HighlightHelper($highlights);
          $ids = $helper->getHighlightIds($this->tool4settings->webshopArtikelHighlightAnzahl);
          $dbwArtikel = \DBWorkArtikel::getDefaultInstance();
          $artikel = $dbwArtikel->getArtikelByIdsKeepOrder($ids);

          return \CreateSightFassade::createListe(new \Datamodul(), 613, $artikel, new \ExpArtikel());
        case 'artikelportoliste':
          $dbw = \DBWorkArtikelPorto::getDefaultInstance();
          $portos = $dbw->getAll();

          return \CreateSightFassade::createListe(new \Datamodul(), 638, $portos, new \ExpArtikelPorto());
        case 'artikelportoliste_inland':
          return $this->getArtikelPortoListe(0);
        case 'artikelportoliste_ausland':
          return $this->getArtikelPortoListe(1);
        case 'artikelportoliste_schweiz':
          return $this->getArtikelPortoListe(2);
        case 'artikellegende':
          $texte = \ArtikelAPI::getAmpel3Texte();
          $result = '';
          foreach ($texte as $stat => $text) {
            $result .= '<li style="margin-bottom:6px;"><img border="0" title="' . $text . '" src="layout/shop_' . $stat . '.gif">&nbsp;&nbsp;&nbsp;' . $text . '</li>';
          }

          return $result;
        case 'artikel_warenkorb_fill_cache':
          \ArtikelAPI::frageVerfuegbareMengeFuerKomplettenWarenkorbAb();

          return '';
        case 'laufbandtext':
          return \CleanOperations::cleanStringContainingHtml($this->tool4settings->marqueetext);
        case 'kathaupt':
          $tmp = new \URLParameterHauptmenue();

          return \CleanOperations::cleanInt($tmp->kathaupt);
          
        case 'kathauptalt':
          $tmp = new \URLParameterHauptmenue();

          return \CleanOperations::cleanInt($tmp->kathauptalt);
          
          
        case 'server_aktiv':
          return (string)\SessionOperations::isSofortEinbuchenServerAktiv();
        case 'server_wartung_ab':
          return \CleanOperations::cleanTimeString($this->tool0settings->downtimestart, '');
        case 'server_wartung_bis':
          return \CleanOperations::cleanTimeString($this->tool0settings->downtimefinish, '');
        case 'ishttps':
          return (string)(\RequestOperations::isHttps());
        case 'server':
        case 'sslserver':
          return \Kufer\Web\Classes\Addfunctions\UrlOperations::getServerAddressFromSettings($varname == 'sslserver');
        case 'ssllogin':
          $loginKuferTools = false;
          
        case 'ssllogintools':
          if (!isset($loginKuferTools)) {
            $loginKuferTools = true;
          }
          if ($this->tool0settings->SSLLogin) {
            if ($loginKuferTools) {
              $sslServerName = $this->tool0settings->SSLserverNameTools;
            } else {
              $sslServerName = $this->tool0settings->SSLserverName;
            }

            $server = $sslServerName;
            $http = 'https';

            if ($server == '') {
              $server = \RequestOperations::getServerName();
            }

            $pathinfo = pathinfo(\RequestOperations::getScriptName());
            $path = $pathinfo['dirname'];
            $tocheck = '-------------------';
            
            
            
            if (\StringOperations::strpos($sslServerName, '/')) {
              $tocheck = \StringOperations::substr(
                $sslServerName,
                \StringOperations::strpos($sslServerName, '/') + 1
              );
            }
            
            if (\StringOperations::strpos($path, $tocheck) === 1) {
              $path = \StringOperations::substr($path, \StringOperations::strlen($tocheck) + 1);
            }
            if ($path === '/' || $path === '\\') {
              $path = '';
            }
            
            return \CleanOperations::cleanStringForHtml(str_replace('\\', '', $http . '://' . $server . $path . '/'));
          } else {
            return '';
          }
          
        case 'verlauf':
          $datamenu = new \DataMenuVerlauf(new \URLParameterBasis());

          return $datamenu->getContent();
        case 'startseitenlinkliste':
          $dbwlink = new \DBWorkWebZLink();
          $links = $dbwlink->getAllZLinks();

          return \CreateSightFassade::createListe(new \Datamodul(), 254, $links, new \ExpBasis());
          
        case 'aussenstformular':
          $formaussenst = \HTMLOperations::CreateInputTag('', 'submit', '', '', 'Filtern')
                          . '</form>';
          
        case 'aussenstform':
          if (!isset($formaussenst)) {
            $formaussenst = '';
          }

          $ausapi = new \AussenstellenAPI();

          return $ausapi->getForm4Aussenst() . $formaussenst;

          
        case 'semesterformular':
          $formsemester = \HTMLOperations::CreateInputTag('', 'submit', '', '', 'Semester filtern')
                          . '</form>';
          
        case 'semesterform':
          if (!isset($formsemester)) {
            $formsemester = '';
          }

          $semapi = new \SemesterAPI();

          return $semapi->getForm4Semester() . $formsemester;

          
        case 'wochentagformular':
          $formwochentag = \HTMLOperations::CreateInputTag('', 'submit', '', '', 'Wochentage filtern')
                          . '</form>';
          
        case 'wochentagform':
          if (!isset($formwochentag)) {
            $formwochentag = '';
          }
          $wotapi = new \WochentagAPI();

          return $wotapi->getForm4Wochentage() . $formwochentag;

          
        case 'zeitraumformular':
          $formzeitraum = \HTMLOperations::CreateInputTag('', 'submit', '', '', 'Veranstaltungszeit filtern') . '</form>';
          
        case 'zeitraumform':
          if (!isset($formzeitraum)) {
            $formzeitraum = '';
          }
          $wotapi = new \ZeitraumAPI();

          return $wotapi->getForm4Zeitbereiche() . $formzeitraum;

        case 'countbodyelements':
          return \CleanOperations::cleanInt($this->nrOfMainBodyElements);
        case 'katid':
          $param = new \URLParameterKategorie();

          return \CleanOperations::cleanInt($param->katid);
        case 'katvaterid':
          $param = new \URLParameterKategorie();

          return \CleanOperations::cleanInt($param->katvaterid);
        case 'vater_kategorie_tiefe2':
          $param = new \URLParameterKategorie();
          $catapi = new \CategoryAPI();

          return \CleanOperations::cleanInt($catapi->getParentDepth2ID($param->katid), '');
        case 'vater_kategorie_tiefe1_url_or_search':
          $id = \SessionOperations::getVarValueSuche('kfs_kursbereich', '');
          
        case 'vater_kategorie_tiefe1':
          $param = new \URLParameterKategorie();
          if (!isset($id) || $param->katid > 0) {
            $id = $param->katid;
          }
          $catapi = new \CategoryAPI();

          return \CleanOperations::cleanStringForHtml($catapi->getParentDepth1ID($id));
        case 'anmart':
          $param = new \URLParameterAnmeldungArt();

          return \CleanOperations::cleanStringForHtml($param->anmart);
        case 'anmactiveschritt':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getVarValueAnm(ANMELDEPFAD_SCHRITT, 0));
        case 'zeitfilter_heute':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_HEUTE));
        case 'zeitfilter_morgen':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_MORGEN));
        case 'zeitfilter_diesewoche':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_DIE_WO));
        case 'zeitfilter_nächstewoche':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_NAE_WO));
        case 'zeitfilter_diesermonat':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_DIE_MO));
        case 'zeitfilter_nächstermonat':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_NAE_MO));
        case 'zeitfilter_übernächstermonat':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_2_MO));
        case 'zeitfilter_3monat':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_3_MO));
        case 'zeitfilter_diesermonat_name':
          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getMonatName(DATE_DIE_MO));
        case 'zeitfilter_nächstermonat_name':
          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getMonatName(DATE_NAE_MO));
        case 'zeitfilter_übernächstermonat_name':
          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getMonatName(DATE_2_MO));
        case 'zeitfilter_3monat_name':
          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getMonatName(DATE_3_MO));
        case 'zeitfilter_diesewoche_ab_heute':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_DIE_WO_AB_HEUTE));
        case 'zeitfilter_diesermonat_ab_heute':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_DIE_MO_AB_HEUTE));
        case 'zeitfilter_diesesquartal':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_DIE_QUARTAL));
        case 'zeitfilter_naechstesquartal':
          return \CleanOperations::cleanStringForHtml(\Kufer\Web\Classes\Addfunctions\UrlOperations::getZeitFilterLink(DATE_NAE_QUARTAL));
        case 'randomlink_text':
          $tmpWZLink = \Kufer\Web\Classes\Addfunctions\UrlOperations::getZufallsLink();
          if ($tmpWZLink != null) {
            return \CleanOperations::cleanStringForHtml($tmpWZLink->text);
          } else {
            return '';
          }
          
        case 'randomlink_bild':
          $tmpWZLink = \Kufer\Web\Classes\Addfunctions\UrlOperations::getZufallsLink();
          if ($tmpWZLink != null) {
            return \CleanOperations::cleanStringForHtml($tmpWZLink->bild);
          } else {
            return '';
          }
          
        case 'randomlink_link':
          $tmpWZLink = \Kufer\Web\Classes\Addfunctions\UrlOperations::getZufallsLink();
          if ($tmpWZLink != null) {
            return \CleanOperations::cleanStringForHtml($tmpWZLink->link);
          } else {
            return '';
          }
          
        case 'randomlink_reset':
          \SessionOperations::setVarValueEinst(RANDOM_LINK_SESS_KEY, null);
          break;
        case 'alle_filter_leeren':
          $urlparam = new \URLParameterNavigation();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparam->getStreamWith(array('clearallfilter'), array('true')));
        case 'alle_filter_leeren_formular':
          $urlparam = new \URLParameterNavigation();
          $input_urlparam = \HTMLOperations::CreateInputTag(
            'urlparameter',
            'hidden',
            '',
            '',
            $urlparam->getStreamWith(array('clearallfilter'), array('true'))
          );
          $input_submit = \HTMLOperations::CreateInputTag(
            '',
            'submit',
            '',
            '',
            'Alle Filter leeren'
          );

          return '<form action="' . \CleanOperations::cleanStringForHtml(INDEXSCRIPT) . '?urlparameter='
          . \CleanOperations::cleanStringForHtml($urlparam->getStreamWith(array('clearallfilter'), array('true'))) . '">'
          . $input_urlparam
          . $input_submit . '</form>';
        case 'letzte_replikation':
          $zeitpkt = \DBWorkWebReplikatSettings::getDefaultInstance()->getReplicatedAt($varparam);

          return \CleanOperations::cleanStringForHtml($zeitpkt->value);
        case 'letzte_replikation_datum':
          $zeitpkt = \DBWorkWebReplikatSettings::getDefaultInstance()->getReplicatedAt($varparam);

          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateFromDatetimeStr($zeitpkt->value));
        case 'letzte_replikation_uhrzeit':
          $zeitpkt = \DBWorkWebReplikatSettings::getDefaultInstance()->getReplicatedAt($varparam);

          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getTimeStr($zeitpkt->value));
        case 'auth_versandt':
          $dbw = new \DBWorkWarenkorbHangarInteressenbekundungVersandt();

          return ($dbw->EntryCount() > 0 ? '1' : '0');
        case 'datum_vor_einem_monat':
          $time = \DateTimeOperations::getTimestampNow();

          return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getDateOneMonthBefore(
            \DateTimeOperations::datefmt('dd', $time),
            \DateTimeOperations::datefmt('MM', $time),
            \DateTimeOperations::datefmt('yyyy', $time)
          ));
        case 'cookie_akzeptiert':
          if (!isset($_COOKIE['cookietest'])) {
            return '';
          }

          return ($_COOKIE['cookietest'] == 'erfolgreich' ? '1' : '0');
        case 'cookiehilfe':
          
          $dmBasis = new \DataMenuBasis(new \UrlParameterGeneric());
          $dmBasis->dataarrayheader = array(new \Datamodul());
          $dmBasis->dataarraybody = array(new \Datamodul());
          $dmBasis->dataarrayfooter = array(new \Datamodul());

          return $dmBasis->getsightcomplete(217, new \ExpBasis());
        case 'cookie_hilf_link':
        case 'cookie_hilflink':
          
          $urlparameter = new \URLParameterBrowse();
          $urlparameter->kathaupt = '210';
          $urlparameter->kathauptname = 'Cookiehilfe';
          unset($urlparameter->katid, $urlparameter->katvaterid, $urlparameter->katname);


          $urlparameter->implodeSettings();

          return \CleanOperations::cleanStringForHtml(INDEXSCRIPT . '?urlparameter=' . $urlparameter->stream);
        case 'typo3_id':
          return \CleanOperations::cleanStringForHtml(\GetOperations::getVarValue('id'));
        case 'typo3_oberpunkt': 
          if (defined('TYPO3_CMS_OBERPUNKT')) {
            return \CleanOperations::cleanStringForHtml(TYPO3_CMS_OBERPUNKT);
          } else {
            return '-1';
          }
          
          
        case 'typo3_wbpfad':
          return \CleanOperations::cleanStringForHtml(TYPO3_CMS_RELPATH);
        case 'typo3_redirect_warenkorb':
          return '';

          
        case 'cms_user_logged_in':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['logged_in'];
        case 'cms_user_username':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['username'];
        case 'cms_user_email':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['email'];
        case 'cms_user_firstname':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['firstname'];
        case 'cms_user_lastname':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['lastname'];
        case 'cms_user_display_name':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['display_name'];
        case 'cms_user_id':
          $anb = \CmsAnb::getAnbindung();

          return $anb->getloggedUserData()['id'];

        case 'sessionid':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getSessionID());
        case 'sessiontime':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getSessionTime());
          
        case 'epaymentverfuegbar':
          return \System::isEpaymentAvailable();
        case 'epaymentaktiviert':
          if (\System::isEpaymentAvailable()) {
            $plugin = \WbPluginSettings::getInstance('epayment');
            if ($plugin) {
              return (string)($plugin->getSetting('schnittstelle') != '');
            }
          }

          return '';
        case 'wk_count':
        case 'wkeintraege':
          $anzahlKurseImWk = \DBWorkWarenkorbKurseWB::getDefaultInstance()->EntryCount();
          $dbwkArtikel = new \DBWorkWarenkorbArtikel();
          $anzahlArtikelImWk = $dbwkArtikel->EntryCount();

          return strval($anzahlKurseImWk + $anzahlArtikelImWk);
        case 'wk_countkurse':
          return \DBWorkWarenkorbKurseWB::getDefaultInstance()->EntryCount();
        case 'wk_countartikel':
          $dbwkArtikel = new \DBWorkWarenkorbArtikel();

          return (string)$dbwkArtikel->EntryCount();
        case 'wktext':
          return \CleanOperations::cleanStringForHtml($this->tool4settings->warenkorbName);
        case 'alternate':
          static $alternate1 = 0; 
          $alternate1 += 1;

          return (($alternate1 % 2) == 1 ? 'alt1' : 'alt2');
        case 'alternate_kombiniert_artikel':
          static $alternate2 = 0; 
          $anzahlKurse = intval($this->resolveVar('wk_countkurse'));
          $alternate2 += 1;

          return ((($alternate2 + $anzahlKurse) % 2) == 1 ? 'alt1' : 'alt2');
        case 'kalender_urlparams_kurse':
          $urlParams = parse_url(\GetOperations::getUrlSelf(), PHP_URL_QUERY);
          parse_str($urlParams, $urlParamsAry);
          $knrs = \StringOperations::preg_grep_keys('/^k\\d+$/', $urlParamsAry);

          return http_build_query($knrs);
        case 'kalender_monat_vorher':
        case 'kalender_monat_nachher':
        case 'kalender':
          $year = \SessionOperations::getVarValueEinst('year', date('Y'));
          $month = \SessionOperations::getVarValueEinst('month', date('n'));
          $veranart = '';
          if (isset($_REQUEST['year']) && $_REQUEST['year'] !== 'aktuell') {
            $year = $_REQUEST['year'];
          }
          if (isset($_REQUEST['month']) && $_REQUEST['month'] !== 'aktuell') {
            $month = $_REQUEST['month'];
          }
          if (isset($_REQUEST['kfs_veranartids'])) {
            $veranart = $_REQUEST['kfs_veranartids'];
          }
          
          if (!is_numeric($month) || !is_numeric($year) || !checkdate($month, 1, $year)) {
            return '';
          } else {
            
            \SessionOperations::setVarValueEinst('year', $year);
            \SessionOperations::setVarValueEinst('month', $month);
          }
          switch ($varname) {
            case 'kalender_monat_vorher':
              $month = \DateTimeOperations::shiftMonth($month, false);
              if ($month == 12) {
                $year--;
              }
              break;
            case 'kalender_monat_nachher':
              $month = \DateTimeOperations::shiftMonth($month, true);
              if ($month == 1) {
                $year++;
              }
              break;
          }

          $kalender = \Kufer\Web\Webbasys\Includee\Api\KalenderAPIFactory::getKalenderAPI();

          return $kalender->getEinzelveranstaltungsTabelle($year, $month, $veranart);
        case 'kalender_monat_leiste_zukunft':
          $nurZukunft = true;
          
        case 'kalender_monat_leiste':
          $retour = '';
          $trenner = '<span class="kalender_trenner">|</span>';
          $currentYear = date('Y');
          $currentMonth = date('n');
          $year = \SessionOperations::getVarValueEinst('year', $currentYear);
          $month = \SessionOperations::getVarValueEinst('month', $currentMonth);
          if (isset($_REQUEST['year']) && $_REQUEST['year'] !== 'aktuell') {
            $year = $_REQUEST['year'];
          }
          if (isset($_REQUEST['month']) && $_REQUEST['month'] !== 'aktuell') {
            $month = $_REQUEST['month'];
          }
          
          if (!is_numeric($month) || !is_numeric($year) || !checkdate($month, 1, $year)) {
            return '';
          } else {
            
            \SessionOperations::setVarValueEinst('year', $year);
            \SessionOperations::setVarValueEinst('month', $month);
          }
          
          $urlparam = new \URLParameterNavigation();
          $urlparam->suchesetzen = '';
          $urlparam->blkeep = true;
          $urlparam->implodeSettings();
          $script = \RequestOperations::getPhpSelf();
          $script = \StringOperations::substr($script, strrpos($script, '/') + 1);
          $start = 'urlparameter=' . $urlparam->stream;
          $monthTmp = $month;
          $yearTmp = $year;
          
          for ($i = 1; $i < 5; $i++) {
            $monthTmp = \DateTimeOperations::shiftMonth($monthTmp, false);
            if ($monthTmp == 12) {
              $yearTmp--;
            }
            if (!isset($nurZukunft) || \DateTimeOperations::isDateBefore("01.$currentMonth.$currentYear", "28.$monthTmp.$yearTmp")) { 
              $retour = '<a href="' . \CleanOperations::cleanStringForHtml($script . '?' . $start . '&month=' . $monthTmp . '&year=' . $yearTmp)
                  . '" title="Kalender für ' . \CleanOperations::cleanStringForHtml($monthTmp) . '.' . \CleanOperations::cleanStringForHtml($yearTmp) . ' anzeigen">' . \CleanOperations::cleanStringForHtml(\DateTimeOperations::getNameofMonth($monthTmp)) . '</a>' . $trenner . $retour;
            }
          }
          
          $retour .= '<span class="aktueller_monat" title="aktueller Monat">' . \CleanOperations::cleanStringForHtml(\DateTimeOperations::getNameofMonth($month)) . '</span>';
          $monthTmp = $month;
          $yearTmp = $year;
          for ($i = 1; $i < 5; $i++) {
            $monthTmp = \DateTimeOperations::shiftMonth($monthTmp, true);
            if ($monthTmp == 1) {
              $yearTmp++;
            }
            $retour .= $trenner . '<a href="' . \CleanOperations::cleanStringForHtml($script . '?' . $start . '&month=' . $monthTmp . '&year=' . $yearTmp)
                . '" title="Kalender für ' . \CleanOperations::cleanStringForHtml($monthTmp) . '.' . \CleanOperations::cleanStringForHtml($yearTmp) . ' anzeigen">' . \CleanOperations::cleanStringForHtml(\DateTimeOperations::getNameofMonth($monthTmp)) . '</a>';
          }

          return $retour;
        case 'kategorienliste':
          $kapi = new \KategorienAPI();

          return $kapi->getCategoryList();

        case 'kategorienliste2':
          
          
          $kapi = new \KategorienApiWbAktivMitSuche();

          return $kapi->getCategoryList();
        case 'kategorienliste_json':
          $kapi = new \KategorienApiJson();

          return $kapi->getCategoryList();
        case 'kategorienliste_json_basic':
          $kapi = new \KategorienApiJsonBasic();

          return $kapi->getCategoryList();
        case 'kategorienliste_json_basic_notempty':
          $kapi = new \KategorienApiJsonBasic();
          $kapi->alsoEmpty = false;

          return $kapi->getCategoryList();
        case 'kategorienliste_sicht261':
          $exportCalcCategoryUrl = new ExportCalcCategoryURL($this->exportCalculation);

          return $exportCalcCategoryUrl->resolveVar('unterkategorienliste_sicht261', new \Category());
        case 'demnaechstmenue_kalender':
          $year = \SessionOperations::getVarValueEinst('year', '##');
          $month = \SessionOperations::getVarValueEinst('month', '##');
          if (isset($_REQUEST['year'])) {
            $year = $_REQUEST['year'];
          }
          if (isset($_REQUEST['month'])) {
            $month = $_REQUEST['month'];
          }
          
          if (!is_numeric($month) || !is_numeric($year) || !checkdate($month, 1, $year)) {
            $lastDayOfMonth = \DateObj::getNow();
            $lastDayOfMonth->setDayToLastDayInMonth();
            $firstDayOfMonth = \DateObj::getNow();
            $firstDayOfMonth->setDay(1);
            $start = $firstDayOfMonth->__toString();
            $stop = $lastDayOfMonth->__toString();
            $api = \Kufer\Web\Webbasys\Includee\Api\KalenderAPIFactory::getKalenderAPI();
            $kurse = $api->getKurse4DemnaechstMenue('', $start, $stop);
            if (count($kurse) == 0) {
              
              
              for ($i = 1; $i <= 12 && count($kurse) == 0; $i++) {
                $firstDayOfMonth->addMonths(1);
                $lastDayOfMonth->addMonths(1)->setDayToLastDayInMonth();
                $kurse = $api->getKurse4DemnaechstMenue('', $firstDayOfMonth->__toString(), $lastDayOfMonth->__toString());
              }
              if (count($kurse) > 0) {
                $year = $firstDayOfMonth->getYear();
                $month = $firstDayOfMonth->getMonth();
                \SessionOperations::setVarValueEinst('year', $year);
                \SessionOperations::setVarValueEinst('month', $month);
              }
            }
          } else {
            
            \SessionOperations::setVarValueEinst('year', $year);
            \SessionOperations::setVarValueEinst('month', $month);

            $month = \StringOperations::lpad($month, 2, '0');
            $start = "01.$month.$year";
            $stop = \DateTimeOperations::getDaysOfMonth($month, $year) . ".$month.$year";
          }
          
        case 'demnaechstmenue':
          if (!isset($start)) {
            $start = '';
          }
          if (!isset($stop)) {
            $stop = '';
          }
          $exp = new \ExpKursuebersicht();
          if (!isset($kurse)) {
            $api = \Kufer\Web\Webbasys\Includee\Api\KalenderAPIFactory::getKalenderAPI();
            $settings = '';
            if ($varparam !== '') {
              $settings = \ToolSettingsAPI::getToolSettings(4);
              $settings->dmnmkalenderveranart = $varparam;
            }
            $kurse = $api->getKurse4DemnaechstMenue($settings, $start, $stop);
          }

          return \CreateSightFassade::createListe(new \Datamodul(), 232, $kurse, $exp);
        case 'demnaechstmenue_sgtinfo_ort':
          
          return $this->extractOrtOrtInfoDmnchst();
        case 't_pers_nr':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getVarValueWk('w_pers_nr'));
        case 'setkurssearch':
          \SessionOperations::setKursSearch();
          break;
        case 'resetkursfilter':

          $kursfilter = new \Kursfilter();
          $kursfilter->setFilter();
          break;
        case 'h_uebernachtung_jn':
          return (\SessionOperations::getVarValueIntern('wh_uebernachtung_jn', '--') == 1) ? '1' : '0';
        case 'warenkorb':
          include_once BASEDIR . 'webbasys' . DIRECTORY_SEPARATOR . 'warenkorb.php';

          return getWarenkorb();
        case 'warenkorb_artikel':
          $wkartikel = new \DBWorkWarenkorbArtikel();
          $items = $wkartikel->getEntries();
          $exp = new \ExpArtikelWare();

          return \CreateSightFassade::createListe(new \Datamodul(), 595, $items, $exp, $exp);
        case 'warenkorb_artikel_summe':
          $wkartikel = new \DBWorkWarenkorbArtikel();
          $summe = $wkartikel->getSumme();

          return \CleanOperations::cleanStringForHtml(\MathOperations::floatToString($summe));
        case 'warenkorb_artikel_summe_komplett':
          $sumkurse = $this->resolveVar('warenkorb_hotel2_summe');
          $sumartikel = $this->resolveVar('warenkorb_artikel_summe');
          $betragKurse = \MathOperations::stringToFloat($sumkurse);
          $betragArtikel = \MathOperations::stringToFloat($sumartikel);
          $betragVersandkosten = \ArtikelAPI::getWkArtikelPortoRegardingVersandInfo();

          return \MathOperations::floatToString($betragKurse + $betragArtikel + $betragVersandkosten);
        case 'warenkorb_artikel_summe_komplett_erm':
          $sumkurse = $this->resolveVar('warenkorb_hotel2_summe_erm');
          $sumartikel = $this->resolveVar('warenkorb_artikel_summe');
          $betragKurse = \MathOperations::stringToFloat($sumkurse);
          $betragArtikel = \MathOperations::stringToFloat($sumartikel);
          $betragVersandkosten = \ArtikelAPI::getWkArtikelPortoRegardingVersandInfo();

          return \MathOperations::floatToString($betragKurse + $betragArtikel + $betragVersandkosten);
        case 'warenkorb_artikel_summe_ohne_hotel_ohne_versand':
          $sumartikel = $this->resolveVar('warenkorb_artikel_summe');
          $betragKurse = \DBWorkWarenkorbKurseWB::getDefaultInstance()->getGebuehrenNichtErmaessigt();
          $betragArtikel = \MathOperations::stringToFloat($sumartikel);

          return \MathOperations::floatToString($betragKurse + $betragArtikel);
        case 'warenkorb_artikelporto_summe':
          return \MathOperations::floatToString(\ArtikelAPI::getWkArtikelPortoRegardingVersandInfo());
        case 'warenkorb_artikelporto_summe_inland':
          return \ArtikelAPI::getWkArtikelPorto(0);
        case 'warenkorb_artikelporto_summe_ausland':
          return \ArtikelAPI::getWkArtikelPorto(1);
        case 'warenkorb_artikelporto_summe_schweiz':
          return \ArtikelAPI::getWkArtikelPorto(2);
        case 'warenkorb_hotel2_summe':
          $hoteldaten = \HotelOperations::getHotel2datenFromSessionRegardingWarenkorb(\DBWorkWarenkorbKurseWB::getDefaultInstance()->getEntries());
          $result = 0.0;
          foreach ($hoteldaten as $kursHotel) {
            $geb = \HotelOperations::getHotelEndGebuehr($kursHotel);
            $result += \MathOperations::stringToFloat($geb);
          }

          return \CleanOperations::cleanFloatMitKomma(\MathOperations::floatToString($result));
        case 'warenkorb_hotel2_summe_erm':
          $hoteldaten = \HotelOperations::getHotel2datenFromSessionRegardingWarenkorb(\DBWorkWarenkorbKurseWB::getDefaultInstance()->getEntries());
          $result = 0.0;
          foreach ($hoteldaten as $kursHotel) {
            $geb = \HotelOperations::getHotelEndGebuehr($pAnmeldedatenHotel = $kursHotel, $istVariableFuerHotelErm = null, $istVariableFuerHotelErm = true);
            $result += \MathOperations::stringToFloat($geb);
          }

          return \CleanOperations::cleanFloatMitKomma(\MathOperations::floatToString($result));
        case 'warenkorb_anmfirma_summe_komplett':
          $hotelDatenInSession = \SessionOperations::getObjectFromSession(\WBAnmeldungFirmaHotel::SESSION_NAME_HOTEL_DATEN, 'AnmeldedatenHotel');
          $sum = 0;
          foreach ($hotelDatenInSession as $maDaten) {
            $sum += \MathOperations::stringToFloat(\HotelOperations::getHotelEndGebuehr($maDaten));
          }

          return \MathOperations::floatToString($sum);
        case 'warenkorb_anmfirma_mit_kennzeichen':
          if ($varparam == '') {
            return '0';
          }
          $knr = \SessionOperations::getVarValueWk(\WBAnmeldungFirmaHotel::SESSION_NAME_FIRMAHOTEL_KNR);
          $kennzlist = \DBWorkKennz::getDefaultInstance()->getKennzListbyKnr($knr);

          return in_array($varparam, $kennzlist) ? '1' : '0';
        case 'warenkorb_anmfirma_onlinezahlung_moeglich':
          $knr = \SessionOperations::getVarValueWk(\WBAnmeldungFirmaHotel::SESSION_NAME_FIRMAHOTEL_KNR);
          $kurs = \DBWorkKurse::getDefaultInstance()->getKurs($knr);
          $epayHinderungsgruende = new \EPaymentHinderungsgruende();

          return $epayHinderungsgruende->isEPaymentAllowedForKurs($kurs) ? '1' : '';
        case 'doz_buchstabenleiste':
          return $this->getBuchstabenleiste(236, new \DBWorkDozentenWB(), $this->tool4settings->dozgruppiertNurS, $this->tool4settings->semlist);
        case 'geb_buchstabenleiste':
          return $this->getBuchstabenleiste(383, new \DBWorkGebaeude(), $this->tool4settings->gebgruppiertNurS, $this->tool4settings->semlist);
        case 'kort_buchstabenleiste':
          $dbw = new \DBWorkKursorteWB();
          $dbw->newSearch();
          $dbw->fromobject->eigenerraum = $this->tool4settings->nurEigeneRaeumeAnzeigen;

          return $this->getBuchstabenleiste(385, $dbw, $this->tool4settings->kortgruppiertNurS);
        case 'sw_buchstabenleiste':
          return $this->getBuchstabenleiste(253, new \DBWorkStichwort(), false, $this->tool4settings->semlist);
        case 'gewaehlter_buchstabe':
          $urlParam = new \URLParameterHauptmenue();

          return \CleanOperations::cleanStringForHtml($urlParam->letter);
        case 'is_ajax':
          return \RequestOperations::isAjax() ? '1' : '0';
          
          
        case 'is_kufertools':
          return  \SessionOperations::isKuferTools() ? '1' : '0';
        case 'get':
          if (\GetOperations::isDefined($varparam)) {
            return \FilterBasis::getOnlyAlphaNumeric(\GetOperations::getVarValue($varparam), '\\.' . $zweiterParam);
          } else {
            return '';
          }
          
          
        case 'get_wochentag':
        case 'get_wochentag_kurz':
        case 'get_jjjj':
        case 'get_jj':
        case 'get_tt':
        case 'get_t':
        case 'get_mmmm':
        case 'get_mmm':
        case 'get_mm':
        case 'get_m':
          return $this->dateHelperForGet($varname, $varparam);
        case 'post':
          if (\PostOperations::isDefined($varparam)) {
            return \FilterBasis::getOnlyAlphaNumeric(\PostOperations::getVarValue($varparam), '\\.' . $zweiterParam);
          } else {
            return '';
          }
          
        case 'cookie':
          if (\CookieOperations::isDefined($varparam)) {
            return \FilterBasis::getOnlyAlphaNumeric(\CookieOperations::getVarValue($varparam), '\\.' . $zweiterParam);
          } else {
            return '';
          }
          
        case 'preview':
          return \SessionOperations::isPreviewMode() ? '1' : '0';
        case 'nachbarschaftskurse':
          if ($this->tool4settings->nbkAktiv) {
            $dm = new \DataMenuNachbarschaftskurse();

            return $dm->getContent();
          }
          break;
        case 'nachbarschaftskurse_formular':
          if ($this->tool4settings->nbkAktiv) {
            $dm = new \DataMenuNachbarschaftskurse();
            $dm->prepareMainmenu();

            return $dm->getnocolumn();
          }
          break;
        case 'nbk_requeststarted':
          return $this->exportCalculation->getVarValue4NachbarschaftskursFormular('requeststarted', new \Datamodul());
        case 'news':
          $dm = new \DataMenuAktuellesWb(new \URLParameterNavigation());
          if ($dm->isRecursive()) {
            \Logger::logg('Die Variable {%sys_news%} darf nicht in der Sicht 278 verwendet werden!', 50);

            return 'Die Nachrichten können wegen einer Fehlkonfiguration nicht angezeigt werden!' . BR . 'Details zu dem Problem wurden protokolliert.';
          } else {
            return $dm->getContent();
          }
          
        case 'legende':
          return $this->getAmpel7Legende();
        case 'warenkorb_kursliste':
          $dbwwk = new \DBWorkWarenkorbKurse();
          $allWarenkorbKurse = $dbwwk->getKurse();

          return \CreateSightFassade::createListe(new \Datamodul(), 388, $allWarenkorbKurse, new \ExpKurse());
        case 'kontaktblock':
          $exp = new \ExpBasis();

          return \CreateSightFassade::createListe(new \Datamodul(), 393, array(), $exp, $exp);
        case 'schnellsuche':
          $exp = new \ExpBasis();
          if (is_array($this->exportCalculation->sightInfo)) {
            foreach ($this->exportCalculation->sightInfo as $key => $value) {
              $exp->setSightInfo($key, $value);
            }
          }

          return \CreateSightFassade::createListe(new \Datamodul(), 394, array(), $exp, $exp);
        case 'katasfilter':
        case 'katasfilter_nojs':
          $string = new \StringObj($varname);
          $nojs = false;
          if ($string->endsWith('_nojs')) {
            $nojs = true;
          }
          
          $result = '<form method="post" action="">';
          $result .= '<label for="kw_katasfilterid">nach Standort filtern:</label>';
          $result .= $this->resolveVar('katasfilter_select' . ($nojs ? '_nojs' : '') . ($varparam != '' ? ':' . $varparam : ''));
          if (!$nojs) {
            $result .= '<noscript>';
          }
          $result .= \HTMLOperations::CreateInputTag('submit', 'submit', '', '', 'go');
          if (!$nojs) {
            $result .= '</noscript>';
          }
          $result .= '</form>';

          return $result;
        case 'katasfilter_wert':
        case 'katasfilter_value':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getKatAsFilter());
        case 'katasfilter_select':
        case 'katasfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatAsRendererSelect();

          return $renderer->render($varname, $varparam);
        case 'katasfilter_cb':
        case 'katasfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatAsRendererCheckbox();

          return $renderer->render($varname, $varparam);
        case 'katasfilter_cb_list':
        case 'katasfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatAsRendererCheckboxAsList();

          return $renderer->render($varname, $varparam);
        case 'katwotagefilter_value':
          $wotageInvers = \SessionOperations::getKatWochentagFilterInvers();
          if ($wotageInvers === '') {
            return '';
          } else {
            $wotage = array_diff(array(1, 2, 3, 4, 5, 6, 7), explode(',', $wotageInvers));

            return \CleanOperations::cleanStringForHtml(implode(',', $wotage));
          }
          
        case 'katwotagefilter_select_lang':
        case 'katwotagefilter_select_lang_nojs':
        case 'katwotagefilter_select':
        case 'katwotagefilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatWotageRendererSelect();

          return $renderer->render($varname, $varparam);
        case 'katwotagefilter_cb_lang':
        case 'katwotagefilter_cb_lang_nojs':
        case 'katwotagefilter_cb':
        case 'katwotagefilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatWotageRendererCb();

          return $renderer->render($varname, $varparam);
        case 'katwotagefilter_cb_list_lang':
        case 'katwotagefilter_cb_list_lang_nojs':
        case 'katwotagefilter_cb_list':
        case 'katwotagefilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatWotageRendererCheckboxAsList();

          return $renderer->render($varname, $varparam);
        case 'katzeitraumfilter_value':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getKatZeitraumFilter());
        case 'katzeitraumfilter_select':
        case 'katzeitraumfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatZeitraumFilter();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katzeitraumfilter_rb':
        case 'katzeitraumfilter_rb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatZeitraumRendererRadioButtons();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katzeitraumfilter_rb_list':
        case 'katzeitraumfilter_rb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatZeitraumRendererRadioButtonAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);

        case 'katortfilter_value':
          $val = \SessionOperations::getKatOrtFilter();
          if (is_array($val)) {
            $val = implode(',', $val);
          }

          return \CleanOperations::cleanStringForHtml($val);
        case 'katortortfilter_select':
        case 'katortortfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortortfilter_cb':
        case 'katortortfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortortfilter_cb_list':
        case 'katortortfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortraumfilter_cb':
        case 'katortraumfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtRaumRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortraumfilter_cb_list':
        case 'katortraumfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtRaumRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortraumfilter_select':
        case 'katortraumfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtRaumRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortfilter_select':
        case 'katortfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtPlzRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortfilter_cb':
        case 'katortfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtPlzRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortfilter_cb_list':
        case 'katortfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtPlzRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortasfilter_select':
        case 'katortasfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtAsRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortasfilter_cb':
        case 'katortasfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtAsRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katortasfilter_cb_list':
        case 'katortasfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatOrtAsRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katumkreisfilter':
        case 'katumkreisfilter_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatUmkreisRenderer();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katumkreisfilterplz':
        case 'katumkreisfilterplz_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatUmkreisPlzRenderer();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katumkreisfilterradius':
        case 'katumkreisfilterradius_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatUmkreisRadiusRenderer();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katbeginndatvonfilter_text':
        case 'katbeginndatvonfilter_text_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatBeginndatVonRendererText();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katbeginndatbisfilter_text':
        case 'katbeginndatbisfilter_text_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatBeginndatBisRendererText();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katbeginndatintervallfilter_select':
        case 'katbeginndatintervallfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatBeginndatIntervallFilter();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katendedatbisfilter_text':
        case 'katendedatbisfilter_text_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatEndedatBisRendererText();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katendedatbisvormonatfilter_text':
        case 'katendedatbisvormonatfilter_text_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatEndedatBisVorMonatRendererText();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkeinebegonnenenfilter_cb':
        case 'katkeinebegonnenenfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKeineBegonnenRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkeinebegonnenenfilter_cb_list':
        case 'katkeinebegonnenenfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKeineBegonnenRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katgebuehrvonfilter_text':
        case 'katgebuehrvonfilter_text_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatGebuehrVonRendererText();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katgebuehrbisfilter_text':
        case 'katgebuehrbisfilter_text_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatGebuehrBisRendererText();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katneuerkursfilter_cb':
        case 'katneuerkursfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatNeuerKursRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katneuerkursfilter_cb_list':
        case 'katneuerkursfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatNeuerKursRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katnichtvollefilter_cb':
        case 'katnichtvollefilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatNichtVolleRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katnichtvollefilter_cb_list':
        case 'katnichtvollefilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatNichtVolleRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katdozorfilter_cb':
        case 'katdozorfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatDozOrRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katdozorfilter_cb_list':
        case 'katdozorfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatDozOrRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkennzorfilter_cb':
        case 'katkennzorfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKennzOrRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkennzorfilter_cb_list':
        case 'katkennzorfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKennzOrRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkennzorfilter_cb_list_bootstrap':
        case 'katkennzorfilter_cb_list_bootstrap_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKennzOrRendererCheckboxAsBootstrapRow();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkennzandfilter_cb':
        case 'katkennzandfilter_cb_nojs':
          if (\DBOperation::getInstanceDB1()->getDBName() === 'MYSQL') {
            $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKennzAndRendererCheckbox();

            return $renderer->render($varname, $varparam, $zweiterParam);
          } else {
            return '';
          }
          
        case 'katkennzandfilter_cb_list':
        case 'katkennzandfilter_cb_list_nojs':
          if (\DBOperation::getInstanceDB1()->getDBName() === 'MYSQL') {
            $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKennzAndRendererCheckboxAsList();

            return $renderer->render($varname, $varparam, $zweiterParam);
          } else {
            return '';
          }
          
        case 'katkennzandfilter_cb_list_bootstrap':
        case 'katkennzandfilter_cb_list_bootstrap_nojs':
          if (\DBOperation::getInstanceDB1()->getDBName() === 'MYSQL') {
            $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKennzAndRendererCheckboxAsBootstrapRow();

            return $renderer->render($varname, $varparam, $zweiterParam);
          } else {
            return '';
          }
          
        case 'katanykennzfilter_cb':
        case 'katanykennzfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatAnyKennzRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katanykennzfilter_cb_list':
        case 'katanykennzfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatAnyKennzRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katnokennzfilter_cb':
        case 'katnokennzfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatNoKennzRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katnokennzfilter_cb_list':
        case 'katnokennzfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatNoKennzRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katexceptkennzfilter_cb':
        case 'katexceptkennzfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatExceptKennzRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katexceptkennzfilter_cb_list':
        case 'katexceptkennzfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatExceptKennzRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkategorienfilter_is_level1':
          $level = 1;
          
        case 'katkategorienfilter_is_level2':
          if (!isset($level)) {
            $level = 2;
          }
          
        case 'katkategorienfilter_is_level3':
          if (!isset($level)) {
            $level = 3;
          }
          $gefilterteKatid = \SessionOperations::getKatKategorienFilter();
          if ($gefilterteKatid === '') {
            return '0';
          }
          $id = \KategorienAPI::getParentXLevelsUp($gefilterteKatid, $level);

          return $id == $varparam ? '1' : '0'; 
        case 'katkategorienfilter_text_level1':
        case 'katkategorienfilter_text_level2':
        case 'katkategorienfilter_text_level3':
          $level = intval(substr($varname, -1, 1));
          $id = $this->getKatFilterId4Level($level, $varparam);
          if ($id > 0) {
            $cat = \DBWorkCategories::getDefaultInstance()->getCategory($id);

            return $cat->text;
          }

          return '';
        case 'katkategorienfilter_id_level1':
        case 'katkategorienfilter_id_level2':
        case 'katkategorienfilter_id_level3':
          $level = intval(substr($varname, -1, 1));

          return $this->getKatFilterId4Level($level, $varparam);
        case 'katkategorienfilter_select_level2':
        case 'katkategorienfilter_select_level2_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienLevel2RendererSelect();
          $aktfilter = \SessionOperations::getKatKategorienFilter();
          if ($this->resolveVar('katkategorienfilter_is_level1:' . $varparam) == '1') {
            return $renderer->render($varname, $aktfilter, $zweiterParam);
          }
          if ($this->resolveVar('katkategorienfilter_is_level2:' . $varparam) == '1') {
            return $renderer->render($varname, \KategorienAPI::getParentXLevelsUp($aktfilter, 1), $zweiterParam);
          }
          if ($this->resolveVar('katkategorienfilter_is_level3:' . $varparam) == '1') {
            return $renderer->render($varname, \KategorienAPI::getParentXLevelsUp($aktfilter, 2), $zweiterParam);
          }

          return '';
        case 'katkategorienfilter_select_level3':
        case 'katkategorienfilter_select_level3_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienLevel3RendererSelect();
          $aktfilter = \SessionOperations::getKatKategorienFilter();
          if ($this->resolveVar('katkategorienfilter_is_level2:' . $varparam) == '1') {
            return $renderer->render($varname, $aktfilter, $zweiterParam);
          }
          if ($this->resolveVar('katkategorienfilter_is_level3:' . $varparam) == '1') {
            return $renderer->render($varname, \KategorienAPI::getParentXLevelsUp($aktfilter, 1), $zweiterParam);
          }

          return '';
        case 'katkategorienfilter_select':
        case 'katkategorienfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katsonderkategorienfilter_select':
        case 'katsonderkategorienfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatSonderKategorienRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katsonderkategorienallfilter_select':
        case 'katsonderkategorienallfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatSonderKategorienAllRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkategorienfilter_cb':
        case 'katkategorienfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkategorienfilter_cb_list':
        case 'katkategorienfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katkategorienfilter_cb_level2':
        case 'katkategorienfilter_cb_level2_nojs':
          $katid = $this->determineKatIdForCbLevel2();
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienRendererCheckbox();

          return $renderer->render($varname, $katid, $zweiterParam);
        case 'katkategorienfilter_cb_list_level2':
        case 'katkategorienfilter_cb_list_level2_nojs':
          $katid = $this->determineKatIdForCbLevel2();
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKategorienRendererCheckboxAsList();

          return $renderer->render($varname, $katid, $zweiterParam);
        case 'katveranartfilter_select':
        case 'katveranartfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatVeranartRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katveranartfilter_cb':
        case 'katveranartfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatVeranartRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'katveranartfilter_cb_list':
        case 'katveranartfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatVeranartRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case (preg_match('/^katkursauswahl([1-9]|1[0-6])filter_select(_nojs)?$/', \StringOperations::strtolower($varname), $matches) ? true : false):
          $lfdnr = $matches[1];
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKursauswahlRendererSelect($lfdnr);

          return $renderer->render($varname, $varparam, $zweiterParam);
        case (preg_match('/^katkursauswahl([1-9]|1[0-6])filter_cb(_nojs)?$/', \StringOperations::strtolower($varname), $matches) ? true : false):
          $lfdnr = $matches[1];
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKursauswahlRendererCheckbox($lfdnr);

          return $renderer->render($varname, $varparam, $zweiterParam);
        case (preg_match('/^katkursauswahl([1-9]|1[0-6])filter_cb_list(_nojs)?$/', \StringOperations::strtolower($varname), $matches) ? true : false):
          $lfdnr = $matches[1];
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKatKursauswahlRendererCheckboxAsList($lfdnr);

          return $renderer->render($varname, $varparam, $zweiterParam);

        case 'zielgruppefilter_select':
        case 'zielgruppefilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionZielgruppeRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'zielgruppefilter_cb':
        case 'zielgruppefilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionZielgruppeRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'zielgruppefilter_cb_list':
        case 'zielgruppefilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionZielgruppeRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
          
        case 'webinarfilter_select':
        case 'webinarfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionWebinarRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'webinarfilter_cb':
        case 'webinarfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionWebinarRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'webinarfilter_cb_list':
        case 'webinarfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionWebinarRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);

          
        case 'kurstypfilter_select':
        case 'kurstypfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKurstypRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'kurstypfilter_cb':
        case 'kurstypfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKurstypRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'kurstypfilter_cb_list':
        case 'kurstypfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionKurstypRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);
          
        case 'mandantfilter_select':
        case 'mandantfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionMandantRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'mandantfilter_cb':
        case 'mandantfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionMandantRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'mandantfilter_cb_list':
        case 'mandantfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionMandantRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);

          
        case 'fachbereichfilter_select':
        case 'fachbereichfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionFachbereichRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'fachbereichfilter_cb':
        case 'fachbereichfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionFachbereichRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'fachbereichfilter_cb_list':
        case 'fachbereichfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionFachbereichRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);

          
        case 'gebietfilter_select':
        case 'gebietfilter_select_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionGebietRendererSelect();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'gebietfilter_cb':
        case 'gebietfilter_cb_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionGebietRendererCheckbox();

          return $renderer->render($varname, $varparam, $zweiterParam);
        case 'gebietfilter_cb_list':
        case 'gebietfilter_cb_list_nojs':
          $renderer = new \Kufer\Web\Classes\Api\SearchRestriction\SearchRestrictionGebietRendererCheckboxAsList();

          return $renderer->render($varname, $varparam, $zweiterParam);

        case 'kal_jahr':
          $year = \SessionOperations::getVarValueEinst('year', date('Y'));

          return \CleanOperations::cleanStringForHtml($year);
        case 'kal_monat':
        case 'kal_monat_lang':
          $month = \SessionOperations::getVarValueEinst('month', date('n'));

          return \CleanOperations::cleanStringForHtml((\StringOperations::strpos($varname, 'lang') !== false) ? \DateTimeOperations::getNameofMonth($month) : $month);
        case 'tagcloud_stichwort':
          $tc_type = 1;
          
        case 'tagcloud_kategorie':
          if (!isset($tc_type)) {
            $tc_type = 2;
          }
          
        case 'tagcloud_statistik':
          if (!isset($tc_type)) {
            $tc_type = 3;
          }
          $urlparam = new \URLParameterTagcloud(false);
          $urlparam->tc_type = $tc_type;
          if ($varparam != '') {
            $urlparam->tc_id = (int)$varparam;
          }
          $dmtc = \DataMenuTagcloud::getDataMenu($urlparam);

          return $dmtc->getContent();
        
        case 'anm_anzahl_personen':
          return \CleanOperations::cleanInt(\SessionOperations::getAnzahlPersonen());

        
        case 'anm_weitere_personen':
          return \CleanOperations::cleanInt(\SessionOperations::getAnzahlPersonen() - 1);
        case 'anm_dublette_sperrvermerk':
          $tn = \SessionOperations::getHauptTeilnehmerFromSession();
          if (!is_null($tn)) {
            $tnIdAry = \TeilnehmerAPI::isDublette($tn);
            if ($tnIdAry !== 'nichtAktiviert' && $tnIdAry['sqlid'] !== false && $tnIdAry['sqlid'] > 0) {
              $tnInfos = \TeilnehmerAPI::getTeilnehmerInfosPerDMZ($tnIdAry['sqlid'], true);

              return $tnInfos->kz_text;
            }
          }

          return '';

        case 'is_wt_user_logged_in':
          return (\SessionOperations::isWtUserLoggedIn() ? '1' : '0');
        case 'fdsicht':
          if (!is_numeric($varparam) || $varparam < 1) {
            return 'Falscher Aufruf - hier muss die Sichtenid oder die laufende Nummer mit angegeben werden, z.B. {%sys_fdsicht:108%} entspricht {%sys_fdsicht:1%}';
          }
          $sightId = $varparam;
          
          if ($sightId <= 20) {
            $sightId = 107 + $varparam;
          } elseif ($sightId <= 40) {
            $sightId = 128 + $varparam;
          } elseif ($sightId <= 50) {
            $sightId = 166 + $varparam;
          }
          $cs = new \CreateSight();

          return $cs->createEmptyHBF($sightId, $this->exportCalculation->sightInfo);
        case 'katfilter':
          $cs = new \CreateSight();

          return $cs->createEmptyHBF(562, $this->exportCalculation->sightInfo);
        case 'katfilter_separat':
          $cs = new \CreateSight();

          return $cs->createEmptyHBF(614, $this->exportCalculation->sightInfo);
        case 'katfilter_isset':
          $emptyKurs = new \Kurs();
          $kursFromNachher = clone $emptyKurs;
          $kursToNachher = clone $emptyKurs;
          \SessionOperations::applyKursKategorieRestrictions($kursFromNachher, $kursToNachher);
          $diffFrom = $emptyKurs->getDiffFields($kursFromNachher);
          if (count($diffFrom) > 0) {
            return '1';
          }
          $diffTo = $emptyKurs->getDiffFields($kursToNachher);
          if (count($diffTo) > 0) {
            return '1';
          }

          return '0';
        case 'katfilter_clear':
          \SessionOperations::resetKursKategorieRestrictions();

          return '';
        case 'katidfromkursbereichorkatidorsonderrubrik':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getKatIdFromKursbereichOrSonderrubrik());
        case 'katidfromkursbereichorkatid':
          return \CleanOperations::cleanStringForHtml(\SessionOperations::getKatIdFromKursbereichOrSonderrubrik(true));
        case 'iskursavailable':
          $kurs = \WBKursStore::getKurs($varparam);

          return $kurs->isEmpty() ? '0' : '1';
        case 'countmerkliste_nuranzuzeigendekurse':
          $mlapi = new \MerklisteAPI();
          $stammhoererTnr = \SessionOperations::getCurrentStammhoererTnr();
          if ($stammhoererTnr == 0) {
            return '0';
          }

          return (string)$mlapi->countMerklisteNurAnzuzeigendeKurse($stammhoererTnr);

        case 'zsazielbereiche_json':
          $categorieTree = \Kufer\Web\Classes\Api\Helpers\ZsaHelper::getZsaZielbereiche();

          return \JsonOperations::encode($categorieTree);
        case 'zsadienststellen_json':
          $dbwZsaBkBvTn = \DBWorkZsaBkBvTn::getDefaultInstance();
          $mapZbDs = $dbwZsaBkBvTn->getMapZielbereichDienststelle(true);

          $alleDsIds = array();
          foreach ($mapZbDs as $dsAry) {
            $alleDsIds = array_merge($alleDsIds, $dsAry);
          }

          $dbwDs = new \DBWorkZsaDs(1, true);

          $dienststellen = $dbwDs->getSome($alleDsIds);
          $dsById = \ArrayOperations::setAttributAsKey($dienststellen, 'id');


          $result = array();
          foreach ($mapZbDs as $zb => $dsAry) {
            $result[$zb] = array();
            foreach ($dsAry as $ds) {
              if (isset($dsById[$ds])) {
                $result[$zb][] = $dsById[$ds];
              }
            }
          }

          return \JsonOperations::encode($result);
        case 'zielbereich_optionen_ohne_eigene':
          $result = '';

          $categorieTree = \Kufer\Web\Classes\Api\Helpers\ZsaHelper::getZsaZielbereiche();

          $tnr = \SessionOperations::getCurrentStammhoererTnr();
          $dbwZsaBkBvTn = \DBWorkZsaBkBvTn::getDefaultInstance();
          $bkbvtnAry = $dbwZsaBkBvTn->getEintraegeByTnrAndTyp($tnr, array('TN'));
          $eigeneZielbereichAry = \ArrayOperations::mapAttribut($bkbvtnAry, 'zb');

          if ($categorieTree) {
            foreach ($categorieTree->subCategories as $category) {
              if (!in_array($category->id, $eigeneZielbereichAry)) {
                $selected = ''; 
                $result .= '<option value="' . $category->id . '" ' . $selected . '>' . $category->text . '</option>';
              }
            }
          }

          return $result;
        case 'zielbereich_optionen_alle':
          $result = '';

          $categorieTree = \Kufer\Web\Classes\Api\Helpers\ZsaHelper::getZsaZielbereiche();

          if ($categorieTree) {
            foreach ($categorieTree->subCategories as $category) {
              $selected = ''; 
              $result .= '<option value="' . $category->id . '" ' . $selected . '>' . $category->text . '</option>';
            }
          }

          return $result;
        case 'status_zb_aendern':
          return \DataMenuZsaZielbereichAendern::$status;
        case 'dmz_erreichbar':
          static $dmzerreichbar = null;
          if (is_null($dmzerreichbar)) {
            $dmzerreichbar = (\AbgleichAPI::ping()) ? '1' : '0';
          }

          return $dmzerreichbar;
        case 'sembeginn_sprache':
          $dbwHl = \DBWorkHLGrundSys::getDefaultInstance();

          return $dbwHl->getFeldWert('WEB_SEMBEGINN_SPRACHE');
        case 'kulturkarten_knr':
          $dbw = \DBWorkKurseINetAktiv::getDefaultInstance();
          $dbw->newSearch();
          $dbw->fromobject->typ = 'D';
          $kulturkartenKnrs = $dbw->getKursIds();
          if (count($kulturkartenKnrs) === 0) {
            \Logger::logg('Kulturkarten-Kursnummer wurde abgefragt {%sys_kulturkarten_knr%}, aber kein Kurs mit Typ "D" gefunden', 11);

            return '';
          } else {
            return $kulturkartenKnrs[0];
          }
          
        case 'tnkarte_betrag':
          $dbwHl = \DBWorkHLGrundSys::getDefaultInstance();

          return $dbwHl->getFeldWert('PASSZRVAR_ERMBETRAG');
        case 'tnkarte_knr':
          $dbw = \DBWorkKurseINetAktiv::getDefaultInstance();
          $dbw->newSearch();
          $kurs = $dbw->getCurrentTnKartenKurs();

          
          if (is_null($kurs->id)) {
            \Logger::logg('{%sys_tnkarte_knr%}: kein passender Kurs hinterlegt!', 3020);

            return '';
          }

          return $kurs->id;
        case 'is_t3user_loggedin':
          $t3 = new \Typo3_Anb();
          $loggedIn = $t3->isFrontendUserLoggedIn();

          return $loggedIn ? '1' : '0';
        case 'islogin':
          if ($varparam == '') {
            return '0';
          }
          
          
          if (preg_match('/^%(\\w+:?\\w*)%$/', $varparam, $matches)) {
            
            $resolvedVar = \ExportBasis::exportSingleVar($matches[1] . TRENNER_VORBELEGUNG . '@_%+-\\.', new \Datamodul(), new \ExportBasis());
            $zusatzParam = \StringOperations::html_entity_decode($resolvedVar);
            if ($zusatzParam == '') {
              return '0';
            }
            if (!\StammhoererAPI::isLoginUnique($zusatzParam)) {
              return '1';
            }
          }

          return '0';
        case 'uebern_preise_hlzimmertyp':
          $dbwHlZimmertyp = \DBWorkHLZimmertyp::getDefaultInstance();
          $zt = $dbwHlZimmertyp->getPricesValidAtDate(\DateTimeOperations::getDateNow());

          return \JsonOperations::encode($zt);
        case 'kufertools_login_mit_captcha':
          if ($this->tool0settings->captchaLoginFehlerhaft) {
            $dbwLoginVersuch = new \DBWorkToolsLoginError(1, true);

            return (string)$dbwLoginVersuch->useCaptcha4CurrentIp(true);
          }

          return '';
        case 'kufertools_statusmeldungen':
          $messageContainer = \Kufer\Web\KuferTools\Utils\StatusMessages\StatusMessageContainer::getSharedInstance();
          $meldungen = $messageContainer->getStatusMessages4Html();
          $messageContainer->clear();

          return $meldungen;
        case 'blaettern_leiste':
          if (is_null($this->blaetternInfo) || !($this->blaetternInfo instanceof \BlaetternLink)) {
            return '';
          }

          return \Kufer\Web\Classes\Api\BlaetternAPI::getInstance()->getBlaetternLeiste($this->blaetternInfo);
        case 'blaettern_seite':
          if (is_null($this->blaetternInfo) || !($this->blaetternInfo instanceof \BlaetternLink)) {
            return '';
          }

          return $this->blaetternInfo->aktuelleSeite ?? '';
        case 'blaettern_anzahl_seiten':
          if (is_null($this->blaetternInfo) || !($this->blaetternInfo instanceof \BlaetternLink)) {
            return '';
          }

          return $this->blaetternInfo->anzahlSeiten ?? '';
        case 'blaettern_urlparam_vorige_seite':
          if (is_null($this->blaetternInfo) || !($this->blaetternInfo instanceof \BlaetternLink)) {
            return '';
          }
          if ($this->blaetternInfo->aktuelleSeite > 1) {
            return 'urlparameter=' . $this->blaetternInfo->rest . 'seite' . ':' . ($this->blaetternInfo->aktuelleSeite - 1) . ';';
          } else {
            return '';
          }
          
        case 'blaettern_urlparam_naechste_seite':
          if (is_null($this->blaetternInfo) || !($this->blaetternInfo instanceof \BlaetternLink)) {
            return '';
          }
          if ($this->blaetternInfo->aktuelleSeite < $this->blaetternInfo->anzahlSeiten) {
            return 'urlparameter=' . $this->blaetternInfo->rest . 'seite' . ':' . ($this->blaetternInfo->aktuelleSeite + 1) . ';';
          } else {
            return '';
          }
          
        case 'k_kennz':
          if (is_numeric($varparam) && $hatZweitenParam) {
            
            $zweiterParam = \ExportBasis::replaceVarInParam($zweiterParam);
            $kurs = \WBKursStore::getKurs($zweiterParam);

            return $this->exportCalculation->getVarValue4Kurs('kennz:' . $varparam, $kurs);
          }

          return '';

        case 'iskufersql5':
          return \System::isKuferSql5() ? '1' : '0';

        case 'kwlayoutpath':
          return \Kufer\Web\Classes\KwResourceLocator::getInstance()->locateLayoutDirRelative();
        case 'captcha_kufertools':
          $capi = \Kufer\Web\Classes\Captchas\CaptchaFactory::getCaptcha4KuferTools();

          return $capi->getCaptcha(false, 'Zeichenfolge');
        case 'isweitermeldung':
          return \SessionOperations::getVarValueWeitermelden('active', '0');
      }

      if (\StringOperations::startsWith($varname, 'wk_')) {
        $varname = \StringOperations::substr($varname, 3);
        $varname .= \StringOperations::strlen($varparam) > 0 ? ':' . $varparam : '';
        $exportCalcWk = new ExportCalcWarenkorb();

        return $exportCalcWk->resolveVar($varname, new \Datamodul());
      }

      if (\StringOperations::startsWith($varname, 'login_')) {
        $exportCalcLogin = new ExportCalcLogin();

        return $exportCalcLogin->resolveVar(\StringOperations::substr($varname . (($varparam != '') ? ':' . $varparam : ''), 6));
      }

      return '';
    }
  }

  private function getArtikelPortoListe(string $pRegion): string
  {
    $dbw = \DBWorkArtikelPorto::getDefaultInstance();
    $dbw->newSearch();
    $dbw->fromobject->region = $pRegion;
    $portos = $dbw->getSomeBySearch();

    return \CreateSightFassade::createListe(new \Datamodul(), 638, $portos, new \ExpArtikelPorto());
  }

  
  private function extractOrtOrtInfoDmnchst()
  {
    $api = \Kufer\Web\Webbasys\Includee\Api\KalenderAPIFactory::getKalenderAPI();
    $kurse = $api->getKurse4DemnaechstMenue('');
    if (count($kurse) > 0) {
      $dbwko = \DBWorkKursorteWB::getDefaultInstance();
      $mktexte = array();
      foreach ($kurse as $k) {
        $mktexte[] = $k->ort;
      }
      $mktexte = array_filter($mktexte);
      $anzahlen = array_count_values($mktexte);
      $kursorte = $dbwko->getKursorteByMktextary($mktexte);
      $orte = array();
      foreach ($kursorte as $ko) {
        if (!isset($orte[\StringOperations::getOrt($ko->ort)])) {
          $orte[\StringOperations::getOrt($ko->ort)] = $anzahlen[$ko->mktext];
        }
      }

      return '"orte":' . \JsonOperations::encode($orte);
    }

    return '';
  }

  
  private function getBuchstabenleiste($pSichtId, $pDbWork, $pNurS = false, $pSemlist = '')
  {
    $exp = new \ExpGruppiert();
    $initialLetter = $this->getDefaultLetterArray();
    if ($pNurS) {
      $initialLetter['Sch'] = 0;
      $initialLetter['St'] = 0;
    }
    if ($pSemlist != '') {
      $body = $pDbWork->getGetLetterList($initialLetter, $pSemlist);
    } else {
      $body = $pDbWork->getGetLetterList($initialLetter);
    }

    return \CreateSightFassade::createListe(new \Datamodul(), $pSichtId, $body, $exp);
  }

  
  private function getDefaultLetterArray(): array
  {
    return array(
      'A' => 0,
      'B' => 0,
      'C' => 0,
      'D' => 0,
      'E' => 0,
      'F' => 0,
      'G' => 0,
      'H' => 0,
      'I' => 0,
      'J' => 0,
      'K' => 0,
      'L' => 0,
      'M' => 0,
      'N' => 0,
      'O' => 0,
      'P' => 0,
      'Q' => 0,
      'R' => 0,
      'S' => 0,
      'T' => 0,
      'U' => 0,
      'V' => 0,
      'W' => 0,
      'X' => 0,
      'Y' => 0,
      'Z' => 0
    );
  }

  private function dateHelperForGet(string $varname, string $varparam): string
  {
    if (!\GetOperations::isDefined($varparam)) {
      return '';
    }
    $date = \GetOperations::getVarValue($varparam);
    if (!\DateTimeOperations::isValidDate($date)) {
      return '';
    }
    switch ($varname) {
      case 'get_wochentag':
        return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getWeekDay($date));
      case 'get_wochentag_kurz':
        return \CleanOperations::cleanStringForHtml(\DateTimeOperations::getWeekDayShort($date));
      default:
        $format = \StringOperations::substr($varname, 4);

        return \CleanOperations::cleanStringForHtml(\StringOperations::formatDateString($date, $format));
    }
  }

  
  private function getKatFilterIdXLevelsUp(int $level)
  {
    $gefilterteKatid = \SessionOperations::getKatKategorienFilter();
    if ($gefilterteKatid === '') {
      return '0';
    }

    return \KategorienAPI::getParentXLevelsUp($gefilterteKatid, $level);
  }

  
  public function determineKatIdForCbLevel2(): int
  {
    $katid = (new \URLParameterNavigation())->katid;
    $aktfilter = \SessionOperations::getKatKategorienFilter();
    if (is_array($aktfilter) && is_numeric($aktfilter[0])) {
      $catapi = new \CategoryAPI();
      $katid = $catapi->getParentDepth1ID($aktfilter[0]);
    } elseif (is_numeric($aktfilter)) {
      $catapi = new \CategoryAPI();
      $katid = $catapi->getParentDepth1ID($aktfilter);
    }

    return $katid;
  }

  
  private function getKatFilterId4Level(int $level, string $varparam)
  {
    if ($level == 1) {
      if ($this->resolveVar('katkategorienfilter_is_level1:' . $varparam) == '1') {
        return $this->getKatFilterIdXLevelsUp(0);
      } elseif ($this->resolveVar('katkategorienfilter_is_level2:' . $varparam) == '1') {
        return $this->getKatFilterIdXLevelsUp(1);
      } elseif ($this->resolveVar('katkategorienfilter_is_level3:' . $varparam) == '1') {
        return $this->getKatFilterIdXLevelsUp(2);
      }
    } elseif ($level == 2) {
      if ($this->resolveVar('katkategorienfilter_is_level2:' . $varparam) == '1') {
        return $this->getKatFilterIdXLevelsUp(0);
      } elseif ($this->resolveVar('katkategorienfilter_is_level3:' . $varparam) == '1') {
        return $this->getKatFilterIdXLevelsUp(1);
      }
    } elseif ($level == 3) {
      if ($this->resolveVar('katkategorienfilter_is_level3:' . $varparam) == '1') {
        return $this->getKatFilterIdXLevelsUp(0);
      }
    }

    return 0;
  }

  
  private function getAmpel7Legende()
  {
    $return = '';
    $settings = $this->tool4settings;

    switch ($settings->legendeContainer) {
      case 'div':
        if (KW_BOOTSTRAP) {
          $layoutElements = array(
            'wrapperAll' => '<div class="legend list-group">:content</div>',
            'wrapperElement' => '<div class="legend row list-group-item"><div class="col-xs-2">:image</div><div class="col-xs-10">:text</div><div class="clear_div"></div></div>'
          );
        } else {
          $layoutElements = array(
            'wrapperAll' => '<div class="legend">:content</div>',
            'wrapperElement' => '<div class="legend_row"><div class="image">:image</div><div class="text">:text</div><div class="clear_div"></div></div>'
          );
        }
        break;
      case 'ul':
        if (KW_BOOTSTRAP) {
          $layoutElements = array(
            'wrapperAll' => '<ul class="legend list-group">:content</ul>',
            'wrapperElement' => '<li class="list-group-item">:image<span class="text">:text</span></li>'
          );
        } else {
          $layoutElements = array(
            'wrapperAll' => '<ul class="legend">:content</ul>',
            'wrapperElement' => '<li>:image<span class="text">:text</span></li>'
          );
        }
        break;
      case 'dl':
        if (KW_BOOTSTRAP) {
          $layoutElements = array(
            'wrapperAll' => '<dl class="legend list-group">:content</dl>',
            'wrapperElement' => '<dt class="list-group-item">:image</dt><dd>:text</dd>'
          );
        } else {
          $layoutElements = array(
            'wrapperAll' => '<dl class="legend">:content</dl>',
            'wrapperElement' => '<dt>:image</dt><dd>:text</dd>'
          );
        }
        break;
      case 'table':
      default:
        $layoutElements = array(
          'wrapperAll' => '<table class="legend">:content</table>',
          'wrapperElement' => '<tr class="legend_row"><td class="legend_image">:image</td><td class="legend_label">:text</td></tr>'
        );
        break;
    }

    if ($settings->optionstatuslegend1 || $settings->optionstatuslegend2 || $settings->optionstatuslegend3 || $settings->optionstatuslegend4
       or $settings->optionstatuslegend5 || $settings->optionstatuslegend6 || $settings->optionstatuslegend7) {
      $innerContent = '';

      $renderer = new \Kufer\Web\Classes\Ampel\Renderer\Ampel7Renderer(false);
      for ($i = 1; $i < 8; $i++) {
        if ($settings->{'optionstatuslegend' . $i}) {
          $title = $settings->{'optionstatustext' . $i};
          $status_pic = ($settings->{'optionstatus' . ($i)} != 'text') ? $renderer->create($i - 1) : '';

          if ($status_pic !== false) {
            $innerContent .= str_replace(array(':image', ':text'), array(\CleanOperations::cleanStringContainingHtml($status_pic), \CleanOperations::cleanStringContainingHtml($title)), $layoutElements['wrapperElement']);
          }
        }
      }

      $return .= str_replace(':content', $innerContent, $layoutElements['wrapperAll']);
    }

    return $return;
  }
}