ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
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 $web_fs=null, ?Filesystem $tmp_fs=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  $web_fs = null,
?Filesystem  $tmp_fs = null,
?ilCertificateBackgroundImageFileService  $backgroundImageFileService = null 
)

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

67 {
68 global $DIC;
69 $this->httpWrapper = $DIC->http()->wrapper();
70 $this->page_template = $DIC->ui()->mainTemplate();
71 $this->refinery = $DIC->refinery();
72 $this->objectId = $objectId;
73 $this->language = $language;
74 $this->ctrl = $ctrl;
75 $this->access = $access;
76 $this->toolbar = $toolbar;
77 $this->placeholderDescriptionObject = $placeholderDescriptionObject;
78 $this->hasAdditionalElements = $hasAdditionalElements;
79 $this->global_certificate_settings = new ilObjCertificateSettings();
80
81 $database = $DIC->database();
82
83 if (null === $logger) {
84 $logger = $logger = $DIC->logger()->cert();
85 }
86
87 if (null === $pageFormats) {
89 }
90 $this->pageFormats = $pageFormats;
91
92 if (null === $formFieldParser) {
94 }
95 $this->formFieldParser = $formFieldParser;
96
97 if (null === $web_fs) {
98 $web_fs = $DIC->filesystem()->web();
99 }
100 if (null === $tmp_fs) {
101 $tmp_fs = $DIC->filesystem()->temp();
102 }
103
104 if (null === $importAction) {
106 $objectId,
107 $certificatePath,
109 $logger,
110 $web_fs,
111 $tmp_fs
112 );
113 }
114 $this->importAction = $importAction;
115
116 if (null === $templateRepository) {
118 }
119 $this->templateRepository = $templateRepository;
120
121 if (null === $backgroundImageFileService) {
122 $backgroundImageFileService = new ilCertificateBackgroundImageFileService(
123 $certificatePath,
124 $web_fs
125 );
126 }
127 $this->backGroundImageFileService = $backgroundImageFileService;
128 }
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 140 of file class.ilCertificateSettingsFormRepository.php.

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

369 : array
370 {
371 return $this->formFieldParser->fetchDefaultFormFields($content);
372 }

◆ save()

ilCertificateSettingsFormRepository::save ( array  $formFields)

Implements ilCertificateFormRepository.

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

361 : void
362 {
363 }

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: