Phalcon Framework 5.5.0

Error: Call to a member function children() on null

/var/www/vhosts/bundderversicherten.de/app/Models/Tree.php (130)
#0App\Models\Tree->getChildren
/var/www/vhosts/bundderversicherten.de/app/Helper/SitemapGenerator.php (86)
<?php
 
namespace App\Helper;
 
use App\Models\Tree;
use App\Models\Content;
use App\Models\Pressemitteilung;
use App\Models\Newsletter\Mail;
use App\Helper\Mailer;
use App\Helper\FilterSegment;
 
/**
 * Description of SitemapGenerator
 *
 * @author callya
 */
class SitemapGenerator {
    
    private $xml_document;
    private $config;
    private $kat_send;
    
    public function setConfig($Config){
        $this->config = $Config;
    }
    public function setTree($Tree){
        $this->Tree = $Tree;
    }
    
    public function generate(){
                    $priority = [];
                    $priority['Startseite'] = '1.0';
                    
                    $ausnahmen = [];
                    $ausnahmen[] = "/offsite/optin";
                    $ausnahmen[] = "/offsite/optin-fehler";
                    $ausnahmen[] = "/offsite/optin-erfolgreich";
                    $ausnahmen[] = "/offsite/suche";
                    $ausnahmen[] = "/offsite/mein-passwort";
                    $ausnahmen[] = "/offsite/optin-erfolgreich";
                    $ausnahmen[] = "/offsite/cookie-einstellungen";
                    $ausnahmen[] = "/offsite/sitemap";
                    $ausnahmen[] = "/sitemap";
                    $ausnahmen[] = "/cookie-einstellungen";
                    $ausnahmen[] = "/optin-erfolgreich";
                    $ausnahmen[] = "/mein-passwort";
                    $ausnahmen[] = "/optin-erfolgreich";
                    $ausnahmen[] = "/suche";
                    $ausnahmen[] = "/optin-fehler";
                    $ausnahmen[] = "/optin";
                    
                    
                    $ausnahmen[] = "/main-navi/bdv-mitgliederportal";
                    
        $ausnahmen[] = "/main-navi/musterbriefe";
        $ausnahmen[] = "/werden-sie-mitglied/warum-mitglied-werden";
        $ausnahmen[] = "/werden-sie-mitglied/infos-zur-mitgliedschaft";
        $ausnahmen[] = "/werden-sie-mitglied/haeufige-fragen";
        $ausnahmen[] = "/werden-sie-mitglied/beitrittserklaerung";
        
        $ausnahmen[] = "/top-navi/haeufige-fragen";
                    $ausnahmen[] = "/top-navi/english";
                    $ausnahmen[] = "/footer-navi/impressum";
                    $ausnahmen[] = "/footer-navi/datenschutz";
                    $ausnahmen[] = "/footer-navi/rechtliche-hinweise";
                    $ausnahmen[] = "/footer-navi/cookie-einstellungen-1";
        
                    $kat_send = [];
                    
                    #$this->Tree = new Tree();
                    #$this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
                    $offsite_nodes = $this->Tree->getOffsiteNodes($this->session);
                    $main_nodes = $this->Tree->getMainNaviNodes($this->session);
                    $top_navi_nodes = $this->Tree->getTopNaviNodes($this->session);
                    $footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session);
                    
                    $result = [];
                    $result = array_merge ($result,$offsite_nodes);
                    $result = array_merge ($result,$main_nodes);
                    $result = array_merge ($result,$top_navi_nodes);
                    $result = array_merge ($result,$footer_navi_nodes);
                    
                    $children = [];
                    $res = [];
                    foreach( $result as $Node){
                        $children = $Node->getChildren();
                        #echo "<strong>".$Node->node_name."  -> ".count($children)."</strong><br>";
                        $is_online = $Node->is_online;
                        
                        if($is_online == 'ja'){
                        
                            if(count($children)> 0){
                                foreach($children as $ChildNode){
                                    $res[] = $ChildNode;
                                    #echo $ChildNode->node_perma."<br>";
                                }
                            }else{
                                $res[] = $Node;
                            }
                        }
                    }
                    // Pressemitteilungen sollen mit reingeneriert werden
                    
                    $pressemitteilungen = Mail::find(["mail_typ = 'Pressemitteilung' AND is_online='ja'"]);
                    // https://weblab.bundderversicherten.de/presse-und-oeffentlichkeitsarbeit/pressemitteilungen/bund-der-versicherten-sieht-chancen-bei-europa-rente
                    $page_link = 'pressemitteilungen/';
                    foreach($pressemitteilungen as $Mail){
                        $perma = $Mail->mail_perma;
                        $PresseNode = new Tree();
                        $PresseNode->node_perma = $page_link.$perma;
                        $PresseNode->node_name = 'Presse- und Öffentlichkeitsarbeit';
                        $PresseNode->parent_id = -1;
                        $PresseNode->updated_at = date('Y-m-d', strtotime($Mail->updated_at));
                        $res[] = $PresseNode;
                    }
                    
                    $page_url = $this->config->url->httpScheme.$this->config->url->hostName;
                    $lastmod = date("Y-m-d");
                    $changefreq = 'daily';
                    $prio = $priority['Startseite'];
                    $xw = xmlwriter_open_memory();
                    xmlwriter_set_indent($xw, 1);
                    xmlwriter_start_document($xw, '1.0', 'UTF-8');
                    xmlwriter_start_element($xw, 'urlset');
                        xmlwriter_start_attribute($xw, 'xmlns');
                        xmlwriter_text($xw, 'http://www.sitemaps.org/schemas/sitemap/0.9');
                        xmlwriter_end_attribute($xw);
                        
                        //Startseite nicht vergessen !!
                        xmlwriter_start_element($xw, 'url');
                        
                            xmlwriter_start_element($xw, 'loc');
                                xmlwriter_text($xw, $page_url);
                            xmlwriter_end_element($xw);
                            
                            xmlwriter_start_element($xw, 'lastmod');
                                xmlwriter_text($xw, $lastmod);
                            xmlwriter_end_element($xw);
                            
                            xmlwriter_start_element($xw, 'changefreq');
                                xmlwriter_text($xw, $changefreq);
                            xmlwriter_end_element($xw);
                            
                            xmlwriter_start_element($xw, 'priority');
                                xmlwriter_text($xw, $prio);
                            xmlwriter_end_element($xw);
                            
                        xmlwriter_end_element($xw);
                        
                        
                        
                    foreach($res as $Node){
                        
                        if($Node->parent_id == -1){
                            $Parent = Tree::findFirst(['node_name="Presse- und Öffentlichkeitsarbeit"']);
                            $Node->change_freq = $Parent->change_freq;
                            $Node->priority = $Parent->priority;
                        } else {
                            $Parent = Tree::findFirst(["id = '".$Node->parent_id."'"]);                            
                        }
                        
                        $Content = Content::findFirst(["id = '".$Node->content_id."'"]);
                        
                        
                        $parent_perma = $Parent->node_perma;
                        if(empty($parent_perma)){
                            $link = "/".$Node->node_perma;
                            $lastmod = $Node->updated_at;
                        }else{
                            if($Parent->node_perma == 'offsite'){
                                $link = "/".$Node->node_perma;
                                $lastmod = date('Y-m-d', strtotime($Content->updated_at));; // Soll aktueller Tag sein
                            }else{
                                $link = "/".$Parent->node_perma."/".$Node->node_perma;
                                $lastmod = date('Y-m-d', strtotime($Content->updated_at));; // Soll aktueller Tag sein
                            }
                        }
                        
                      
                        // $lastmod = date('Y-m-d');
                                if (!in_array($link, $ausnahmen)) {
                                    $url = $page_url . $link;
                                    $changefreq = $Node->change_freq;
                                    $prio = $Node->priority;
                                    if ($changefreq == 'vererbt') {
                                        $changefreq = $Parent->change_freq;
                                    }
 
                                    if ($prio == 'vererbt') {
                                        $prio = $Parent->priority;
                                    }
 
 
                                    xmlwriter_start_element($xw, 'url');
 
                                    xmlwriter_start_element($xw, 'loc');
                                    xmlwriter_text($xw, $url);
                                    xmlwriter_end_element($xw);
 
                                    xmlwriter_start_element($xw, 'lastmod');
                                    xmlwriter_text($xw, $lastmod);
                                    xmlwriter_end_element($xw);
 
                                    xmlwriter_start_element($xw, 'changefreq');
                                    xmlwriter_text($xw, $changefreq);
                                    xmlwriter_end_element($xw);
 
                                    xmlwriter_start_element($xw, 'priority');
                                    xmlwriter_text($xw, $prio);
                                    xmlwriter_end_element($xw);
 
                                    xmlwriter_end_element($xw);
                                }
                            }
                    xmlwriter_end_element($xw);
                    xmlwriter_end_document($xw);
                    
                    $this->xml_document = $xw;
                    
    }
    
    public function print(){
        header ("Content-Type:text/xml");   
        echo xmlwriter_output_memory($this->xml_document);
    }
}
#1App\Helper\SitemapGenerator->generate
/var/www/vhosts/bundderversicherten.de/app/Controllers/Web/ContentController.php (827)
<?php
 
namespace App\Controllers\Web;
 
use Phery\Phery;
use Phery\PheryResponse;
use Phalcon\Http\Request;
use App\Models\UrlVerkuerzer;
use App\Models\Tree;
use App\Models\Content;
// index
use App\Models\Tipp;
use App\Models\Medium;
use App\Models\Snippet;
// modul
use App\Models\News;
use App\Models\Wita;
use App\Models\Modul;
use App\Models\Content as StaticContent;
use App\Models\Termin;
use App\Models\Kontakt;
use App\Models\Beitrag;
use App\Models\WitaVortrag;
use App\Models\WitaReferent;
use App\Models\Stellungnahme;
use App\Models\MusterbriefListe;
use App\Models\Newsletter;
use App\Models\TerminKategorie;
use App\Models\BeitragKategorie;
use App\Models\StellungnahmeKategorie;
// beitrittserklaerung
use App\Models\Land;
use App\Models\Bundesland;
use App\Models\Kampagne;
// meine anschrift
use App\Models\LandAlle;
// liste
use App\Models\Faq;
use App\Models\FaqKfz;
use App\Models\Flyer;
use App\Models\Thema;
use App\Models\Teaser;
use App\Models\Agenda;
use App\Models\Mythen;
use App\Models\CoronaMythen;
use App\Models\Beirat;
use App\Models\Bdvinfo;
use App\Models\Vorstand;
use App\Models\Leitfaden;
use App\Models\Broschuere;
use App\Models\Mitarbeiter;
use App\Models\Aufsichtsrat;
use App\Models\FacebookPost;
use App\Models\TwitterTweet;
use App\Models\DownloadListe;
use App\Models\Stellenangebot;
use App\Models\PressefotoListe;
use App\Models\Pressemitteilung;
use App\Models\Kooperationspartner;
use App\Models\LinkTracking;
use App\Models\Newsletter\Mail;
use App\Models\Youtubevideo;
// system and helper
use App\Helper\Pagination;
use App\Helper\FilterSegment;
use App\Helper\PressemitteilungPdf;
use App\Helper\SitemapGenerator;
use App\Controllers\Web\BaseController;
// widgets
use App\Widgets\Web\MitgliedLoginWidget;
// plugins
use App\Plugins\Web\News as NewsPlugin;
use App\Plugins\Web\Optin as OptinPlugin;
use App\Plugins\Web\Suche as SuchePlugin;
use App\Plugins\Web\Logout as LogoutPlugin;
use App\Plugins\Web\Termin as TerminPlugin;
use App\Plugins\Web\Beitrag as BeitragPlugin;
use App\Plugins\Web\Kontakt as KontaktPlugin;
use App\Plugins\Web\InfoEvent as InfoEventPlugin;
use App\Plugins\Web\Bewerbung as BewerbungPlugin;
use App\Plugins\Web\Password as PasswordPlugin;
use App\Plugins\Web\WitaLogin as WitaLoginPlugin;
use App\Plugins\Web\UserLogin as UserLoginPlugin;
use App\Plugins\Web\Broschuere as BroschuerePlugin;
use App\Plugins\Web\QuickConnect as QuickConnectPlugin;
use App\Plugins\Web\MeinPasswort as MeinPasswortPlugin;
use App\Plugins\Web\UserRegister as UserRegisterPlugin;
use App\Plugins\Web\MeineBdvinfo as MeineBdvinfoPlugin;
use App\Plugins\Web\BdvNewsletter as BdvNewsletterPlugin;
use App\Plugins\Web\ContentPopup as ContentPopupPlugin;
use App\Plugins\Web\Stellungnahme as StellungnahmePlugin;
use App\Plugins\Web\MitgliedLogin as MitgliedLoginPlugin;
use App\Plugins\Web\WitaNachricht as WitaNachrichtPlugin;
use App\Plugins\Web\WitaAnmeldung as WitaAnmeldungPlugin;
use App\Plugins\Web\MeineAnschrift as MeineAnschriftPlugin;
use App\Plugins\Web\Pressemitteilung as PressemitteilungPlugin;
use App\Plugins\Web\MeineZugangsdaten as MeineZugangsdatenPlugin;
use App\Plugins\Web\MeineBankverbindung as MeineBankverbindungPlugin;
use App\Plugins\Web\Beitrittserklaerung as BeitrittserklaerungPlugin;
use App\Plugins\Web\ContentPopup as ContentPopup;
// bedarfscheck
use App\Models\CalcBeruf;
use App\Models\CalcZusatz;
use App\Models\CalcFamilie;
use App\Plugins\Web\BedarfsCheck as BedarfsCheckPlugin;
 
class ContentController extends BaseController
{
 
  private static $news_limit = 3;
  private static $termin_limit = 3;
  private static $beitrag_limit = 3;
  private static $stellungnahme_limit = 3;
 
  public function linkTrackerAction()
  {
 
    $unique_id = htmlentities($this->request->get('u'), ENT_QUOTES);
    $TrackingLink = LinkTracking::findFirst(["link_id = '" . $unique_id . "'"]);
    $TrackingLink->hits = $TrackingLink->hits + 1;
    $TrackingLink->save();
 
    header('Location: ' . $TrackingLink->target);
    exit;
  }
 
  public function countImageAction($args)
  {
    $unique_id = htmlentities($this->request->get('u'), ENT_QUOTES);
    if (!empty($unique_id)) {
      if ($Mail = Mail::findFirst(["count_id = '$unique_id'"])) {
        $Mail->opened = $Mail->opened + 1;
        $Mail->save();
      }
    }
    header("Content-type: image/png");
    $im = imagecreate(1, 1);
    imagecolorallocate($im, 255, 255, 255);
    imagepng($im);
    imagedestroy($im);
    exit;
  }
 
  public function shortURLRedirect()
  {
    $short_url = $_SERVER['REQUEST_URI'];
    $short_url = substr($short_url, 1);
    if (!empty($short_url)) {
      if (($UrlVerkuerzer = UrlVerkuerzer::findFirst("url_kurz='" . $short_url . "'"))) {
        $httpScheme = $this->config->url->httpScheme;
        $hostName = $this->config->url->hostName;
        header("Location:" . $httpScheme . $hostName . "/" . $UrlVerkuerzer->url_ziel);
        exit();
      }
    }
  }
 
  public function indexAction()
  {
 
    if (Phery::is_ajax()) {
 
      $args = $_REQUEST['args'] ?? [];
      if (isset($args['content']) && $args['content'] == 'cookie-check') {
        $PheryResonse = (new ContentPopup())->procAction($args);
        echo $PheryResonse;
        exit;
      }
    }
 
    parent::setBaseValues();
 
    $this->shortURLRedirect();
    
    if (!Phery::is_ajax()) {
      $this->setView();
    } elseif (!$this->isIndex() and (!$this->setContent() or !$this->isValidNavi())) {
      // ToDo: phery error
    } else {
      $phery_request = $this->request->getPost('phery');
      $remote = array_get($phery_request, "remote");
 
      $this->setPhery($remote);
    }
  }
 
  private function setCoronaLandingPageVars()
  {
 
    //JSON - Mythos daten
    $mythen_orig = CoronaMythen::find(['order' => 'gruppe ASC']);
    foreach ($mythen_orig as $mythos) {
      $mythos->antwort = strip_tags($mythos->antwort);
      $mythos->mythos = strip_tags($mythos->mythos);
      $mythos->name = strip_tags($mythos->name);
      $mythen[] = $mythos;
    }
    $this->view->setVar('mythenArray', $mythen);
    // Footer Variablen Laden 
    $this->Tree = new Tree();
    $this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
    $this->Tree->getOffsiteNodes($this->session);
 
    if (($footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session))) {
      $this->view->setVar("footer_navi_nodes", $footer_navi_nodes);
      ob_start();
      $this->view->partial('partials/footerMenu', ['footer_navi_nodes' => $footer_navi_nodes]);
      $menu_html = ob_get_clean();
 
      if (($Footer = \App\Models\Footer::findFirst(array('id' => 1)))) {
        $footer_html = $Footer->text;
        $footer_html = str_replace("[# footerSocial #]", '', $footer_html);
 
        if (isset($menu_html)) {
          $footer_html = str_replace("[# footerMenu #]", $menu_html, $footer_html);
        }
        $this->view->setVar("footer_test", $footer_html);
      }
    }
    //Footer ende
 
    $LandingPage = \App\Models\LandingPageCorona::findFirst();
    $this->tag->title()->set($LandingPage->meta_title);
    $this->view->setVar('meta_description', $LandingPage->meta_description);
    $this->view->setVar('meta_keywords', $LandingPage->meta_keywords);
    $this->view->setVar('global_headline', $LandingPage->global_headline);
 
    $this->view->setVar('global_headline_second', $LandingPage->global_headline_second);
    $headline = str_replace('–', "–<br class='smartBr'>", $LandingPage->text1_headline);
    $this->view->setVar('text1_headline', $headline);
    $this->view->setVar('text1_text', $LandingPage->text1_text);
    $this->view->setVar('text1_subline', $LandingPage->text1_subline);
 
    $this->view->setVar('text2_headline', $LandingPage->text2_headline);
    $this->view->setVar('text2_text', $LandingPage->text2_text);
    $this->view->setVar('text2_subline', $LandingPage->text2_subline);
    $this->view->setVar('fotocase', $LandingPage->getLink2Image());
 
    $models = (new \Phalcon\Mvc\Model\Query\Builder())
      ->addFrom('App\Models\LandingPageCoronaModules', 'LandingPageCoronaModules')
      ->columns([
        'id' => 'LandingPageCoronaModules.id',
        'modultemplate' => 'Modul.modul_template',
        'class' => 'Modul.modul_class',
        'headline' => 'Content.content_headline',
        'text' => 'Content.content_text',
        'image_name' => 'Content.image_name',
        'image_ext' => 'Content.image_ext',
        'content_image_name' => 'ContentImage.image_name',
        'content_image_ext' => 'ContentImage.image_ext'
      ])
      ->join('\App\Models\Modul', 'LandingPageCoronaModules.modul_id = Modul.id', 'Modul')
      ->join('\App\Models\Content', 'LandingPageCoronaModules.modul_id = Content.modul_id', 'Content')
      ->join('\App\Models\ContentImage', 'Content.id = ContentImage.content_id', 'ContentImage')
      ->orderBy('pos ASC')
      ->getQuery()->execute();
 
 
    $moduleTemplates = [];
 
    foreach ($models as $modulEntry) {
      $headline = $modulEntry->headline;
      $text = $modulEntry->text;
      $image = $modulEntry->image_name . $modulEntry->image_ext;
      $image2 = $modulEntry->content_image_name . $modulEntry->content_image_ext;
      $classname = '\\App\\Models\\' . $modulEntry->class;
      $classnameAdditional = '\\App\\Models\\' . $modulEntry->class . 'Text';
 
 
      // Snippet Texte
      $snippet_text = Snippet::getSnippetTextByPerma('lp_leitfaden_txt1');
 
      $snipets['lp_leitfaden_txt1'] = strip_tags($snippet_text);
 
      $variables = ['headline' => $headline, 'text' => $text, 'image' => $image, 'image2' => $image2, 'snippets' => $snipets];
 
      $model = new $classname();
      $variables = $model->bindVariables($variables);
 
      if (class_exists($classnameAdditional)) {
 
        $modelAdditional = new $classnameAdditional();
        $variables = $modelAdditional->bindVariables($variables);
      }
 
 
      $html_template = $this->view->getPartial('modul/' . $modulEntry->modultemplate, $variables);
      $moduleTemplates[] = $html_template;
    }
    $this->view->setVar('moduleTemplates', $moduleTemplates);
 
    $gruppe = html_entity_decode($_GET['gruppe'], ENT_QUOTES);
    if (empty($gruppe)) {
      $this->view->setVar('groupSet', false);
    } else {
      $this->view->setVar('groupSet', true);
    }
 
 
 
    //$args['content'] = 'cookie-check';
    //$Phery = (new ContentPopupPlugin())->procAction($args);
 
    $x = ($this->cookies->has("ga-disable-UA-113554189-1") ? true : false);
 
