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

class Foto extends Datamodul
{
  public const TYP_BENUTZER = 'B';
  public const TYP_DOZENTEN = 'D';
  public const TYP_GEBAEUDE = 'G';
  public const TYP_KURSE = 'K';
  public const TYP_KURSORTE = 'R';
  public const TYP_AUSSENSTELLEN = 'S';
  public const TYP_ARTIKEL = 'Q'; 
  public const TYP_ALLGEMEIN = 'X';

  
  public $typ;
  
  public $nr;
  
  public $knr;
  
  public $lfdNr;
  
  public $untertitel;
  
  public $beschreibung_bf;
  
  public $copyright;

  
  public $bezugsquelle;

  
  public $portrait = '';

  
  public $portrait_inArbeit = '';

  
  public $pfoto = '';

  
  public $pfoto_inArbeit = '';

  
  public $portrait_flag = 0;

  
  public function setValue2Var($var, $val)
  {
    switch ($var) {  default: $this->{$var} = $val; break;  }
  }

  public function getID()
  {
    $typ = $this->getVarValue('typ');
    if ($typ == 'K') {
      return $this->getVarValue('knr');
    } else {
      return $this->getVarValue('nr');
    }
  }

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'nr':
      case 'portrait_flag':
        return \DatamodulVarType::TYPE_INT;
      case 'pfoto_inArbeit':
      case 'pfoto':
        return \DatamodulVarType::TYPE_BINARY;
    }
  }

  
  public function getImageLink($pSuffix)
  {
    return PortraitAPI::getPortraitFotoLinkForKuferTools($this->typ, $this->nr, $pSuffix);
  }
}