ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStudyProgrammePlaceholderValues.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 private readonly \ilDefaultPlaceholderValues $defaultPlaceholderValuesObject;
26 private readonly \ilCertificateObjectHelper $objectHelper;
27
28 public function __construct(
29 ?\ilDefaultPlaceholderValues $defaultPlaceholderValues = null,
30 ?\ilLanguage $language = null,
32 ) {
33 if (null === $language) {
34 global $DIC;
35 $language = $DIC->language();
36 $language->loadLanguageModule('certificate');
37 }
38
39 if (null === $defaultPlaceholderValues) {
40 $defaultPlaceholderValues = new \ilDefaultPlaceholderValues();
41 }
42
43 if (null === $objectHelper) {
44 $objectHelper = new \ilCertificateObjectHelper();
45 }
46 $this->objectHelper = $objectHelper;
47
48 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
49 }
50
61 public function getPlaceholderValues(int $userId, int $objId): array
62 {
63 $object = $this->objectHelper->getInstanceByObjId($objId);
64 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
65
66 $latest_progress = false;
67 $ass_id = $object->getCertificateRelevantAssignmentIds($userId);
68 if ($ass_id !== []) {
69 $latest_progress = $object->getSpecificAssignment(current($ass_id))->getProgressTree();
70 }
71
72 $type = $object->getSubType();
73 $placeholders['PRG_TITLE'] = \ilLegacyFormElementsUtil::prepareFormOutput($object->getTitle());
74 $placeholders['PRG_DESCRIPTION'] = \ilLegacyFormElementsUtil::prepareFormOutput($object->getDescription());
75 $placeholders['PRG_TYPE'] = \ilLegacyFormElementsUtil::prepareFormOutput($type ? $type->getTitle() : '');
76 $placeholders['PRG_POINTS'] = \ilLegacyFormElementsUtil::prepareFormOutput(
77 $latest_progress ? (string) $latest_progress->getCurrentAmountOfPoints() : ''
78 );
79 $placeholders['PRG_COMPLETION_DATE'] = \ilLegacyFormElementsUtil::prepareFormOutput(
80 $latest_progress && $latest_progress->getCompletionDate() instanceof \DateTimeImmutable ? $latest_progress->getCompletionDate(
81 )->format('d.m.Y') : ''
82 );
83 $placeholders['PRG_EXPIRES_AT'] = \ilLegacyFormElementsUtil::prepareFormOutput(
84 $latest_progress && $latest_progress->getValidityOfQualification(
85 ) instanceof \DateTimeImmutable ? $latest_progress->getValidityOfQualification()->format('d.m.Y') : ''
86 );
87 return $placeholders;
88 }
89
95 public function getPlaceholderValuesForPreview(int $userId, int $objId): array
96 {
97 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
98
99 $object = $this->objectHelper->getInstanceByObjId($objId);
100 $type = $object->getSubType();
101 $today = \ilLegacyFormElementsUtil::prepareFormOutput((new \DateTime())->format('d.m.Y'));
102 $placeholders['PRG_TITLE'] = \ilLegacyFormElementsUtil::prepareFormOutput($object->getTitle());
103 $placeholders['PRG_DESCRIPTION'] = \ilLegacyFormElementsUtil::prepareFormOutput($object->getDescription());
104 $placeholders['PRG_TYPE'] = \ilLegacyFormElementsUtil::prepareFormOutput($type ? $type->getTitle() : '');
105 $placeholders['PRG_POINTS'] = \ilLegacyFormElementsUtil::prepareFormOutput((string) $object->getPoints());
106 $placeholders['PRG_COMPLETION_DATE'] = $today;
107 $placeholders['PRG_EXPIRES_AT'] = $today;
108 return $placeholders;
109 }
110
111}
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
__construct(?\ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?\ilLanguage $language=null, ?\ilCertificateObjectHelper $objectHelper=null)
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
Collection of basic placeholder values that can be used.
language handling
static prepareFormOutput($a_str, bool $a_strip=false)
global $DIC
Definition: shib_login.php:26
$objId
Definition: xapitoken.php:57