19declare(strict_types=1);
24use Psr\Http\Message\ServerRequestInterface;
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();
82 if ($language ===
null) {
92 if ($request ===
null) {
122 if (
null === $filesystem) {
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);
177 $this->certificateLogger,
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) {
198 foreach ($this->sortationOptions as $fieldAndDirection => $lngVariable) {
202 $sortViewControl = $this->uiFactory
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)) {
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());
Just a wrapper class to create Unit Test for other classes.
static useRelativeDates()
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getWebspaceDir(string $mode="filesystem")
get webspace directory
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 _getLink(?int $a_ref_id, string $a_type='', array $a_params=array(), string $append="")
Component logger with individual log levels by component id.
static _getAllReferences(int $id)
get all reference ids for object ID
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ServerRequestInterface $request
ilGlobalTemplateInterface $template
ilUserCertificateRepository $userCertificateRepository
__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)
const SORTATION_SESSION_KEY
ilLogger $certificateLogger
ilSetting $certificateSettings
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static signFile(string $path_to_file)
This is how the factory for UI elements looks.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ilPdfGeneratorConstantsTest.