/**
  * Prepare the table value for the index screen
  * @param array $data
  * @param null|XMLElement $link
  * @return string
  */
 public function prepareTableValue($data, XMLElement $link = NULL)
 {
     if (!($file = $data['file'])) {
         if ($link) {
             return parent::prepareTableValue(null, $link);
         } else {
             return parent::prepareTableValue(null);
         }
     }
     $linkStr = '<a href="' . URL . '/symphony/extension/private_upload/?file=' . $file . '">' . basename($file) . '</a>';
     return $linkStr;
 }
示例#2
0
 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);
 }