get() public static method

public static get ( string $name ) : null | self
$name string
return null | self
Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
            } catch (rex_sql_exception $e) {
                $error = rex_i18n::msg('pool_selectedmedia_error');
            }
        }
    } else {
        $error = rex_i18n::msg('pool_selectedmedia_error');
    }
}
if ($PERMALL && $media_method == 'delete_selectedmedia') {
    $selectedmedia = rex_post('selectedmedia', 'array');
    if (count($selectedmedia) != 0) {
        $error = [];
        $success = [];
        $countDeleted = 0;
        foreach ($selectedmedia as $file_name) {
            $media = rex_media::get($file_name);
            if ($media) {
                if ($PERMALL || rex::getUser()->getComplexPerm('media')->hasCategoryPerm($media->getCategoryId())) {
                    $return = rex_mediapool_deleteMedia($file_name);
                    if ($return['ok']) {
                        ++$countDeleted;
                    } else {
                        $error[] = $return['msg'];
                    }
                } else {
                    $error[] = rex_i18n::msg('no_permission');
                }
            } else {
                $error[] = rex_i18n::msg('pool_file_not_found');
            }
        }
       <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;
Ejemplo n.º 5
0
 /**
  * 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();
 }