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

namespace Kufer\KuferTools\Mitarbeiter\RaumUebersicht\RaumDetails\Detailsreiter\Kurse;

class ReiterKursePresenter extends \Kufer\KuferTools\Basis\Raumbelegung\Raumdetails\Detailsreiter\Kurse\ReiterKursePresenter
{
  protected function getView()
  {
    return new ReiterKurseView($this->getViewModel());
  }

  protected function setModelKursAttribute4Links($pViewModel)
  {
    
    
    $pViewModel->kurs->isAllowedToolDozInfo = $this->useCaseResponse->isAllowedToolDozInfo;
    $pViewModel->kurs->refererLink = $this->useCaseResponse->refererLink;
    $pViewModel->kurs->refererLabel = $this->useCaseResponse->refererLabel;
  }

  
  protected function getLinkZuKursdetails($pDatamodul)
  {
    return in_array($pDatamodul->id, $this->useCaseResponse->kursIdsAry4User)
      ? '<a href="index.php?tool_id=8&amp;action=kursdetails&amp;knr=' . $pDatamodul->id
         
            . '&amp;referer=' . $this->useCaseResponse->refererLink
         
            . '&amp;refererLabel=' . $this->useCaseResponse->refererLabel
            . '" title="Kursdetails" alt="Kursdetails">
        <i class="hm_termine fa fa-search-plus" aria-hidden="true"></i>
      </a>'
    : '';
  }

  protected function getView4AnderenContent($pViewModel)
  {
    return new KursView($pViewModel);
  }

  
  protected function getHyperlink4Columns($pDatamodul, $pColumns)
  {
    $columnsCount = count($pColumns);
    
    
    
    $columnsCopy = array();
    for ($i = 0; $i < $columnsCount; $i++) {
      $columnsCopy[$i] = clone $pColumns[$i];
    }

    
    for ($i = 0; $i < $columnsCount; $i++) {
      
      if ($this->isKursLink($pDatamodul, $columnsCopy[$i])) {
        $linkToOtherTool = 'index.php?tool_id=' . \ToolsAPI::TOOL_KURSPLANUNG_MA . '&action=kursdetails&knr=' . $pDatamodul->id;
        
        $columnsCopy[$i]->hyperlink = $linkToOtherTool . '&referer=' . urlencode('index.php?tool_id=34&action=raumdetails&rnr='
            . $this->useCaseResponse->kursort->id) . '&refererLabel=' . urlencode(\StringOperations::htmlentities('Zurück zu den Raumdetails'));
      } 

      
      
    } 

    return $columnsCopy;
  }

  

  
  protected function isKursLink($pDataModul, $pColumn)
  {
    return (in_array($pDataModul->id, $this->useCaseResponse->kursIdsAry4User)
       && ($pColumn->fieldname == 'id' && $pColumn->datamodul == 'kurs'));
  }

  

  
  
  
  protected function isDozentenLink($pColumn)
  {
  }
}