19 declare(strict_types=1);
46 'title_ASC' =>
'cert_sortable_by_title_asc',
47 'title_DESC' =>
'cert_sortable_by_title_desc',
48 'date_ASC' =>
'cert_sortable_by_issue_date_asc',
49 'date_DESC' =>
'cert_sortable_by_issue_date_desc',
60 ?ServerRequestInterface $request = null,
70 $logger = $DIC->logger()->cert();
72 if ($template === null) {
73 $template = $DIC->ui()->mainTemplate();
82 if ($language === null) {
83 $language = $DIC->language();
92 if ($request === null) {
93 $request = $DIC->http()->request();
97 if ($certificateLogger === null) {
98 $certificateLogger = $DIC->logger()->cert();
102 if ($certificateSettings === null) {
103 $certificateSettings =
new ilSetting(
"certificate");
107 if (null === $uiFactory) {
108 $uiFactory = $DIC->ui()->factory();
112 if (null === $uiRenderer) {
113 $uiRenderer = $DIC->ui()->renderer();
117 if (null === $access) {
118 $access = $DIC->access();
122 if (null === $filesystem) {
123 $filesystem = $DIC->filesystem()->web();
127 if ($userCertificateRepository === null) {
132 $this->
language->loadLanguageModule(
'cert');
133 $this->
language->loadLanguageModule(
'cert');
138 return 'listCertificates';
143 $nextClass = $this->
ctrl->getNextClass($this);
144 $cmd = $this->
ctrl->getCmd();
146 if (!$this->certificateSettings->get(
'active',
'0')) {
147 $this->
ctrl->returnToParent($this);
150 $this->
template->setTitle($this->
language->txt(
'obj_cert'));
152 switch ($nextClass) {
154 if (!method_exists($this, $cmd)) {
171 if (!$this->certificateSettings->get(
'active',
'0')) {
172 $this->
ctrl->redirect($this);
178 $this->
language->txt(
'certificate_no_object_title')
183 $this->
user->getId(),
185 'order_field' => explode(
'_', $sorting)[0],
186 'order_direction' => explode(
'_', $sorting)[1],
187 'language' => $this->
user->getLanguage()
194 if (count(
$data[
'items']) > 0) {
195 $sortationOptions = [];
198 foreach ($this->sortationOptions as $fieldAndDirection => $lngVariable) {
199 $sortationOptions[$fieldAndDirection] = $this->
language->txt($lngVariable);
202 $sortViewControl = $this->uiFactory
204 ->sortation($sortationOptions)
205 ->withLabel($this->
language->txt($this->sortationOptions[$sorting]))
206 ->withTargetURL($this->
ctrl->getLinkTarget($this,
'applySortation'),
'sort_by');
207 $uiComponents[] = $sortViewControl;
209 foreach (
$data[
'items'] as $certificateData) {
210 $thumbnailImagePath = $certificateData[
'thumbnail_image_path'];
212 if ($thumbnailImagePath === null
213 || $thumbnailImagePath ===
'' 214 || !$this->
filesystem->has($thumbnailImagePath)
219 $cardImage = $this->uiFactory->image()->standard(
221 $certificateData[
'title']
226 if ($certificateData[
'description'] !==
'') {
227 $sections[] = $this->uiFactory->listing()->descriptive([
228 $this->
language->txt(
'cert_description_label') => $certificateData[
'description']
234 $sections[] = $this->uiFactory->listing()->descriptive([
241 $objectTypeIcon = $this->uiFactory
244 ->standard($certificateData[
'obj_type'], $certificateData[
'obj_type']);
246 $objectTitle = $certificateData[
'title'];
248 if (count($refIds) > 0) {
249 foreach ($refIds as
$refId) {
250 if ($this->
access->checkAccess(
'read',
'', $refId)) {
251 $objectTitle = $this->uiRenderer->render(
259 $sections[] = $this->uiFactory->listing()->descriptive([$this->
language->txt(
'cert_object_label') => implode(
262 $this->uiRenderer->render($objectTypeIcon),
268 $this->
ctrl->setParameter($this,
'certificate_id', $certificateData[
'id']);
269 $downloadHref = $this->
ctrl->getLinkTarget($this,
'download');
270 $this->
ctrl->clearParameters($this);
271 $sections[] = $this->uiFactory->button()->standard(
'Download', $downloadHref);
273 $card = $this->uiFactory
275 ->standard($certificateData[
'title'], $cardImage)
276 ->withSections($sections);
281 $deck = $this->uiFactory->deck($cards)->withSmallCardsSize();
283 $uiComponents[] = $this->uiFactory->divider()->horizontal();
285 $uiComponents[] = $deck;
287 $this->
template->setOnScreenMessage(
'info', $this->
language->txt(
'cert_currently_no_certs'));
290 $this->
template->setContent($this->uiRenderer->render($uiComponents));
296 if (!array_key_exists($sorting, $this->sortationOptions)) {
310 if (!array_key_exists($sorting, $this->sortationOptions)) {
326 $language = $DIC->language();
328 $pdfGenerator =
new ilPdfGenerator($this->userCertificateRepository, $this->certificateLogger);
330 $userCertificateId = (
int) $this->request->getQueryParams()[
'certificate_id'];
333 $userCertificate = $this->userCertificateRepository->fetchCertificate($userCertificateId);
334 if ($userCertificate->getUserId() !== $user->
getId()) {
336 'User "%s" tried to access certificate: "%s"',
342 $this->certificateLogger->warning($exception->getMessage());
343 $this->
template->setOnScreenMessage(
'failure', $language->
txt(
'cert_error_no_access'));
349 $this->certificateLogger,
352 $this->
language->txt(
'error_creating_certificate_pdf')
355 $pdfAction->
downloadPdf($userCertificate->getUserId(), $userCertificate->getObjId());
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static get(string $a_var)
An entity that renders components to a string output.
Class ilPdfGeneratorConstantsTest.
ilUserCertificateRepository $userCertificateRepository
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getAllReferences(int $id)
get all reference ids for object ID
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
ilSetting $certificateSettings
__construct(?ilGlobalTemplateInterface $template=null, ?ilCtrlInterface $ctrl=null, ?ilLanguage $language=null, ?ilObjUser $user=null, ?ilUserCertificateRepository $userCertificateRepository=null, ?ServerRequestInterface $request=null, ?ilLogger $certificateLogger=null, ?ilSetting $certificateSettings=null, ?Factory $uiFactory=null, ?Renderer $uiRenderer=null, ?ilAccessHandler $access=null, ?Filesystem $filesystem=null)
static useRelativeDates()
array string $defaultSorting
const SORTATION_SESSION_KEY
ilLogger $certificateLogger
static _getLink(?int $a_ref_id, string $a_type='', array $a_params=array(), string $append="")
ilGlobalTemplateInterface $template
Just a wrapper class to create Unit Test for other classes.
ServerRequestInterface $request
static signFile(string $path_to_file)
static setUseRelativeDates(bool $a_status)
set use relative dates
static set(string $a_var, $a_val)
Set a value.
Class FlySystemFileAccessTest disabled disabled disabled.
downloadPdf(int $userId, int $objectId)