ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSecureTokenSrcBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
28
33{
35
36 public function __construct(
38 ) {
39 $this->inline = new InlineSrcBuilder($file_delivery);
40 }
41
42 public function getRevisionURL(
43 Revision $revision,
44 bool $signed = true,
45 float $valid_for_at_least_minutes = 60.0,
46 ?string $filename = null
47 ): string {
48 // get stream from revision
49 $stream = $revision->maybeStreamResolver()?->getStream();
50
51 return (string) $this->file_delivery->buildTokenURL(
52 $stream,
53 $filename ?? $revision->getTitle(),
54 Disposition::INLINE,
55 $GLOBALS['ilUser']->getId() ?? 0,
56 (int) (ceil($valid_for_at_least_minutes / 60))
57 );
58 }
59
60 public function getFlavourURLs(Flavour $flavour, bool $signed = true): \Generator
61 {
62 try {
63 global $DIC;
64
66 ->resourceStorage()
67 ->manage()
68 ->getResource($flavour->getResourceId())
69 ->getSpecificRevision($flavour->getRevision())
70 ?->getInformation()
71 ->getTitle() ?? '';
72
73 $frindly_name = preg_replace(
74 '/[^a-zA-Z0-9-_]/',
75 '',
76 strtolower($flavour->getDefinition()->getInternalName())
77 );
78 } catch (Throwable) {
79 $filename = '';
80 $frindly_name = 'fl';
81 }
82
83
84 foreach ($flavour->getStreamResolvers() as $i => $stream_resolver) {
85 $stream = $stream_resolver->getStream();
86 if ($stream_resolver->isInMemory() || $stream->getMetadata()['uri'] === 'php://memory') {
87 // must deliver as data uri
88 yield $this->inline->buildDataURLFromStream($stream);
89 } else {
90
91 yield (string) $this->file_delivery->buildTokenURL(
92 $stream,
93 $frindly_name . '_' . $i . '_' . $filename,
94 Disposition::INLINE,
95 $GLOBALS['ilUser']->getId() ?? 0,
96 1
97 );
98 }
99 }
100 }
101
102}
$filename
Definition: buildRTE.php:78
getRevisionURL(Revision $revision, bool $signed=true, float $valid_for_at_least_minutes=60.0, ?string $filename=null)
getFlavourURLs(Flavour $flavour, bool $signed=true)
__construct(private Services $file_delivery)
$file_delivery
Definition: deliver.php:29
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54