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


class DataMenuSucheKurse extends DataMenuKurse
{
  public function __construct($urlparameter)
  {
    SessionOperations::setKursSearch();

    SessionOperations::setVarValueSuche('kfs_suchegesetzt', 'true');

    parent::__construct($urlparameter);
    $this->urlparameter->implodeSettingsbyType(new URLParameterBasis());
    $this->status1 = "<a class='statusadresse' href='" . CleanOperations::cleanStringForHtml(INDEXSCRIPT) . '?urlparameter=' . CleanOperations::cleanStringForHtml($this->urlparameter->getStreamWith(array('kathaupt'), array('6'))) . "'>Suchergebnis</a>\n";

    
    
    if (RequestOperations::isPost()) {
      header_remove('Cache-Control');
    }
  }

  protected function getDefaultOrderBy()
  {
    
    return null;

    return $this->settings->sortkurse;
  }

  protected function getDefaultOderbyAsc()
  {
    
    return null;

    return $this->settings->sortkurseasc;
  }

  
  public function _getClickPath()
  {
    
    DataMenuMain::_getClickPath();
    
    if ($this->toolsettings->titleKursBereich != '') {
      $this->clickpfad = "<span class='clickadresse'>" . ' ' . CleanOperations::cleanStringForHtml(stripslashes($this->toolsettings->titleKursBereich)) . ' ' . "</span>\n";
      $this->clickpfad .= "<span class='trennzeichen'>" . ' ' . CleanOperations::cleanStringContainingHtml($this->toolsettings->trennzeichenKategorie) . ' ' . '</span>';
    }
    $this->clickpfad .= "<a class='clickadresse' href='" . CleanOperations::cleanStringForHtml(INDEXSCRIPT) . '?urlparameter='
                        . CleanOperations::cleanStringForHtml($this->urlparameter->getEmptyStreamWith(
                          array('kathaupt', 'suchformular'),
                          array('6', 'true')
                        )) . "' title='Suche'>" . CleanOperations::cleanStringForHtml($this->toolsettings->clickSucheText) . '</a>'
                        . "<span class='trennzeichen'>" . ' ' . CleanOperations::cleanStringContainingHtml($this->toolsettings->trennzeichenKategorie) . ' ' . '</span>'
                        . "<span class='clickadrbold'>" . CleanOperations::cleanStringForHtml($this->toolsettings->clickSuchergebnisText) . "</span>\n";
    
    return $this->clickpfad;
  }

  
  public function getdataarraybody($pZeitBereich = 'noRestrict')
  {
    
    
    
    
    
    
    
    
    if ((SessionOperations::getVarValueSuche('kfs_dozentname') != '')
      || (SessionOperations::getVarValueSuche('kfs_dozentvorname') != '')
      || (SessionOperations::getVarValueSuche('kfs_dozentid') != '')
      || (SessionOperations::getVarValueSuche('kfs_schlagwort') != '')
      || (SessionOperations::getVarValueSuche('kfs_dozentnamevorname') != '')
      || (SessionOperations::getVarValueSuche('kfs_seminarort_select') != '')
      || (SessionOperations::getVarValueSuche('kfs_gebuehrvon') != '')
      || (SessionOperations::getVarValueSuche('kfs_gebuehrbis') != '')) {
      $this->setKursSearch();
      $dozname = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_dozentname'));
      $dozvorname = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_dozentvorname'));
      $doznamevorname = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_dozentnamevorname'));
      $schlagwort = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_schlagwort'));
      $dozId = SessionOperations::getVarValueSuche('kfs_dozentid');
      $seminarOrt = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_seminarort_select'));
      $gebuehrvon = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_gebuehrvon'));
      $gebuehrbis = $this->addfstring->replaceWildcards(SessionOperations::getVarValueSuche('kfs_gebuehrbis'));

      if (!isset($this->dbwkurse->fromobject->hauptdozent)) {
        $this->dbwkurse->fromobject->hauptdozent = new Dozent();
      }

      if ($dozname != '') {
        $this->dbwkurse->fromobject->hauptdozent->name = $dozname;
      }
      if ($dozvorname != '') {
        $this->dbwkurse->fromobject->hauptdozent->vorname = $dozvorname;
      }
      if ($doznamevorname != '') {
        $this->dbwkurse->fromobject->hauptdozent->namevorname = $doznamevorname;
      }
      if ($dozId != '' && $dozId > -1) {
        $this->dbwkurse->fromobject->hauptdozent->id = $dozId;
      }
      if ($schlagwort != '') {
        $this->dbwkurse->fromobject->schlagwort = $schlagwort;
      }
      
      
      if (isset($this->dbwkurse->fromobject->stichworte) && $schlagwort == $this->dbwkurse->fromobject->stichworte) {
        $this->dbwkurse->fromobject->stichwortFindetSchlagwort = true;
      }


      
      
      $aktDate = DateTimeOperations::getDateNow();
      if ($pZeitBereich == 'vonHeute') {
        
        
        $this->dbwkurse->fromobject->beginn_dat = DateTimeOperations::max($this->dbwkurse->fromobject->beginn_dat, $aktDate);
      } elseif ($pZeitBereich == 'bisHeute') {
        
        
        $this->dbwkurse->toobject->beginn_dat = DateTimeOperations::min($this->dbwkurse->toobject->beginn_dat, DateTimeOperations::getDateDaysBefore($aktDate, 1));
      } else {
        
      }


      if ($seminarOrt != '') {
        $this->dbwkurse->fromobject->ortProgheft1 = $seminarOrt;
      }

      if ($gebuehrvon != '') {
        $this->dbwkurse->fromobject->gebuehr = $gebuehrvon;
      }

      if ($gebuehrbis != '') {
        $this->dbwkurse->toobject->gebuehr = $gebuehrbis;
      }

      $param = new URLParameterFilter();
      if ($param->clearAllKatfilter()) {
        SessionOperations::resetKursKategorieRestrictions();
      }

      SessionOperations::applyKursKategorieRestrictions($this->dbwkurse->fromobject, $this->dbwkurse->toobject);

      $kursids = $this->dbwkurse->getKursebyCategoryLimit(
        $this->addfstring->getfilledStr($this->urlparameter->katid, '0'),
        WBKursStore::getKurs($this->urlparameter->knr),
        $this->getAnzahlKurseProSeite(),
        ($this->addfstring->getfilledStr($this->urlparameter->browse, 'forward') == 'forward')
      );
      $this->dataarraybody = WBKursStore::getKurseByIdArray($kursids);
    } else {
      DataMenuKurse::getdataarraybody($pZeitBereich);
    }

    
    
    
    if (count($this->dataarraybody) == 0) {
      $this->getsight(50);
    }
  }

  

  public function get2ndColumn()
  {
    
    $this->getsight(50);
    $this->dataarraynodata = array(new Datamodul());

    return $this->getnodata();
  }
}