ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 

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
 

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 49 of file class.ilCertificateSettingsFormRepository.php.

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().

65  {
66  global $DIC;
67  $this->httpWrapper = $DIC->http()->wrapper();
68  $this->refinery = $DIC->refinery();
69  $this->objectId = $objectId;
70  $this->language = $language;
71  $this->ctrl = $ctrl;
72  $this->access = $access;
73  $this->toolbar = $toolbar;
74  $this->placeholderDescriptionObject = $placeholderDescriptionObject;
75  $this->hasAdditionalElements = $hasAdditionalElements;
76  $this->global_certificate_settings = new ilObjCertificateSettings();
77 
78  $database = $DIC->database();
79 
80  if (null === $logger) {
81  $logger = $logger = $DIC->logger()->cert();
82  }
83 
84  if (null === $pageFormats) {
85  $pageFormats = new ilPageFormats($language);
86  }
87  $this->pageFormats = $pageFormats;
88 
89  if (null === $formFieldParser) {
91  }
92  $this->formFieldParser = $formFieldParser;
93 
94  if (null === $importAction) {
96  $objectId,
97  $certificatePath,
98  $placeholderDescriptionObject,
99  $logger,
100  $DIC->filesystem()->web()
101  );
102  }
103  $this->importAction = $importAction;
104 
105  if (null === $templateRepository) {
107  }
108  $this->templateRepository = $templateRepository;
109 
110  if (null === $filesystem) {
111  $filesystem = $DIC->filesystem()->web();
112  }
113 
114  if (null === $backgroundImageFileService) {
115  $backgroundImageFileService = new ilCertificateBackgroundImageFileService(
116  $certificatePath,
117  $filesystem
118  );
119  }
120  $this->backGroundImageFileService = $backgroundImageFileService;
121  }
global $DIC
Definition: feed.php:28
Class ilObjCertificateSettings.
ilCertificatePlaceholderDescription $placeholderDescriptionObject
+ 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 133 of file class.ilCertificateSettingsFormRepository.php.

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

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

◆ fetchFormFieldData()

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

Implements ilCertificateFormRepository.

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

352  : array
353  {
354  return $this->formFieldParser->fetchDefaultFormFields($content);
355  }

◆ save()

ilCertificateSettingsFormRepository::save ( array  $formFields)

Implements ilCertificateFormRepository.

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

344  : void
345  {
346  }

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().

◆ $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: