/**
  * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileOpeningTag()
  */
 public function compileOpeningTag(TemplateCompiler $templateCompiler)
 {
     // get translation
     $translation = Application::getI18nHandler()->getTranslator()->translate($this->getArgument('key'));
     // return translation
     return $this->getArgument('htmlEncode') ? StringUtil::encodeHtml($translation) : $translation;
 }
Exemplo n.º 2
0
 /**
  * @see \Ableron\Core\Form\FormInterface::getOpenTag()
  */
 public function getOpenTag()
 {
     // get form attributes
     $formAttributes = $this->attributes->toArray();
     // if name is set but and id is not, treat element name as id
     if (!$this->attributes->containsKey('id') && $this->attributes->containsKey(self::ATTR_NAME)) {
         $formAttributes['id'] = $this->attributes->get([self::ATTR_NAME]);
     }
     // declare attribute strings
     $attributeStrings = array();
     // build attribute string
     foreach ($formAttributes as $formAttributeName => $formAttributeValue) {
         // make key lower case
         $formAttributeName = StringUtil::toLowerCase($formAttributeName);
         // skip boolean attributes which values are "false" (false = default)
         if ($formAttributeValue === false) {
             continue;
         }
         // compose attribute
         $attributeStrings[] = sprintf('%s="%s"', StringUtil::encodeHtml($formAttributeName), StringUtil::encodeHtml($formAttributeValue));
     }
     // build final HTML tag
     return sprintf('<form %s>', implode(' ', $attributeStrings));
 }