    $this->view->setVar("cookie", $x);
  }
 
  private function setLandingPageVars()
  {
    // Footer Variablen Laden 
    $this->Tree = new Tree();
    $this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
    $this->Tree->getOffsiteNodes($this->session);
    if (($footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session))) {
      $this->view->setVar("footer_navi_nodes", $footer_navi_nodes);
      ob_start();
      $this->view->partial('partials/footerMenu', ['footer_navi_nodes' => $footer_navi_nodes]);
      $menu_html = ob_get_clean();
 
      if (($Footer = \App\Models\Footer::findFirst(array('id' => 1)))) {
        $footer_html = $Footer->text;
        $footer_html = str_replace("[# footerSocial #]", '', $footer_html);
 
        if (isset($menu_html)) {
          $footer_html = str_replace("[# footerMenu #]", $menu_html, $footer_html);
        }
        $this->view->setVar("footer_test", $footer_html);
      }
    }
    //Footer ende
 
    $LandingPage = \App\Models\LandingPage::findFirst();
    $this->tag->title()->set($LandingPage->meta_title);
    $this->view->setVar('meta_description', $LandingPage->meta_description);
    $this->view->setVar('meta_keywords', $LandingPage->meta_keywords);
    $this->view->setVar('global_headline', $LandingPage->global_headline);
 
    $this->view->setVar('global_headline_second', $LandingPage->global_headline_second);
 
    $this->view->setVar('text1_headline', $LandingPage->text1_headline);
    $this->view->setVar('text1_text', $LandingPage->text1_text);
    $this->view->setVar('text1_subline', $LandingPage->text1_subline);
 
    $this->view->setVar('text2_headline', $LandingPage->text2_headline);
    $this->view->setVar('text2_text', $LandingPage->text2_text);
    $this->view->setVar('text2_subline', $LandingPage->text2_subline);
    $this->view->setVar('fotocase', $LandingPage->getLink2Image());
 
    $models = (new \Phalcon\Mvc\Model\Query\Builder())
      ->addFrom('App\Models\LandingPageModules', 'LandingPageModules')
      ->columns([
        'id' => 'LandingPageModules.id',
        'modultemplate' => 'Modul.modul_template',
        'class' => 'Modul.modul_class',
        'headline' => 'Content.content_headline',
        'text' => 'Content.content_text',
        'image_name' => 'Content.image_name',
        'image_ext' => 'Content.image_ext',
        'content_image_name' => 'ContentImage.image_name',
        'content_image_ext' => 'ContentImage.image_ext'
      ])
      ->join('\App\Models\Modul', 'LandingPageModules.modul_id = Modul.id', 'Modul')
      ->join('\App\Models\Content', 'LandingPageModules.modul_id = Content.modul_id', 'Content')
      ->join('\App\Models\ContentImage', 'Content.id = ContentImage.content_id', 'ContentImage')
      ->orderBy('pos ASC')
      ->getQuery()->execute();
 
 
    $moduleTemplates = [];
 
    foreach ($models as $modulEntry) {
      $headline = $modulEntry->headline;
      $text = $modulEntry->text;
      $image = $modulEntry->image_name . $modulEntry->image_ext;
      $image2 = $modulEntry->content_image_name . $modulEntry->content_image_ext;
      $classname = '\\App\\Models\\' . $modulEntry->class;
      $classnameAdditional = '\\App\\Models\\' . $modulEntry->class . 'Text';
 
 
      // Snippet Texte
      $snippet_text = Snippet::getSnippetTextByPerma('lp_leitfaden_txt1');
 
      $snipets['lp_leitfaden_txt1'] = strip_tags($snippet_text);
 
      $variables = ['headline' => $headline, 'text' => $text, 'image' => $image, 'image2' => $image2, 'snippets' => $snipets];
 
      $model = new $classname();
      $variables = $model->bindVariables($variables);
 
      if (class_exists($classnameAdditional)) {
 
        $modelAdditional = new $classnameAdditional();
        $variables = $modelAdditional->bindVariables($variables);
      }
 
 
      $html_template = $this->view->getPartial('modul/' . $modulEntry->modultemplate, $variables);
      $moduleTemplates[] = $html_template;
    }
    $this->view->setVar('moduleTemplates', $moduleTemplates);
 
 
    //$args['content'] = 'cookie-check';
    //$Phery = (new ContentPopupPlugin())->procAction($args);
    $x = ($this->cookies->has("ga-disable-UA-113554189-1") ? true : false);
    $this->view->setVar("cookie", $x);
  }
 
  private function setView()
  {
 
  
    $this->view->setVar("Content", null);
    $this->view->setVar("param", $this->param);
    $cookie = ($this->cookies->has("cookie-check") ? true : false);
    $this->view->setVar("cookie", $cookie);
 
    if ($this->isLandingPage()) {
      //Pick the landingpage template
      $this->view->setMainView("landingpage");
      $this->setLandingPageVars();
 
      $request = new Request();
 
      if (true === $request->isPost()) {
        if (true === $request->isAjax()) {
          $action = $request->get('action');
          die("AJAX " . $action);
        }
      }
    } elseif ($this->isCoronaLandingPage()) {
      //Pick the landingpage template
      $this->view->setMainView("corona-landingpage");
      $this->setCoronaLandingPageVars();
 
      $request = new Request();
 
      if (true === $request->isPost()) {
        if (true === $request->isAjax()) {
          $action = $request->get('action');
          die("AJAX " . $action);
        }
      }
    } elseif ($this->isIndex() and !$this->setIndex()) {
      parent::setTreeNavis();
      $this->get404Page();
    } elseif (!$this->isIndex() and !$this->setContent()) {
      ini_set('display_errors', 1);
      ini_set('display_startup_errors', 1);
      error_reporting(E_ALL);
      
      parent::setTreeNavis();
      
      $this->get404Page();
    } elseif (!$this->isValidNavi()) {
      $this->redirToIndex();
    }
 
    if ($this->Content) {
      //die("Content is ready...465");
      $this->Content->parseContentText();
      $this->view->setVar("Content", $this->Content);
      $this->view->setVar("is_presse", $this->is_presse);
      $this->view->setVar("is_mitglied", $this->is_mitglied);
      $this->view->setVar("is_index", $this->isIndex());
      parent::setTreeNavis();
      $this->setMetaTitle();
      $this->setMetaKeywords();
      $this->setMetaDescription();
      //$this->setCoronaLandingPageVars();
      if ($this->isIndex()) {
        $this->setViewIndexVars();
      }
 
      if (strlen($this->Content->liste_id) and ($Liste = $this->Content->getListe())) {
        $this->setViewListeVars($Liste);
      }
      if (strlen($this->Content->layout_id) and ($Layout = $this->Content->getLayout())) {
        $this->view->setLayout($Layout->volt_file);
      }
      if (strlen($this->Content->modul_id) and ($this->Modul = $this->Content->getModul())) {
      
        $this->setViewModulVars($this->Modul);
        $this->procModulAction($this->Modul);
        
      }
      if (strlen($this->Content->risikoklasse_id) and ($Risikoklasse = $this->Content->getRisikoklasse())) {
        $this->setViewRisikoklasse($Risikoklasse);
      }
 
      if (!$this->isIndex() and !$this->isValidArgs()) {
        $this->get404Page();
      }
 
      $this->getYoutubeVideoPlatzhalter();
      // $this->getYoutubeVideoWrapper();
    }
  }
 
  private function isIndex()
  {
    if (empty($this->perma)) {
      return true;
    }
    return false;
  }
 
  private function isLandingPage()
  {
 
    if (!empty($this->perma)) {
      return ($this->perma == "bu");
    } else {
      return false;
    }
  }
 
  private function isCoronaLandingPage()
  {
    if (!empty($this->perma)) {
      return ($this->perma == "versicherungen-corona");
    } else {
      return false;
    }
  }
 
  private function setIndex()
  {
    return $this->Content = Content::getContentIndex();
  }
 
  private function setContent()
  {
    
    if ($_REQUEST['_url'] == '/werden-sie-mitglied/beitrittserklaerung-danke') {
      return $this->Content = StaticContent::findFirst(['content_perma = "beitrittserklaerung-danke"']);
    }
 
    if ("stellungnahmen" === array_get($this->folders, 0)) {
      $this->perma = "stellungnahmen";
    }
  
    if ($this->setNavi() and $this->isValidPath()) {
 
      $this->Content = $this->Navi->getContent();
      return true;
    }
 
    return false;
  }
 
  private function setNavi()
  {
    $anz_folders = count($this->folders);
    
    if (!is_array($this->folders) or $anz_folders == 0) {
      return false;
    } elseif (($this->Navi = Tree::findNaviByPermaAndDepth($this->perma, $anz_folders))) {
      if (count($this->args) == 0) {
        $this->args = null;
      }
      return true;
    }
 
    return $this->setArgs();
  }
 
  private function setArgs()
  {
    
    $args = array_pop($this->folders);
    array_unshift($this->args, $args);
    $this->perma = end($this->folders);
    if ("stellungnahmen" === array_get($this->folders, 0)) {
      $this->perma = "stellungnahmen";
    }
 
    return $this->setNavi();
  }
 
  private function isValidArgs()
  {
    return true;
  }
 
  private function isValidNavi()
  {
    if (empty($this->perma)) {
      return true;
    } elseif ("nein" == $this->Navi->is_protected) {
      return true;
    } elseif ("ja" == $this->Navi->is_protected and !$this->is_mitglied) {
      return false;
    } elseif ("nor" == $this->Navi->is_protected and $this->is_mitglied) {
      return false;
    }
 
    return true;
  }
 
  private function isValidPath()
  {
 
    /*
    $node_ary = [];
    $owner = Tree::findFirst($this->Navi->getParentId());
    $this->Navi->getNestedSet($owner);
    if (($nodes = $this->Navi->ancestorsAndSelf())) {
      
      foreach ($nodes as $Node) {
        $node_ary[] = $Node->node_perma;
      }
      $node_ary[] = $this->Navi->node_perma;
      
      return ($this->folders === $node_ary);
    }
    */
 
    return true;
  }
 
  private function getYoutubeVideoPlatzhalter()
  {
 
 
    $Youtubevideo = YoutubeVideo::find();
 
    $YTV_search = [];
    $YTV_replace = [];
 
    foreach ($Youtubevideo as $Video) {
      array_push($YTV_search, $Video->platzhalter);
      array_push($YTV_replace, $Video->code);
    }
 
    $this->view->setVar('YTVsearch', $YTV_search);
    $this->view->setVar('YTVreplace', $YTV_replace);
  }
 
  private function setMedium4Adventskalender()
  {
 
 
    //die("Hier");
    if (IS_LAB) {
      $DatumJetzt = new \DateTime('2019-12-01');
      #$DatumJetzt = new \DateTime();
      $datum = isset($_GET['kalender_datum']) ? $_GET['kalender_datum'] : false;
    } else {
      $DatumJetzt = new \DateTime();
      // $datum = false;
      // Wegen den Vergangenen Türchen
      $datum = isset($_GET['kalender_datum']) ? $_GET['kalender_datum'] : false;
    }
 
 
    $DatumDezember = new \DateTime((new \DateTime)->format('Y') . '-12-01');
 
    if ($datum or ($DatumJetzt >= $DatumDezember)) {
      if (!$datum) {
        $datum = $DatumJetzt->format("Y-m-d");
      }
 
      if ($AdventsTag = \App\Models\AdventListe::findFirst(["datum = '" . $datum . "'"])) {
 
        $this->view->setVar("AdventsTag", $AdventsTag);
      }
    }
  }
 
  private function setMedien4Adventskalender()
  {
    $DatumJetzt = new \DateTime('now');
    //$DatumJetzt = new \DateTime('2017-12-24');
    $args = [
      "datum <= '" . $DatumJetzt->format("Y-m-d") . "'",
      "order" => "datum",
    ];
    if (($medien = Medium::find($args))) {
      $this->view->setVar("medien", $medien);
    }
  }
 
  private function setViewIndexVars()
  {
 
    $this->setMedium4Adventskalender();
 
    $this->view->setVar("is_index", true);
 
 
    if (($Tipp = Tipp::getTipp4Index())) {
      $this->view->setVar("Tipp", $Tipp);
    }
 
    if (($themas = Thema::getThemaPage())) {
      $this->view->setVar("themas", $themas);
    }
 
    if (($Snippet = Snippet::findFirst("snippet_perma = 'ServiceTeaser'"))) {
      $this->view->setVar("Snippet", $Snippet);
    }
 
    if (($smallTeaser = Teaser::findFirst("teaser_perma = 'smallteaser'"))) {
      $this->view->setVar("SmallTeaser", $smallTeaser);
    }
 
    if (($pressemitteilungen = self::getPressemitteilungPage(null, "deutsch"))) {
      $item_ary = [];
      foreach ($pressemitteilungen->items as $Pressemitteilung) {
        $Paragraphs = getParagraphs($Pressemitteilung['mail']->mail_vorwort);
        if ($Pressemitteilung['mail']->mail_vorwort == $Paragraphs->prepend) {
          $Pressemitteilung->weiterlesenLink = false;
        } else {
          $Pressemitteilung->weiterlesenLink = true;
          $Pressemitteilung['mail']->mail_vorwort = $Paragraphs->prepend;
        }
 
        $item_ary[] = $Pressemitteilung;
      }
      $this->view->setVar("pressemitteilungen", $item_ary);
    }
 
    if (($PressemitteilungNode = Tree::findNodeByModulClass("Pressemitteilung"))) {
      $path = parent::getPathByNodeID($PressemitteilungNode->id);
      $this->view->setVar("link2pressemitteilung", $path);
    }
 
    if (($facebookPosts = FacebookPost::getFacebookPosts())) {
      $this->view->setVar("facebook_posts", $facebookPosts);
    } else {
      $facebookPosts = [];
    }
 
    if (($twitterTweets = TwitterTweet::getTwitterTweets())) {
      $this->view->setVar("twitter_tweets", $twitterTweets);
    } else {
      $twitterTweets = [];
    }
  }
 
  private function setViewListeVars($Liste)
  {
 
    $this->view->setVar("Liste", $Liste);
 
    if ("Mitarbeiter" == $Liste->liste_class) {
      if (($PageObj = self::getMitarbeiterPage())) {
        $this->view->setVar('mitarbeiter', $PageObj);
      }
    } elseif ("Faq" == $Liste->liste_class) {
      if (($PageObj = self::getFaqPage())) {
        $this->view->setVar('faqs', $PageObj);
      }
    } elseif ("FaqKfz" == $Liste->liste_class) {
      if (($PageObj = self::getFaqKfzPage())) {
        $this->view->setVar('faqs_kfz', $PageObj);
      }
    } elseif ("Kooperationspartner" == $Liste->liste_class) {
      if (($PageObj = self::getKooperationspartnerPage())) {
        $this->view->setVar('kooperationspartner', $PageObj);
      }
    } elseif ("Stellenangebot" == $Liste->liste_class) {
      if (($PageObj = self::getStellenangebotPage())) {
        $this->view->setVar('stellenangebot', $PageObj);
      }
    } elseif ("Aufsichtsrat" == $Liste->liste_class) {
      if (($PageObj = self::getAufsichtsratPage())) {
        $this->view->setVar('aufsichtsrat', $PageObj);
      }
    } elseif ("Vorstand" == $Liste->liste_class) {
      if (($PageObj = self::getVorstandPage())) {
        $this->view->setVar('vorstand', $PageObj);
      }
    } elseif ("Organe" == $Liste->liste_class) {
      if (($PageObj = self::getAufsichtsratPage())) {
        $this->view->setVar('aufsichtsrat', $PageObj);
      }
      if (($PageObj = self::getVorstandPage())) {
        $this->view->setVar('vorstand', $PageObj);
      }
    } elseif ("PressefotoListe" == $Liste->liste_class) {
      if ($this->is_presse) {
        $PageObj = self::getPressefotoListePage();
        $this->view->setVar('pressefoto_liste', $PageObj);
      } elseif (($Modul = Modul::findFirst("modul_class = 'UserLogin'"))) {
        $this->setViewModulVars($Modul);
        if (($Content = Content::findFirst('modul_id = ' . $Modul->getKey()))) {
          $this->view->Content = $Content;
        }
      }
    } elseif ("Agenda" == $Liste->liste_class) {
      if (($PageObj = self::getAgendaPage())) {
        $this->view->setVar('agenda', $PageObj);
      }
    } elseif ("Broschuere" == $Liste->liste_class) {
 
      if (($PageObj = self::getBroschuerePage('deutsch'))) {
        $this->view->setVar('broschuere', $PageObj);
      }
    } elseif ("Beirat" == $Liste->liste_class) {
      if (($PageObj = self::getBeiratPage())) {
        $this->view->setVar('beirat', $PageObj);
      }
    } elseif ("Leitfaden" == $Liste->liste_class) {
      if (($PageObj = self::getLeitfadenPage())) {
        $this->view->setVar('leitfaden', $PageObj);
      }
    } elseif ("Flyer" == $Liste->liste_class) {
      if (($PageObj = self::getFlyerPage())) {
        $this->view->setVar('flyer', $PageObj);
      }
    } elseif ("Bdvinfo" == $Liste->liste_class) {
      if (($PageObj = self::getBdvinfoPage())) {
        $this->view->setVar('bdvinfo', $PageObj);
      }
    } elseif ("DownloadListe" == $Liste->liste_class) {
      if ($this->is_mitglied) {
        $PageObj = self::getDownloadListePage();
        $this->view->setVar('download_liste', $PageObj);
      }
    } elseif ("Sitemap" == $Liste->liste_class) {
      $sitemap = new SitemapGenerator();
      $sitemap->setConfig($this->config);
      $sitemap->setTree($this->Tree);
      $sitemap->generate();
      $sitemap->print();
      exit;
    }
  }
 
  private function setViewModulVars($Modul)
  {
 
 
    if (strlen($Modul->modul_template)) {
      $this->view->setVar("Modul", $Modul);
    }
 
    // Suche
    if ("Medium" === $Modul->modul_class) {
      $this->setMedien4Adventskalender();
    } elseif ("Suche" === $Modul->modul_class) {
      
      $this->response->setHeader("Cache-Control", "max-age=180");
      $search_string = $this->request->getPost("search_string");
 
      $Suche = new SuchePlugin();
      $Suche->setPathAry($this->path_ary);
 
      $this->view->setVar("search_string", $search_string);
      $this->view->setVar("search_result", $Suche->getSearchResultByPostRequest($search_string));
    }
    // MitgliedIndex
    elseif ("MitgliedIndex" === $Modul->modul_class) {
      if (($ary = $this->session->get("mitglied"))) {
        $this->Content->content_headline .= ' ' . array_get($ary, "vorname") . ' ' . array_get($ary, "nachname");
        $this->view->setVar("Content", $this->Content);
      }
 
      $PageObj = self::getNewsPage([]);
      $this->view->setVar('news_items', NewsPlugin::getNewsItems($PageObj));
      $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
    }
    // Pressemitteilung
    elseif ("Pressemitteilung" === $Modul->modul_class) {
 
      if ($key = $this->request->get("print") and $PmModel = Pressemitteilung::getPressemitteilungByKey($key)) {
        PressemitteilungPdf::outputPdf($PmModel);
      } else {
 
        $this->args = $this->args ?? [];
        $FilterSegments = FilterSegment::getFilterSegments($this->args ?? []);
        $FilterArrays = Pressemitteilung::getFilterArrays($FilterSegments);
        $this->setViewFilterSegments($FilterSegments);
        $is404 = false;
        if ($FilterArrays) {
          if (count($this->args) === 1 and !is_numeric($this->args[0]) and !Pressemitteilung::findFirst("kategorie_perma = '" . array_get($this->args, 0) . "'")) {
            if (($MailObj = Pressemitteilung::getPressemitteilungByPerma(array_get($this->args, 0)))) {
 
              $this->view->setVar('Pressemitteilung', PressemitteilungPlugin::getPressemitteilungItem($MailObj));
              // facebook_metas fuer Detailseite vorbereiten 
              $site_url = $this->config->url->httpScheme . $this->config->url->hostName;
              $page_url = $site_url . $this->request->getURI();
              $image_url = $site_url . $MailObj->getLink2Image();
              $facebook_metas = Pressemitteilung::getPressemitteilungMetas($MailObj, $page_url, $image_url);
 
              $extra_fb_meta_image = $MailObj->getLink2ThirdImage();
 
              if (empty($extra_fb_meta_image)) {
                $extra_fb_meta_image = $MailObj->getLink2Image();
              }
 
              if (!empty($extra_fb_meta_image)) {
                $this->view->setVar('extra_fb_meta_image', $extra_fb_meta_image);
              }
 
 
              $this->view->setVar('facebook_metas', $facebook_metas);
              $this->tag->title()->set($MailObj->mail_subject . ' - Bund der Versicherten');
              $this->view->setVar('meta_keywords', $MailObj->mail_subject);
              $this->view->setVar('title', $MailObj->mail_subject);
              $this->view->setVar('meta_description', $MailObj->mail_subline);
            } else {
              $is404 = true;
              $this->get404Page();
            }
          } elseif (($PageObj = self::getPressemitteilungPage($FilterSegments))) {
            $this->view->setVar('pressemitteilung_items', PressemitteilungPlugin::getPressemitteilungItems($PageObj));
            $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
          }
 
          if (!$is404) {
            $this->view->setVar('page_link', '/' . implode("/", $this->folders));
            $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
            $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
            $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
          }
        }
      }
    } elseif ("Musterbrief" == $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $kategorie_filter = $FilterSegments->kategorie_filter;
 
      $this->view->setVar('kategorie_filter', "alle");
      $this->view->setVar('liste_ary', MusterbriefListe::getMusterbriefListen());
      $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
      if ($kategorie_filter and $PageObj = self::getMusterbriefListePage($FilterSegments)) {
        $this->view->setVar('musterbrief_liste', $PageObj);
        $this->view->setVar('kategorie_filter', $FilterSegments->kategorie_filter);
      } else {
        $this->view->setVar('musterbrief_liste', self::getMusterbriefListePage());
      }
 
      $this->view->setVar('hat_beliebte_musterbriefe', false);
      if (MusterbriefListe::getMusterbriefListen(["is_beliebt" => true])) {
        $this->view->setVar('hat_beliebte_musterbriefe', true);
      }
    }
    // Beitrag 
    elseif ("Beitrag" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = BeitragKategorie::getFilterArrays($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
 
      if ($FilterArrays) {
        $this->args = $this->args ?? [];
        $arg = ((count($this->args) === 1 and !is_numeric($this->args[0])) ? array_get($this->args, 0) : false);
        if ($arg and !BeitragKategorie::findFirst("kategorie_perma = '" . $arg . "'")) {
          $params = "beitrag_perma = '" . $arg . "' AND is_online = 'ja'";
          if (($Beitrag = Beitrag::findFirst($params))) {
            $this->view->setVar('Beitrag', BeitragPlugin::getBeitragItem($Beitrag));
          } else {
            $this->get404Page();
          }
        } elseif (($PageObj = self::getBeitragPage($FilterSegments))) {
          $this->view->setVar('beitrag_items', BeitragPlugin::getBeitragItems($PageObj));
          $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
        }
 
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
        $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
      }
    }
    // Stellungnahme
    elseif ("Stellungnahme" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = StellungnahmeKategorie::getFilterArrays($FilterSegments);
      $PageObj = self::getStellungnahmePage($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
      if ($FilterArrays and $PageObj) {
        $this->view->setVar('stellungnahme_items', StellungnahmePlugin::getStellungnahmeItems($PageObj));
        $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
        $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
      }
    } elseif ("LandingPage" === $Modul->modul_class) {
      #die("Hier");
    } // Termin
    elseif ("Termin" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = TerminKategorie::getFilterArrays($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
      if (is_object($FilterSegments) and "termine" == $FilterSegments->kategorie_filter) {
        $termin_ary = self::getTerminAry($FilterSegments);
        $Modul->modul_template = "termin-liste";
 
        $this->view->setVar("Modul", $Modul);
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('termin_ary', $termin_ary);
      } else {
        $PageObj = self::getTerminPage($FilterSegments);
        if ($FilterArrays and $PageObj) {
          $this->view->setVar('termin_items', TerminPlugin::getTerminItems($PageObj));
          $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
          $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
          $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
          $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
          $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
        }
 
        if (!$this->args and ($termin_ary = self::getTerminAry([]))) {
          $this->view->setVar('termin_ary', $termin_ary);
        } elseif (!empty($FilterSegments->jahr_filter) and empty($FilterSegments->kategorie_filter) and empty($FilterSegments->monat_filter)) {
          if (($termin_ary = self::getTerminAry($FilterSegments))) {
            $this->view->setVar('termin_ary', $termin_ary);
          }
        }
      }
    }
    // Beitrittserklärung
    elseif ("Beitrittserklaerung" === $Modul->modul_class) {
 
      $this->view->setVar('bundeslaender', Bundesland::find());
      $this->view->setVar('laender', Land::find(["order" => "pos"]));
 
      $objs = Kampagne::find(["is_online = 'ja'", "order" => "pos"]);
      $this->view->setVar('kampagne_ary', $objs);
    }
    // Meine Anschrift
    elseif ("MeineAnschrift" === $Modul->modul_class) {
 
      $this->view->setVar('laenderAlle', LandAlle::find(["order" => "id"]));
    }
    // Wita
    elseif ("Wita" === $Modul->modul_class) {
 
 
      if (empty($this->args)) {
        //$this->args = [date('Y')];
        // Hier soll das höchste jahr genommen werden
        $witas = Wita::fetchWitas();
        $Wita = $witas[0];
        $year = date('Y', strtotime($Wita->datum_von));
        $this->args = [$year];
      }
 
      if (($Wita = Wita::fetchWita($this->args))) {
        $this->view->setVar('logged_in', false);
        $this->view->setVar('Wita', $Wita);
        $this->view->setVar('referenten', WitaReferent::fetchReferentenByWita($Wita));
 
        if (checkSession(['wita', $Wita->login_code])) {
          $this->view->setVar('logged_in', true);
          $this->view->setVar('vortraege', WitaVortrag::fetchVortraegeByWitaID($Wita->getKey()));
          $this->view->setVar('teilnehmer', $Wita->getTeilnehmer());
        }
        if (($witas = Wita::fetchWitas())) {
          $counter = 0;
          $link_ary = [];
          foreach ($witas as $TmpWita) {
            //$wita_link = '/' . implode("/", $this->folders) . (($counter > 0) ? '/' . $TmpWita->wita_jahr : null);
            $wita_link = '/' . implode("/", $this->folders) . '/' . $TmpWita->wita_jahr;
            $link_ary[] = ['link' => $wita_link, 'jahr' => $TmpWita->wita_jahr];
            $counter++;
          }
          $this->view->setVar('wita_links', $link_ary);
        }
      } else {
        $this->get404Page();
      }
    }
    // Newsletter
    elseif ("Newsletter" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments4Newsletter($this->args);
      $FilterArrays = Newsletter::getFilterArrays($FilterSegments);
 
      $this->view->setVar("show_form", false);
      $this->view->setVar("show_liste", false);
      $this->view->setVar("is_subscriber", null);
 
      if ($FilterSegments->jahr_filter) {
        if (($newsletter = Newsletter::fetchNewsletterByJahr($FilterSegments->jahr_filter))) {
          $this->view->setVar("show_liste", true);
          $this->view->setVar("newsletter", $newsletter);
        }
      } elseif ($FilterSegments->perma_filter) {
        if (($Newsletter = Newsletter::findFirst("mail_perma = '" . $FilterSegments->perma_filter . "'"))) {
          $this->view->setVar("Newsletter", $Newsletter);
          $this->view->setVar("newsletterArtikel", $Newsletter->newsletterArtikel);
          $FilterSegments->jahr_filter = $Newsletter->jahr;
 
          if (($newsletter = Newsletter::fetchNewsletterByJahr($Newsletter->jahr))) {
            $this->view->setVar("newsletter", $newsletter);
          }
        }
      } elseif (($Newsletter = Newsletter::fetchLastNewsletter())) {
        $this->view->setVar("Newsletter", $Newsletter);
        $this->view->setVar("newsletterArtikel", $Newsletter->newsletterArtikel);
 
        if ($mitglied_ary = $this->session->get("mitglied")) {
          $this->view->setVar("show_form", true);
          $this->view->setVar("is_subscriber", (("N" == array_get($mitglied_ary, "newsletter")) ? false : true));
        }
      }
 
      $this->setViewFilterSegments($FilterSegments);
      $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
      $this->view->setVar("page_link", '/' . implode("/", $this->folders));
    }
    // Englisch
    elseif ("Englisch" === $Modul->modul_class) {
      $this->view->setVar("is_englisch", true);
 
      /*
       * snippet text
       */
 
      if (($snippet_text = Snippet::getSnippetTextByPerma("BoxEnglisch"))) {
        $this->view->setVar("snippet_text", $snippet_text);
      }
 
      /*
       * pressemitteilung
       */
      if (($PageObj = self::getPressemitteilungPage(null, "englisch"))) {
        if (($PressemitteilungNode = Tree::findNodeByModulClass("Pressemitteilung"))) {
          $path = parent::getPathByNodeID($PressemitteilungNode->id);
          $this->view->setVar("link2pressemitteilung", $path);
        }
 
        $item_ary = [];
        foreach ($PageObj->items as $Item) {
          $Paragraphs = getParagraphs($Item['mail']->mail_vorwort);
          $Item['mail']->mail_vorwort = $Paragraphs->prepend;
          $item_ary[] = $Item;
        }
 
        $this->view->setVar("pressemitteilungen", $item_ary);
      }
 
      /*
       * stellungnahme
       */
      if (($PageObj = self::getStellungnahmePage(null, "englisch"))) {
        if (($StellungnahmeNode = Tree::findNodeByModulClass("Stellungnahme"))) {
          $path = parent::getPathByNodeID($StellungnahmeNode->id);
          $this->view->setVar("link2stellungnahme", $path);
        }
 
        $item_ary = [];
        foreach ($PageObj->items as $Item) {
          $Paragraphs = getParagraphs($Item['stellungnahme']->stellungnahme_text);
          $Item['stellungnahme']->stellungnahme_text = $Paragraphs->prepend;
          $item_ary[] = $Item;
        }
 
        $this->view->setVar('stellungnahme', $item_ary);
      }
      /*
       * broschuere
       */
      if (($PageObj = self::getBroschuerePage("englisch"))) {
        $this->view->setVar('broschuere', $PageObj);
      }
    } elseif ("BedarfsCheck" === $Modul->modul_class) {
      $calcBerufAry = CalcBeruf::find([null, 'order' => "pos"]);
      $calcFamilieAry = CalcFamilie::find([null, 'order' => "pos"]);
      $calcZusatzBinAry = CalcZusatz::find(["typ = 'was-bin-ich'", 'order' => "pos"]);
      $calcZusatzBesitzeAry = CalcZusatz::find(["typ = 'was-besitze-ich'", 'order' => "pos"]);
 
      $this->view->setVar('beruf_ary', $calcBerufAry);
      $this->view->setVar('familie_ary', $calcFamilieAry);
      $this->view->setVar('zusatz_bin_ary', $calcZusatzBinAry);
      $this->view->setVar('zusatz_besitze_ary', $calcZusatzBesitzeAry);
    } elseif ("Kontakt" === $Modul->modul_class) {
      $this->view->setVar('anliegen', []);
      if (($anliegen = Kontakt::find(["order" => "pos"]))) {
        $this->view->setVar('anliegen', $anliegen);
      }
    } elseif ("Bewerbung" === $Modul->modul_class) {
 
      $this->view->setVar('widerruf', "");
      $this->view->setVar('stellenangebote', []);
 
      if (($stellenangebote = self::getStellenangebotPage()) and $stellenangebote->count()) {
        $this->view->setVar('stellenangebote', self::getStellenangebotPage());
      }
 
      if (($widerruf = Snippet::getSnippetTextByPerma("BewerbungWiderruf"))) {
        $this->view->setVar('widerruf', strip_tags($widerruf, "<a>"));
      }
    }
  }
 
  private function setViewFilterSegments($FilterSegments)
  {
    $this->view->setVar('kategorie_filter', "");
    $this->view->setVar('jahr_filter', "");
    $this->view->setVar('monat_filter', "");
    $this->view->setVar('perma_filter', "");
 
    if (isset($FilterSegments)) {
      if (isset($FilterSegments->kategorie_filter) and ($kategorie = $FilterSegments->kategorie_filter)) {
        $this->view->setVar('kategorie_filter', LINK_ROOT . $kategorie);
 
        if (($jahr = $FilterSegments->jahr_filter)) {
          $this->view->setVar('jahr_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr);
          if (($monat = $FilterSegments->monat_filter)) {
            $this->view->setVar('monat_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr . LINK_ROOT . $monat);
          } else {
            $this->view->setVar('monat_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr);
          }
        }
      } elseif (($jahr = $FilterSegments->jahr_filter)) {
        $this->view->setVar('jahr_filter', LINK_ROOT . $jahr);
 
        if (isset($FilterSegments->monat_filter) and ($monat = $FilterSegments->monat_filter)) {
          $this->view->setVar('monat_filter', LINK_ROOT . $jahr . LINK_ROOT . $monat);
        }
 
        if (isset($FilterSegments->perma_filter) and ($perma = $FilterSegments->perma_filter)) {
          $this->view->setVar('perma_filter', $perma);
        }
      }
    }
  }
 
  private function procModulAction($Modul)
  {
    if ("Logout" == $Modul->modul_class) {
      (new LogoutPlugin())->procAction();
    } elseif ("Optin" == $Modul->modul_class) {
      (new OptinPlugin())->procAction();
    }
  }
 
  private function setViewRisikoklasse($Risikoklasse)
  {
    $merkblaetter = $Risikoklasse->getMerkblaetter($this->is_mitglied);
    $link2beitrittserklaerung = $this->getPathByModulClass("Beitrittserklaerung");
 
    $this->view->setVar("Risikoklasse", $Risikoklasse);
    $this->view->setVar("merkblaetter", $merkblaetter);
    $this->view->setVar("link2beitrittserklaerung", LINK_ROOT . $link2beitrittserklaerung);
 
    if (($Snippet = Snippet::findFirst("snippet_perma = 'MerkblattHinweis'"))) {
      $this->view->setVar("Snippet", $Snippet);
    }
  }
 
  /*
   * Pages
   */
 
  private static function getNewsPage()
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$news_limit);
 
    return News::getNewsPage($args);
  }
 
  private static function getMusterbriefListePage($FilterSegments = null)
  {
    $args = [];
    if ($FilterSegments) {
      if ("beliebteste" == $FilterSegments->kategorie_filter) {
        array_set($args, "is_beliebt", "ja");
      } else {
        array_set($args, "liste_perma", $FilterSegments->kategorie_filter);
      }
    }
    return MusterbriefListe::getMusterbriefListePage($args);
  }
 
  private static function getPressemitteilungPage($FilterSegments = null, $lang = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$news_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    if ($lang) {
      array_set($args, "mail_sprache", $lang);
    }
 
    return Pressemitteilung::getPressemitteilungPage($args);
  }
 
  private static function getStellungnahmePage($FilterSegments = null, $lang = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$stellungnahme_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    if ($lang) {
      array_set($args, "lang", $lang);
    }
 
    return Stellungnahme::getStellungnahmePage($args);
  }
 
  private static function getBeitragPage($FilterSegments = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$beitrag_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    return Beitrag::getBeitragPage($args);
  }
 
  private static function getTerminPage($FilterSegments = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$termin_limit);
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    return Termin::getTerminPage($args);
  }
 
  private static function getTerminAry($FilterSegments)
  {
    $args = [];
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
    }
 
    return Termin::getTerminAry($args);
  }
 
  private static function getMitarbeiterPage()
  {
    $args = ["is_online" => "ja"];
    return Mitarbeiter::getMitarbeiterPage($args);
  }
 
  private static function getFaqPage()
  {
    $args = ["is_online" => "ja"];
    return Faq::getFaqPage($args);
  }
 
  private static function getFaqKfzPage()
  {
    $args = ["is_online" => "ja"];
    return FaqKfz::getFaqKfzPage($args);
  }
 
  private static function getKooperationspartnerPage()
  {
    $args = ["is_online" => "ja"];
    return Kooperationspartner::getKooperationspartnerPage($args);
  }
 
  private static function getStellenangebotPage()
  {
    $args = ["is_online" => "ja"];
    return Stellenangebot::getStellenangebotPage($args);
  }
 
  private static function getAufsichtsratPage()
  {
    $args = ["is_online" => "ja"];
    return Aufsichtsrat::getAufsichtsratPage($args);
  }
 
  private static function getVorstandPage()
  {
    $args = ["is_online" => "ja"];
    return Vorstand::getVorstandPage($args);
  }
 
  private static function getBdvinfoPage()
  {
    $args = ["is_online" => "ja"];
    return Bdvinfo::getBdvinfoPage($args);
  }
 
  private static function getPressefotoListePage()
  {
    $args = [];
    return PressefotoListe::getPressefotoListePage($args);
  }
 
  private static function getAgendaPage()
  {
    $args = ["is_online" => "ja"];
    return Agenda::getAgendaPage($args);
  }
 
  private static function getBroschuerePage($lang)
  {
    $args = ["is_online" => "ja", "lang" => $lang];
    return Broschuere::getBroschuerePage($args);
  }
 
  private static function getBeiratPage()
  {
    $args = ["is_online" => "ja"];
    return Beirat::getBeiratPage($args);
  }
 
  private static function getLeitfadenPage()
  {
    $args = ["is_online" => "ja"];
    return Leitfaden::getLeitfadenPage($args);
  }
 
  private static function getFlyerPage()
  {
    $args = ["is_online" => "ja"];
    return Flyer::getFlyerPage($args);
  }
 
  private static function getDownloadListePage()
  {
    $args = [];
    return DownloadListe::getDownloadListePage($args);
  }
 
  /*
   * phery action 
   */
 
  public function procKontaktForm($args)
  {
    return (new KontaktPlugin())->procAction($args);
  }
 
  public function procInfoEventAnmeldung($args)
  {
    return (new InfoEventPlugin())->procAction($args);
  }
 
  public function procBewerbungForm($args)
  {
    return (new BewerbungPlugin())->procAction($args);
  }
 
  public function procQuickConnectForm($args)
  {
    return (new QuickConnectPlugin())->procAction($args);
  }
 
  public function procBroschuereForm($args)
  {
    return (new BroschuerePlugin())->procAction($args);
  }
 
  public function procBedarfsCheckForm($args)
  {
    return (new BedarfsCheckPlugin())->procAction($args);
  }
 
  public function procSucheForm($args)
  {
    parent::setTreeNavis();
    $SuchePlugin = new SuchePlugin();
    $SuchePlugin->setPathAry($this->path_ary);
 
    return $SuchePlugin->procAction($args);
  }
 
  // liste stuff
  public function procFetchNews($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new NewsPlugin())->procAction($ary);
  }
 
  public function procFetchPressemitteilungen($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new PressemitteilungPlugin())->procAction($ary);
  }
 
  public function procFetchStellungnahmen($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new StellungnahmePlugin())->procAction($ary);
  }
 
  public function procFetchTermine($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$termin_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new TerminPlugin())->procAction($ary);
  }
 
  // user stuff
  public function procUserRegisterForm($args)
  {
    return (new UserRegisterPlugin())->procAction($args);
  }
 
  public function procUserLoginForm($args)
  {
    $Modul = Modul::findFirst("modul_class = 'UserLogin'");
    return (new UserLoginPlugin())->procAction($args, $Modul);
  }
 
  public function procMitgliedLoginForm($args)
  {
    return (new MitgliedLoginPlugin())->procAction($args);
  }
 
  public function procPasswordForm($args)
  {
    return (new PasswordPlugin())->procAction($args);
  }
 
  // wita stuff
  public function procWitaLoginForm($args)
  {
    return (new WitaLoginPlugin())->procAction($args);
  }
 
  public function procWitaNachrichtForm($args)
  {
    return (new WitaNachrichtPlugin())->procAction($args);
  }
 
  public function procWitaAnmeldungForm($args)
  {
    return (new WitaAnmeldungPlugin())->procAction($args);
  }
 
  // mitglied stuff
  public function procMeinPasswortForm($args)
  {
    return (new MeinPasswortPlugin())->procAction($args);
  }
 
  public function procMeineAnschriftForm($args)
  {
    return (new MeineAnschriftPlugin())->procAction($args);
  }
 
  public function procMeineBankverbindungForm($args)
  {
    return (new MeineBankverbindungPlugin())->procAction($args);
  }
 
  public function procMeineZugangsdatenForm($args)
  {
    return (new MeineZugangsdatenPlugin())->procAction($args);
  }
 
  public function procMeineBdvinfoForm($args)
  {
    return (new MeineBdvinfoPlugin())->procAction($args);
  }
 
  public function procBdvNewsletterForm($args)
  {
    return (new BdvNewsletterPlugin())->procAction($args);
  }
 
  public function procBeitrittserklaerungForm($args)
  {
    return (new BeitrittserklaerungPlugin())->procAction($args);
  }
 
  // mitglied login stuff
  public function procGetMitgliedLoginForm()
  {
    $request_uri = strtok($this->request->getURI(), "?");
    return (new MitgliedLoginWidget())->getForm($request_uri);
  }
 
  public function procSendMitgliedLoginForm($args)
  {
    return (new MitgliedLoginPlugin())->procAction($args);
  }
 
  public function procIsLoggedIn()
  {
    $tmp_ary = ["status" => $this->is_mitglied];
    return PheryResponse::factory()->json($tmp_ary);
  }
 
  // stuff
  public function procGetContentPopup($args)
  {
    return (new ContentPopupPlugin())->procAction($args);
  }
 
  public function procSetCookieCheck()
  {
    $time = time() + 365 * 86400;
    setcookie("cookie-check", "ja", $time);
  }
 
  /*
   * Phery
   */
 
  private function setPhery($remote = null)
  {
    $Phry = Phery::instance();
 
    if ("kontakt" == $remote) {
      $Phry->set([$remote => [$this, 'procKontaktForm']]);
    } elseif ("send_info_event" == $remote) {
      $response = $this->procInfoEventAnmeldung($this->request);
      echo json_encode($response);
      exit;
    } elseif ("bewerbung" == $remote) {
      $Phry->set([$remote => [$this, 'procBewerbungForm']]);
    } elseif ("quick_connect" == $remote) {
      $Phry->set([$remote => [$this, 'procQuickConnectForm']]);
    } elseif ("broschuere" == $remote) {
      $Phry->set([$remote => [$this, 'procBroschuereForm']]);
    } elseif ("bedarfscheck" == $remote) {
      $Phry->set([$remote => [$this, 'procBedarfsCheckForm']]);
    } elseif ("send_suche_form" == $remote) {
      $Phry->set([$remote => [$this, 'procSucheForm']]);
    }
    // liste stuff
    elseif ("fetch_news" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchNews']]);
    } elseif ("fetch_pressemitteilungen" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchPressemitteilungen']]);
    } elseif ("fetch_stellungnahmen" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchStellungnahmen']]);
    } elseif ("fetch_termine" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchTermine']]);
    }
    // user stuff
    elseif ("send_password_form" == $remote) {
      $Phry->set([$remote => [$this, 'procPasswordForm']]);
    } elseif ("user_register" == $remote) {
      $Phry->set([$remote => [$this, 'procUserRegisterForm']]);
    } elseif ("user_login" == $remote) {
      $Phry->set([$remote => [$this, 'procUserLoginForm']]);
    }
    // wita stuff
    elseif ("wita_login" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaLoginForm']]);
    } elseif ("wita_nachricht" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaNachrichtForm']]);
    } elseif ("wita_anmeldung" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaAnmeldungForm']]);
    }
    // mitgliederbereich stuff
    elseif ("mitglied_login" == $remote) {
      $Phry->set([$remote => [$this, 'procMitgliedLoginForm']]);
    } elseif ("mein_passwort" == $remote) {
      $Phry->set([$remote => [$this, 'procMeinPasswortForm']]);
    } elseif ("meine_anschrift" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineAnschriftForm']]);
    } elseif ("meine_bankverbindung" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineBankverbindungForm']]);
    } elseif ("meine_zugangsdaten" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineZugangsdatenForm']]);
    } elseif ("meine_bdvinfo" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineBdvinfoForm']]);
    } elseif ("bdv_newsletter" == $remote) {
      $Phry->set([$remote => [$this, 'procBdvNewsletterForm']]);
    } elseif ("beitrittserklaerung" == $remote) {
      $Phry->set([$remote => [$this, 'procBeitrittserklaerungForm']]);
    }
    // mitglied login
    elseif ("get_login_form" == $remote) {
      $Phry->set([$remote => [$this, 'procGetMitgliedLoginForm']]);
    } elseif ("send_login_form" == $remote) {
      $Phry->set([$remote => [$this, 'procSendMitgliedLoginForm']]);
    } elseif ("is_logged_in" == $remote) {
      $Phry->set([$remote => [$this, 'procIsLoggedIn']]);
    }
    // stuff
    elseif ("get_content_popup" == $remote) {
      $Phry->set([$remote => [$this, 'procGetContentPopup']]);
    } elseif ("set_cookie_check" == $remote) {
      $Phry->set([$remote => [$this, 'procSetCookieCheck']]);
    }
 
    $Phry->process();
  }
}
#2App\Controllers\Web\ContentController->setViewListeVars
/var/www/vhosts/bundderversicherten.de/app/Controllers/Web/ContentController.php (477)
<?php
 
