ILIAS  release_8 Revision v8.24
class.ilAssOrderingElement.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
29{
31
32 public static $objectInstanceCounter = 0;
34
39 public int $id;
40
48 protected ?int $random_identifier = null;
49
60 protected ?int $solution_identifier = null;
61
65 protected int $indentation = 0;
66
70 protected ?int $position = null;
71 protected ?string $content = null;
72 protected ?string $uploadImageName = null;
73 protected ?string $uploadImageFile = null;
74 protected bool $imageRemovalRequest = false;
75 protected ?string $imagePathWeb = null;
76 protected ?string $imagePathFs = null;
77 protected $imageThumbnailPrefix = null;
78
82 public function __construct(int $id = -1)
83 {
84 $this->id = $id;
85 $this->objectInstanceId = ++self::$objectInstanceCounter;
86 }
87
91 public function __clone()
92 {
93 $this->objectInstanceId = ++self::$objectInstanceCounter;
94 }
95
96 public function getClone(): ilAssOrderingElement
97 {
98 return clone $this;
99 }
100
101 public function getId(): int
102 {
103 return $this->id;
104 }
105
106 public function setId(int $id): void
107 {
108 $this->id = $id;
109 }
110
111 public function getRandomIdentifier(): ?int
112 {
114 }
115
116 public function setRandomIdentifier(int $random_identifier): void
117 {
118 $this->random_identifier = $random_identifier;
119 }
120
124 public function getSolutionIdentifier(): ?int
125 {
127 }
128
130 {
131 $this->solution_identifier = $solution_identifier;
132 }
133
134 public function setIndentation(int $indentation): void
135 {
136 $this->indentation = $indentation;
137 }
138
139 public function getIndentation(): int
140 {
141 return $this->indentation;
142 }
143
144 public function getPosition(): ?int
145 {
146 return $this->position;
147 }
148
149 public function setPosition(int $position): void
150 {
151 $this->position = $position;
152 }
153
157 public function getContent(): ?string
158 {
159 return $this->content;
160 }
161
162
163 public function setContent($content): void
164 {
165 if (is_array($content)) {
166 $content = array_shift($content);
167 }
168 $this->content = $content;
169 }
170
171 public function getUploadImageFile(): ?string
172 {
174 }
175
180 {
181 if (is_array($uploadImageFile)) {
182 $uploadImageFile = array_shift($uploadImageFile);
183 }
184 $this->uploadImageFile = $uploadImageFile;
185 }
186
190 public function getUploadImageName(): ?string
191 {
193 }
194
199 {
200 if (is_array($uploadImageName)) {
201 $uploadImageName = array_shift($uploadImageName);
202 }
203 $this->uploadImageName = $uploadImageName;
204 }
205
209 public function isImageUploadAvailable(): bool
210 {
211 return (bool) strlen($this->getUploadImageFile());
212 }
213
217 public function isImageRemovalRequest(): ?bool
218 {
220 }
221
226 {
227 $this->imageRemovalRequest = $imageRemovalRequest;
228 }
229
233 public function getImagePathWeb(): ?string
234 {
235 return $this->imagePathWeb;
236 }
237
241 public function setImagePathWeb($imagePathWeb): void
242 {
243 $this->imagePathWeb = $imagePathWeb;
244 }
245
249 public function getImagePathFs(): ?string
250 {
251 return $this->imagePathFs;
252 }
253
257 public function setImagePathFs($imagePathFs): void
258 {
259 $this->imagePathFs = $imagePathFs;
260 }
261
262 public function getImageThumbnailPrefix()
263 {
265 }
266
268 {
269 $this->imageThumbnailPrefix = $imageThumbnailPrefix;
270 }
271
276 public function isSameElement(ilAssOrderingElement $element): bool
277 {
278 return [
279 $this->getRandomIdentifier(),
280 $this->getSolutionIdentifier(),
281 $this->getPosition(),
282 $this->getIndentation(),
283 ] == [
284 $element->getRandomIdentifier(),
285 $element->getSolutionIdentifier(),
286 $element->getPosition(),
287 $element->getIndentation()
288 ];
289 }
290
291 public function getStorageValue1($orderingType)
292 {
293 switch ($orderingType) {
296
297 return $this->getPosition();
298
301 default:
302 return $this->getSolutionIdentifier();
303 }
304 }
305
306 public function getStorageValue2($orderingType)
307 {
308 switch ($orderingType) {
311
312 return $this->getRandomIdentifier() . ':' . $this->getIndentation();
313
316 default:
317 return $this->getPosition() + 1;
318 }
319 }
320
321 public function __toString(): string
322 {
323 return $this->getContent() ?? '';
324 }
325
326 protected function thumbnailFileExists(): bool
327 {
328 if (!$this->getContent()) {
329 return false;
330 }
331
332 return file_exists($this->getThumbnailFilePath());
333 }
334
335 protected function getThumbnailFilePath(): string
336 {
337 return $this->getImagePathFs() . $this->getImageThumbnailPrefix() . $this->getContent();
338 }
339
340 protected function getThumbnailFileUrl(): string
341 {
342 return $this->getImagePathWeb() . $this->getImageThumbnailPrefix() . $this->getContent();
343 }
344
345 protected function imageFileExists(): bool
346 {
347 if (!$this->getContent()) {
348 return false;
349 }
350
351 return file_exists($this->getImageFilePath());
352 }
353
354 protected function getImageFilePath(): string
355 {
356 return $this->getImagePathFs() . $this->getContent();
357 }
358
359 protected function getImageFileUrl(): string
360 {
361 return $this->getImagePathWeb() . $this->getContent();
362 }
363
364 public function getPresentationImageUrl(): string
365 {
366 if ($this->thumbnailFileExists()) {
367 return $this->getThumbnailFileUrl();
368 }
369
370 if ($this->imageFileExists()) {
371 return $this->getImageFileUrl();
372 }
373
374 return '';
375 }
376
377 public function getExportIdent(): string
378 {
379 $ident = array(
380 $this->getRandomIdentifier(),
381 $this->getSolutionIdentifier(),
382 $this->getPosition(),
383 $this->getIndentation()
384 );
385
386 return implode(self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident);
387 }
388
389 public function isExportIdent(string $ident): bool
390 {
391 if (!strlen($ident)) {
392 return false;
393 }
394
395 $parts = explode(self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident);
396 return
397 count($parts) == 4
402 }
403
404 public function setExportIdent($ident): void
405 {
406 if ($this->isExportIdent($ident)) {
407 list($randomId, $solutionId, $pos, $indent) = explode(
408 self::EXPORT_IDENT_PROPERTY_SEPARATOR,
409 $ident
410 );
411 $this->setRandomIdentifier((int) $randomId);
412 $this->setSolutionIdentifier((int) $solutionId);
413 $this->setPosition((int) $pos);
414 $this->setIndentation((int) $indent);
415 }
416 }
417
418
419 public function withRandomIdentifier(int $id): self
420 {
421 $clone = clone $this;
422 $clone->random_identifier = $id;
423 return $clone;
424 }
425 public function withSolutionIdentifier(int $id): self
426 {
427 $clone = clone $this;
428 $clone->solution_identifier = $id;
429 return $clone;
430 }
431 public function withPosition(int $position): self
432 {
433 $clone = clone $this;
434 $clone->position = $position;
435 return $clone;
436 }
437 public function withIndentation(int $indentation): self
438 {
439 $clone = clone $this;
440 $clone->indentation = $indentation;
441 return $clone;
442 }
443 public function withContent(string $content): self
444 {
445 $clone = clone $this;
446 $clone->content = $content;
447 return $clone;
448 }
449}
int $position
the correct position in the ordering sequence
int $indentation
the correct width of indentation for the element
__construct(int $id=-1)
ilAssOrderingElement constructor.
setImageRemovalRequest($imageRemovalRequest)
setImageThumbnailPrefix($imageThumbnailPrefix)
setRandomIdentifier(int $random_identifier)
isSameElement(ilAssOrderingElement $element)
int $random_identifier
this identifier is generated randomly it is recycled for known elements
setSolutionIdentifier(int $solution_identifier)
int $solution_identifier
this identifier is used to identify elements and is stored together with the set position and indenta...
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64