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);
}