namespace App\Controllers\Web;
 
use Phery\Phery;
use Phery\PheryResponse;
use Phalcon\Http\Request;
use App\Models\UrlVerkuerzer;
use App\Models\Tree;
use App\Models\Content;
// index
use App\Models\Tipp;
use App\Models\Medium;
use App\Models\Snippet;
// modul
use App\Models\News;
use App\Models\Wita;
use App\Models\Modul;
use App\Models\Content as StaticContent;
use App\Models\Termin;
use App\Models\Kontakt;
use App\Models\Beitrag;
use App\Models\WitaVortrag;
use App\Models\WitaReferent;
use App\Models\Stellungnahme;
use App\Models\MusterbriefListe;
use App\Models\Newsletter;
use App\Models\TerminKategorie;
use App\Models\BeitragKategorie;
use App\Models\StellungnahmeKategorie;
// beitrittserklaerung
use App\Models\Land;
use App\Models\Bundesland;
use App\Models\Kampagne;
// meine anschrift
use App\Models\LandAlle;
// liste
use App\Models\Faq;
use App\Models\FaqKfz;
use App\Models\Flyer;
use App\Models\Thema;
use App\Models\Teaser;
use App\Models\Agenda;
use App\Models\Mythen;
use App\Models\CoronaMythen;
use App\Models\Beirat;
use App\Models\Bdvinfo;
use App\Models\Vorstand;
use App\Models\Leitfaden;
use App\Models\Broschuere;
use App\Models\Mitarbeiter;
use App\Models\Aufsichtsrat;
use App\Models\FacebookPost;
use App\Models\TwitterTweet;
use App\Models\DownloadListe;
use App\Models\Stellenangebot;
use App\Models\PressefotoListe;
use App\Models\Pressemitteilung;
use App\Models\Kooperationspartner;
use App\Models\LinkTracking;
use App\Models\Newsletter\Mail;
use App\Models\Youtubevideo;
// system and helper
use App\Helper\Pagination;
use App\Helper\FilterSegment;
use App\Helper\PressemitteilungPdf;
use App\Helper\SitemapGenerator;
use App\Controllers\Web\BaseController;
// widgets
use App\Widgets\Web\MitgliedLoginWidget;
// plugins
use App\Plugins\Web\News as NewsPlugin;
use App\Plugins\Web\Optin as OptinPlugin;
use App\Plugins\Web\Suche as SuchePlugin;
use App\Plugins\Web\Logout as LogoutPlugin;
use App\Plugins\Web\Termin as TerminPlugin;
use App\Plugins\Web\Beitrag as BeitragPlugin;
use App\Plugins\Web\Kontakt as KontaktPlugin;
use App\Plugins\Web\InfoEvent as InfoEventPlugin;
use App\Plugins\Web\Bewerbung as BewerbungPlugin;
use App\Plugins\Web\Password as PasswordPlugin;
use App\Plugins\Web\WitaLogin as WitaLoginPlugin;
use App\Plugins\Web\UserLogin as UserLoginPlugin;
use App\Plugins\Web\Broschuere as BroschuerePlugin;
use App\Plugins\Web\QuickConnect as QuickConnectPlugin;
use App\Plugins\Web\MeinPasswort as MeinPasswortPlugin;
use App\Plugins\Web\UserRegister as UserRegisterPlugin;
use App\Plugins\Web\MeineBdvinfo as MeineBdvinfoPlugin;
use App\Plugins\Web\BdvNewsletter as BdvNewsletterPlugin;
use App\Plugins\Web\ContentPopup as ContentPopupPlugin;
use App\Plugins\Web\Stellungnahme as StellungnahmePlugin;
use App\Plugins\Web\MitgliedLogin as MitgliedLoginPlugin;
use App\Plugins\Web\WitaNachricht as WitaNachrichtPlugin;
use App\Plugins\Web\WitaAnmeldung as WitaAnmeldungPlugin;
use App\Plugins\Web\MeineAnschrift as MeineAnschriftPlugin;
use App\Plugins\Web\Pressemitteilung as PressemitteilungPlugin;
use App\Plugins\Web\MeineZugangsdaten as MeineZugangsdatenPlugin;
use App\Plugins\Web\MeineBankverbindung as MeineBankverbindungPlugin;
use App\Plugins\Web\Beitrittserklaerung as BeitrittserklaerungPlugin;
use App\Plugins\Web\ContentPopup as ContentPopup;
// bedarfscheck
use App\Models\CalcBeruf;
use App\Models\CalcZusatz;
use App\Models\CalcFamilie;
use App\Plugins\Web\BedarfsCheck as BedarfsCheckPlugin;
 
class ContentController extends BaseController
{
 
  private static $news_limit = 3;
  private static $termin_limit = 3;
  private static $beitrag_limit = 3;
  private static $stellungnahme_limit = 3;
 
  public function linkTrackerAction()
  {
 
    $unique_id = htmlentities($this->request->get('u'), ENT_QUOTES);
    $TrackingLink = LinkTracking::findFirst(["link_id = '" . $unique_id . "'"]);
    $TrackingLink->hits = $TrackingLink->hits + 1;
    $TrackingLink->save();
 
    header('Location: ' . $TrackingLink->target);
    exit;
  }
 
  public function countImageAction($args)
  {
    $unique_id = htmlentities($this->request->get('u'), ENT_QUOTES);
    if (!empty($unique_id)) {
      if ($Mail = Mail::findFirst(["count_id = '$unique_id'"])) {
        $Mail->opened = $Mail->opened + 1;
        $Mail->save();
      }
    }
    header("Content-type: image/png");
    $im = imagecreate(1, 1);
    imagecolorallocate($im, 255, 255, 255);
    imagepng($im);
    imagedestroy($im);
    exit;
  }
 
  public function shortURLRedirect()
  {
    $short_url = $_SERVER['REQUEST_URI'];
    $short_url = substr($short_url, 1);
    if (!empty($short_url)) {
      if (($UrlVerkuerzer = UrlVerkuerzer::findFirst("url_kurz='" . $short_url . "'"))) {
        $httpScheme = $this->config->url->httpScheme;
        $hostName = $this->config->url->hostName;
        header("Location:" . $httpScheme . $hostName . "/" . $UrlVerkuerzer->url_ziel);
        exit();
      }
    }
  }
 
