Inheritance: use trait rex_instance_pool_trait
Example #1
0
 public static function getForward($params)
 {
     // Url wurde von einer anderen Extension bereits gesetzt
     if (isset($params['subject']) && $params['subject'] != '') {
         return $params['subject'];
     }
     self::init();
     $domain = $params['domain'];
     if ($domain == 'undefined') {
         $domain = '';
     }
     $url = $params['url'];
     foreach (self::$paths as $p) {
         if ($p['domain'] == $domain && ($p['url'] == $url || $p['url'] . '/' == $url)) {
             $forward_url = '';
             if ($p['type'] == 'article' && ($art = rex_article::get($p['article_id'], $p['clang']))) {
                 $forward_url = rex_getUrl($p['article_id'], $p['clang']);
             } elseif ($p['type'] == 'media' && ($media = rex_media::get($p['media']))) {
                 $forward_url = '/files/' . $p['media'];
             } elseif ($p['type'] == 'extern' && $p['extern'] != '') {
                 $forward_url = $p['extern'];
             }
             if ($forward_url != '') {
                 header('HTTP/1.1 ' . self::$movetypes[$p['movetype']]);
                 header('Location: ' . $forward_url);
                 exit;
             }
         }
     }
     return false;
 }
Example #2
0
 protected function getOutput()
 {
     $id = $this->getArg('id', 0, true);
     if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 10) {
         return false;
     }
     $value = $this->getContextData()->getValue('media' . $id);
     if ($this->hasArg('isset') && $this->getArg('isset')) {
         return $value ? 'true' : 'false';
     }
     if ($this->hasArg('widget') && $this->getArg('widget')) {
         if (!$this->environmentIs(self::ENV_INPUT)) {
             return false;
         }
         $args = [];
         foreach (['category', 'preview', 'types'] as $key) {
             if ($this->hasArg($key)) {
                 $args[$key] = $this->getArg($key);
             }
         }
         $value = self::getWidget($id, 'REX_INPUT_MEDIA[' . $id . ']', $value, $args);
     } else {
         if ($this->hasArg('output') && $this->getArg('output') == 'mimetype') {
             $media = rex_media::get($value);
             if ($media) {
                 $value = $media->getType();
             }
         }
     }
     return self::quote($value);
 }
