ILIAS  release_8 Revision v8.24
ilCertificateSettingsFormRepository Class Reference
+ Inheritance diagram for ilCertificateSettingsFormRepository:
+ Collaboration diagram for ilCertificateSettingsFormRepository:

Public Member Functions

 __construct (int $objectId, string $certificatePath, bool $hasAdditionalElements, ilLanguage $language, ilCtrlInterface $ctrl, ilAccess $access, ilToolbarGUI $toolbar, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ?ilPageFormats $pageFormats=null, ?ilFormFieldParser $formFieldParser=null, ?ilCertificateTemplateImportAction $importAction=null, ?ilLogger $logger=null, ?ilCertificateTemplateRepository $templateRepository=null, ?Filesystem $filesystem=null, ?ilCertificateBackgroundImageFileService $backgroundImageFileService=null)
 
 createForm (ilCertificateGUI $certificateGUI)
 
 save (array $formFields)
 
 fetchFormFieldData (string $content)
 
 createForm (ilCertificateGUI $certificateGUI)
 
 save (array $formFields)
 
 fetchFormFieldData (string $content)
 

Private Attributes

int $objectId
 
ilLanguage $language
 
ilCtrlInterface $ctrl
 
ilAccess $access
 
ilToolbarGUI $toolbar
 
ilCertificatePlaceholderDescription $placeholderDescriptionObject
 
ilPageFormats $pageFormats
 
ilFormFieldParser $formFieldParser
 
ilCertificateTemplateImportAction $importAction
 
ilCertificateTemplateRepository $templateRepository
 
bool $hasAdditionalElements
 
ilCertificateBackgroundImageFileService $backGroundImageFileService
 
WrapperFactory $httpWrapper
 
Factory $refinery
 
ilObjCertificateSettings $global_certificate_settings
 
ilGlobalTemplateInterface $page_template
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateSettingsFormRepository::__construct ( int  $objectId,
string  $certificatePath,
bool  $hasAdditionalElements,
ilLanguage  $language,
ilCtrlInterface  $ctrl,
ilAccess  $access,
ilToolbarGUI  $toolbar,
ilCertificatePlaceholderDescription  $placeholderDescriptionObject,
?ilPageFormats  $pageFormats = null,
?ilFormFieldParser  $formFieldParser = null,
?ilCertificateTemplateImportAction  $importAction = null,
?ilLogger  $logger = null,
?ilCertificateTemplateRepository  $templateRepository = null,
?Filesystem  $filesystem = null,
?ilCertificateBackgroundImageFileService  $backgroundImageFileService = null 
)

Definition at line 50 of file class.ilCertificateSettingsFormRepository.php.

66 {
67 global $DIC;
68 $this->httpWrapper = $DIC->http()->wrapper();
69 $this->page_template = $DIC->ui()->mainTemplate();
70 $this->refinery = $DIC->refinery();
71 $this->objectId = $objectId;
72 $this->language = $language;
73 $this->ctrl = $ctrl;
74 $this->access = $access;
75 $this->toolbar = $toolbar;
76 $this->placeholderDescriptionObject = $placeholderDescriptionObject;
77 $this->hasAdditionalElements = $hasAdditionalElements;
78 $this->global_certificate_settings = new ilObjCertificateSettings();
79
80 $database = $DIC->database();
81
82 if (null === $logger) {
83 $logger = $logger = $DIC->logger()->cert();
84 }
85
86 if (null === $pageFormats) {
88 }
89 $this->pageFormats = $pageFormats;
90
91 if (null === $formFieldParser) {
93 }
94 $this->formFieldParser = $formFieldParser;
95
96 if (null === $importAction) {
99 $certificatePath,
101 $logger,
102 $DIC->filesystem()->web()
103 );
104 }
105 $this->importAction = $importAction;
106
107 if (null === $templateRepository) {
109 }
110 $this->templateRepository = $templateRepository;
111
112 if (null === $filesystem) {
113 $filesystem = $DIC->filesystem()->web();
114 }
115
116 if (null === $backgroundImageFileService) {
117 $backgroundImageFileService = new ilCertificateBackgroundImageFileService(
118 $certificatePath,
119 $filesystem
120 );
121 }
122 $this->backGroundImageFileService = $backgroundImageFileService;
123 }
ilCertificatePlaceholderDescription $placeholderDescriptionObject
Class ilObjCertificateSettings.
global $DIC
Definition: feed.php:28

