ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 }
66 $this->language = $language;
67
68 if (null === $defaultPlaceholderValues) {
69 $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
70 }
71
72 if (null === $objectHelper) {
74 }
75 $this->objectHelper = $objectHelper;
76
77 if (null === $participantsHelper) {
79 }
80 $this->participantsHelper = $participantsHelper;
81
82 if (null === $ilUtilHelper) {
84 }
85 $this->ilUtilHelper = $ilUtilHelper;
86
87 if (null === $dateHelper) {
89 }
90 $this->dateHelper = $dateHelper;
91
92 if (null === $lpStatusHelper) {
94 }
95 $this->lpStatusHelper = $lpStatusHelper;
96
97 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
98 }
99
104 private function hasCompletionDate($possibleDate) : bool
105 {
106 return (
107 $possibleDate !== false &&
108 $possibleDate !== null &&
109 $possibleDate !== ''
110 );
111 }
112
126 public function getPlaceholderValues(int $userId, int $objId) : array
127 {
128 $courseObject = $this->objectHelper->getInstanceByObjId($objId);
129
130 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
131
132 $completionDate = $this->participantsHelper->getDateTimeOfPassed($objId, $userId);
133 if (!$this->hasCompletionDate($completionDate)) {
134 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
135 }
136
137 if ($this->hasCompletionDate($completionDate)) {
138 $placeholders['DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
139 $placeholders['DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
140 }
141
142 $placeholders['COURSE_TITLE'] = $this->ilUtilHelper->prepareFormOutput($courseObject->getTitle());
143
144 return $placeholders;
145 }
146
156 public function getPlaceholderValuesForPreview(int $userId, int $objId)
157 {
158 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
159
160 $object = $this->objectHelper->getInstanceByObjId($objId);
161
162 $placeholders['COURSE_TITLE'] = ilUtil::prepareFormOutput($object->getTitle());
163
164 return $placeholders;
165 }
166}
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
global $DIC
Definition: saml.php:7