ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCoursePlaceholderValues.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
13
17 private $language;
18
23
28
33
37 private $dateHelper;
38
43
53 public function __construct(
54 ilDefaultPlaceholderValues $defaultPlaceholderValues = null,
55 ilLanguage $language = null,
61 ) {
62 if (null === $language) {
63 global $DIC;
64 $language = $DIC->language();
65 $language->loadLanguageModule('certificate');
66 }
67 $this->language = $language;
68
69 if (null === $defaultPlaceholderValues) {
70 $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
71 }
72
73 if (null === $objectHelper) {
75 }
76 $this->objectHelper = $objectHelper;
77
78 if (null === $participantsHelper) {
80 }
81 $this->participantsHelper = $participantsHelper;
82
83 if (null === $ilUtilHelper) {
85 }
86 $this->ilUtilHelper = $ilUtilHelper;
87
88 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
89
90 if (null === $dateHelper) {
92 }
93 $this->dateHelper = $dateHelper;
94
95 if (null === $lpStatusHelper) {
97 }
98 $this->lpStatusHelper = $lpStatusHelper;
99
100 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
101 }
102
107 private function hasCompletionDate($possibleDate) : bool
108 {
109 return (
110 $possibleDate !== false &&
111 $possibleDate !== null &&
112 $possibleDate !== ''
113 );
114 }
115
127 public function getPlaceholderValues(int $userId, int $objId) : array
128 {
129 $courseObject = $this->objectHelper->getInstanceByObjId($objId);
130
131 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
132
133 $placeholders['COURSE_TITLE'] = $this->ilUtilHelper->prepareFormOutput($courseObject->getTitle());
134 $completionDate = $this->participantsHelper->getDateTimeOfPassed($objId, $userId);
135 if (!$this->hasCompletionDate($completionDate)) {
136 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
137 }
138
139 if ($this->hasCompletionDate($completionDate)) {
140 $placeholders['DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
141 $placeholders['DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
142 }
143
144 $placeholders['COURSE_TITLE'] = $this->ilUtilHelper->prepareFormOutput($courseObject->getTitle());
145
146 return $placeholders;
147 }
148
157 public function getPlaceholderValuesForPreview(int $userId, int $objId)
158 {
159 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
160
161 $object = $this->objectHelper->getInstanceByObjId($objId);
162
163 $placeholders['COURSE_TITLE'] = ilUtil::prepareFormOutput($object->getTitle());
164
165 return $placeholders;
166 }
167}
An exception for terminatinating execution or to throw for unit testing.
Just a wrapper class to create Unit Test for other classes.
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, ilCertificateParticipantsHelper $participantsHelper=null, ilCertificateUtilHelper $ilUtilHelper=null, ilCertificateDateHelper $dateHelper=null, ilCertificateLPStatusHelper $lpStatusHelper=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, $a_strip=false)
prepares string output for html forms @access public
language()
Definition: language.php:2
$DIC
Definition: xapitoken.php:46
$objId
Definition: xapitoken.php:41