Example #3
0
         if ($media_manager) {
             $thumbnail = '<img class="thumbnail" src="' . rex_url::backendController(['rex_media_type' => 'rex_mediapool_preview', 'rex_media_file' => $encoded_file_name]) . '" alt="' . $alt . '" title="' . $alt . '" />';
         }
     }
 }
 // ----- get file size
 $size = $file_size;
 $file_size = rex_formatter::bytes($size);
 if ($file_title == '') {
     $file_title = '[' . rex_i18n::msg('pool_file_notitle') . ']';
 }
 $file_title .= ' [' . $file_id . ']';
 // ----- opener
 $opener_link = '';
 if ($opener_input_field == 'TINYIMG') {
     if (rex_media::isImageType(rex_file::extension($file_name))) {
         $opener_link .= '<a class="btn btn-select" href="javascript:insertImage(\'$file_name\',\'' . $files->getValue('title') . '\')">' . rex_i18n::msg('pool_image_get') . '</a>';
     }
 } elseif ($opener_input_field == 'TINY') {
     $opener_link .= '<a class="btn btn-select" href="javascript:insertLink(\'' . $file_name . '\');"">' . rex_i18n::msg('pool_link_get') . '</a>';
 } elseif ($opener_input_field != '') {
     $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedia(\'' . $file_name . '\', \'' . addslashes(htmlspecialchars($files->getValue('title'))) . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
     if (substr($opener_input_field, 0, 14) == 'REX_MEDIALIST_') {
         $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedialist(\'' . $file_name . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
     }
 }
 $ilink = rex_url::currentBackendPage(array_merge(['file_id' => $file_id, 'rex_file_category' => $rex_file_category], $arg_url));
 $add_td = '<td></td>';
 if ($PERMALL) {
     $add_td = '<td><input type="checkbox" name="selectedmedia[]" value="' . $file_name . '" /></td>';
 }
       <label class="col-sm-3 control-label">Text</label>
       <div class="col-sm-9">' . $value['text'] . '</div>
     </div>' . PHP_EOL;
     }
 }
 /****
 *
 *     Bild
 *
 ****/
 $media = '';
 $bild = '';
 $outbackbildinfos = '';
 $position = '';
 if ($value['media_1'] != '') {
     $file = rex_media::get($value['media_1']);
     $filename = $file->getFilename();
     $titel = $file->getTitle();
     $beschreibung = $file->getValue('description');
     $copyright = $file->getValue('copyright');
     if ($value['bildanpassen'] == 'nein') {
         $width = '';
     } else {
         $width = 'width="100%"';
     }
     $bild_img = '<img src="' . rex_url::frontendController() . '?rex_media_type=' . $mediamanagertyp . '&rex_media_file=' . $filename . '" alt="' . $value['alt'] . '" ' . $width . ' />' . PHP_EOL;
     if ($value['bildlink'] == 'ja') {
         $bild_img = $linkanfang . $bild_img . $linkende;
     }
     if ($titel != '') {
         $outbackbildinfos .= '<br/><b>Titel:</b> ' . $titel;
Example #5
0
 /**
  * Löscht die gecachte Medium-Datei.
  *
  * @param string $filename Dateiname
  */
 public static function delete($filename)
 {
     rex_file::delete(rex_path::addonCache('mediapool', $filename . '.media'));
     rex_media::clearInstance($filename);
     self::deleteLists();
 }
 /**
  * Returns array('success'=>true) or array('error'=>'error message')
  */
 function handleUpload($uploadDirectory, $replaceOldFile = FALSE)
 {
     if (!is_writable($uploadDirectory)) {
         return array('error' => "Fehler: Upload-Verzeichnis hat keine Schreibrechte.");
     }
     if (!$this->file) {
         return array('error' => 'Fehler: Es wurden keine Dateien hochgeladen.');
     }
     $size = $this->file->getSize();
     if ($size == 0) {
         return array('error' => 'Fehler: Die Datei ist leer');
     }
     if ($size > $this->sizeLimit) {
         return array('error' => 'Fehler: Die Datei ist zu groß');
     }
     $pathinfo = pathinfo($this->file->getName());
     $filename = $pathinfo['filename'];
     //$filename = md5(uniqid());
     if (!isset($pathinfo['extension'])) {
         $pathinfo['extension'] = '';
     }
     $ext = $pathinfo['extension'];
     if ($this->allowedExtensions && in_array(strtolower($ext), $this->allowedExtensions)) {
         $these = implode(', ', $this->allowedExtensions);
         return array('error' => 'Fehler: Die Datei hat eine ungültige Endung, verboten sind: ' . $these . '.');
     }
     if (!$replaceOldFile) {
         $final_name = rex_mediapool_filename($filename . '.' . $ext);
     }
     if ($this->file->save($uploadDirectory . $final_name)) {
         rex_mediapool_syncFile($final_name, rex_get('mediaCat', 'int'), '');
         rex_set_session('media[rex_file_category]', rex_get('mediaCat', 'int'));
         return array('success' => true, 'filename' => '' . $final_name . '', 'mediaCatId' => rex_get('mediaCat', 'int'), 'fileId' => rex_media::get($final_name)->getId(), 'originalname' => '' . $filename . '.' . $ext . '', 'timestamp' => time());
     } else {
         return array('error' => 'Die Datei konnte nicht gespeichert werden.' . 'Der Upload wurde abgebrochen, oder es handelt sich um einen internen Fehler');
     }
 }
 public function execute()
 {
     $this->media->asImage();
     $gdimage = $this->media->getImage();
     $w = $this->media->getWidth();
     $h = $this->media->getHeight();
     $filename = $this->media->getMediaFilename();
     if ($im_image = rex_media::get($filename)) {
         $focuspoint_data = explode(",", $im_image->getValue('med_focuspoint_data'), 2);
         if (count($focuspoint_data) == 2) {
             // Mittelpunkt finden
             $x = ceil($w / 2);
             $y = ceil($h / 2);
             // focusoffsets einarbeiten
             $fp_w = $focuspoint_data[0];
             $fp_h = $focuspoint_data[1];
             // Neuen Mittelpunkt finden
             $nx = $x + ceil($x * $fp_w);
             $ny = $y - ceil($y * $fp_h);
             // Abstand zum Rand herausfinden
             $nw = $w - $nx;
             // 1/2 Breite
             if ($fp_w < 0) {
                 $nw = $nx;
                 // 1/2 Breite
             }
             $nh = $ny;
             // 1/2 Breite
             if ($fp_h < 0) {
                 $nh = $h - $ny;
                 // 1/2 Breite
             }
             $npx = $nx - $nw;
             $npy = $ny - $nh;
             $nw = $nw * 2;
             $nh = $nh * 2;
             if (function_exists('ImageCreateTrueColor')) {
                 $des = @ImageCreateTrueColor($nw, $nh);
             } else {
                 $des = @ImageCreate($nw, $nh);
             }
             $this->keepTransparent($des);
             imagecopyresampled($des, $gdimage, 0, 0, $npx, $npy, $nw, $nh, $nw, $nh);
             $gdimage = $des;
             $this->media->refreshImageDimensions();
             $w = $nw;
             $h = $nh;
         }
     }
     if (!isset($this->params['style']) || !in_array($this->params['style'], $this->options)) {
         $this->params['style'] = 'maximum';
     }
     // relatives resizen
     if (substr(trim($this->params['width']), -1) === '%') {
         $this->params['width'] = round($w * (rtrim($this->params['width'], '%') / 100));
     }
     if (substr(trim($this->params['height']), -1) === '%') {
         $this->params['height'] = round($h * (rtrim($this->params['height'], '%') / 100));
     }
     if ($this->params['style'] == 'maximum') {
         $this->resizeMax($w, $h);
     } elseif ($this->params['style'] == 'minimum') {
         $this->resizeMin($w, $h);
     } else {
         // warp => nichts tun
     }
     // ----- not enlarge image
     if ($w <= $this->params['width'] && $h <= $this->params['height'] && $this->params['allow_enlarge'] == 'not_enlarge') {
         $this->params['width'] = $w;
         $this->params['height'] = $h;
         $this->keepTransparent($gdimage);
         return;
     }
     if (!isset($this->params['width'])) {
         $this->params['width'] = $w;
     }
     if (!isset($this->params['height'])) {
         $this->params['height'] = $h;
     }
     if (function_exists('ImageCreateTrueColor')) {
         $des = @imagecreatetruecolor($this->params['width'], $this->params['height']);
     } else {
         $des = @imagecreate($this->params['width'], $this->params['height']);
     }
     if (!$des) {
         return;
     }
     // Transparenz erhalten
     $this->keepTransparent($des);
     imagecopyresampled($des, $gdimage, 0, 0, 0, 0, $this->params['width'], $this->params['height'], $w, $h);
     $this->media->setImage($des);
     $this->media->refreshImageDimensions();
 }