ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCertificateSettingsFormRepository.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{
12 private $objectId;
13
17 private $language;
18
22 private $controller;
23
27 private $access;
28
32 private $toolbar;
33
38
42 private $pageFormats;
43
48
53
58
63
68
73
88 public function __construct(
89 int $objectId,
90 string $certificatePath,
100 ilLogger $logger = null,
102 \ILIAS\Filesystem\Filesystem $filesystem = null,
103 ilCertificateBackgroundImageFileService $backgroundImageFileService = null
104 ) {
105 global $DIC;
106
107 $this->objectId = $objectId;
108 $this->language = $language;
109 $this->controller = $controller;
110 $this->access = $access;
111 $this->toolbar = $toolbar;
112 $this->placeholderDescriptionObject = $placeholderDescriptionObject;
113 $this->certificatePath = $certificatePath;
114 $this->hasAdditionalElements = $hasAdditionalElements;
115
116 $database = $DIC->database();
117
118
119 if (null === $logger) {
120 $logger = $logger = $DIC->logger()->cert();
121 }
122
123 if (null === $pageFormats) {
125 }
126 $this->pageFormats = $pageFormats;
127
128 if (null === $formFieldParser) {
130 }
131 $this->formFieldParser = $formFieldParser;
132
133 if (null === $importAction) {
135 (int) $objectId,
138 $logger,
139 $DIC->filesystem()->web()
140 );
141 }
142 $this->importAction = $importAction;
143
144 if (null === $templateRepository) {
146 }
147 $this->templateRepository = $templateRepository;
148
149 if (null === $filesystem) {
150 $filesystem = $DIC->filesystem()->web();
151 }
152
153 if (null === $backgroundImageFileService) {
154 $backgroundImageFileService = new ilCertificateBackgroundImageFileService(
156 $filesystem
157 );
158 }
159 $this->backGroundImageFileService = $backgroundImageFileService;
160 }
161
174 public function createForm(ilCertificateGUI $certificateGUI)
175 {
176 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
177
178 $command = $this->controller->getCmd();
179
180 $form = new ilPropertyFormGUI();
181 $form->setPreventDoubleSubmission(false);
182 $form->setFormAction($this->controller->getFormAction($certificateGUI));
183 $form->setTitle($this->language->txt("cert_form_sec_availability"));
184 $form->setMultipart(true);
185 $form->setTableWidth("100%");
186 $form->setId("certificate");
187
188 $active = new ilCheckboxInputGUI($this->language->txt("active"), "active");
189 $form->addItem($active);
190
191 $import = new ilFileInputGUI($this->language->txt("import"), "certificate_import");
192 $import->setRequired(false);
193 $import->setSuffixes(array("zip"));
194
195 // handle the certificate import
196 if (strlen($_FILES["certificate_import"]["name"])) {
197 if ($import->checkInput()) {
198 $result = $this->importAction->import($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
199 if ($result == false) {
200 $import->setAlert($this->language->txt("certificate_error_import"));
201 } else {
202 $this->controller->redirect($certificateGUI, "certificateEditor");
203 }
204 }
205 }
206 $form->addItem($import);
207
208 $formSection = new \ilFormSectionHeaderGUI();
209 $formSection->setTitle($this->language->txt("cert_form_sec_layout"));
210 $form->addItem($formSection);
211
212 $pageformat = new ilRadioGroupInputGUI($this->language->txt("certificate_page_format"), "pageformat");
213 $pageformats = $this->pageFormats->fetchPageFormats();
214
215 foreach ($pageformats as $format) {
216 $option = new ilRadioOption($format["name"], $format["value"]);
217
218 if (strcmp($format["value"], "custom") == 0) {
219 $pageheight = new ilTextInputGUI($this->language->txt("certificate_pageheight"), "pageheight");
220 $pageheight->setSize(6);
221 $pageheight->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
222 $pageheight->setInfo($this->language->txt("certificate_unit_description"));
223 $pageheight->setRequired(true);
224 $option->addSubitem($pageheight);
225
226 $pagewidth = new ilTextInputGUI($this->language->txt("certificate_pagewidth"), "pagewidth");
227 $pagewidth->setSize(6);
228 $pagewidth->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
229 $pagewidth->setInfo($this->language->txt("certificate_unit_description"));
230 $pagewidth->setRequired(true);
231 $option->addSubitem($pagewidth);
232 }
233
234 $pageformat->addOption($option);
235 }
236
237 $pageformat->setRequired(true);
238
239 if (strcmp($command, "certificateSave") == 0) {
240 $pageformat->checkInput();
241 }
242
243 $form->addItem($pageformat);
244
245 $bgimage = new ilImageFileInputGUI($this->language->txt("certificate_background_image"), "background");
246 $bgimage->setRequired(false);
247 $bgimage->setUseCache(false);
248
249 $bgimage->setALlowDeletion(true);
250 if (!$this->backGroundImageFileService->hasBackgroundImage($certificateTemplate)) {
254 $bgimage->setImage($imagePath);
255 $bgimage->setALlowDeletion(false);
256 }
257 } else {
259
260 $thumbnailPath = $this->backGroundImageFileService->getBackgroundImageThumbPath();
261
262 if (!file_exists($thumbnailPath)) {
264 $bgimage->setALlowDeletion(false);
265 }
266 $imagePath = ilWACSignedPath::signFile($thumbnailPath);
267 $bgimage->setImage($imagePath);
268 }
269
270 $form->addItem($bgimage);
271
272 $thumbnailImage = new ilImageFileInputGUI($this->language->txt('certificate_card_thumbnail_image'), 'certificate_card_thumbnail_image');
273 $thumbnailImage->setRequired(false);
274 $thumbnailImage->setUseCache(false);
275 $thumbnailImage->setSuffixes(array('svg'));
276
277 $allowThumbnailDeletion = false;
278
279 $cardThumbnailImagePath = $certificateTemplate->getThumbnailImagePath();
280 if ('' !== $cardThumbnailImagePath) {
281 $presentationThumbnailImagePath = CLIENT_WEB_DIR . $cardThumbnailImagePath;
282 $thumbnailImage->setImage(ilWACSignedPath::signFile($presentationThumbnailImagePath));
283 $allowThumbnailDeletion = true;
284 }
285
286 $thumbnailImage->setAllowDeletion($allowThumbnailDeletion);
287
288 $form->addItem($thumbnailImage);
289
290 $rect = new ilCSSRectInputGUI($this->language->txt("certificate_margin_body"), "margin_body");
291 $rect->setRequired(true);
292 $rect->setUseUnits(true);
293 $rect->setInfo($this->language->txt("certificate_unit_description"));
294
295 if (strcmp($command, "certificateSave") == 0) {
296 $rect->checkInput();
297 }
298
299 $form->addItem($rect);
300
301 $certificate = new ilTextAreaInputGUI($this->language->txt("certificate_text"), "certificate_text");
302 $certificate->removePlugin('ilimgupload');
303 $certificate->setRequired(true);
304 $certificate->setRows(20);
305 $certificate->setCols(80);
306
307 $placeholderHtmlDescription = $this->placeholderDescriptionObject->createPlaceholderHtmlDescription();
308
309 $placeholderDescriptionInHtml = $placeholderHtmlDescription;
310
311 $certificate->setInfo($placeholderDescriptionInHtml);
312
313 $certificate->setUseRte(true, '3.4.7');
314
315 $tags = array(
316 "br",
317 "em",
318 "font",
319 "li",
320 "ol",
321 "p",
322 "span",
323 "strong",
324 "u",
325 "ul"
326 );
327
328 $certificate->setRteTags($tags);
329
330 if (strcmp($command, "certificateSave") == 0) {
331 $certificate->checkInput();
332 }
333
334 $form->addItem($certificate);
335
336 if (true === $this->hasAdditionalElements) {
337 $formSection = new \ilFormSectionHeaderGUI();
338 $formSection->setTitle($this->language->txt("cert_form_sec_add_features"));
339 $form->addItem($formSection);
340 }
341
342 if ($this->access->checkAccess("write", "", $_GET["ref_id"])) {
343 if ($certificateTemplate->isCurrentlyActive()) {
344 $this->toolbar->setFormAction($this->controller->getFormAction($certificateGUI));
345
347 $preview->setCaption('certificate_preview');
348 $preview->setCommand('certificatePreview');
349 $this->toolbar->addStickyItem($preview);
350
351 $export = ilSubmitButton::getInstance();
352 $export->setCaption('certificate_export');
353 $export->setCommand('certificateExportFO');
354 $this->toolbar->addButtonInstance($export);
355
356 $delete = ilSubmitButton::getInstance();
357 $delete->setCaption('delete');
358 $delete->setCommand('certificateDelete');
359 $this->toolbar->addButtonInstance($delete);
360 }
361 $form->addCommandButton("certificateSave", $this->language->txt("save"));
362 }
363
364 return $form;
365 }
366
371 public function save(array $formFields)
372 {
373 }
374
379 public function fetchFormFieldData(string $content)
380 {
381 return $this->formFieldParser->fetchDefaultFormFields($content);
382 }
383}
$result
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Class ilAccessHandler.
This class represents a text property in a property form.
GUI class to create PDF certificates.
__construct(int $objectId, string $certificatePath, bool $hasAdditionalElements, ilLanguage $language, ilCtrl $controller, ilAccess $access, ilToolbarGUI $toolbar, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilPageFormats $pageFormats=null, ilFormFieldParser $formFieldParser=null, ilCertificateTemplateImportAction $importAction=null, ilLogger $logger=null, ilCertificateTemplateRepository $templateRepository=null, \ILIAS\Filesystem\Filesystem $filesystem=null, ilCertificateBackgroundImageFileService $backgroundImageFileService=null)
This class represents a checkbox property in a property form.
This class provides processing control methods.
This class represents a file property in a property form.
This class represents an image file property in a property form.
language handling
Component logger with individual log levels by component id.
static hasBackgroundImage()
Returns wheather or not a default background image exists.
static getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
static getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static getInstance()
Factory.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static signFile($path_to_file)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
language()
Definition: language.php:2
$format
Definition: metadata.php:218
Class FlySystemFileAccessTest.
Class ChatMainBarProvider \MainMenu\Provider.
$preview
$DIC
Definition: xapitoken.php:46