  public function indexAction()
  {
 
    if (Phery::is_ajax()) {
 
      $args = $_REQUEST['args'] ?? [];
      if (isset($args['content']) && $args['content'] == 'cookie-check') {
        $PheryResonse = (new ContentPopup())->procAction($args);
        echo $PheryResonse;
        exit;
      }
    }
 
    parent::setBaseValues();
 
    $this->shortURLRedirect();
    
    if (!Phery::is_ajax()) {
      $this->setView();
    } elseif (!$this->isIndex() and (!$this->setContent() or !$this->isValidNavi())) {
      // ToDo: phery error
    } else {
      $phery_request = $this->request->getPost('phery');
      $remote = array_get($phery_request, "remote");
 
      $this->setPhery($remote);
    }
  }
 
  private function setCoronaLandingPageVars()
  {
 
    //JSON - Mythos daten
    $mythen_orig = CoronaMythen::find(['order' => 'gruppe ASC']);
    foreach ($mythen_orig as $mythos) {
      $mythos->antwort = strip_tags($mythos->antwort);
      $mythos->mythos = strip_tags($mythos->mythos);
      $mythos->name = strip_tags($mythos->name);
      $mythen[] = $mythos;
    }
    $this->view->setVar('mythenArray', $mythen);
    // Footer Variablen Laden 
    $this->Tree = new Tree();
    $this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
    $this->Tree->getOffsiteNodes($this->session);
 
    if (($footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session))) {
      $this->view->setVar("footer_navi_nodes", $footer_navi_nodes);
      ob_start();
      $this->view->partial('partials/footerMenu', ['footer_navi_nodes' => $footer_navi_nodes]);
      $menu_html = ob_get_clean();
 
      if (($Footer = \App\Models\Footer::findFirst(array('id' => 1)))) {
        $footer_html = $Footer->text;
        $footer_html = str_replace("[# footerSocial #]", '', $footer_html);
 
        if (isset($menu_html)) {
          $footer_html = str_replace("[# footerMenu #]", $menu_html, $footer_html);
        }
        $this->view->setVar("footer_test", $footer_html);
      }
    }
    //Footer ende
 
    $LandingPage = \App\Models\LandingPageCorona::findFirst();
    $this->tag->title()->set($LandingPage->meta_title);
    $this->view->setVar('meta_description', $LandingPage->meta_description);
    $this->view->setVar('meta_keywords', $LandingPage->meta_keywords);
    $this->view->setVar('global_headline', $LandingPage->global_headline);
 
    $this->view->setVar('global_headline_second', $LandingPage->global_headline_second);
    $headline = str_replace('–', "–<br class='smartBr'>", $LandingPage->text1_headline);
    $this->view->setVar('text1_headline', $headline);
    $this->view->setVar('text1_text', $LandingPage->text1_text);
    $this->view->setVar('text1_subline', $LandingPage->text1_subline);
 
    $this->view->setVar('text2_headline', $LandingPage->text2_headline);
    $this->view->setVar('text2_text', $LandingPage->text2_text);
    $this->view->setVar('text2_subline', $LandingPage->text2_subline);
    $this->view->setVar('fotocase', $LandingPage->getLink2Image());
 
    $models = (new \Phalcon\Mvc\Model\Query\Builder())
      ->addFrom('App\Models\LandingPageCoronaModules', 'LandingPageCoronaModules')
      ->columns([
        'id' => 'LandingPageCoronaModules.id',
        'modultemplate' => 'Modul.modul_template',
        'class' => 'Modul.modul_class',
        'headline' => 'Content.content_headline',
        'text' => 'Content.content_text',
        'image_name' => 'Content.image_name',
        'image_ext' => 'Content.image_ext',
        'content_image_name' => 'ContentImage.image_name',
        'content_image_ext' => 'ContentImage.image_ext'
      ])
      ->join('\App\Models\Modul', 'LandingPageCoronaModules.modul_id = Modul.id', 'Modul')
      ->join('\App\Models\Content', 'LandingPageCoronaModules.modul_id = Content.modul_id', 'Content')
      ->join('\App\Models\ContentImage', 'Content.id = ContentImage.content_id', 'ContentImage')
      ->orderBy('pos ASC')
      ->getQuery()->execute();
 
 
    $moduleTemplates = [];
 
    foreach ($models as $modulEntry) {
      $headline = $modulEntry->headline;
      $text = $modulEntry->text;
      $image = $modulEntry->image_name . $modulEntry->image_ext;
      $image2 = $modulEntry->content_image_name . $modulEntry->content_image_ext;
      $classname = '\\App\\Models\\' . $modulEntry->class;
      $classnameAdditional = '\\App\\Models\\' . $modulEntry->class . 'Text';
 
 
      // Snippet Texte
      $snippet_text = Snippet::getSnippetTextByPerma('lp_leitfaden_txt1');
 
      $snipets['lp_leitfaden_txt1'] = strip_tags($snippet_text);
 
      $variables = ['headline' => $headline, 'text' => $text, 'image' => $image, 'image2' => $image2, 'snippets' => $snipets];
 
      $model = new $classname();
      $variables = $model->bindVariables($variables);
 
      if (class_exists($classnameAdditional)) {
 
        $modelAdditional = new $classnameAdditional();
        $variables = $modelAdditional->bindVariables($variables);
      }
 
 
      $html_template = $this->view->getPartial('modul/' . $modulEntry->modultemplate, $variables);
      $moduleTemplates[] = $html_template;
    }
    $this->view->setVar('moduleTemplates', $moduleTemplates);
 
    $gruppe = html_entity_decode($_GET['gruppe'], ENT_QUOTES);
    if (empty($gruppe)) {
      $this->view->setVar('groupSet', false);
    } else {
      $this->view->setVar('groupSet', true);
    }
 
 
 
    //$args['content'] = 'cookie-check';
    //$Phery = (new ContentPopupPlugin())->procAction($args);
 
    $x = ($this->cookies->has("ga-disable-UA-113554189-1") ? true : false);
 
