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