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

namespace Kufer\KuferTools\Utils\WssField;


class WssFieldKommunikationEmailgrafik extends 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);
  }
}