Skip to content

Commit

Permalink
new method mediaUrl (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
skerbis authored Jun 4, 2024
1 parent c4a3c8b commit 312b50f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/pdfout.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public function setName(string $name): self

public function setHtml(string $html, bool $outputfilter = false): self
{
if ($outputfilter)
{
$html = rex_extension::registerPoint(new rex_extension_point('OUTPUT_FILTER', $html));
if ($outputfilter) {
$html = rex_extension::registerPoint(new rex_extension_point('OUTPUT_FILTER', $html));
}
$this->html = $html;
return $this;
Expand Down Expand Up @@ -78,7 +77,7 @@ public function setDpi(int $dpi): self
$this->dpi = $dpi;
return $this;
}

public function setSaveAndSend(bool $saveAndSend): self
{
$this->saveAndSend = $saveAndSend;
Expand All @@ -101,15 +100,15 @@ public function run(): void
$this->render();
// Pagecounter Placeholder esetzen, wenn vorhanden
$this->injectPageCount($this);

// Speichern des PDF
if ($this->saveToPath !== '') {
$savedata = $this->output();
if (!is_null($savedata)) {
rex_file::put($this->saveToPath . rex_string::normalize($this->name) . '.pdf', $savedata);
}
}

// Ausliefern des PDF
if ($this->saveToPath === '' || $this->saveAndSend === true) {
rex_response::cleanOutputBuffers(); // OutputBuffer leeren
Expand All @@ -119,6 +118,16 @@ public function run(): void
}
}

public static function mediaUrl(string $type, string $file): string
{
$paddon = rex_addon::get('pdfout');
$url = rex_media_manager::getUrl($type, $file);
if ($addon->getProperty('aspdf', false) || rex_request('pdfout', 'int', 0) === 1) {
return rex::getServer() . $url;
}
return $url;
}

public static function viewer(string $file = ''): string
{
if ($file !== '') {
Expand Down

0 comments on commit 312b50f

Please sign in to comment.