Exemple #1
0
    public function render($doctype, $environment)
    {
        $languages = ipContent()->getLanguages();
        $answer = '';
        foreach ($languages as $language) {
            $langValue = '';
            $fieldValue = $this->getValue();
            if (is_array($fieldValue)) {
                if (!empty($fieldValue[$language->getCode()])) {
                    $langValue = $fieldValue[$language->getCode()];
                }
            }
            if (!is_string($langValue)) {
                //just in case we have an array or something else incompatible with bellow code in the database
                $langValue = '';
            }
            $answer .= '
<div class="input-group">
  <span class="input-group-addon">' . esc($language->getAbbreviation()) . '</span>

<textarea ' . $this->getAttributesStr($doctype) . ' class="form-control ' . implode(' ', $this->getClasses()) . '" name="' . escattr($this->getName()) . '[' . $language->getCode() . ']" ' . $this->getValidationAttributesStr($doctype) . ' >' . escTextarea($langValue) . '</textarea>


</div>
            ';
        }
        return $answer;
    }
Exemple #2
0
 /**
  * Render field
  *
  * @param string $doctype
  * @param $environment
  * @return string
  */
 public function render($doctype, $environment)
 {
     return '<textarea ' . $this->getAttributesStr($doctype) . ' class="form-control ' . implode(' ', $this->getClasses()) . '" name="' . escattr($this->getName()) . '" ' . $this->getValidationAttributesStr($doctype) . ' >' . escTextarea($this->getValue()) . '</textarea>';
 }
Exemple #3
0
/**
 * Translate and escape a string
 *
 * @param string $text Original value in English.
 * @param string $domain Context, e.g. plugin name.
 * @param string $esc Escape type. Available values: false, 'html', 'attr', 'textarea'.
 * @return string Translated string or original string if no translation exists.
 * @throws Ip\Exception
 */
function __($text, $domain, $esc = 'html')
{
    $translation = \Ip\ServiceLocator::translator()->translate($text, $domain);
    if ('html' == $esc) {
        return esc($translation);
    } elseif (false === $esc) {
        return $translation;
    } elseif ('attr' == $esc) {
        return escAttr($translation);
    } elseif ('textarea' == $esc) {
        return escTextarea($translation);
    }
    throw new \Ip\Exception('Unknown escape method: {$esc}');
}