    $this->view->setVar("cookie", $x);
  }
 
  private function setLandingPageVars()
  {
    // Footer Variablen Laden 
    $this->Tree = new Tree();
    $this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
    $this->Tree->getOffsiteNodes($this->session);
    if (($footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session))) {
      $this->view->setVar("footer_navi_nodes", $footer_navi_nodes);
      ob_start();
      $this->view->partial('partials/footerMenu', ['footer_navi_nodes' => $footer_navi_nodes]);
      $menu_html = ob_get_clean();
 
      if (($Footer = \App\Models\Footer::findFirst(array('id' => 1)))) {
        $footer_html = $Footer->text;
        $footer_html = str_replace("[# footerSocial #]", '', $footer_html);
 
        if (isset($menu_html)) {
          $footer_html = str_replace("[# footerMenu #]", $menu_html, $footer_html);
        }
        $this->view->setVar("footer_test", $footer_html);
      }
    }
    //Footer ende
 
    $LandingPage = \App\Models\LandingPage::findFirst();
    $this->tag->title()->set($LandingPage->meta_title);
    $this->view->setVar('meta_description', $LandingPage->meta_description);
    $this->view->setVar('meta_keywords', $LandingPage->meta_keywords);
    $this->view->setVar('global_headline', $LandingPage->global_headline);
 
    $this->view->setVar('global_headline_second', $LandingPage->global_headline_second);
 
    $this->view->setVar('text1_headline', $LandingPage->text1_headline);
    $this->view->setVar('text1_text', $LandingPage->text1_text);
    $this->view->setVar('text1_subline', $LandingPage->text1_subline);
 
    $this->view->setVar('text2_headline', $LandingPage->text2_headline);
    $this->view->setVar('text2_text', $LandingPage->text2_text);
    $this->view->setVar('text2_subline', $LandingPage->text2_subline);
    $this->view->setVar('fotocase', $LandingPage->getLink2Image());
 
    $models = (new \Phalcon\Mvc\Model\Query\Builder())
      ->addFrom('App\Models\LandingPageModules', 'LandingPageModules')
      ->columns([
        'id' => 'LandingPageModules.id',
        'modultemplate' => 'Modul.modul_template',
        'class' => 'Modul.modul_class',
        'headline' => 'Content.content_headline',
        'text' => 'Content.content_text',
        'image_name' => 'Content.image_name',
        'image_ext' => 'Content.image_ext',
        'content_image_name' => 'ContentImage.image_name',
        'content_image_ext' => 'ContentImage.image_ext'
      ])
      ->join('\App\Models\Modul', 'LandingPageModules.modul_id = Modul.id', 'Modul')
      ->join('\App\Models\Content', 'LandingPageModules.modul_id = Content.modul_id', 'Content')
      ->join('\App\Models\ContentImage', 'Content.id = ContentImage.content_id', 'ContentImage')
      ->orderBy('pos ASC')
      ->getQuery()->execute();
 
 
    $moduleTemplates = [];
 
    foreach ($models as $modulEntry) {
      $headline = $modulEntry->headline;
      $text = $modulEntry->text;
      $image = $modulEntry->image_name . $modulEntry->image_ext;
      $image2 = $modulEntry->content_image_name . $modulEntry->content_image_ext;
      $classname = '\\App\\Models\\' . $modulEntry->class;
      $classnameAdditional = '\\App\\Models\\' . $modulEntry->class . 'Text';
 
 
      // Snippet Texte
      $snippet_text = Snippet::getSnippetTextByPerma('lp_leitfaden_txt1');
 
      $snipets['lp_leitfaden_txt1'] = strip_tags($snippet_text);
 
      $variables = ['headline' => $headline, 'text' => $text, 'image' => $image, 'image2' => $image2, 'snippets' => $snipets];
 
      $model = new $classname();
      $variables = $model->bindVariables($variables);
 
      if (class_exists($classnameAdditional)) {
 
        $modelAdditional = new $classnameAdditional();
        $variables = $modelAdditional->bindVariables($variables);
      }
 
 
      $html_template = $this->view->getPartial('modul/' . $modulEntry->modultemplate, $variables);
      $moduleTemplates[] = $html_template;
    }
    $this->view->setVar('moduleTemplates', $moduleTemplates);
 
 
    //$args['content'] = 'cookie-check';
    //$Phery = (new ContentPopupPlugin())->procAction($args);
    $x = ($this->cookies->has("ga-disable-UA-113554189-1") ? true : false);
    $this->view->setVar("cookie", $x);
  }
 
  private function setView()
  {
 
  
    $this->view->setVar("Content", null);
    $this->view->setVar("param", $this->param);
    $cookie = ($this->cookies->has("cookie-check") ? true : false);
    $this->view->setVar("cookie", $cookie);
 
    if ($this->isLandingPage()) {
      //Pick the landingpage template
      $this->view->setMainView("landingpage");
      $this->setLandingPageVars();
 
      $request = new Request();
 
      if (true === $request->isPost()) {
        if (true === $request->isAjax()) {
          $action = $request->get('action');
          die("AJAX " . $action);
        }
      }
    } elseif ($this->isCoronaLandingPage()) {
      //Pick the landingpage template
      $this->view->setMainView("corona-landingpage");
      $this->setCoronaLandingPageVars();
 
      $request = new Request();
 
      if (true === $request->isPost()) {
        if (true === $request->isAjax()) {
          $action = $request->get('action');
          die("AJAX " . $action);
        }
      }
    } elseif ($this->isIndex() and !$this->setIndex()) {
      parent::setTreeNavis();
      $this->get404Page();
    } elseif (!$this->isIndex() and !$this->setContent()) {
      ini_set('display_errors', 1);
      ini_set('display_startup_errors', 1);
      error_reporting(E_ALL);
      
      parent::setTreeNavis();
      
      $this->get404Page();
    } elseif (!$this->isValidNavi()) {
      $this->redirToIndex();
    }
 
    if ($this->Content) {
      //die("Content is ready...465");
      $this->Content->parseContentText();
      $this->view->setVar("Content", $this->Content);
      $this->view->setVar("is_presse", $this->is_presse);
      $this->view->setVar("is_mitglied", $this->is_mitglied);
      $this->view->setVar("is_index", $this->isIndex());
      parent::setTreeNavis();
      $this->setMetaTitle();
      $this->setMetaKeywords();
      $this->setMetaDescription();
      //$this->setCoronaLandingPageVars();
      if ($this->isIndex()) {
        $this->setViewIndexVars();
      }
 
      if (strlen($this->Content->liste_id) and ($Liste = $this->Content->getListe())) {
        $this->setViewListeVars($Liste);
      }
      if (strlen($this->Content->layout_id) and ($Layout = $this->Content->getLayout())) {
        $this->view->setLayout($Layout->volt_file);
      }
      if (strlen($this->Content->modul_id) and ($this->Modul = $this->Content->getModul())) {
      
        $this->setViewModulVars($this->Modul);
        $this->procModulAction($this->Modul);
        
      }
      if (strlen($this->Content->risikoklasse_id) and ($Risikoklasse = $this->Content->getRisikoklasse())) {
        $this->setViewRisikoklasse($Risikoklasse);
      }
 
      if (!$this->isIndex() and !$this->isValidArgs()) {
        $this->get404Page();
      }
 
      $this->getYoutubeVideoPlatzhalter();
      // $this->getYoutubeVideoWrapper();
    }
  }
 
  private function isIndex()
  {
    if (empty($this->perma)) {
      return true;
    }
    return false;
  }
 
  private function isLandingPage()
  {
 
    if (!empty($this->perma)) {
      return ($this->perma == "bu");
    } else {
      return false;
    }
  }
 
  private function isCoronaLandingPage()
  {
    if (!empty($this->perma)) {
      return ($this->perma == "versicherungen-corona");
    } else {
      return false;
    }
  }
 
  private function setIndex()
  {
    return $this->Content = Content::getContentIndex();
  }
 
  private function setContent()
  {
    
    if ($_REQUEST['_url'] == '/werden-sie-mitglied/beitrittserklaerung-danke') {
      return $this->Content = StaticContent::findFirst(['content_perma = "beitrittserklaerung-danke"']);
    }
 
    if ("stellungnahmen" === array_get($this->folders, 0)) {
      $this->perma = "stellungnahmen";
    }
  
    if ($this->setNavi() and $this->isValidPath()) {
 
      $this->Content = $this->Navi->getContent();
      return true;
    }
 
    return false;
  }
 
  private function setNavi()
  {
    $anz_folders = count($this->folders);
    
    if (!is_array($this->folders) or $anz_folders == 0) {
      return false;
    } elseif (($this->Navi = Tree::findNaviByPermaAndDepth($this->perma, $anz_folders))) {
      if (count($this->args) == 0) {
        $this->args = null;
      }
      return true;
    }
 
    return $this->setArgs();
  }
 
  private function setArgs()
  {
    
    $args = array_pop($this->folders);
    array_unshift($this->args, $args);
    $this->perma = end($this->folders);
    if ("stellungnahmen" === array_get($this->folders, 0)) {
      $this->perma = "stellungnahmen";
    }
 
    return $this->setNavi();
  }
 
  private function isValidArgs()
  {
    return true;
  }
 
  private function isValidNavi()
  {
    if (empty($this->perma)) {
      return true;
    } elseif ("nein" == $this->Navi->is_protected) {
      return true;
    } elseif ("ja" == $this->Navi->is_protected and !$this->is_mitglied) {
      return false;
    } elseif ("nor" == $this->Navi->is_protected and $this->is_mitglied) {
      return false;
    }
 
    return true;
  }
 
  private function isValidPath()
  {
 
    /*
    $node_ary = [];
    $owner = Tree::findFirst($this->Navi->getParentId());
    $this->Navi->getNestedSet($owner);
    if (($nodes = $this->Navi->ancestorsAndSelf())) {
      
      foreach ($nodes as $Node) {
        $node_ary[] = $Node->node_perma;
      }
      $node_ary[] = $this->Navi->node_perma;
      
      return ($this->folders === $node_ary);
    }
    */
 
    return true;
  }
 
  private function getYoutubeVideoPlatzhalter()
  {
 
 
    $Youtubevideo = YoutubeVideo::find();
 
    $YTV_search = [];
    $YTV_replace = [];
 
    foreach ($Youtubevideo as $Video) {
      array_push($YTV_search, $Video->platzhalter);
      array_push($YTV_replace, $Video->code);
    }
 
    $this->view->setVar('YTVsearch', $YTV_search);
    $this->view->setVar('YTVreplace', $YTV_replace);
  }
 
  private function setMedium4Adventskalender()
  {
 
 
    //die("Hier");
    if (IS_LAB) {
      $DatumJetzt = new \DateTime('2019-12-01');
      #$DatumJetzt = new \DateTime();
      $datum = isset($_GET['kalender_datum']) ? $_GET['kalender_datum'] : false;
    } else {
      $DatumJetzt = new \DateTime();
      // $datum = false;
      // Wegen den Vergangenen Türchen
      $datum = isset($_GET['kalender_datum']) ? $_GET['kalender_datum'] : false;
    }
 
 
    $DatumDezember = new \DateTime((new \DateTime)->format('Y') . '-12-01');
 
    if ($datum or ($DatumJetzt >= $DatumDezember)) {
      if (!$datum) {
        $datum = $DatumJetzt->format("Y-m-d");
      }
 
      if ($AdventsTag = \App\Models\AdventListe::findFirst(["datum = '" . $datum . "'"])) {
 
        $this->view->setVar("AdventsTag", $AdventsTag);
      }
    }
  }
 
  private function setMedien4Adventskalender()
  {
    $DatumJetzt = new \DateTime('now');
    //$DatumJetzt = new \DateTime('2017-12-24');
    $args = [
      "datum <= '" . $DatumJetzt->format("Y-m-d") . "'",
      "order" => "datum",
    ];
    if (($medien = Medium::find($args))) {
      $this->view->setVar("medien", $medien);
    }
  }
 
  private function setViewIndexVars()
  {
 
    $this->setMedium4Adventskalender();
 
    $this->view->setVar("is_index", true);
 
 
    if (($Tipp = Tipp::getTipp4Index())) {
      $this->view->setVar("Tipp", $Tipp);
    }
 
    if (($themas = Thema::getThemaPage())) {
      $this->view->setVar("themas", $themas);
    }
 
    if (($Snippet = Snippet::findFirst("snippet_perma = 'ServiceTeaser'"))) {
      $this->view->setVar("Snippet", $Snippet);
    }
 
    if (($smallTeaser = Teaser::findFirst("teaser_perma = 'smallteaser'"))) {
      $this->view->setVar("SmallTeaser", $smallTeaser);
    }
 
    if (($pressemitteilungen = self::getPressemitteilungPage(null, "deutsch"))) {
      $item_ary = [];
      foreach ($pressemitteilungen->items as $Pressemitteilung) {
        $Paragraphs = getParagraphs($Pressemitteilung['mail']->mail_vorwort);
        if ($Pressemitteilung['mail']->mail_vorwort == $Paragraphs->prepend) {
          $Pressemitteilung->weiterlesenLink = false;
        } else {
          $Pressemitteilung->weiterlesenLink = true;
          $Pressemitteilung['mail']->mail_vorwort = $Paragraphs->prepend;
        }
 
        $item_ary[] = $Pressemitteilung;
      }
      $this->view->setVar("pressemitteilungen", $item_ary);
    }
 
    if (($PressemitteilungNode = Tree::findNodeByModulClass("Pressemitteilung"))) {
      $path = parent::getPathByNodeID($PressemitteilungNode->id);
      $this->view->setVar("link2pressemitteilung", $path);
    }
 
    if (($facebookPosts = FacebookPost::getFacebookPosts())) {
      $this->view->setVar("facebook_posts", $facebookPosts);
    } else {
      $facebookPosts = [];
    }
 
    if (($twitterTweets = TwitterTweet::getTwitterTweets())) {
      $this->view->setVar("twitter_tweets", $twitterTweets);
    } else {
      $twitterTweets = [];
    }
  }
 
  private function setViewListeVars($Liste)
  {
 
    $this->view->setVar("Liste", $Liste);
 
    if ("Mitarbeiter" == $Liste->liste_class) {
      if (($PageObj = self::getMitarbeiterPage())) {
        $this->view->setVar('mitarbeiter', $PageObj);
      }
    } elseif ("Faq" == $Liste->liste_class) {
      if (($PageObj = self::getFaqPage())) {
        $this->view->setVar('faqs', $PageObj);
      }
    } elseif ("FaqKfz" == $Liste->liste_class) {
      if (($PageObj = self::getFaqKfzPage())) {
        $this->view->setVar('faqs_kfz', $PageObj);
      }
    } elseif ("Kooperationspartner" == $Liste->liste_class) {
      if (($PageObj = self::getKooperationspartnerPage())) {
        $this->view->setVar('kooperationspartner', $PageObj);
      }
    } elseif ("Stellenangebot" == $Liste->liste_class) {
      if (($PageObj = self::getStellenangebotPage())) {
        $this->view->setVar('stellenangebot', $PageObj);
      }
    } elseif ("Aufsichtsrat" == $Liste->liste_class) {
      if (($PageObj = self::getAufsichtsratPage())) {
        $this->view->setVar('aufsichtsrat', $PageObj);
      }
    } elseif ("Vorstand" == $Liste->liste_class) {
      if (($PageObj = self::getVorstandPage())) {
        $this->view->setVar('vorstand', $PageObj);
      }
    } elseif ("Organe" == $Liste->liste_class) {
      if (($PageObj = self::getAufsichtsratPage())) {
        $this->view->setVar('aufsichtsrat', $PageObj);
      }
      if (($PageObj = self::getVorstandPage())) {
        $this->view->setVar('vorstand', $PageObj);
      }
    } elseif ("PressefotoListe" == $Liste->liste_class) {
      if ($this->is_presse) {
        $PageObj = self::getPressefotoListePage();
        $this->view->setVar('pressefoto_liste', $PageObj);
      } elseif (($Modul = Modul::findFirst("modul_class = 'UserLogin'"))) {
        $this->setViewModulVars($Modul);
        if (($Content = Content::findFirst('modul_id = ' . $Modul->getKey()))) {
          $this->view->Content = $Content;
        }
      }
    } elseif ("Agenda" == $Liste->liste_class) {
      if (($PageObj = self::getAgendaPage())) {
        $this->view->setVar('agenda', $PageObj);
      }
    } elseif ("Broschuere" == $Liste->liste_class) {
 
      if (($PageObj = self::getBroschuerePage('deutsch'))) {
        $this->view->setVar('broschuere', $PageObj);
      }
    } elseif ("Beirat" == $Liste->liste_class) {
      if (($PageObj = self::getBeiratPage())) {
        $this->view->setVar('beirat', $PageObj);
      }
    } elseif ("Leitfaden" == $Liste->liste_class) {
      if (($PageObj = self::getLeitfadenPage())) {
        $this->view->setVar('leitfaden', $PageObj);
      }
    } elseif ("Flyer" == $Liste->liste_class) {
      if (($PageObj = self::getFlyerPage())) {
        $this->view->setVar('flyer', $PageObj);
      }
    } elseif ("Bdvinfo" == $Liste->liste_class) {
      if (($PageObj = self::getBdvinfoPage())) {
        $this->view->setVar('bdvinfo', $PageObj);
      }
    } elseif ("DownloadListe" == $Liste->liste_class) {
      if ($this->is_mitglied) {
        $PageObj = self::getDownloadListePage();
        $this->view->setVar('download_liste', $PageObj);
      }
    } elseif ("Sitemap" == $Liste->liste_class) {
      $sitemap = new SitemapGenerator();
      $sitemap->setConfig($this->config);
      $sitemap->setTree($this->Tree);
      $sitemap->generate();
      $sitemap->print();
      exit;
    }
  }
 
  private function setViewModulVars($Modul)
  {
 
 
    if (strlen($Modul->modul_template)) {
      $this->view->setVar("Modul", $Modul);
    }
 
    // Suche
    if ("Medium" === $Modul->modul_class) {
      $this->setMedien4Adventskalender();
    } elseif ("Suche" === $Modul->modul_class) {
      
      $this->response->setHeader("Cache-Control", "max-age=180");
      $search_string = $this->request->getPost("search_string");
 
      $Suche = new SuchePlugin();
      $Suche->setPathAry($this->path_ary);
 
      $this->view->setVar("search_string", $search_string);
      $this->view->setVar("search_result", $Suche->getSearchResultByPostRequest($search_string));
    }
    // MitgliedIndex
    elseif ("MitgliedIndex" === $Modul->modul_class) {
      if (($ary = $this->session->get("mitglied"))) {
        $this->Content->content_headline .= ' ' . array_get($ary, "vorname") . ' ' . array_get($ary, "nachname");
        $this->view->setVar("Content", $this->Content);
      }
 
      $PageObj = self::getNewsPage([]);
      $this->view->setVar('news_items', NewsPlugin::getNewsItems($PageObj));
      $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
    }
    // Pressemitteilung
    elseif ("Pressemitteilung" === $Modul->modul_class) {
 
      if ($key = $this->request->get("print") and $PmModel = Pressemitteilung::getPressemitteilungByKey($key)) {
        PressemitteilungPdf::outputPdf($PmModel);
      } else {
 
        $this->args = $this->args ?? [];
        $FilterSegments = FilterSegment::getFilterSegments($this->args ?? []);
        $FilterArrays = Pressemitteilung::getFilterArrays($FilterSegments);
        $this->setViewFilterSegments($FilterSegments);
        $is404 = false;
        if ($FilterArrays) {
          if (count($this->args) === 1 and !is_numeric($this->args[0]) and !Pressemitteilung::findFirst("kategorie_perma = '" . array_get($this->args, 0) . "'")) {
            if (($MailObj = Pressemitteilung::getPressemitteilungByPerma(array_get($this->args, 0)))) {
 
              $this->view->setVar('Pressemitteilung', PressemitteilungPlugin::getPressemitteilungItem($MailObj));
              // facebook_metas fuer Detailseite vorbereiten 
              $site_url = $this->config->url->httpScheme . $this->config->url->hostName;
              $page_url = $site_url . $this->request->getURI();
              $image_url = $site_url . $MailObj->getLink2Image();
              $facebook_metas = Pressemitteilung::getPressemitteilungMetas($MailObj, $page_url, $image_url);
 
              $extra_fb_meta_image = $MailObj->getLink2ThirdImage();
 
              if (empty($extra_fb_meta_image)) {
                $extra_fb_meta_image = $MailObj->getLink2Image();
              }
 
              if (!empty($extra_fb_meta_image)) {
                $this->view->setVar('extra_fb_meta_image', $extra_fb_meta_image);
              }
 
 
              $this->view->setVar('facebook_metas', $facebook_metas);
              $this->tag->title()->set($MailObj->mail_subject . ' - Bund der Versicherten');
              $this->view->setVar('meta_keywords', $MailObj->mail_subject);
              $this->view->setVar('title', $MailObj->mail_subject);
              $this->view->setVar('meta_description', $MailObj->mail_subline);
            } else {
              $is404 = true;
              $this->get404Page();
            }
          } elseif (($PageObj = self::getPressemitteilungPage($FilterSegments))) {
            $this->view->setVar('pressemitteilung_items', PressemitteilungPlugin::getPressemitteilungItems($PageObj));
            $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
          }
 
          if (!$is404) {
            $this->view->setVar('page_link', '/' . implode("/", $this->folders));
            $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
            $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
            $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
          }
        }
      }
    } elseif ("Musterbrief" == $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $kategorie_filter = $FilterSegments->kategorie_filter;
 
      $this->view->setVar('kategorie_filter', "alle");
      $this->view->setVar('liste_ary', MusterbriefListe::getMusterbriefListen());
      $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
      if ($kategorie_filter and $PageObj = self::getMusterbriefListePage($FilterSegments)) {
        $this->view->setVar('musterbrief_liste', $PageObj);
        $this->view->setVar('kategorie_filter', $FilterSegments->kategorie_filter);
      } else {
        $this->view->setVar('musterbrief_liste', self::getMusterbriefListePage());
      }
 
      $this->view->setVar('hat_beliebte_musterbriefe', false);
      if (MusterbriefListe::getMusterbriefListen(["is_beliebt" => true])) {
        $this->view->setVar('hat_beliebte_musterbriefe', true);
      }
    }
    // Beitrag 
    elseif ("Beitrag" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = BeitragKategorie::getFilterArrays($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
 
      if ($FilterArrays) {
        $this->args = $this->args ?? [];
        $arg = ((count($this->args) === 1 and !is_numeric($this->args[0])) ? array_get($this->args, 0) : false);
        if ($arg and !BeitragKategorie::findFirst("kategorie_perma = '" . $arg . "'")) {
          $params = "beitrag_perma = '" . $arg . "' AND is_online = 'ja'";
          if (($Beitrag = Beitrag::findFirst($params))) {
            $this->view->setVar('Beitrag', BeitragPlugin::getBeitragItem($Beitrag));
          } else {
            $this->get404Page();
          }
        } elseif (($PageObj = self::getBeitragPage($FilterSegments))) {
          $this->view->setVar('beitrag_items', BeitragPlugin::getBeitragItems($PageObj));
          $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
        }
 
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
        $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
      }
    }
    // Stellungnahme
    elseif ("Stellungnahme" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = StellungnahmeKategorie::getFilterArrays($FilterSegments);
      $PageObj = self::getStellungnahmePage($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
      if ($FilterArrays and $PageObj) {
        $this->view->setVar('stellungnahme_items', StellungnahmePlugin::getStellungnahmeItems($PageObj));
        $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
        $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
      }
    } elseif ("LandingPage" === $Modul->modul_class) {
      #die("Hier");
    } // Termin
    elseif ("Termin" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = TerminKategorie::getFilterArrays($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
      if (is_object($FilterSegments) and "termine" == $FilterSegments->kategorie_filter) {
        $termin_ary = self::getTerminAry($FilterSegments);
        $Modul->modul_template = "termin-liste";
 
        $this->view->setVar("Modul", $Modul);
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('termin_ary', $termin_ary);
      } else {
        $PageObj = self::getTerminPage($FilterSegments);
        if ($FilterArrays and $PageObj) {
          $this->view->setVar('termin_items', TerminPlugin::getTerminItems($PageObj));
          $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
          $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
          $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
          $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
          $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
        }
 
        if (!$this->args and ($termin_ary = self::getTerminAry([]))) {
          $this->view->setVar('termin_ary', $termin_ary);
        } elseif (!empty($FilterSegments->jahr_filter) and empty($FilterSegments->kategorie_filter) and empty($FilterSegments->monat_filter)) {
          if (($termin_ary = self::getTerminAry($FilterSegments))) {
            $this->view->setVar('termin_ary', $termin_ary);
          }
        }
      }
    }
    // Beitrittserklärung
    elseif ("Beitrittserklaerung" === $Modul->modul_class) {
 
      $this->view->setVar('bundeslaender', Bundesland::find());
      $this->view->setVar('laender', Land::find(["order" => "pos"]));
 
      $objs = Kampagne::find(["is_online = 'ja'", "order" => "pos"]);
      $this->view->setVar('kampagne_ary', $objs);
    }
    // Meine Anschrift
    elseif ("MeineAnschrift" === $Modul->modul_class) {
 
      $this->view->setVar('laenderAlle', LandAlle::find(["order" => "id"]));
    }
    // Wita
    elseif ("Wita" === $Modul->modul_class) {
 
 
      if (empty($this->args)) {
        //$this->args = [date('Y')];
        // Hier soll das höchste jahr genommen werden
        $witas = Wita::fetchWitas();
        $Wita = $witas[0];
        $year = date('Y', strtotime($Wita->datum_von));
        $this->args = [$year];
      }
 
      if (($Wita = Wita::fetchWita($this->args))) {
        $this->view->setVar('logged_in', false);
        $this->view->setVar('Wita', $Wita);
        $this->view->setVar('referenten', WitaReferent::fetchReferentenByWita($Wita));
 
        if (checkSession(['wita', $Wita->login_code])) {
          $this->view->setVar('logged_in', true);
          $this->view->setVar('vortraege', WitaVortrag::fetchVortraegeByWitaID($Wita->getKey()));
          $this->view->setVar('teilnehmer', $Wita->getTeilnehmer());
        }
        if (($witas = Wita::fetchWitas())) {
          $counter = 0;
          $link_ary = [];
          foreach ($witas as $TmpWita) {
            //$wita_link = '/' . implode("/", $this->folders) . (($counter > 0) ? '/' . $TmpWita->wita_jahr : null);
            $wita_link = '/' . implode("/", $this->folders) . '/' . $TmpWita->wita_jahr;
            $link_ary[] = ['link' => $wita_link, 'jahr' => $TmpWita->wita_jahr];
            $counter++;
          }
          $this->view->setVar('wita_links', $link_ary);
        }
      } else {
        $this->get404Page();
      }
    }
    // Newsletter
    elseif ("Newsletter" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments4Newsletter($this->args);
      $FilterArrays = Newsletter::getFilterArrays($FilterSegments);
 
      $this->view->setVar("show_form", false);
      $this->view->setVar("show_liste", false);
      $this->view->setVar("is_subscriber", null);
 
      if ($FilterSegments->jahr_filter) {
        if (($newsletter = Newsletter::fetchNewsletterByJahr($FilterSegments->jahr_filter))) {
          $this->view->setVar("show_liste", true);
          $this->view->setVar("newsletter", $newsletter);
        }
      } elseif ($FilterSegments->perma_filter) {
        if (($Newsletter = Newsletter::findFirst("mail_perma = '" . $FilterSegments->perma_filter . "'"))) {
          $this->view->setVar("Newsletter", $Newsletter);
          $this->view->setVar("newsletterArtikel", $Newsletter->newsletterArtikel);
          $FilterSegments->jahr_filter = $Newsletter->jahr;
 
          if (($newsletter = Newsletter::fetchNewsletterByJahr($Newsletter->jahr))) {
            $this->view->setVar("newsletter", $newsletter);
          }
        }
      } elseif (($Newsletter = Newsletter::fetchLastNewsletter())) {
        $this->view->setVar("Newsletter", $Newsletter);
        $this->view->setVar("newsletterArtikel", $Newsletter->newsletterArtikel);
 
        if ($mitglied_ary = $this->session->get("mitglied")) {
          $this->view->setVar("show_form", true);
          $this->view->setVar("is_subscriber", (("N" == array_get($mitglied_ary, "newsletter")) ? false : true));
        }
      }
 
      $this->setViewFilterSegments($FilterSegments);
      $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
      $this->view->setVar("page_link", '/' . implode("/", $this->folders));
    }
    // Englisch
    elseif ("Englisch" === $Modul->modul_class) {
      $this->view->setVar("is_englisch", true);
 
      /*
       * snippet text
       */
 
      if (($snippet_text = Snippet::getSnippetTextByPerma("BoxEnglisch"))) {
        $this->view->setVar("snippet_text", $snippet_text);
      }
 
      /*
       * pressemitteilung
       */
      if (($PageObj = self::getPressemitteilungPage(null, "englisch"))) {
        if (($PressemitteilungNode = Tree::findNodeByModulClass("Pressemitteilung"))) {
          $path = parent::getPathByNodeID($PressemitteilungNode->id);
          $this->view->setVar("link2pressemitteilung", $path);
        }
 
        $item_ary = [];
        foreach ($PageObj->items as $Item) {
          $Paragraphs = getParagraphs($Item['mail']->mail_vorwort);
          $Item['mail']->mail_vorwort = $Paragraphs->prepend;
          $item_ary[] = $Item;
        }
 
        $this->view->setVar("pressemitteilungen", $item_ary);
      }
 
      /*
       * stellungnahme
       */
      if (($PageObj = self::getStellungnahmePage(null, "englisch"))) {
        if (($StellungnahmeNode = Tree::findNodeByModulClass("Stellungnahme"))) {
          $path = parent::getPathByNodeID($StellungnahmeNode->id);
          $this->view->setVar("link2stellungnahme", $path);
        }
 
        $item_ary = [];
        foreach ($PageObj->items as $Item) {
          $Paragraphs = getParagraphs($Item['stellungnahme']->stellungnahme_text);
          $Item['stellungnahme']->stellungnahme_text = $Paragraphs->prepend;
          $item_ary[] = $Item;
        }
 
        $this->view->setVar('stellungnahme', $item_ary);
      }
      /*
       * broschuere
       */
      if (($PageObj = self::getBroschuerePage("englisch"))) {
        $this->view->setVar('broschuere', $PageObj);
      }
    } elseif ("BedarfsCheck" === $Modul->modul_class) {
      $calcBerufAry = CalcBeruf::find([null, 'order' => "pos"]);
      $calcFamilieAry = CalcFamilie::find([null, 'order' => "pos"]);
      $calcZusatzBinAry = CalcZusatz::find(["typ = 'was-bin-ich'", 'order' => "pos"]);
      $calcZusatzBesitzeAry = CalcZusatz::find(["typ = 'was-besitze-ich'", 'order' => "pos"]);
 
      $this->view->setVar('beruf_ary', $calcBerufAry);
      $this->view->setVar('familie_ary', $calcFamilieAry);
      $this->view->setVar('zusatz_bin_ary', $calcZusatzBinAry);
      $this->view->setVar('zusatz_besitze_ary', $calcZusatzBesitzeAry);
    } elseif ("Kontakt" === $Modul->modul_class) {
      $this->view->setVar('anliegen', []);
      if (($anliegen = Kontakt::find(["order" => "pos"]))) {
        $this->view->setVar('anliegen', $anliegen);
      }
    } elseif ("Bewerbung" === $Modul->modul_class) {
 
      $this->view->setVar('widerruf', "");
      $this->view->setVar('stellenangebote', []);
 
      if (($stellenangebote = self::getStellenangebotPage()) and $stellenangebote->count()) {
        $this->view->setVar('stellenangebote', self::getStellenangebotPage());
      }
 
      if (($widerruf = Snippet::getSnippetTextByPerma("BewerbungWiderruf"))) {
        $this->view->setVar('widerruf', strip_tags($widerruf, "<a>"));
      }
    }
  }
 
  private function setViewFilterSegments($FilterSegments)
  {
    $this->view->setVar('kategorie_filter', "");
    $this->view->setVar('jahr_filter', "");
    $this->view->setVar('monat_filter', "");
    $this->view->setVar('perma_filter', "");
 
    if (isset($FilterSegments)) {
      if (isset($FilterSegments->kategorie_filter) and ($kategorie = $FilterSegments->kategorie_filter)) {
        $this->view->setVar('kategorie_filter', LINK_ROOT . $kategorie);
 
        if (($jahr = $FilterSegments->jahr_filter)) {
          $this->view->setVar('jahr_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr);
          if (($monat = $FilterSegments->monat_filter)) {
            $this->view->setVar('monat_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr . LINK_ROOT . $monat);
          } else {
            $this->view->setVar('monat_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr);
          }
        }
      } elseif (($jahr = $FilterSegments->jahr_filter)) {
        $this->view->setVar('jahr_filter', LINK_ROOT . $jahr);
 
        if (isset($FilterSegments->monat_filter) and ($monat = $FilterSegments->monat_filter)) {
          $this->view->setVar('monat_filter', LINK_ROOT . $jahr . LINK_ROOT . $monat);
        }
 
        if (isset($FilterSegments->perma_filter) and ($perma = $FilterSegments->perma_filter)) {
          $this->view->setVar('perma_filter', $perma);
        }
      }
    }
  }
 
  private function procModulAction($Modul)
  {
    if ("Logout" == $Modul->modul_class) {
      (new LogoutPlugin())->procAction();
    } elseif ("Optin" == $Modul->modul_class) {
      (new OptinPlugin())->procAction();
    }
  }
 
  private function setViewRisikoklasse($Risikoklasse)
  {
    $merkblaetter = $Risikoklasse->getMerkblaetter($this->is_mitglied);
    $link2beitrittserklaerung = $this->getPathByModulClass("Beitrittserklaerung");
 
    $this->view->setVar("Risikoklasse", $Risikoklasse);
    $this->view->setVar("merkblaetter", $merkblaetter);
    $this->view->setVar("link2beitrittserklaerung", LINK_ROOT . $link2beitrittserklaerung);
 
    if (($Snippet = Snippet::findFirst("snippet_perma = 'MerkblattHinweis'"))) {
      $this->view->setVar("Snippet", $Snippet);
    }
  }
 
  /*
   * Pages
   */
 
  private static function getNewsPage()
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$news_limit);
 
    return News::getNewsPage($args);
  }
 
  private static function getMusterbriefListePage($FilterSegments = null)
  {
    $args = [];
    if ($FilterSegments) {
      if ("beliebteste" == $FilterSegments->kategorie_filter) {
        array_set($args, "is_beliebt", "ja");
      } else {
        array_set($args, "liste_perma", $FilterSegments->kategorie_filter);
      }
    }
    return MusterbriefListe::getMusterbriefListePage($args);
  }
 
  private static function getPressemitteilungPage($FilterSegments = null, $lang = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$news_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    if ($lang) {
      array_set($args, "mail_sprache", $lang);
    }
 
    return Pressemitteilung::getPressemitteilungPage($args);
  }
 
  private static function getStellungnahmePage($FilterSegments = null, $lang = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$stellungnahme_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    if ($lang) {
      array_set($args, "lang", $lang);
    }
 
    return Stellungnahme::getStellungnahmePage($args);
  }
 
  private static function getBeitragPage($FilterSegments = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$beitrag_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    return Beitrag::getBeitragPage($args);
  }
 
  private static function getTerminPage($FilterSegments = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$termin_limit);
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    return Termin::getTerminPage($args);
  }
 
  private static function getTerminAry($FilterSegments)
  {
    $args = [];
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
    }
 
    return Termin::getTerminAry($args);
  }
 
  private static function getMitarbeiterPage()
  {
    $args = ["is_online" => "ja"];
    return Mitarbeiter::getMitarbeiterPage($args);
  }
 
  private static function getFaqPage()
  {
    $args = ["is_online" => "ja"];
    return Faq::getFaqPage($args);
  }
 
  private static function getFaqKfzPage()
  {
    $args = ["is_online" => "ja"];
    return FaqKfz::getFaqKfzPage($args);
  }
 
  private static function getKooperationspartnerPage()
  {
    $args = ["is_online" => "ja"];
    return Kooperationspartner::getKooperationspartnerPage($args);
  }
 
  private static function getStellenangebotPage()
  {
    $args = ["is_online" => "ja"];
    return Stellenangebot::getStellenangebotPage($args);
  }
 
  private static function getAufsichtsratPage()
  {
    $args = ["is_online" => "ja"];
    return Aufsichtsrat::getAufsichtsratPage($args);
  }
 
  private static function getVorstandPage()
  {
    $args = ["is_online" => "ja"];
    return Vorstand::getVorstandPage($args);
  }
 
  private static function getBdvinfoPage()
  {
    $args = ["is_online" => "ja"];
    return Bdvinfo::getBdvinfoPage($args);
  }
 
  private static function getPressefotoListePage()
  {
    $args = [];
    return PressefotoListe::getPressefotoListePage($args);
  }
 
  private static function getAgendaPage()
  {
    $args = ["is_online" => "ja"];
    return Agenda::getAgendaPage($args);
  }
 
  private static function getBroschuerePage($lang)
  {
    $args = ["is_online" => "ja", "lang" => $lang];
    return Broschuere::getBroschuerePage($args);
  }
 
  private static function getBeiratPage()
  {
    $args = ["is_online" => "ja"];
    return Beirat::getBeiratPage($args);
  }
 
  private static function getLeitfadenPage()
  {
    $args = ["is_online" => "ja"];
    return Leitfaden::getLeitfadenPage($args);
  }
 
  private static function getFlyerPage()
  {
    $args = ["is_online" => "ja"];
    return Flyer::getFlyerPage($args);
  }
 
  private static function getDownloadListePage()
  {
    $args = [];
    return DownloadListe::getDownloadListePage($args);
  }
 
  /*
   * phery action 
   */
 
  public function procKontaktForm($args)
  {
    return (new KontaktPlugin())->procAction($args);
  }
 
  public function procInfoEventAnmeldung($args)
  {
    return (new InfoEventPlugin())->procAction($args);
  }
 
  public function procBewerbungForm($args)
  {
    return (new BewerbungPlugin())->procAction($args);
  }
 
  public function procQuickConnectForm($args)
  {
    return (new QuickConnectPlugin())->procAction($args);
  }
 
  public function procBroschuereForm($args)
  {
    return (new BroschuerePlugin())->procAction($args);
  }
 
  public function procBedarfsCheckForm($args)
  {
    return (new BedarfsCheckPlugin())->procAction($args);
  }
 
  public function procSucheForm($args)
  {
    parent::setTreeNavis();
    $SuchePlugin = new SuchePlugin();
    $SuchePlugin->setPathAry($this->path_ary);
 
    return $SuchePlugin->procAction($args);
  }
 
  // liste stuff
  public function procFetchNews($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new NewsPlugin())->procAction($ary);
  }
 
  public function procFetchPressemitteilungen($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new PressemitteilungPlugin())->procAction($ary);
  }
 
  public function procFetchStellungnahmen($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new StellungnahmePlugin())->procAction($ary);
  }
 
  public function procFetchTermine($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$termin_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new TerminPlugin())->procAction($ary);
  }
 
  // user stuff
  public function procUserRegisterForm($args)
  {
    return (new UserRegisterPlugin())->procAction($args);
  }
 
  public function procUserLoginForm($args)
  {
    $Modul = Modul::findFirst("modul_class = 'UserLogin'");
    return (new UserLoginPlugin())->procAction($args, $Modul);
  }
 
  public function procMitgliedLoginForm($args)
  {
    return (new MitgliedLoginPlugin())->procAction($args);
  }
 
  public function procPasswordForm($args)
  {
    return (new PasswordPlugin())->procAction($args);
  }
 
  // wita stuff
  public function procWitaLoginForm($args)
  {
    return (new WitaLoginPlugin())->procAction($args);
  }
 
  public function procWitaNachrichtForm($args)
  {
    return (new WitaNachrichtPlugin())->procAction($args);
  }
 
  public function procWitaAnmeldungForm($args)
  {
    return (new WitaAnmeldungPlugin())->procAction($args);
  }
 
  // mitglied stuff
  public function procMeinPasswortForm($args)
  {
    return (new MeinPasswortPlugin())->procAction($args);
  }
 
  public function procMeineAnschriftForm($args)
  {
    return (new MeineAnschriftPlugin())->procAction($args);
  }
 
  public function procMeineBankverbindungForm($args)
  {
    return (new MeineBankverbindungPlugin())->procAction($args);
  }
 
  public function procMeineZugangsdatenForm($args)
  {
    return (new MeineZugangsdatenPlugin())->procAction($args);
  }
 
  public function procMeineBdvinfoForm($args)
  {
    return (new MeineBdvinfoPlugin())->procAction($args);
  }
 
  public function procBdvNewsletterForm($args)
  {
    return (new BdvNewsletterPlugin())->procAction($args);
  }
 
  public function procBeitrittserklaerungForm($args)
  {
    return (new BeitrittserklaerungPlugin())->procAction($args);
  }
 
  // mitglied login stuff
  public function procGetMitgliedLoginForm()
  {
    $request_uri = strtok($this->request->getURI(), "?");
    return (new MitgliedLoginWidget())->getForm($request_uri);
  }
 
  public function procSendMitgliedLoginForm($args)
  {
    return (new MitgliedLoginPlugin())->procAction($args);
  }
 
  public function procIsLoggedIn()
  {
    $tmp_ary = ["status" => $this->is_mitglied];
    return PheryResponse::factory()->json($tmp_ary);
  }
 
  // stuff
  public function procGetContentPopup($args)
  {
    return (new ContentPopupPlugin())->procAction($args);
  }
 
  public function procSetCookieCheck()
  {
    $time = time() + 365 * 86400;
    setcookie("cookie-check", "ja", $time);
  }
 
  /*
   * Phery
   */
 
  private function setPhery($remote = null)
  {
    $Phry = Phery::instance();
 
    if ("kontakt" == $remote) {
      $Phry->set([$remote => [$this, 'procKontaktForm']]);
    } elseif ("send_info_event" == $remote) {
      $response = $this->procInfoEventAnmeldung($this->request);
      echo json_encode($response);
      exit;
    } elseif ("bewerbung" == $remote) {
      $Phry->set([$remote => [$this, 'procBewerbungForm']]);
    } elseif ("quick_connect" == $remote) {
      $Phry->set([$remote => [$this, 'procQuickConnectForm']]);
    } elseif ("broschuere" == $remote) {
      $Phry->set([$remote => [$this, 'procBroschuereForm']]);
    } elseif ("bedarfscheck" == $remote) {
      $Phry->set([$remote => [$this, 'procBedarfsCheckForm']]);
    } elseif ("send_suche_form" == $remote) {
      $Phry->set([$remote => [$this, 'procSucheForm']]);
    }
    // liste stuff
    elseif ("fetch_news" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchNews']]);
    } elseif ("fetch_pressemitteilungen" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchPressemitteilungen']]);
    } elseif ("fetch_stellungnahmen" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchStellungnahmen']]);
    } elseif ("fetch_termine" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchTermine']]);
    }
    // user stuff
    elseif ("send_password_form" == $remote) {
      $Phry->set([$remote => [$this, 'procPasswordForm']]);
    } elseif ("user_register" == $remote) {
      $Phry->set([$remote => [$this, 'procUserRegisterForm']]);
    } elseif ("user_login" == $remote) {
      $Phry->set([$remote => [$this, 'procUserLoginForm']]);
    }
    // wita stuff
    elseif ("wita_login" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaLoginForm']]);
    } elseif ("wita_nachricht" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaNachrichtForm']]);
    } elseif ("wita_anmeldung" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaAnmeldungForm']]);
    }
    // mitgliederbereich stuff
    elseif ("mitglied_login" == $remote) {
      $Phry->set([$remote => [$this, 'procMitgliedLoginForm']]);
    } elseif ("mein_passwort" == $remote) {
      $Phry->set([$remote => [$this, 'procMeinPasswortForm']]);
    } elseif ("meine_anschrift" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineAnschriftForm']]);
    } elseif ("meine_bankverbindung" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineBankverbindungForm']]);
    } elseif ("meine_zugangsdaten" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineZugangsdatenForm']]);
    } elseif ("meine_bdvinfo" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineBdvinfoForm']]);
    } elseif ("bdv_newsletter" == $remote) {
      $Phry->set([$remote => [$this, 'procBdvNewsletterForm']]);
    } elseif ("beitrittserklaerung" == $remote) {
      $Phry->set([$remote => [$this, 'procBeitrittserklaerungForm']]);
    }
    // mitglied login
    elseif ("get_login_form" == $remote) {
      $Phry->set([$remote => [$this, 'procGetMitgliedLoginForm']]);
    } elseif ("send_login_form" == $remote) {
      $Phry->set([$remote => [$this, 'procSendMitgliedLoginForm']]);
    } elseif ("is_logged_in" == $remote) {
      $Phry->set([$remote => [$this, 'procIsLoggedIn']]);
    }
    // stuff
    elseif ("get_content_popup" == $remote) {
      $Phry->set([$remote => [$this, 'procGetContentPopup']]);
    } elseif ("set_cookie_check" == $remote) {
      $Phry->set([$remote => [$this, 'procSetCookieCheck']]);
    }
 
    $Phry->process();
  }
}
#3App\Controllers\Web\ContentController->setView
/var/www/vhosts/bundderversicherten.de/app/Controllers/Web/ContentController.php (176)
<?php
 
