/** * @return string */ public function generate() { $arrUnits = array(); foreach ($this->arrUnits as $arrUnit) { $arrUnits[] = sprintf('<option value="%s"%s>%s</option>', specialchars($arrUnit['value']), $this->isSelected($arrUnit), $arrUnit['label']); } if (!is_array($this->varValue)) { $this->varValue = array('value' => $this->varValue); } // Get languages array with values $this->varValue['value'] = TranslationFieldsModel::getTranslationsByFid($this->varValue['value']); /* @var $objLanguages Languages */ $objLanguages = \System::getContainer()->get('craffft.translation_fields.service.languages'); $arrLngInputs = $objLanguages->getLanguageKeys(); $arrFields = array(); foreach ($arrLngInputs as $i => $strLanguage) { $arrFields[] = sprintf('<div class="tf_field_wrap tf_field_wrap_%s%s"><input type="text" name="%s[value][%s]" id="ctrl_%s" class="tf_field tl_text_unit" value="%s"%s onfocus="Backend.getScrollOffset()"></div>', $strLanguage, $i > 0 ? ' hide' : '', $this->strName, $strLanguage, $this->strId . '_' . $strLanguage, specialchars(@$this->varValue['value'][$strLanguage]), $i > 0 ? WidgetUtil::getCleanedAttributes($this->getAttributes()) : $this->getAttributes()); } $strUnit = sprintf('<select name="%s[unit]" class="tl_select_unit" onfocus="Backend.getScrollOffset()">%s</select>', $this->strName, implode('', $arrUnits)); // Get language button $strLngButton = WidgetUtil::getCurrentTranslationLanguageButton(); // Get language list $strLngList = WidgetUtil::getTranslationLanguagesList(isset($this->varValue['value']) && is_array($this->varValue['value']) ? $this->varValue['value'] : array()); return sprintf('<div id="ctrl_%s" class="tf_wrap tf_text_unit_wrap%s">%s%s%s</div> %s%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', implode(' ', $arrFields), $strLngList, $strLngButton, $strUnit, $this->wizard); }
/** * @return string */ public function generate() { $type = $this->hideInput ? 'password' : 'text'; // Get post array $arrPost = \Input::post($this->strName); // Get languages array with values $this->varValue = TranslationFieldsModel::getTranslationsByFid($this->varValue); /* @var $objLanguages Languages */ $objLanguages = \System::getContainer()->get('craffft.translation_fields.service.languages'); $arrLngInputs = $objLanguages->getLanguageKeys(); $arrFields = array(); foreach ($arrLngInputs as $i => $strLanguage) { $arrFields[] = sprintf('<div class="tf_field_wrap tf_field_wrap_%s%s"><input type="%s" name="%s[%s]" id="ctrl_%s" class="tf_field tl_text" value="%s"%s onfocus="Backend.getScrollOffset()"></div>', $strLanguage, $i > 0 ? ' hide' : '', $type, $this->strName, $strLanguage, $this->strId . '_' . $strLanguage, specialchars(isset($arrPost[$strLanguage]) && $arrPost[$strLanguage] !== null ? $arrPost[$strLanguage] : @$this->varValue[$strLanguage]), $i > 0 ? WidgetUtil::getCleanedAttributes($this->getAttributes()) : $this->getAttributes()); } // Get language button $strLngButton = WidgetUtil::getCurrentTranslationLanguageButton(); // Get language list $strLngList = WidgetUtil::getTranslationLanguagesList(is_array($this->varValue) ? $this->varValue : array()); return sprintf('<div id="ctrl_%s" class="tf_wrap tf_text_wrap%s">%s%s%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', implode(' ', $arrFields), $strLngList, $strLngButton, $this->wizard); }
/** * @return string * @throws \Exception */ public function generate() { // Get post array $arrPost = \Input::post($this->strName); // Get languages array with values $this->varValue = TranslationFieldsModel::getTranslationsByFid($this->varValue); /* @var $objLanguages Languages */ $objLanguages = \System::getContainer()->get('craffft.translation_fields.service.languages'); $arrLngInputs = $objLanguages->getLanguageKeys(); $arrFields = array(); foreach ($arrLngInputs as $i => $strLanguage) { $strRte = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['eval']['rte']; $key = 'ctrl_' . $this->strId . '_' . $strLanguage; $strScript = $this->getRteScriptByTranslatedField($strRte, $key); $arrFields[] = sprintf('<div class="tf_field_wrap tf_field_wrap_%s%s"><textarea name="%s[%s]" id="%s" class="tf_field tl_textarea" rows="%s" cols="%s"%s onfocus="Backend.getScrollOffset()">%s</textarea>%s</div>', $strLanguage, $i > 0 ? ' hide' : '', $this->strName, $strLanguage, $key, $this->intRows, $this->intCols, $i > 0 ? WidgetUtil::getCleanedAttributes($this->getAttributes()) : $this->getAttributes(), specialchars(isset($arrPost[$strLanguage]) && $arrPost[$strLanguage] !== null ? $arrPost[$strLanguage] : @$this->varValue[$strLanguage]), $strScript); } // Get language button $strLngButton = WidgetUtil::getCurrentTranslationLanguageButton(); // Get language list $strLngList = WidgetUtil::getTranslationLanguagesList(is_array($this->varValue) ? $this->varValue : array()); return sprintf('<div id="ctrl_%s" class="tf_wrap tf_textarea_wrap%s%s">%s%s%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', !empty($this->rte) ? ' rte' : '', implode(' ', $arrFields), $strLngList, $strLngButton, $this->wizard); }