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

namespace Kufer\Web\KuferTools\Utils\WssField\Kommunikation;


class WssFieldKommunikationEmailgrafik extends \Kufer\Web\KuferTools\Utils\WssField\WssField
{
  protected function getValue($datamodulWert, $pIsFormular = false)
  {
    
    
    $val = $datamodulWert->getVarValueEx($this->getFieldName(), $this->getDatamodulName());

    
    if (\StringOperations::strpos($val, 'invalidMailLink') !== false) {
      $formatted = preg_replace('/<img[^>]*>/', '<i class="fa fa-envelope-square" aria-hidden="true"></i>', $val);
    } else {
      $formatted = preg_replace('/<img[^>]*>/', '<i class="fa fa-envelope" aria-hidden="true"></i>', $val);
    }

    return $formatted;
  }

  protected function encodeValue($value)
  {
    return $this->purifyHtml($value);
  }
}