namespace App\Controllers\Web;
 
use Phery\Phery;
use Phery\PheryResponse;
use Phalcon\Http\Request;
use App\Models\UrlVerkuerzer;
use App\Models\Tree;
use App\Models\Content;
// index
use App\Models\Tipp;
use App\Models\Medium;
use App\Models\Snippet;
// modul
use App\Models\News;
use App\Models\Wita;
use App\Models\Modul;
use App\Models\Content as StaticContent;
use App\Models\Termin;
use App\Models\Kontakt;
use App\Models\Beitrag;
use App\Models\WitaVortrag;
use App\Models\WitaReferent;
use App\Models\Stellungnahme;
use App\Models\MusterbriefListe;
use App\Models\Newsletter;
use App\Models\TerminKategorie;
use App\Models\BeitragKategorie;
use App\Models\StellungnahmeKategorie;
// beitrittserklaerung
use App\Models\Land;
use App\Models\Bundesland;
use App\Models\Kampagne;
// meine anschrift
use App\Models\LandAlle;
// liste
use App\Models\Faq;
use App\Models\FaqKfz;
use App\Models\Flyer;
use App\Models\Thema;
use App\Models\Teaser;
use App\Models\Agenda;
use App\Models\Mythen;
use App\Models\CoronaMythen;
use App\Models\Beirat;
use App\Models\Bdvinfo;
use App\Models\Vorstand;
use App\Models\Leitfaden;
use App\Models\Broschuere;
use App\Models\Mitarbeiter;
use App\Models\Aufsichtsrat;
use App\Models\FacebookPost;
use App\Models\TwitterTweet;
use App\Models\DownloadListe;
use App\Models\Stellenangebot;
use App\Models\PressefotoListe;
use App\Models\Pressemitteilung;
use App\Models\Kooperationspartner;
use App\Models\LinkTracking;
use App\Models\Newsletter\Mail;
use App\Models\Youtubevideo;
// system and helper
use App\Helper\Pagination;
use App\Helper\FilterSegment;
use App\Helper\PressemitteilungPdf;
use App\Helper\SitemapGenerator;
use App\Controllers\Web\BaseController;
// widgets
use App\Widgets\Web\MitgliedLoginWidget;
// plugins
use App\Plugins\Web\News as NewsPlugin;
use App\Plugins\Web\Optin as OptinPlugin;
use App\Plugins\Web\Suche as SuchePlugin;
use App\Plugins\Web\Logout as LogoutPlugin;
use App\Plugins\Web\Termin as TerminPlugin;
use App\Plugins\Web\Beitrag as BeitragPlugin;
use App\Plugins\Web\Kontakt as KontaktPlugin;
use App\Plugins\Web\InfoEvent as InfoEventPlugin;
use App\Plugins\Web\Bewerbung as BewerbungPlugin;
use App\Plugins\Web\Password as PasswordPlugin;
use App\Plugins\Web\WitaLogin as WitaLoginPlugin;
use App\Plugins\Web\UserLogin as UserLoginPlugin;
use App\Plugins\Web\Broschuere as BroschuerePlugin;
use App\Plugins\Web\QuickConnect as QuickConnectPlugin;
use App\Plugins\Web\MeinPasswort as MeinPasswortPlugin;
use App\Plugins\Web\UserRegister as UserRegisterPlugin;
use App\Plugins\Web\MeineBdvinfo as MeineBdvinfoPlugin;
use App\Plugins\Web\BdvNewsletter as BdvNewsletterPlugin;
use App\Plugins\Web\ContentPopup as ContentPopupPlugin;
use App\Plugins\Web\Stellungnahme as StellungnahmePlugin;
use App\Plugins\Web\MitgliedLogin as MitgliedLoginPlugin;
use App\Plugins\Web\WitaNachricht as WitaNachrichtPlugin;
use App\Plugins\Web\WitaAnmeldung as WitaAnmeldungPlugin;
use App\Plugins\Web\MeineAnschrift as MeineAnschriftPlugin;
use App\Plugins\Web\Pressemitteilung as PressemitteilungPlugin;
use App\Plugins\Web\MeineZugangsdaten as MeineZugangsdatenPlugin;
use App\Plugins\Web\MeineBankverbindung as MeineBankverbindungPlugin;
use App\Plugins\Web\Beitrittserklaerung as BeitrittserklaerungPlugin;
use App\Plugins\Web\ContentPopup as ContentPopup;
// bedarfscheck
use App\Models\CalcBeruf;
use App\Models\CalcZusatz;
use App\Models\CalcFamilie;
use App\Plugins\Web\BedarfsCheck as BedarfsCheckPlugin;
 
class ContentController extends BaseController
{
 
  private static $news_limit = 3;
  private static $termin_limit = 3;
  private static $beitrag_limit = 3;
  private static $stellungnahme_limit = 3;
 
  public function linkTrackerAction()
  {
 
    $unique_id = htmlentities($this->request->get('u'), ENT_QUOTES);
    $TrackingLink = LinkTracking::findFirst(["link_id = '" . $unique_id . "'"]);
    $TrackingLink->hits = $TrackingLink->hits + 1;
    $TrackingLink->save();
 
    header('Location: ' . $TrackingLink->target);
    exit;
  }
 
  public function countImageAction($args)
  {
    $unique_id = htmlentities($this->request->get('u'), ENT_QUOTES);
    if (!empty($unique_id)) {
      if ($Mail = Mail::findFirst(["count_id = '$unique_id'"])) {
        $Mail->opened = $Mail->opened + 1;
        $Mail->save();
      }
    }
    header("Content-type: image/png");
    $im = imagecreate(1, 1);
    imagecolorallocate($im, 255, 255, 255);
    imagepng($im);
    imagedestroy($im);
    exit;
  }
 
  public function shortURLRedirect()
  {
    $short_url = $_SERVER['REQUEST_URI'];
    $short_url = substr($short_url, 1);
    if (!empty($short_url)) {
      if (($UrlVerkuerzer = UrlVerkuerzer::findFirst("url_kurz='" . $short_url . "'"))) {
        $httpScheme = $this->config->url->httpScheme;
        $hostName = $this->config->url->hostName;
        header("Location:" . $httpScheme . $hostName . "/" . $UrlVerkuerzer->url_ziel);
        exit();
      }
    }
  }
 
  public function indexAction()
  {
 
    if (Phery::is_ajax()) {
 
      $args = $_REQUEST['args'] ?? [];
      if (isset($args['content']) && $args['content'] == 'cookie-check') {
        $PheryResonse = (new ContentPopup())->procAction($args);
        echo $PheryResonse;
        exit;
      }
    }
 
    parent::setBaseValues();
 
    $this->shortURLRedirect();
    
    if (!Phery::is_ajax()) {
      $this->setView();
    } elseif (!$this->isIndex() and (!$this->setContent() or !$this->isValidNavi())) {
      // ToDo: phery error
    } else {
      $phery_request = $this->request->getPost('phery');
      $remote = array_get($phery_request, "remote");
 
      $this->setPhery($remote);
    }
  }
 
  private function setCoronaLandingPageVars()
  {
 
    //JSON - Mythos daten
    $mythen_orig = CoronaMythen::find(['order' => 'gruppe ASC']);
    foreach ($mythen_orig as $mythos) {
      $mythos->antwort = strip_tags($mythos->antwort);
      $mythos->mythos = strip_tags($mythos->mythos);
      $mythos->name = strip_tags($mythos->name);
      $mythen[] = $mythos;
    }
    $this->view->setVar('mythenArray', $mythen);
    // Footer Variablen Laden 
    $this->Tree = new Tree();
    $this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
    $this->Tree->getOffsiteNodes($this->session);
 
    if (($footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session))) {
      $this->view->setVar("footer_navi_nodes", $footer_navi_nodes);
      ob_start();
      $this->view->partial('partials/footerMenu', ['footer_navi_nodes' => $footer_navi_nodes]);
      $menu_html = ob_get_clean();
 
      if (($Footer = \App\Models\Footer::findFirst(array('id' => 1)))) {
        $footer_html = $Footer->text;
        $footer_html = str_replace("[# footerSocial #]", '', $footer_html);
 
        if (isset($menu_html)) {
          $footer_html = str_replace("[# footerMenu #]", $menu_html, $footer_html);
        }
        $this->view->setVar("footer_test", $footer_html);
      }
    }
    //Footer ende
 
    $LandingPage = \App\Models\LandingPageCorona::findFirst();
    $this->tag->title()->set($LandingPage->meta_title);
    $this->view->setVar('meta_description', $LandingPage->meta_description);
    $this->view->setVar('meta_keywords', $LandingPage->meta_keywords);
    $this->view->setVar('global_headline', $LandingPage->global_headline);
 
    $this->view->setVar('global_headline_second', $LandingPage->global_headline_second);
    $headline = str_replace('–', "–<br class='smartBr'>", $LandingPage->text1_headline);
    $this->view->setVar('text1_headline', $headline);
    $this->view->setVar('text1_text', $LandingPage->text1_text);
    $this->view->setVar('text1_subline', $LandingPage->text1_subline);
 
    $this->view->setVar('text2_headline', $LandingPage->text2_headline);
    $this->view->setVar('text2_text', $LandingPage->text2_text);
    $this->view->setVar('text2_subline', $LandingPage->text2_subline);
    $this->view->setVar('fotocase', $LandingPage->getLink2Image());
 
    $models = (new \Phalcon\Mvc\Model\Query\Builder())
      ->addFrom('App\Models\LandingPageCoronaModules', 'LandingPageCoronaModules')
      ->columns([
        'id' => 'LandingPageCoronaModules.id',
        'modultemplate' => 'Modul.modul_template',
        'class' => 'Modul.modul_class',
        'headline' => 'Content.content_headline',
        'text' => 'Content.content_text',
        'image_name' => 'Content.image_name',
        'image_ext' => 'Content.image_ext',
        'content_image_name' => 'ContentImage.image_name',
        'content_image_ext' => 'ContentImage.image_ext'
      ])
      ->join('\App\Models\Modul', 'LandingPageCoronaModules.modul_id = Modul.id', 'Modul')
      ->join('\App\Models\Content', 'LandingPageCoronaModules.modul_id = Content.modul_id', 'Content')
      ->join('\App\Models\ContentImage', 'Content.id = ContentImage.content_id', 'ContentImage')
      ->orderBy('pos ASC')
      ->getQuery()->execute();
 
 
    $moduleTemplates = [];
 
    foreach ($models as $modulEntry) {
      $headline = $modulEntry->headline;
      $text = $modulEntry->text;
      $image = $modulEntry->image_name . $modulEntry->image_ext;
      $image2 = $modulEntry->content_image_name . $modulEntry->content_image_ext;
      $classname = '\\App\\Models\\' . $modulEntry->class;
      $classnameAdditional = '\\App\\Models\\' . $modulEntry->class . 'Text';
 
 
      // Snippet Texte
      $snippet_text = Snippet::getSnippetTextByPerma('lp_leitfaden_txt1');
 
      $snipets['lp_leitfaden_txt1'] = strip_tags($snippet_text);
 
      $variables = ['headline' => $headline, 'text' => $text, 'image' => $image, 'image2' => $image2, 'snippets' => $snipets];
 
      $model = new $classname();
      $variables = $model->bindVariables($variables);
 
      if (class_exists($classnameAdditional)) {
 
        $modelAdditional = new $classnameAdditional();
        $variables = $modelAdditional->bindVariables($variables);
      }
 
 
      $html_template = $this->view->getPartial('modul/' . $modulEntry->modultemplate, $variables);
      $moduleTemplates[] = $html_template;
    }
    $this->view->setVar('moduleTemplates', $moduleTemplates);
 
    $gruppe = html_entity_decode($_GET['gruppe'], ENT_QUOTES);
    if (empty($gruppe)) {
      $this->view->setVar('groupSet', false);
    } else {
      $this->view->setVar('groupSet', true);
    }
 
 
 
    //$args['content'] = 'cookie-check';
    //$Phery = (new ContentPopupPlugin())->procAction($args);
 
    $x = ($this->cookies->has("ga-disable-UA-113554189-1") ? true : false);
 