References $access, $ctrl, $DIC, $formFieldParser, $hasAdditionalElements, $importAction, $language, $objectId, $pageFormats, $placeholderDescriptionObject, $templateRepository, $toolbar, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ createForm()

ilCertificateSettingsFormRepository::createForm ( ilCertificateGUI  $certificateGUI)
Parameters
ilCertificateGUI$certificateGUI
Returns
ilPropertyFormGUI
Exceptions
FileAlreadyExistsException
FileNotFoundException
IOException
ilDatabaseException
ilException
ilWACException

Implements ilCertificateFormRepository.

Definition at line 135 of file class.ilCertificateSettingsFormRepository.php.

136 {
137 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
138
139 $command = $this->ctrl->getCmd();
140
141 $form = new ilPropertyFormGUI();
142 $form->setPreventDoubleSubmission(false);
143 $form->setFormAction($this->ctrl->getFormAction($certificateGUI));
144 $form->setTitle($this->language->txt("cert_form_sec_availability"));
145 $form->setMultipart(true);
146 $form->setTableWidth("100%");
147 $form->setId("certificate");
148
149 $active = new ilCheckboxInputGUI($this->language->txt("active"), "active");
150 $form->addItem($active);
151
152 $import = new ilFileInputGUI($this->language->txt("import"), "certificate_import");
153 $import->setRequired(false);
154 $import->setSuffixes(["zip"]);
155
156 // handle the certificate import
157 if (!empty($_FILES["certificate_import"]["name"]) && $import->checkInput()) {
158 $result = $this->importAction->import(
159 $_FILES["certificate_import"]["tmp_name"],
160 $_FILES["certificate_import"]["name"]
161 );
162 if ($result === false) {
163 $this->page_template->setOnScreenMessage(
164 $this->page_template::MESSAGE_TYPE_FAILURE,
165 $this->language->txt('certificate_error_import'),
166 true
167 );
168 $this->ctrl->redirect($certificateGUI, 'certificateEditor');
169 } else {
170 $this->page_template->setOnScreenMessage(
171 $this->page_template::MESSAGE_TYPE_SUCCESS,
172 $this->language->txt('saved_successfully'),
173 true
174 );
175 $this->ctrl->redirect($certificateGUI, 'certificateEditor');
176 }
177 }
178 $form->addItem($import);
179
180 $formSection = new ilFormSectionHeaderGUI();
181 $formSection->setTitle($this->language->txt("cert_form_sec_layout"));
182 $form->addItem($formSection);
183
184 $pageformat = new ilRadioGroupInputGUI($this->language->txt("certificate_page_format"), "pageformat");
185 $pageformats = $this->pageFormats->fetchPageFormats();
186
187 foreach ($pageformats as $format) {
188 $option = new ilRadioOption($format["name"], $format["value"]);
189
190 if (strcmp($format["value"], "custom") === 0) {
191 $pageheight = new ilTextInputGUI($this->language->txt("certificate_pageheight"), "pageheight");
192 $pageheight->setSize(6);
193 $pageheight->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
194 $pageheight->setInfo($this->language->txt("certificate_unit_description"));
195 $pageheight->setRequired(true);
196 $option->addSubItem($pageheight);
197
198 $pagewidth = new ilTextInputGUI($this->language->txt("certificate_pagewidth"), "pagewidth");
199 $pagewidth->setSize(6);
200 $pagewidth->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
201 $pagewidth->setInfo($this->language->txt("certificate_unit_description"));
202 $pagewidth->setRequired(true);
203 $option->addSubItem($pagewidth);
204 }
205
206 $pageformat->addOption($option);
207 }
208
209 $pageformat->setRequired(true);
210
211 if (strcmp($command, "certificateSave") === 0) {
212 $pageformat->checkInput();
213 }
214
215 $form->addItem($pageformat);
216
217 $bgimage = new ilImageFileInputGUI($this->language->txt("certificate_background_image"), "background");
218 $bgimage->setRequired(false);
219 $bgimage->setUseCache(false);
220
221 $bgimage->setAllowDeletion(true);
222 if (!$this->backGroundImageFileService->hasBackgroundImage($certificateTemplate)) {
223 if ($this->global_certificate_settings->hasBackgroundImage()) {
225 $imagePath = ilWACSignedPath::signFile($this->global_certificate_settings->getBackgroundImageThumbPathWeb());
226 $bgimage->setImage($imagePath);
227 $bgimage->setAllowDeletion(false);
228 }
229 } else {
231
232 $thumbnail_path = $this->backGroundImageFileService->getBackgroundImageThumbPath();
233
234 if (!is_file($thumbnail_path)) {
235 //Trying if it uses default image path
236 $thumbnail_path = CLIENT_WEB_DIR . $certificateTemplate->getBackgroundImagePath() . '.thumb.jpg';
237 if (!is_file($thumbnail_path)) {
238 //Trying to use global default image
239 $thumbnail_path = $this->global_certificate_settings->getDefaultBackgroundImageThumbPath();
240 if (!is_file($thumbnail_path)) {
241 //No image global default configured
242 $thumbnail_path = '';
243 }
244 }
245 $bgimage->setALlowDeletion(false);
246 }
247 $imagePath = ilWACSignedPath::signFile($thumbnail_path);
248 $bgimage->setImage($imagePath);
249 }
250
251 $form->addItem($bgimage);
252
253 $thumbnailImage = new ilImageFileInputGUI(
254 $this->language->txt('certificate_card_thumbnail_image'),
255 'certificate_card_thumbnail_image'
256 );
257 $thumbnailImage->setRequired(false);
258 $thumbnailImage->setUseCache(false);
259 $thumbnailImage->setSuffixes(['svg']);
260
261 $allowThumbnailDeletion = false;
262
263 $cardThumbnailImagePath = $certificateTemplate->getThumbnailImagePath();
264 if ('' !== $cardThumbnailImagePath) {
265 $presentationThumbnailImagePath = CLIENT_WEB_DIR . $cardThumbnailImagePath;
266 $thumbnailImage->setImage(ilWACSignedPath::signFile($presentationThumbnailImagePath));
267 $allowThumbnailDeletion = true;
268 }
269
270 $thumbnailImage->setAllowDeletion($allowThumbnailDeletion);
271
272 $form->addItem($thumbnailImage);
273
274 $rect = new ilCSSRectInputGUI($this->language->txt("certificate_margin_body"), "margin_body");
275 $rect->setRequired(true);
276 $rect->setUseUnits(true);
277 $rect->setInfo($this->language->txt("certificate_unit_description"));
278
279 if (strcmp($command, "certificateSave") === 0) {
280 $rect->checkInput();
281 }
282
283 $form->addItem($rect);
284
285 $certificate = new ilTextAreaInputGUI($this->language->txt("certificate_text"), "certificate_text");
286 $certificate->setInfo($this->language->txt('certificate_text_info'));
287 $certificate->removePlugin('ilimgupload');
288 $certificate->setRequired(true);
289 $certificate->setRows(20);
290 $certificate->setCols(80);
291
292 $placeholderHtmlDescription = $this->placeholderDescriptionObject->createPlaceholderHtmlDescription();
293
294 $placeholderDescriptionInHtml = $placeholderHtmlDescription;
295
296 $certificate->setInfo($placeholderDescriptionInHtml);
297
298 $certificate->setUseRte(true, '3.4.7');
299
300 $tags = [
301 "br",
302 "em",
303 "font",
304 "li",
305 "ol",
306 "p",
307 "span",
308 "strong",
309 "u",
310 "ul"
311 ];
312
313 $certificate->setRteTags($tags);
314
315 if (strcmp($command, "certificateSave") === 0) {
316 $certificate->checkInput();
317 }
318
319 $form->addItem($certificate);
320
321 if (true === $this->hasAdditionalElements) {
322 $formSection = new ilFormSectionHeaderGUI();
323 $formSection->setTitle($this->language->txt("cert_form_sec_add_features"));
324 $form->addItem($formSection);
325 }
326
327 if ($this->access->checkAccess(
328 "write",
329 "",
330 $this->httpWrapper->query()->retrieve("ref_id", $this->refinery->kindlyTo()->int())
331 )) {
332 if ($certificateTemplate->isCurrentlyActive()) {
333 $this->toolbar->setFormAction($this->ctrl->getFormAction($certificateGUI));
334
336 $preview->setCaption('certificate_preview');
337 $preview->setCommand('certificatePreview');
338 $this->toolbar->addStickyItem($preview);
339
340 $export = ilSubmitButton::getInstance();
341 $export->setCaption('certificate_export');
342 $export->setCommand('certificateExportFO');
343 $this->toolbar->addButtonInstance($export);
344
345 $delete = ilSubmitButton::getInstance();
346 $delete->setCaption('delete');
347 $delete->setCommand('certificateDelete');
348 $this->toolbar->addButtonInstance($delete);
349 }
350 $form->addCommandButton("certificateSave", $this->language->txt("save"));
351 }
352
353 return $form;
354 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This class represents a file property in a property form.
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 class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
static signFile(string $path_to_file)
const CLIENT_WEB_DIR
Definition: constants.php:47
$preview
Definition: imgupload.php:81
$format
Definition: metadata.php:235

References $format, $preview, ILIAS\Repository\access(), CLIENT_WEB_DIR, ILIAS\Repository\ctrl(), ilSubmitButton\getInstance(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), ilWACSignedPath\signFile(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ fetchFormFieldData()

ilCertificateSettingsFormRepository::fetchFormFieldData ( string  $content)
Parameters
string$content
Returns
array

Implements ilCertificateFormRepository.

Definition at line 364 of file class.ilCertificateSettingsFormRepository.php.

364 : array
365 {
366 return $this->formFieldParser->fetchDefaultFormFields($content);
367 }

◆ save()

ilCertificateSettingsFormRepository::save ( array  $formFields)

Implements ilCertificateFormRepository.

Definition at line 356 of file class.ilCertificateSettingsFormRepository.php.

356 : void
357 {
358 }

Field Documentation

◆ $access

ilAccess ilCertificateSettingsFormRepository::$access
private

Definition at line 36 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $backGroundImageFileService

ilCertificateBackgroundImageFileService ilCertificateSettingsFormRepository::$backGroundImageFileService
private

◆ $ctrl

ilCtrlInterface ilCertificateSettingsFormRepository::$ctrl
private

Definition at line 35 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $formFieldParser

ilFormFieldParser ilCertificateSettingsFormRepository::$formFieldParser
private

Definition at line 40 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $global_certificate_settings

ilObjCertificateSettings ilCertificateSettingsFormRepository::$global_certificate_settings
private

◆ $hasAdditionalElements

bool ilCertificateSettingsFormRepository::$hasAdditionalElements
private

Definition at line 43 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $httpWrapper

WrapperFactory ilCertificateSettingsFormRepository::$httpWrapper
private

◆ $importAction

ilCertificateTemplateImportAction ilCertificateSettingsFormRepository::$importAction
private

Definition at line 41 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $language

ilLanguage ilCertificateSettingsFormRepository::$language
private

Definition at line 34 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $objectId

int ilCertificateSettingsFormRepository::$objectId
private

Definition at line 33 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $page_template

ilGlobalTemplateInterface ilCertificateSettingsFormRepository::$page_template
private

◆ $pageFormats

ilPageFormats ilCertificateSettingsFormRepository::$pageFormats
private

Definition at line 39 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $placeholderDescriptionObject

ilCertificatePlaceholderDescription ilCertificateSettingsFormRepository::$placeholderDescriptionObject
private

Definition at line 38 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $refinery

Factory ilCertificateSettingsFormRepository::$refinery
private

◆ $templateRepository

ilCertificateTemplateRepository ilCertificateSettingsFormRepository::$templateRepository
private

Definition at line 42 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilCertificateSettingsFormRepository::$toolbar
private

Definition at line 37 of file class.ilCertificateSettingsFormRepository.php.

Referenced by __construct().


The documentation for this class was generated from the following file: