/** * Display the settings panel when editing a section * @param \XMLElement $wrapper * @param null $errors */ public function displaySettingsPanel(&$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); $label = Widget::Label(__('Destination directory on the server')); $destination = $this->get('destination'); if ($destination == null) { $destination = DOCROOT; } $label->appendChild(Widget::Input('fields[' . $this->get('sortorder') . '][destination]', $destination)); if (isset($errors['destination'])) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['destination'])); } else { $wrapper->appendChild($label); } $this->buildValidationSelect($wrapper, $this->get('validator'), 'fields[' . $this->get('sortorder') . '][validator]', 'upload'); $div = new XMLElement('div', NULL, array('class' => 'compact')); $this->appendRequiredCheckbox($div); $this->appendShowColumnCheckbox($div); $wrapper->appendChild($div); }
public function prepareTableValue($data, XMLElement $link = null, $entry_id = null) { if (!($file = $data['file'])) { if ($link) { return parent::prepareTableValue(null, $link); } else { return parent::prepareTableValue(null); } } if ($data['width'] > $data['height']) { $width = 40; $height = 0; } else { $width = 0; $height = 40; } $destination = str_replace('/workspace', '', $this->get('destination')) . '/'; $src = ''; if (isset($data['mimetype']) && self::isSvg($data['mimetype'])) { $src = URL . '/workspace' . $destination . $file; } else { $src = URL . '/image/1/' . $width . '/' . $height . $destination . $file; } $image = '<img style="vertical-align: middle; max-height:40px;" src="' . $src . '" alt="' . $this->get('label') . ' of Entry ' . $entry_id . '"/>'; if ($link) { $link->setValue($image); } else { $link = Widget::Anchor($image, URL . $this->get('destination') . '/' . $file); } $link->setAttribute('data-path', $this->get('destination')); return $link->generate(); }
public function prepareTableValue($data, XMLElement $link = NULL, $entry_id = null) { // default to backend language $language_code = Lang::get(); if (!in_array($language_code, FLang::instance()->ld()->languageCodes())) { $language_code = FLang::instance()->referenceLanguage(); } $data['file'] = $data['file-' . $language_code]; if ($this->get('use_def_lang_vals') == 'yes' && $data['file'] == '') { // If value is empty for this language, load value of default language $language_code = FLang::instance()->referenceLanguage(); $data['file'] = $data['file-' . $language_code]; } return parent::prepareTableValue($data, $link, $entry_id); }