    $this->view->setVar("cookie", $x);
  }
 
  private function setLandingPageVars()
  {
    // Footer Variablen Laden 
    $this->Tree = new Tree();
    $this->Tree->active_node_id = ($this->Navi ? $this->Navi->getKey() : null);
    $this->Tree->getOffsiteNodes($this->session);
    if (($footer_navi_nodes = $this->Tree->getFooterNaviNodes($this->session))) {
      $this->view->setVar("footer_navi_nodes", $footer_navi_nodes);
      ob_start();
      $this->view->partial('partials/footerMenu', ['footer_navi_nodes' => $footer_navi_nodes]);
      $menu_html = ob_get_clean();
 
      if (($Footer = \App\Models\Footer::findFirst(array('id' => 1)))) {
        $footer_html = $Footer->text;
        $footer_html = str_replace("[# footerSocial #]", '', $footer_html);
 
        if (isset($menu_html)) {
          $footer_html = str_replace("[# footerMenu #]", $menu_html, $footer_html);
        }
        $this->view->setVar("footer_test", $footer_html);
      }
    }
    //Footer ende
 
    $LandingPage = \App\Models\LandingPage::findFirst();
    $this->tag->title()->set($LandingPage->meta_title);
    $this->view->setVar('meta_description', $LandingPage->meta_description);
    $this->view->setVar('meta_keywords', $LandingPage->meta_keywords);
    $this->view->setVar('global_headline', $LandingPage->global_headline);
 
    $this->view->setVar('global_headline_second', $LandingPage->global_headline_second);
 
    $this->view->setVar('text1_headline', $LandingPage->text1_headline);
    $this->view->setVar('text1_text', $LandingPage->text1_text);
    $this->view->setVar('text1_subline', $LandingPage->text1_subline);
 
    $this->view->setVar('text2_headline', $LandingPage->text2_headline);
    $this->view->setVar('text2_text', $LandingPage->text2_text);
    $this->view->setVar('text2_subline', $LandingPage->text2_subline);
    $this->view->setVar('fotocase', $LandingPage->getLink2Image());
 
    $models = (new \Phalcon\Mvc\Model\Query\Builder())
      ->addFrom('App\Models\LandingPageModules', 'LandingPageModules')
      ->columns([
        'id' => 'LandingPageModules.id',
        'modultemplate' => 'Modul.modul_template',
        'class' => 'Modul.modul_class',
        'headline' => 'Content.content_headline',
        'text' => 'Content.content_text',
        'image_name' => 'Content.image_name',
        'image_ext' => 'Content.image_ext',
        'content_image_name' => 'ContentImage.image_name',
        'content_image_ext' => 'ContentImage.image_ext'
      ])
      ->join('\App\Models\Modul', 'LandingPageModules.modul_id = Modul.id', 'Modul')
      ->join('\App\Models\Content', 'LandingPageModules.modul_id = Content.modul_id', 'Content')
      ->join('\App\Models\ContentImage', 'Content.id = ContentImage.content_id', 'ContentImage')
      ->orderBy('pos ASC')
      ->getQuery()->execute();
 
 
    $moduleTemplates = [];
 
    foreach ($models as $modulEntry) {
      $headline = $modulEntry->headline;
      $text = $modulEntry->text;
      $image = $modulEntry->image_name . $modulEntry->image_ext;
      $image2 = $modulEntry->content_image_name . $modulEntry->content_image_ext;
      $classname = '\\App\\Models\\' . $modulEntry->class;
      $classnameAdditional = '\\App\\Models\\' . $modulEntry->class . 'Text';
 
 
      // Snippet Texte
      $snippet_text = Snippet::getSnippetTextByPerma('lp_leitfaden_txt1');
 
      $snipets['lp_leitfaden_txt1'] = strip_tags($snippet_text);
 
      $variables = ['headline' => $headline, 'text' => $text, 'image' => $image, 'image2' => $image2, 'snippets' => $snipets];
 
      $model = new $classname();
      $variables = $model->bindVariables($variables);
 
      if (class_exists($classnameAdditional)) {
 
        $modelAdditional = new $classnameAdditional();
        $variables = $modelAdditional->bindVariables($variables);
      }
 
 
      $html_template = $this->view->getPartial('modul/' . $modulEntry->modultemplate, $variables);
      $moduleTemplates[] = $html_template;
    }
    $this->view->setVar('moduleTemplates', $moduleTemplates);
 
 
    //$args['content'] = 'cookie-check';
    //$Phery = (new ContentPopupPlugin())->procAction($args);
    $x = ($this->cookies->has("ga-disable-UA-113554189-1") ? true : false);
    $this->view->setVar("cookie", $x);
  }
 
  private function setView()
  {
 
  
    $this->view->setVar("Content", null);
    $this->view->setVar("param", $this->param);
    $cookie = ($this->cookies->has("cookie-check") ? true : false);
    $this->view->setVar("cookie", $cookie);
 
    if ($this->isLandingPage()) {
      //Pick the landingpage template
      $this->view->setMainView("landingpage");
      $this->setLandingPageVars();
 
      $request = new Request();
 
      if (true === $request->isPost()) {
        if (true === $request->isAjax()) {
          $action = $request->get('action');
          die("AJAX " . $action);
        }
      }
    } elseif ($this->isCoronaLandingPage()) {
      //Pick the landingpage template
      $this->view->setMainView("corona-landingpage");
      $this->setCoronaLandingPageVars();
 
      $request = new Request();
 
      if (true === $request->isPost()) {
        if (true === $request->isAjax()) {
          $action = $request->get('action');
          die("AJAX " . $action);
        }
      }
    } elseif ($this->isIndex() and !$this->setIndex()) {
      parent::setTreeNavis();
      $this->get404Page();
    } elseif (!$this->isIndex() and !$this->setContent()) {
      ini_set('display_errors', 1);
      ini_set('display_startup_errors', 1);
      error_reporting(E_ALL);
      
      parent::setTreeNavis();
      
      $this->get404Page();
    } elseif (!$this->isValidNavi()) {
      $this->redirToIndex();
    }
 
    if ($this->Content) {
      //die("Content is ready...465");
      $this->Content->parseContentText();
      $this->view->setVar("Content", $this->Content);
      $this->view->setVar("is_presse", $this->is_presse);
      $this->view->setVar("is_mitglied", $this->is_mitglied);
      $this->view->setVar("is_index", $this->isIndex());
      parent::setTreeNavis();
      $this->setMetaTitle();
      $this->setMetaKeywords();
      $this->setMetaDescription();
      //$this->setCoronaLandingPageVars();
      if ($this->isIndex()) {
        $this->setViewIndexVars();
      }
 
      if (strlen($this->Content->liste_id) and ($Liste = $this->Content->getListe())) {
        $this->setViewListeVars($Liste);
      }
      if (strlen($this->Content->layout_id) and ($Layout = $this->Content->getLayout())) {
        $this->view->setLayout($Layout->volt_file);
      }
      if (strlen($this->Content->modul_id) and ($this->Modul = $this->Content->getModul())) {
      
        $this->setViewModulVars($this->Modul);
        $this->procModulAction($this->Modul);
        
      }
      if (strlen($this->Content->risikoklasse_id) and ($Risikoklasse = $this->Content->getRisikoklasse())) {
        $this->setViewRisikoklasse($Risikoklasse);
      }
 
      if (!$this->isIndex() and !$this->isValidArgs()) {
        $this->get404Page();
      }
 
      $this->getYoutubeVideoPlatzhalter();
      // $this->getYoutubeVideoWrapper();
    }
  }
 
  private function isIndex()
  {
    if (empty($this->perma)) {
      return true;
    }
    return false;
  }
 
  private function isLandingPage()
  {
 
    if (!empty($this->perma)) {
      return ($this->perma == "bu");
    } else {
      return false;
    }
  }
 
  private function isCoronaLandingPage()
  {
    if (!empty($this->perma)) {
      return ($this->perma == "versicherungen-corona");
    } else {
      return false;
    }
  }
 
  private function setIndex()
  {
    return $this->Content = Content::getContentIndex();
  }
 
  private function setContent()
  {
    
    if ($_REQUEST['_url'] == '/werden-sie-mitglied/beitrittserklaerung-danke') {
      return $this->Content = StaticContent::findFirst(['content_perma = "beitrittserklaerung-danke"']);
    }
 
    if ("stellungnahmen" === array_get($this->folders, 0)) {
      $this->perma = "stellungnahmen";
    }
  
    if ($this->setNavi() and $this->isValidPath()) {
 
      $this->Content = $this->Navi->getContent();
      return true;
    }
 
    return false;
  }
 
  private function setNavi()
  {
    $anz_folders = count($this->folders);
    
    if (!is_array($this->folders) or $anz_folders == 0) {
      return false;
    } elseif (($this->Navi = Tree::findNaviByPermaAndDepth($this->perma, $anz_folders))) {
      if (count($this->args) == 0) {
        $this->args = null;
      }
      return true;
    }
 
    return $this->setArgs();
  }
 
  private function setArgs()
  {
    
    $args = array_pop($this->folders);
    array_unshift($this->args, $args);
    $this->perma = end($this->folders);
    if ("stellungnahmen" === array_get($this->folders, 0)) {
      $this->perma = "stellungnahmen";
    }
 
    return $this->setNavi();
  }
 
  private function isValidArgs()
  {
    return true;
  }
 
  private function isValidNavi()
  {
    if (empty($this->perma)) {
      return true;
    } elseif ("nein" == $this->Navi->is_protected) {
      return true;
    } elseif ("ja" == $this->Navi->is_protected and !$this->is_mitglied) {
      return false;
    } elseif ("nor" == $this->Navi->is_protected and $this->is_mitglied) {
      return false;
    }
 
    return true;
  }
 
  private function isValidPath()
  {
 
    /*
    $node_ary = [];
    $owner = Tree::findFirst($this->Navi->getParentId());
    $this->Navi->getNestedSet($owner);
    if (($nodes = $this->Navi->ancestorsAndSelf())) {
      
      foreach ($nodes as $Node) {
        $node_ary[] = $Node->node_perma;
      }
      $node_ary[] = $this->Navi->node_perma;
      
      return ($this->folders === $node_ary);
    }
    */
 
    return true;
  }
 
  private function getYoutubeVideoPlatzhalter()
  {
 
 
    $Youtubevideo = YoutubeVideo::find();
 
    $YTV_search = [];
    $YTV_replace = [];
 
    foreach ($Youtubevideo as $Video) {
      array_push($YTV_search, $Video->platzhalter);
      array_push($YTV_replace, $Video->code);
    }
 
    $this->view->setVar('YTVsearch', $YTV_search);
    $this->view->setVar('YTVreplace', $YTV_replace);
  }
 
  private function setMedium4Adventskalender()
  {
 
 
    //die("Hier");
    if (IS_LAB) {
      $DatumJetzt = new \DateTime('2019-12-01');
      #$DatumJetzt = new \DateTime();
      $datum = isset($_GET['kalender_datum']) ? $_GET['kalender_datum'] : false;
    } else {
      $DatumJetzt = new \DateTime();
      // $datum = false;
      // Wegen den Vergangenen Türchen
      $datum = isset($_GET['kalender_datum']) ? $_GET['kalender_datum'] : false;
    }
 
 
    $DatumDezember = new \DateTime((new \DateTime)->format('Y') . '-12-01');
 
    if ($datum or ($DatumJetzt >= $DatumDezember)) {
      if (!$datum) {
        $datum = $DatumJetzt->format("Y-m-d");
      }
 
      if ($AdventsTag = \App\Models\AdventListe::findFirst(["datum = '" . $datum . "'"])) {
 
        $this->view->setVar("AdventsTag", $AdventsTag);
      }
    }
  }
 
  private function setMedien4Adventskalender()
  {
    $DatumJetzt = new \DateTime('now');
    //$DatumJetzt = new \DateTime('2017-12-24');
    $args = [
      "datum <= '" . $DatumJetzt->format("Y-m-d") . "'",
      "order" => "datum",
    ];
    if (($medien = Medium::find($args))) {
      $this->view->setVar("medien", $medien);
    }
  }
 
  private function setViewIndexVars()
  {
 
    $this->setMedium4Adventskalender();
 
    $this->view->setVar("is_index", true);
 
 
    if (($Tipp = Tipp::getTipp4Index())) {
      $this->view->setVar("Tipp", $Tipp);
    }
 
    if (($themas = Thema::getThemaPage())) {
      $this->view->setVar("themas", $themas);
    }
 
    if (($Snippet = Snippet::findFirst("snippet_perma = 'ServiceTeaser'"))) {
      $this->view->setVar("Snippet", $Snippet);
    }
 
    if (($smallTeaser = Teaser::findFirst("teaser_perma = 'smallteaser'"))) {
      $this->view->setVar("SmallTeaser", $smallTeaser);
    }
 
    if (($pressemitteilungen = self::getPressemitteilungPage(null, "deutsch"))) {
      $item_ary = [];
      foreach ($pressemitteilungen->items as $Pressemitteilung) {
        $Paragraphs = getParagraphs($Pressemitteilung['mail']->mail_vorwort);
        if ($Pressemitteilung['mail']->mail_vorwort == $Paragraphs->prepend) {
          $Pressemitteilung->weiterlesenLink = false;
        } else {
          $Pressemitteilung->weiterlesenLink = true;
          $Pressemitteilung['mail']->mail_vorwort = $Paragraphs->prepend;
        }
 
        $item_ary[] = $Pressemitteilung;
      }
      $this->view->setVar("pressemitteilungen", $item_ary);
    }
 
    if (($PressemitteilungNode = Tree::findNodeByModulClass("Pressemitteilung"))) {
      $path = parent::getPathByNodeID($PressemitteilungNode->id);
      $this->view->setVar("link2pressemitteilung", $path);
    }
 
    if (($facebookPosts = FacebookPost::getFacebookPosts())) {
      $this->view->setVar("facebook_posts", $facebookPosts);
    } else {
      $facebookPosts = [];
    }
 
    if (($twitterTweets = TwitterTweet::getTwitterTweets())) {
      $this->view->setVar("twitter_tweets", $twitterTweets);
    } else {
      $twitterTweets = [];
    }
  }
 
  private function setViewListeVars($Liste)
  {
 
    $this->view->setVar("Liste", $Liste);
 
    if ("Mitarbeiter" == $Liste->liste_class) {
      if (($PageObj = self::getMitarbeiterPage())) {
        $this->view->setVar('mitarbeiter', $PageObj);
      }
    } elseif ("Faq" == $Liste->liste_class) {
      if (($PageObj = self::getFaqPage())) {
        $this->view->setVar('faqs', $PageObj);
      }
    } elseif ("FaqKfz" == $Liste->liste_class) {
      if (($PageObj = self::getFaqKfzPage())) {
        $this->view->setVar('faqs_kfz', $PageObj);
      }
    } elseif ("Kooperationspartner" == $Liste->liste_class) {
      if (($PageObj = self::getKooperationspartnerPage())) {
        $this->view->setVar('kooperationspartner', $PageObj);
      }
    } elseif ("Stellenangebot" == $Liste->liste_class) {
      if (($PageObj = self::getStellenangebotPage())) {
        $this->view->setVar('stellenangebot', $PageObj);
      }
    } elseif ("Aufsichtsrat" == $Liste->liste_class) {
      if (($PageObj = self::getAufsichtsratPage())) {
        $this->view->setVar('aufsichtsrat', $PageObj);
      }
    } elseif ("Vorstand" == $Liste->liste_class) {
      if (($PageObj = self::getVorstandPage())) {
        $this->view->setVar('vorstand', $PageObj);
      }
    } elseif ("Organe" == $Liste->liste_class) {
      if (($PageObj = self::getAufsichtsratPage())) {
        $this->view->setVar('aufsichtsrat', $PageObj);
      }
      if (($PageObj = self::getVorstandPage())) {
        $this->view->setVar('vorstand', $PageObj);
      }
    } elseif ("PressefotoListe" == $Liste->liste_class) {
      if ($this->is_presse) {
        $PageObj = self::getPressefotoListePage();
        $this->view->setVar('pressefoto_liste', $PageObj);
      } elseif (($Modul = Modul::findFirst("modul_class = 'UserLogin'"))) {
        $this->setViewModulVars($Modul);
        if (($Content = Content::findFirst('modul_id = ' . $Modul->getKey()))) {
          $this->view->Content = $Content;
        }
      }
    } elseif ("Agenda" == $Liste->liste_class) {
      if (($PageObj = self::getAgendaPage())) {
        $this->view->setVar('agenda', $PageObj);
      }
    } elseif ("Broschuere" == $Liste->liste_class) {
 
      if (($PageObj = self::getBroschuerePage('deutsch'))) {
        $this->view->setVar('broschuere', $PageObj);
      }
    } elseif ("Beirat" == $Liste->liste_class) {
      if (($PageObj = self::getBeiratPage())) {
        $this->view->setVar('beirat', $PageObj);
      }
    } elseif ("Leitfaden" == $Liste->liste_class) {
      if (($PageObj = self::getLeitfadenPage())) {
        $this->view->setVar('leitfaden', $PageObj);
      }
    } elseif ("Flyer" == $Liste->liste_class) {
      if (($PageObj = self::getFlyerPage())) {
        $this->view->setVar('flyer', $PageObj);
      }
    } elseif ("Bdvinfo" == $Liste->liste_class) {
      if (($PageObj = self::getBdvinfoPage())) {
        $this->view->setVar('bdvinfo', $PageObj);
      }
    } elseif ("DownloadListe" == $Liste->liste_class) {
      if ($this->is_mitglied) {
        $PageObj = self::getDownloadListePage();
        $this->view->setVar('download_liste', $PageObj);
      }
    } elseif ("Sitemap" == $Liste->liste_class) {
      $sitemap = new SitemapGenerator();
      $sitemap->setConfig($this->config);
      $sitemap->setTree($this->Tree);
      $sitemap->generate();
      $sitemap->print();
      exit;
    }
  }
 
  private function setViewModulVars($Modul)
  {
 
 
    if (strlen($Modul->modul_template)) {
      $this->view->setVar("Modul", $Modul);
    }
 
    // Suche
    if ("Medium" === $Modul->modul_class) {
      $this->setMedien4Adventskalender();
    } elseif ("Suche" === $Modul->modul_class) {
      
      $this->response->setHeader("Cache-Control", "max-age=180");
      $search_string = $this->request->getPost("search_string");
 
      $Suche = new SuchePlugin();
      $Suche->setPathAry($this->path_ary);
 
      $this->view->setVar("search_string", $search_string);
      $this->view->setVar("search_result", $Suche->getSearchResultByPostRequest($search_string));
    }
    // MitgliedIndex
    elseif ("MitgliedIndex" === $Modul->modul_class) {
      if (($ary = $this->session->get("mitglied"))) {
        $this->Content->content_headline .= ' ' . array_get($ary, "vorname") . ' ' . array_get($ary, "nachname");
        $this->view->setVar("Content", $this->Content);
      }
 
      $PageObj = self::getNewsPage([]);
      $this->view->setVar('news_items', NewsPlugin::getNewsItems($PageObj));
      $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
    }
    // Pressemitteilung
    elseif ("Pressemitteilung" === $Modul->modul_class) {
 
      if ($key = $this->request->get("print") and $PmModel = Pressemitteilung::getPressemitteilungByKey($key)) {
        PressemitteilungPdf::outputPdf($PmModel);
      } else {
 
        $this->args = $this->args ?? [];
        $FilterSegments = FilterSegment::getFilterSegments($this->args ?? []);
        $FilterArrays = Pressemitteilung::getFilterArrays($FilterSegments);
        $this->setViewFilterSegments($FilterSegments);
        $is404 = false;
        if ($FilterArrays) {
          if (count($this->args) === 1 and !is_numeric($this->args[0]) and !Pressemitteilung::findFirst("kategorie_perma = '" . array_get($this->args, 0) . "'")) {
            if (($MailObj = Pressemitteilung::getPressemitteilungByPerma(array_get($this->args, 0)))) {
 
              $this->view->setVar('Pressemitteilung', PressemitteilungPlugin::getPressemitteilungItem($MailObj));
              // facebook_metas fuer Detailseite vorbereiten 
              $site_url = $this->config->url->httpScheme . $this->config->url->hostName;
              $page_url = $site_url . $this->request->getURI();
              $image_url = $site_url . $MailObj->getLink2Image();
              $facebook_metas = Pressemitteilung::getPressemitteilungMetas($MailObj, $page_url, $image_url);
 
              $extra_fb_meta_image = $MailObj->getLink2ThirdImage();
 
              if (empty($extra_fb_meta_image)) {
                $extra_fb_meta_image = $MailObj->getLink2Image();
              }
 
              if (!empty($extra_fb_meta_image)) {
                $this->view->setVar('extra_fb_meta_image', $extra_fb_meta_image);
              }
 
 
              $this->view->setVar('facebook_metas', $facebook_metas);
              $this->tag->title()->set($MailObj->mail_subject . ' - Bund der Versicherten');
              $this->view->setVar('meta_keywords', $MailObj->mail_subject);
              $this->view->setVar('title', $MailObj->mail_subject);
              $this->view->setVar('meta_description', $MailObj->mail_subline);
            } else {
              $is404 = true;
              $this->get404Page();
            }
          } elseif (($PageObj = self::getPressemitteilungPage($FilterSegments))) {
            $this->view->setVar('pressemitteilung_items', PressemitteilungPlugin::getPressemitteilungItems($PageObj));
            $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
          }
 
          if (!$is404) {
            $this->view->setVar('page_link', '/' . implode("/", $this->folders));
            $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
            $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
            $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
          }
        }
      }
    } elseif ("Musterbrief" == $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $kategorie_filter = $FilterSegments->kategorie_filter;
 
      $this->view->setVar('kategorie_filter', "alle");
      $this->view->setVar('liste_ary', MusterbriefListe::getMusterbriefListen());
      $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
      if ($kategorie_filter and $PageObj = self::getMusterbriefListePage($FilterSegments)) {
        $this->view->setVar('musterbrief_liste', $PageObj);
        $this->view->setVar('kategorie_filter', $FilterSegments->kategorie_filter);
      } else {
        $this->view->setVar('musterbrief_liste', self::getMusterbriefListePage());
      }
 
      $this->view->setVar('hat_beliebte_musterbriefe', false);
      if (MusterbriefListe::getMusterbriefListen(["is_beliebt" => true])) {
        $this->view->setVar('hat_beliebte_musterbriefe', true);
      }
    }
    // Beitrag 
    elseif ("Beitrag" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = BeitragKategorie::getFilterArrays($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
 
      if ($FilterArrays) {
        $this->args = $this->args ?? [];
        $arg = ((count($this->args) === 1 and !is_numeric($this->args[0])) ? array_get($this->args, 0) : false);
        if ($arg and !BeitragKategorie::findFirst("kategorie_perma = '" . $arg . "'")) {
          $params = "beitrag_perma = '" . $arg . "' AND is_online = 'ja'";
          if (($Beitrag = Beitrag::findFirst($params))) {
            $this->view->setVar('Beitrag', BeitragPlugin::getBeitragItem($Beitrag));
          } else {
            $this->get404Page();
          }
        } elseif (($PageObj = self::getBeitragPage($FilterSegments))) {
          $this->view->setVar('beitrag_items', BeitragPlugin::getBeitragItems($PageObj));
          $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
        }
 
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
        $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
      }
    }
    // Stellungnahme
    elseif ("Stellungnahme" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = StellungnahmeKategorie::getFilterArrays($FilterSegments);
      $PageObj = self::getStellungnahmePage($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
      if ($FilterArrays and $PageObj) {
        $this->view->setVar('stellungnahme_items', StellungnahmePlugin::getStellungnahmeItems($PageObj));
        $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
        $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
      }
    } elseif ("LandingPage" === $Modul->modul_class) {
      #die("Hier");
    } // Termin
    elseif ("Termin" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments($this->args);
      $FilterArrays = TerminKategorie::getFilterArrays($FilterSegments);
      $this->setViewFilterSegments($FilterSegments);
 
      if (is_object($FilterSegments) and "termine" == $FilterSegments->kategorie_filter) {
        $termin_ary = self::getTerminAry($FilterSegments);
        $Modul->modul_template = "termin-liste";
 
        $this->view->setVar("Modul", $Modul);
        $this->view->setVar('page_link', '/' . implode("/", $this->folders));
        $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
        $this->view->setVar('termin_ary', $termin_ary);
      } else {
        $PageObj = self::getTerminPage($FilterSegments);
        if ($FilterArrays and $PageObj) {
          $this->view->setVar('termin_items', TerminPlugin::getTerminItems($PageObj));
          $this->view->setVar('has_pagination', Pagination::hasPagination($PageObj));
          $this->view->setVar('page_link', '/' . implode("/", $this->folders));
 
          $this->view->setVar('kategorie_ary', $FilterArrays->kategorie_ary);
          $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
          $this->view->setVar('monat_ary', $FilterArrays->monat_ary);
        }
 
        if (!$this->args and ($termin_ary = self::getTerminAry([]))) {
          $this->view->setVar('termin_ary', $termin_ary);
        } elseif (!empty($FilterSegments->jahr_filter) and empty($FilterSegments->kategorie_filter) and empty($FilterSegments->monat_filter)) {
          if (($termin_ary = self::getTerminAry($FilterSegments))) {
            $this->view->setVar('termin_ary', $termin_ary);
          }
        }
      }
    }
    // Beitrittserklärung
    elseif ("Beitrittserklaerung" === $Modul->modul_class) {
 
      $this->view->setVar('bundeslaender', Bundesland::find());
      $this->view->setVar('laender', Land::find(["order" => "pos"]));
 
      $objs = Kampagne::find(["is_online = 'ja'", "order" => "pos"]);
      $this->view->setVar('kampagne_ary', $objs);
    }
    // Meine Anschrift
    elseif ("MeineAnschrift" === $Modul->modul_class) {
 
      $this->view->setVar('laenderAlle', LandAlle::find(["order" => "id"]));
    }
    // Wita
    elseif ("Wita" === $Modul->modul_class) {
 
 
      if (empty($this->args)) {
        //$this->args = [date('Y')];
        // Hier soll das höchste jahr genommen werden
        $witas = Wita::fetchWitas();
        $Wita = $witas[0];
        $year = date('Y', strtotime($Wita->datum_von));
        $this->args = [$year];
      }
 
      if (($Wita = Wita::fetchWita($this->args))) {
        $this->view->setVar('logged_in', false);
        $this->view->setVar('Wita', $Wita);
        $this->view->setVar('referenten', WitaReferent::fetchReferentenByWita($Wita));
 
        if (checkSession(['wita', $Wita->login_code])) {
          $this->view->setVar('logged_in', true);
          $this->view->setVar('vortraege', WitaVortrag::fetchVortraegeByWitaID($Wita->getKey()));
          $this->view->setVar('teilnehmer', $Wita->getTeilnehmer());
        }
        if (($witas = Wita::fetchWitas())) {
          $counter = 0;
          $link_ary = [];
          foreach ($witas as $TmpWita) {
            //$wita_link = '/' . implode("/", $this->folders) . (($counter > 0) ? '/' . $TmpWita->wita_jahr : null);
            $wita_link = '/' . implode("/", $this->folders) . '/' . $TmpWita->wita_jahr;
            $link_ary[] = ['link' => $wita_link, 'jahr' => $TmpWita->wita_jahr];
            $counter++;
          }
          $this->view->setVar('wita_links', $link_ary);
        }
      } else {
        $this->get404Page();
      }
    }
    // Newsletter
    elseif ("Newsletter" === $Modul->modul_class) {
      $FilterSegments = FilterSegment::getFilterSegments4Newsletter($this->args);
      $FilterArrays = Newsletter::getFilterArrays($FilterSegments);
 
      $this->view->setVar("show_form", false);
      $this->view->setVar("show_liste", false);
      $this->view->setVar("is_subscriber", null);
 
      if ($FilterSegments->jahr_filter) {
        if (($newsletter = Newsletter::fetchNewsletterByJahr($FilterSegments->jahr_filter))) {
          $this->view->setVar("show_liste", true);
          $this->view->setVar("newsletter", $newsletter);
        }
      } elseif ($FilterSegments->perma_filter) {
        if (($Newsletter = Newsletter::findFirst("mail_perma = '" . $FilterSegments->perma_filter . "'"))) {
          $this->view->setVar("Newsletter", $Newsletter);
          $this->view->setVar("newsletterArtikel", $Newsletter->newsletterArtikel);
          $FilterSegments->jahr_filter = $Newsletter->jahr;
 
          if (($newsletter = Newsletter::fetchNewsletterByJahr($Newsletter->jahr))) {
            $this->view->setVar("newsletter", $newsletter);
          }
        }
      } elseif (($Newsletter = Newsletter::fetchLastNewsletter())) {
        $this->view->setVar("Newsletter", $Newsletter);
        $this->view->setVar("newsletterArtikel", $Newsletter->newsletterArtikel);
 
        if ($mitglied_ary = $this->session->get("mitglied")) {
          $this->view->setVar("show_form", true);
          $this->view->setVar("is_subscriber", (("N" == array_get($mitglied_ary, "newsletter")) ? false : true));
        }
      }
 
      $this->setViewFilterSegments($FilterSegments);
      $this->view->setVar('jahr_ary', $FilterArrays->jahr_ary);
      $this->view->setVar("page_link", '/' . implode("/", $this->folders));
    }
    // Englisch
    elseif ("Englisch" === $Modul->modul_class) {
      $this->view->setVar("is_englisch", true);
 
      /*
       * snippet text
       */
 
      if (($snippet_text = Snippet::getSnippetTextByPerma("BoxEnglisch"))) {
        $this->view->setVar("snippet_text", $snippet_text);
      }
 
      /*
       * pressemitteilung
       */
      if (($PageObj = self::getPressemitteilungPage(null, "englisch"))) {
        if (($PressemitteilungNode = Tree::findNodeByModulClass("Pressemitteilung"))) {
          $path = parent::getPathByNodeID($PressemitteilungNode->id);
          $this->view->setVar("link2pressemitteilung", $path);
        }
 
        $item_ary = [];
        foreach ($PageObj->items as $Item) {
          $Paragraphs = getParagraphs($Item['mail']->mail_vorwort);
          $Item['mail']->mail_vorwort = $Paragraphs->prepend;
          $item_ary[] = $Item;
        }
 
        $this->view->setVar("pressemitteilungen", $item_ary);
      }
 
      /*
       * stellungnahme
       */
      if (($PageObj = self::getStellungnahmePage(null, "englisch"))) {
        if (($StellungnahmeNode = Tree::findNodeByModulClass("Stellungnahme"))) {
          $path = parent::getPathByNodeID($StellungnahmeNode->id);
          $this->view->setVar("link2stellungnahme", $path);
        }
 
        $item_ary = [];
        foreach ($PageObj->items as $Item) {
          $Paragraphs = getParagraphs($Item['stellungnahme']->stellungnahme_text);
          $Item['stellungnahme']->stellungnahme_text = $Paragraphs->prepend;
          $item_ary[] = $Item;
        }
 
        $this->view->setVar('stellungnahme', $item_ary);
      }
      /*
       * broschuere
       */
      if (($PageObj = self::getBroschuerePage("englisch"))) {
        $this->view->setVar('broschuere', $PageObj);
      }
    } elseif ("BedarfsCheck" === $Modul->modul_class) {
      $calcBerufAry = CalcBeruf::find([null, 'order' => "pos"]);
      $calcFamilieAry = CalcFamilie::find([null, 'order' => "pos"]);
      $calcZusatzBinAry = CalcZusatz::find(["typ = 'was-bin-ich'", 'order' => "pos"]);
      $calcZusatzBesitzeAry = CalcZusatz::find(["typ = 'was-besitze-ich'", 'order' => "pos"]);
 
      $this->view->setVar('beruf_ary', $calcBerufAry);
      $this->view->setVar('familie_ary', $calcFamilieAry);
      $this->view->setVar('zusatz_bin_ary', $calcZusatzBinAry);
      $this->view->setVar('zusatz_besitze_ary', $calcZusatzBesitzeAry);
    } elseif ("Kontakt" === $Modul->modul_class) {
      $this->view->setVar('anliegen', []);
      if (($anliegen = Kontakt::find(["order" => "pos"]))) {
        $this->view->setVar('anliegen', $anliegen);
      }
    } elseif ("Bewerbung" === $Modul->modul_class) {
 
      $this->view->setVar('widerruf', "");
      $this->view->setVar('stellenangebote', []);
 
      if (($stellenangebote = self::getStellenangebotPage()) and $stellenangebote->count()) {
        $this->view->setVar('stellenangebote', self::getStellenangebotPage());
      }
 
      if (($widerruf = Snippet::getSnippetTextByPerma("BewerbungWiderruf"))) {
        $this->view->setVar('widerruf', strip_tags($widerruf, "<a>"));
      }
    }
  }
 
  private function setViewFilterSegments($FilterSegments)
  {
    $this->view->setVar('kategorie_filter', "");
    $this->view->setVar('jahr_filter', "");
    $this->view->setVar('monat_filter', "");
    $this->view->setVar('perma_filter', "");
 
    if (isset($FilterSegments)) {
      if (isset($FilterSegments->kategorie_filter) and ($kategorie = $FilterSegments->kategorie_filter)) {
        $this->view->setVar('kategorie_filter', LINK_ROOT . $kategorie);
 
        if (($jahr = $FilterSegments->jahr_filter)) {
          $this->view->setVar('jahr_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr);
          if (($monat = $FilterSegments->monat_filter)) {
            $this->view->setVar('monat_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr . LINK_ROOT . $monat);
          } else {
            $this->view->setVar('monat_filter', LINK_ROOT . $kategorie . LINK_ROOT . $jahr);
          }
        }
      } elseif (($jahr = $FilterSegments->jahr_filter)) {
        $this->view->setVar('jahr_filter', LINK_ROOT . $jahr);
 
        if (isset($FilterSegments->monat_filter) and ($monat = $FilterSegments->monat_filter)) {
          $this->view->setVar('monat_filter', LINK_ROOT . $jahr . LINK_ROOT . $monat);
        }
 
        if (isset($FilterSegments->perma_filter) and ($perma = $FilterSegments->perma_filter)) {
          $this->view->setVar('perma_filter', $perma);
        }
      }
    }
  }
 
  private function procModulAction($Modul)
  {
    if ("Logout" == $Modul->modul_class) {
      (new LogoutPlugin())->procAction();
    } elseif ("Optin" == $Modul->modul_class) {
      (new OptinPlugin())->procAction();
    }
  }
 
  private function setViewRisikoklasse($Risikoklasse)
  {
    $merkblaetter = $Risikoklasse->getMerkblaetter($this->is_mitglied);
    $link2beitrittserklaerung = $this->getPathByModulClass("Beitrittserklaerung");
 
    $this->view->setVar("Risikoklasse", $Risikoklasse);
    $this->view->setVar("merkblaetter", $merkblaetter);
    $this->view->setVar("link2beitrittserklaerung", LINK_ROOT . $link2beitrittserklaerung);
 
    if (($Snippet = Snippet::findFirst("snippet_perma = 'MerkblattHinweis'"))) {
      $this->view->setVar("Snippet", $Snippet);
    }
  }
 
  /*
   * Pages
   */
 
  private static function getNewsPage()
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$news_limit);
 
    return News::getNewsPage($args);
  }
 
  private static function getMusterbriefListePage($FilterSegments = null)
  {
    $args = [];
    if ($FilterSegments) {
      if ("beliebteste" == $FilterSegments->kategorie_filter) {
        array_set($args, "is_beliebt", "ja");
      } else {
        array_set($args, "liste_perma", $FilterSegments->kategorie_filter);
      }
    }
    return MusterbriefListe::getMusterbriefListePage($args);
  }
 
  private static function getPressemitteilungPage($FilterSegments = null, $lang = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$news_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    if ($lang) {
      array_set($args, "mail_sprache", $lang);
    }
 
    return Pressemitteilung::getPressemitteilungPage($args);
  }
 
  private static function getStellungnahmePage($FilterSegments = null, $lang = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$stellungnahme_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    if ($lang) {
      array_set($args, "lang", $lang);
    }
 
    return Stellungnahme::getStellungnahmePage($args);
  }
 
  private static function getBeitragPage($FilterSegments = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$beitrag_limit);
 
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    return Beitrag::getBeitragPage($args);
  }
 
  private static function getTerminPage($FilterSegments = null)
  {
    $args = [];
    array_set($args, "site", 1);
    array_set($args, "limit", self::$termin_limit);
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
      array_set($args, "monat", $FilterSegments->monat_filter);
      array_set($args, "kategorie_perma", $FilterSegments->kategorie_filter);
    }
 
    return Termin::getTerminPage($args);
  }
 
  private static function getTerminAry($FilterSegments)
  {
    $args = [];
    if ($FilterSegments) {
      array_set($args, "jahr", $FilterSegments->jahr_filter);
    }
 
    return Termin::getTerminAry($args);
  }
 
  private static function getMitarbeiterPage()
  {
    $args = ["is_online" => "ja"];
    return Mitarbeiter::getMitarbeiterPage($args);
  }
 
  private static function getFaqPage()
  {
    $args = ["is_online" => "ja"];
    return Faq::getFaqPage($args);
  }
 
  private static function getFaqKfzPage()
  {
    $args = ["is_online" => "ja"];
    return FaqKfz::getFaqKfzPage($args);
  }
 
  private static function getKooperationspartnerPage()
  {
    $args = ["is_online" => "ja"];
    return Kooperationspartner::getKooperationspartnerPage($args);
  }
 
  private static function getStellenangebotPage()
  {
    $args = ["is_online" => "ja"];
    return Stellenangebot::getStellenangebotPage($args);
  }
 
  private static function getAufsichtsratPage()
  {
    $args = ["is_online" => "ja"];
    return Aufsichtsrat::getAufsichtsratPage($args);
  }
 
  private static function getVorstandPage()
  {
    $args = ["is_online" => "ja"];
    return Vorstand::getVorstandPage($args);
  }
 
  private static function getBdvinfoPage()
  {
    $args = ["is_online" => "ja"];
    return Bdvinfo::getBdvinfoPage($args);
  }
 
  private static function getPressefotoListePage()
  {
    $args = [];
    return PressefotoListe::getPressefotoListePage($args);
  }
 
  private static function getAgendaPage()
  {
    $args = ["is_online" => "ja"];
    return Agenda::getAgendaPage($args);
  }
 
  private static function getBroschuerePage($lang)
  {
    $args = ["is_online" => "ja", "lang" => $lang];
    return Broschuere::getBroschuerePage($args);
  }
 
  private static function getBeiratPage()
  {
    $args = ["is_online" => "ja"];
    return Beirat::getBeiratPage($args);
  }
 
  private static function getLeitfadenPage()
  {
    $args = ["is_online" => "ja"];
    return Leitfaden::getLeitfadenPage($args);
  }
 
  private static function getFlyerPage()
  {
    $args = ["is_online" => "ja"];
    return Flyer::getFlyerPage($args);
  }
 
  private static function getDownloadListePage()
  {
    $args = [];
    return DownloadListe::getDownloadListePage($args);
  }
 
  /*
   * phery action 
   */
 
  public function procKontaktForm($args)
  {
    return (new KontaktPlugin())->procAction($args);
  }
 
  public function procInfoEventAnmeldung($args)
  {
    return (new InfoEventPlugin())->procAction($args);
  }
 
  public function procBewerbungForm($args)
  {
    return (new BewerbungPlugin())->procAction($args);
  }
 
  public function procQuickConnectForm($args)
  {
    return (new QuickConnectPlugin())->procAction($args);
  }
 
  public function procBroschuereForm($args)
  {
    return (new BroschuerePlugin())->procAction($args);
  }
 
  public function procBedarfsCheckForm($args)
  {
    return (new BedarfsCheckPlugin())->procAction($args);
  }
 
  public function procSucheForm($args)
  {
    parent::setTreeNavis();
    $SuchePlugin = new SuchePlugin();
    $SuchePlugin->setPathAry($this->path_ary);
 
    return $SuchePlugin->procAction($args);
  }
 
  // liste stuff
  public function procFetchNews($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new NewsPlugin())->procAction($ary);
  }
 
  public function procFetchPressemitteilungen($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new PressemitteilungPlugin())->procAction($ary);
  }
 
  public function procFetchStellungnahmen($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$news_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new StellungnahmePlugin())->procAction($ary);
  }
 
  public function procFetchTermine($args)
  {
    $ary = [];
    $site = intval(array_get($args, "site"));
    $FilterSegments = FilterSegment::getFilterSegments($this->args);
 
    array_set($ary, "site", $site + 1);
    array_set($ary, "limit", self::$termin_limit);
    array_set($ary, "jahr", $FilterSegments->jahr_filter);
    array_set($ary, "monat", $FilterSegments->monat_filter);
    array_set($ary, "kategorie_perma", $FilterSegments->kategorie_filter);
 
    return (new TerminPlugin())->procAction($ary);
  }
 
  // user stuff
  public function procUserRegisterForm($args)
  {
    return (new UserRegisterPlugin())->procAction($args);
  }
 
  public function procUserLoginForm($args)
  {
    $Modul = Modul::findFirst("modul_class = 'UserLogin'");
    return (new UserLoginPlugin())->procAction($args, $Modul);
  }
 
  public function procMitgliedLoginForm($args)
  {
    return (new MitgliedLoginPlugin())->procAction($args);
  }
 
  public function procPasswordForm($args)
  {
    return (new PasswordPlugin())->procAction($args);
  }
 
  // wita stuff
  public function procWitaLoginForm($args)
  {
    return (new WitaLoginPlugin())->procAction($args);
  }
 
  public function procWitaNachrichtForm($args)
  {
    return (new WitaNachrichtPlugin())->procAction($args);
  }
 
  public function procWitaAnmeldungForm($args)
  {
    return (new WitaAnmeldungPlugin())->procAction($args);
  }
 
  // mitglied stuff
  public function procMeinPasswortForm($args)
  {
    return (new MeinPasswortPlugin())->procAction($args);
  }
 
  public function procMeineAnschriftForm($args)
  {
    return (new MeineAnschriftPlugin())->procAction($args);
  }
 
  public function procMeineBankverbindungForm($args)
  {
    return (new MeineBankverbindungPlugin())->procAction($args);
  }
 
  public function procMeineZugangsdatenForm($args)
  {
    return (new MeineZugangsdatenPlugin())->procAction($args);
  }
 
  public function procMeineBdvinfoForm($args)
  {
    return (new MeineBdvinfoPlugin())->procAction($args);
  }
 
  public function procBdvNewsletterForm($args)
  {
    return (new BdvNewsletterPlugin())->procAction($args);
  }
 
  public function procBeitrittserklaerungForm($args)
  {
    return (new BeitrittserklaerungPlugin())->procAction($args);
  }
 
  // mitglied login stuff
  public function procGetMitgliedLoginForm()
  {
    $request_uri = strtok($this->request->getURI(), "?");
    return (new MitgliedLoginWidget())->getForm($request_uri);
  }
 
  public function procSendMitgliedLoginForm($args)
  {
    return (new MitgliedLoginPlugin())->procAction($args);
  }
 
  public function procIsLoggedIn()
  {
    $tmp_ary = ["status" => $this->is_mitglied];
    return PheryResponse::factory()->json($tmp_ary);
  }
 
  // stuff
  public function procGetContentPopup($args)
  {
    return (new ContentPopupPlugin())->procAction($args);
  }
 
  public function procSetCookieCheck()
  {
    $time = time() + 365 * 86400;
    setcookie("cookie-check", "ja", $time);
  }
 
  /*
   * Phery
   */
 
  private function setPhery($remote = null)
  {
    $Phry = Phery::instance();
 
    if ("kontakt" == $remote) {
      $Phry->set([$remote => [$this, 'procKontaktForm']]);
    } elseif ("send_info_event" == $remote) {
      $response = $this->procInfoEventAnmeldung($this->request);
      echo json_encode($response);
      exit;
    } elseif ("bewerbung" == $remote) {
      $Phry->set([$remote => [$this, 'procBewerbungForm']]);
    } elseif ("quick_connect" == $remote) {
      $Phry->set([$remote => [$this, 'procQuickConnectForm']]);
    } elseif ("broschuere" == $remote) {
      $Phry->set([$remote => [$this, 'procBroschuereForm']]);
    } elseif ("bedarfscheck" == $remote) {
      $Phry->set([$remote => [$this, 'procBedarfsCheckForm']]);
    } elseif ("send_suche_form" == $remote) {
      $Phry->set([$remote => [$this, 'procSucheForm']]);
    }
    // liste stuff
    elseif ("fetch_news" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchNews']]);
    } elseif ("fetch_pressemitteilungen" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchPressemitteilungen']]);
    } elseif ("fetch_stellungnahmen" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchStellungnahmen']]);
    } elseif ("fetch_termine" == $remote) {
      $Phry->set([$remote => [$this, 'procFetchTermine']]);
    }
    // user stuff
    elseif ("send_password_form" == $remote) {
      $Phry->set([$remote => [$this, 'procPasswordForm']]);
    } elseif ("user_register" == $remote) {
      $Phry->set([$remote => [$this, 'procUserRegisterForm']]);
    } elseif ("user_login" == $remote) {
      $Phry->set([$remote => [$this, 'procUserLoginForm']]);
    }
    // wita stuff
    elseif ("wita_login" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaLoginForm']]);
    } elseif ("wita_nachricht" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaNachrichtForm']]);
    } elseif ("wita_anmeldung" == $remote) {
      $Phry->set([$remote => [$this, 'procWitaAnmeldungForm']]);
    }
    // mitgliederbereich stuff
    elseif ("mitglied_login" == $remote) {
      $Phry->set([$remote => [$this, 'procMitgliedLoginForm']]);
    } elseif ("mein_passwort" == $remote) {
      $Phry->set([$remote => [$this, 'procMeinPasswortForm']]);
    } elseif ("meine_anschrift" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineAnschriftForm']]);
    } elseif ("meine_bankverbindung" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineBankverbindungForm']]);
    } elseif ("meine_zugangsdaten" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineZugangsdatenForm']]);
    } elseif ("meine_bdvinfo" == $remote) {
      $Phry->set([$remote => [$this, 'procMeineBdvinfoForm']]);
    } elseif ("bdv_newsletter" == $remote) {
      $Phry->set([$remote => [$this, 'procBdvNewsletterForm']]);
    } elseif ("beitrittserklaerung" == $remote) {
      $Phry->set([$remote => [$this, 'procBeitrittserklaerungForm']]);
    }
    // mitglied login
    elseif ("get_login_form" == $remote) {
      $Phry->set([$remote => [$this, 'procGetMitgliedLoginForm']]);
    } elseif ("send_login_form" == $remote) {
      $Phry->set([$remote => [$this, 'procSendMitgliedLoginForm']]);
    } elseif ("is_logged_in" == $remote) {
      $Phry->set([$remote => [$this, 'procIsLoggedIn']]);
    }
    // stuff
    elseif ("get_content_popup" == $remote) {
      $Phry->set([$remote => [$this, 'procGetContentPopup']]);
    } elseif ("set_cookie_check" == $remote) {
      $Phry->set([$remote => [$this, 'procSetCookieCheck']]);
    }
 
    $Phry->process();
  }
}
#4App\Controllers\Web\ContentController->indexAction
#5Phalcon\Dispatcher\AbstractDispatcher->callActionMethod
#6Phalcon\Dispatcher\AbstractDispatcher->dispatch
#7Phalcon\Mvc\Application->handle
/var/www/vhosts/bundderversicherten.de/httpdocs/index.php (94)
<?php
 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL ^ E_DEPRECATED);
 
#phpinfo(); exit;
date_default_timezone_set("Europe/Amsterdam");
 
use Phalcon\Mvc\Application;
use App\Helper\ErrorHandler;
use Phalcon\Config\Adapter\Ini as ConfigIni;
 
// Phery Bugfix
if(!function_exists('get_magic_quotes_gpc')){
    function get_magic_quotes_gpc(){return false;}
}
// Bugfix ende
 
try {
  require_once(__DIR__.'/../app/config/constants.php');
  
  $vendor_path = APP_PATH.'vendor/';
  $config_path = APP_PATH.'app/config/';
  $config_path_web = $config_path.'web/';
  
  /*
   * Read the configuration 
   */
  $res = is_file(APP_PATH . 'app/config/developing.ini');
  
  if ("localhost:8080" == $_SERVER['HTTP_HOST']) {
    $Config = new ConfigIni(APP_PATH . 'app/config/developing.ini');
  } elseif("weblab.bundderversicherten.de" == $_SERVER['HTTP_HOST'] OR "weblab.bdv.info" == $_SERVER['HTTP_HOST']) {
    $Config = new ConfigIni(APP_PATH . 'app/config/testing.ini');
  } else {
    $Config = new ConfigIni(APP_PATH . 'app/config/production.ini');
  }
  #$res = is_file(APP_PATH . 'app/config/developing.ini');
  #var_dump($res);
  #exit;
  define("CONFIG",$Config);
  /**
  * Auto-loader configuration
  */
  require $vendor_path.'autoload.php';
  require $config_path_web.'loader.php';
 
  /*
   * set ErrorHandler
   */
  $ErrorHandler = new ErrorHandler();
  set_error_handler([$ErrorHandler, "errorHandler"]);
 
  /*
   * load application services
   */
  
  require $config_path_web.'services.php';
  
//  bdv.info Weiterleitung und verkürzte URL
  if("bdv.info" == $_SERVER['HTTP_HOST'] OR "weblab.bdv.info" == $_SERVER['HTTP_HOST']){
    $UrlVerkuerzer = App\Models\UrlVerkuerzer::query()
          ->where('url_kurz = :url:', ['url' => substr($_SERVER['REQUEST_URI'], 1)])
          ->execute()
          ->getFirst();
    if($UrlVerkuerzer){
      header ("Location:https://www.bundderversicherten.de/" . $UrlVerkuerzer->url_ziel);
      exit();
    }
    else{
      header ("Location:https://www.bundderversicherten.de/");
      exit();
    }
  }
  
  
  /*
   * Handle the request
   */
  $App = new Application($di);
   
  /*
   * Handle debugbar
   */
   
  if($Config->web->useDebugbar) {
    $di['app'] = $App;
    (new Snowair\Debugbar\ServiceProvider($config_path_web.'debugbar.php'))->start();  
  }
 
//  echo $_SERVER['REQUEST_URI']; exit;
 
  echo $App->handle($_SERVER['REQUEST_URI'])->getContent();
   
 
}
catch (\Exception $e) {
  #if(IS_LAB OR IS_KCS) {
    echo get_class($e), ": ", $e->getMessage(), "\n";
    echo " File=", $e->getFile(), "\n";
    echo " Line=", $e->getLine(), "\n";
    echo $e->getTraceAsString();
  #}
}
KeyValue
_url/Sitemap
KeyValue
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PP_CUSTOM_PHP_INI/var/www/vhosts/system/bundderversicherten.de/etc/php.ini
PP_CUSTOM_PHP_CGI_INDEXplesk-php82-fastcgi
SCRIPT_NAME/index.php
REQUEST_URI/Sitemap
QUERY_STRING_url=/Sitemap
REQUEST_METHODGET
SERVER_PROTOCOLHTTP/1.0
GATEWAY_INTERFACECGI/1.1
REDIRECT_URL/Sitemap
REDIRECT_QUERY_STRING_url=/Sitemap
REMOTE_PORT51412
SCRIPT_FILENAME/var/www/vhosts/bundderversicherten.de/httpdocs/index.php
SERVER_ADMINroot@localhost
CONTEXT_DOCUMENT_ROOT/var/www/vhosts/bundderversicherten.de/httpdocs
CONTEXT_PREFIX
REQUEST_SCHEMEhttps
DOCUMENT_ROOT/var/www/vhosts/bundderversicherten.de/httpdocs
REMOTE_ADDR3.138.179.119
SERVER_PORT443
SERVER_ADDR46.229.46.62
SERVER_NAMEwww.bundderversicherten.de
SERVER_SOFTWAREApache
SERVER_SIGNATURE
HTTP_REFERERhttp://www.bundderversicherten.de/Sitemap
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT*/*
HTTP_CONNECTIONclose
HTTP_X_ACCEL_INTERNAL/internal-nginx-static-location
HTTP_X_REAL_IP3.138.179.119
HTTP_HOSTwww.bundderversicherten.de
HTTPSon
PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY0
PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY0
PERL5LIB/usr/share/awstats/lib:/usr/share/awstats/plugins
SCRIPT_URIhttps://www.bundderversicherten.de/Sitemap
SCRIPT_URL/Sitemap
UNIQUE_IDZjK74nOuHSn3LqfjZT0LugAAAEI
REDIRECT_STATUS200
REDIRECT_HTTPSon
REDIRECT_PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY0
REDIRECT_PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY0
REDIRECT_PERL5LIB/usr/share/awstats/lib:/usr/share/awstats/plugins
REDIRECT_SCRIPT_URIhttps://www.bundderversicherten.de/Sitemap
REDIRECT_SCRIPT_URL/Sitemap
REDIRECT_UNIQUE_IDZjK74nOuHSn3LqfjZT0LugAAAEI
FCGI_ROLERESPONDER
PHP_SELF/index.php
REQUEST_TIME_FLOAT1714600930.7219
REQUEST_TIME1714600930
#Path
0/var/www/vhosts/bundderversicherten.de/httpdocs/index.php
1/var/www/vhosts/bundderversicherten.de/app/config/constants.php
2/var/www/vhosts/bundderversicherten.de/vendor/autoload.php
3/var/www/vhosts/bundderversicherten.de/vendor/composer/autoload_real.php
4/var/www/vhosts/bundderversicherten.de/vendor/composer/platform_check.php
5/var/www/vhosts/bundderversicherten.de/vendor/composer/ClassLoader.php
6/var/www/vhosts/bundderversicherten.de/vendor/composer/autoload_static.php
7/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-mbstring/bootstrap.php
8/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-mbstring/bootstrap80.php
9/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-intl-normalizer/bootstrap.php
10/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php
11/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-ctype/bootstrap.php
12/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-ctype/bootstrap80.php
13/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-php72/bootstrap.php
14/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-intl-grapheme/bootstrap.php
15/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-intl-idn/bootstrap.php
16/var/www/vhosts/bundderversicherten.de/vendor/symfony/var-dumper/Resources/functions/dump.php
17/var/www/vhosts/bundderversicherten.de/vendor/symfony/string/Resources/functions.php
18/var/www/vhosts/bundderversicherten.de/vendor/symfony/deprecation-contracts/function.php
19/var/www/vhosts/bundderversicherten.de/vendor/symfony/polyfill-php80/bootstrap.php
20/var/www/vhosts/bundderversicherten.de/vendor/psy/psysh/src/functions.php
21/var/www/vhosts/bundderversicherten.de/vendor/snowair/phalcon-debugbar/src/Debug.php
22/var/www/vhosts/bundderversicherten.de/vendor_config/tecnickcom/tcpdf/tcpdf_config.php
23/var/www/vhosts/bundderversicherten.de/app/Helper/functions.php
24/var/www/vhosts/bundderversicherten.de/app/Helper/array.php
25/var/www/vhosts/bundderversicherten.de/app/config/web/loader.php
26/var/www/vhosts/bundderversicherten.de/app/Helper/ErrorHandler.php
27/var/www/vhosts/bundderversicherten.de/app/config/web/services.php
28/var/www/vhosts/bundderversicherten.de/app/Controllers/Web/ContentController.php
29/var/www/vhosts/bundderversicherten.de/app/Controllers/Web/BaseController.php
30/var/www/vhosts/bundderversicherten.de/vendor/phery/phery/src/Phery/Phery.php
31/var/www/vhosts/bundderversicherten.de/app/Models/UrlVerkuerzer.php
32/var/www/vhosts/bundderversicherten.de/app/Models/BaseModel.php
33/var/www/vhosts/bundderversicherten.de/app/Models/Tree.php
34/var/www/vhosts/bundderversicherten.de/app/Traits/File.php
35/var/www/vhosts/bundderversicherten.de/app/Models/NestedSet.php
36/var/www/vhosts/bundderversicherten.de/app/Helper/NestedSet.php
37/var/www/vhosts/bundderversicherten.de/app/Models/Content.php
38/var/www/vhosts/bundderversicherten.de/app/Models/ContentImage.php
39/var/www/vhosts/bundderversicherten.de/app/Models/Teaser.php
40/var/www/vhosts/bundderversicherten.de/app/Models/Teaser2Content.php
41/var/www/vhosts/bundderversicherten.de/app/Widgets/Web/NaviWidget.php
42/var/www/vhosts/bundderversicherten.de/cache/volt/web/%%var%%www%%vhosts%%bundderversicherten.de%%app%%views%%web%%partials%%footermenu.volt.php
43/var/www/vhosts/bundderversicherten.de/app/Models/FacebookPost.php
44/var/www/vhosts/bundderversicherten.de/app/Models/TwitterTweet.php
45/var/www/vhosts/bundderversicherten.de/cache/volt/web/%%var%%www%%vhosts%%bundderversicherten.de%%app%%views%%web%%partials%%footersocial.volt.php
46/var/www/vhosts/bundderversicherten.de/cache/volt/web/%%var%%www%%vhosts%%bundderversicherten.de%%app%%views%%web%%partials%%footer-social-media.volt.php
47/var/www/vhosts/bundderversicherten.de/app/Models/Footer.php
48/var/www/vhosts/bundderversicherten.de/app/Models/SocialMedia.php
49/var/www/vhosts/bundderversicherten.de/app/Models/Liste.php
50/var/www/vhosts/bundderversicherten.de/app/Helper/SitemapGenerator.php
51/var/www/vhosts/bundderversicherten.de/app/Models/ErrorHandler.php
Memory
Usage4194304