ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateSettingsFormRepository Class Reference
+ Inheritance diagram for ilCertificateSettingsFormRepository:
+ Collaboration diagram for ilCertificateSettingsFormRepository:

Public Member Functions

 __construct (int $objectId, string $certificatePath, ilLanguage $language, ilTemplate $template, ilCtrl $controller, ilAccess $access, ilToolbarGUI $toolbar, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilPageFormats $pageFormats=null, ilFormFieldParser $formFieldParser=null, ilCertificateTemplateImportAction $importAction=null, ilLogger $logger=null, ilCertificateTemplateRepository $templateRepository=null)
 
 createForm (ilCertificateGUI $certificateGUI, ilCertificate $certificateObject)
 
 save (array $formFields)
 
 fetchFormFieldData (string $content)
 

Private Attributes

 $objectId
 
 $language
 
 $template
 
 $controller
 
 $access
 
 $toolbar
 
 $placeholderDescriptionObject
 
 $pageFormats
 
 $formFieldParser
 
 $importAction
 
 $templateRepository
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateSettingsFormRepository::__construct ( int  $objectId,
string  $certificatePath,
ilLanguage  $language,
ilTemplate  $template,
ilCtrl  $controller,
ilAccess  $access,
ilToolbarGUI  $toolbar,
ilCertificatePlaceholderDescription  $placeholderDescriptionObject,
ilPageFormats  $pageFormats = null,
ilFormFieldParser  $formFieldParser = null,
ilCertificateTemplateImportAction  $importAction = null,
ilLogger  $logger = null,
ilCertificateTemplateRepository  $templateRepository = null 
)
Parameters
integer$objectId
string$certificatePath
ilLanguage$language
ilTemplate$template
ilCtrl$controller
ilAccess$access
ilToolbarGUI$toolbar
ilCertificatePlaceholderDescription$placeholderDescriptionObject
ilPageFormats | null$pageFormats
ilFormFieldParser | null$formFieldParser
ilCertificateTemplateImportAction | null$importAction
ilLogger | null$logger
ilCertificateTemplateRepository | null$templateRepository

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

References $access, $controller, $DIC, $formFieldParser, $importAction, $language, $objectId, $pageFormats, $placeholderDescriptionObject, $template, $templateRepository, and $toolbar.

93  {
94  global $DIC;
95 
96  $this->objectId = $objectId;
97  $this->language = $language;
98  $this->template = $template;
99  $this->controller = $controller;
100  $this->access = $access;
101  $this->toolbar = $toolbar;
102  $this->placeholderDescriptionObject = $placeholderDescriptionObject;
103 
104  $database = $DIC->database();
105 
106 
107  if (null === $logger) {
108  $logger = $logger = $DIC->logger()->cert();
109  }
110 
111  if (null === $pageFormats) {
112  $pageFormats = new ilPageFormats($language);
113  }
114  $this->pageFormats = $pageFormats;
115 
116  if (null === $formFieldParser) {
117  $formFieldParser = new ilFormFieldParser();
118  }
119  $this->formFieldParser = $formFieldParser;
120 
121  if (null === $importAction) {
122  $importAction = new ilCertificateTemplateImportAction(
123  (int) $objectId,
124  $certificatePath,
125  $placeholderDescriptionObject,
126  $logger,
127  $DIC->filesystem()->web()
128  );
129  }
130  $this->importAction = $importAction;
131 
132  if (null === $templateRepository) {
133  $templateRepository = new ilCertificateTemplateRepository($database, $logger);
134  }
135  $this->templateRepository = $templateRepository;
136  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ createForm()

ilCertificateSettingsFormRepository::createForm ( ilCertificateGUI  $certificateGUI,
ilCertificate  $certificateObject 
)
Parameters
ilCertificateGUI$certificateGUI
ilCertificate$certificateObject
Returns
ilPropertyFormGUI
Exceptions

Implements ilCertificateFormRepository.

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

References $_GET, $certificate, $form, $format, $preview, $result, $tags, ilCertificate\getAdapter(), ilObjCertificateSettingsAccess\getBackgroundImageThumbPath(), ilCertificate\getBackgroundImageThumbPath(), ilObjCertificateSettingsAccess\getBackgroundImageThumbPathWeb(), ilSubmitButton\getInstance(), ilObjCertificateSettingsAccess\hasBackgroundImage(), ilCertificate\hasBackgroundImage(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setSize(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().

150  {
151  $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
152 
153  $command = $this->controller->getCmd();
154 
155  $form = new ilPropertyFormGUI();
156  $form->setPreventDoubleSubmission(false);
157  $form->setFormAction($this->controller->getFormAction($certificateGUI));
158  $form->setTitle($this->language->txt("cert_form_sec_availability"));
159  $form->setMultipart(true);
160  $form->setTableWidth("100%");
161  $form->setId("certificate");
162 
163  $active = new ilCheckboxInputGUI($this->language->txt("active"), "active");
164  $form->addItem($active);
165 
166  $import = new ilFileInputGUI($this->language->txt("import"), "certificate_import");
167  $import->setRequired(false);
168  $import->setSuffixes(array("zip"));
169 
170  // handle the certificate import
171  if (strlen($_FILES["certificate_import"]["name"])) {
172  if ($import->checkInput()) {
173  $result = $this->importAction->import($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
174  if ($result == false) {
175  $import->setAlert($this->language->txt("certificate_error_import"));
176  } else {
177  $this->controller->redirect($certificateGUI, "certificateEditor");
178  }
179  }
180  }
181  $form->addItem($import);
182 
183  $formSection = new \ilFormSectionHeaderGUI();
184  $formSection->setTitle($this->language->txt("cert_form_sec_layout"));
185  $form->addItem($formSection);
186 
187  $pageformat = new ilRadioGroupInputGUI($this->language->txt("certificate_page_format"), "pageformat");
188  $pageformats = $this->pageFormats->fetchPageFormats();
189 
190  foreach ($pageformats as $format) {
191  $option = new ilRadioOption($format["name"], $format["value"]);
192 
193  if (strcmp($format["value"], "custom") == 0) {
194  $pageheight = new ilTextInputGUI($this->language->txt("certificate_pageheight"), "pageheight");
195  $pageheight->setSize(6);
196  $pageheight->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
197  $pageheight->setInfo($this->language->txt("certificate_unit_description"));
198  $pageheight->setRequired(true);
199  $option->addSubitem($pageheight);
200 
201  $pagewidth = new ilTextInputGUI($this->language->txt("certificate_pagewidth"), "pagewidth");
202  $pagewidth->setSize(6);
203  $pagewidth->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
204  $pagewidth->setInfo($this->language->txt("certificate_unit_description"));
205  $pagewidth->setRequired(true);
206  $option->addSubitem($pagewidth);
207  }
208 
209  $pageformat->addOption($option);
210  }
211 
212  $pageformat->setRequired(true);
213 
214  if (strcmp($command, "certificateSave") == 0) {
215  $pageformat->checkInput();
216  }
217 
218  $form->addItem($pageformat);
219 
220  $bgimage = new ilImageFileInputGUI($this->language->txt("certificate_background_image"), "background");
221  $bgimage->setRequired(false);
222  $bgimage->setUseCache(false);
223 
224  $bgimage->setALlowDeletion(true);
225  if (!$certificateObject->hasBackgroundImage()) {
229  $bgimage->setImage($imagePath);
230  $bgimage->setALlowDeletion(false);
231  }
232  } else {
234 
235  $thumbnailPath = $certificateObject->getBackgroundImageThumbPath();
236 
237  if (!file_exists($thumbnailPath)) {
239  $bgimage->setALlowDeletion(false);
240  }
241  $imagePath = ilWACSignedPath::signFile($thumbnailPath);
242  $bgimage->setImage($imagePath);
243  }
244 
245  $form->addItem($bgimage);
246 
247  $thumbnailImage = new ilImageFileInputGUI($this->language->txt('certificate_card_thumbnail_image'), 'certificate_card_thumbnail_image');
248  $thumbnailImage->setRequired(false);
249  $thumbnailImage->setUseCache(false);
250  $thumbnailImage->setSuffixes(array('svg'));
251 
252  $allowThumbnailDeletion = false;
253 
254  $cardThumbnailImagePath = $certificateTemplate->getThumbnailImagePath();
255  if ('' !== $cardThumbnailImagePath) {
256  $presentationThumbnailImagePath = CLIENT_WEB_DIR . $cardThumbnailImagePath;
257  $thumbnailImage->setImage(ilWACSignedPath::signFile($presentationThumbnailImagePath));
258  $allowThumbnailDeletion = true;
259  }
260 
261  $thumbnailImage->setAllowDeletion($allowThumbnailDeletion);
262 
263  $form->addItem($thumbnailImage);
264 
265  $rect = new ilCSSRectInputGUI($this->language->txt("certificate_margin_body"), "margin_body");
266  $rect->setRequired(true);
267  $rect->setUseUnits(true);
268  $rect->setInfo($this->language->txt("certificate_unit_description"));
269 
270  if (strcmp($command, "certificateSave") == 0) {
271  $rect->checkInput();
272  }
273 
274  $form->addItem($rect);
275 
276  $certificate = new ilTextAreaInputGUI($this->language->txt("certificate_text"), "certificate_text");
277  $certificate->removePlugin('ilimgupload');
278  $certificate->setRequired(true);
279  $certificate->setRows(20);
280  $certificate->setCols(80);
281 
282 
283  $placeholderHtmlDescription = $this->placeholderDescriptionObject->createPlaceholderHtmlDescription();
284 
285  $placeholderDescriptionInHtml = $placeholderHtmlDescription;
286 
287  $certificate->setInfo($placeholderDescriptionInHtml);
288 
289  $certificate->setUseRte(true, '3.4.7');
290 
291  $tags = array(
292  "br",
293  "em",
294  "font",
295  "li",
296  "ol",
297  "p",
298  "span",
299  "strong",
300  "u",
301  "ul"
302  );
303 
304  $certificate->setRteTags($tags);
305 
306  if (strcmp($command, "certificateSave") == 0) {
307  $certificate->checkInput();
308  }
309 
310  $form->addItem($certificate);
311 
312  if ($certificateObject->getAdapter()->hasAdditionalFormElements()) {
313  $formSection = new \ilFormSectionHeaderGUI();
314  $formSection->setTitle($this->language->txt("cert_form_sec_add_features"));
315  $form->addItem($formSection);
316  }
317 
318  if ($this->access->checkAccess("write", "", $_GET["ref_id"])) {
319  if ($certificateTemplate->isCurrentlyActive()) {
320  $this->toolbar->setFormAction($this->controller->getFormAction($certificateGUI));
321 
323  $preview->setCaption('certificate_preview');
324  $preview->setCommand('certificatePreview');
325  $this->toolbar->addStickyItem($preview);
326 
327  $export = ilSubmitButton::getInstance();
328  $export->setCaption('certificate_export');
329  $export->setCommand('certificateExportFO');
330  $this->toolbar->addButtonInstance($export);
331 
332  $delete = ilSubmitButton::getInstance();
333  $delete->setCaption('delete');
334  $delete->setCommand('certificateDelete');
335  $this->toolbar->addButtonInstance($delete);
336  }
337  $form->addCommandButton("certificateSave", $this->language->txt("save"));
338  }
339 
340  return $form;
341  }
This class represents an option in a radio group.
static getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
$format
Definition: metadata.php:141
$result
This class represents a property form user interface.
$_GET["client_id"]
This class represents a file property in a property form.
$preview
This class represents a checkbox property in a property form.
This class represents a text property in a property form.
hasBackgroundImage()
Checks for the background image of the certificate.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
This class represents a property in a property form.
getAdapter()
Gets the adapter.
if(isset($_POST['submit'])) $form
$tags
Definition: croninfo.php:19
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
static signFile($path_to_file)
static hasBackgroundImage()
Returns wheather or not a default background image exists.
This class represents an image file property in a property form.
This class represents a text area property in a property form.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ fetchFormFieldData()

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

Implements ilCertificateFormRepository.

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

356  {
357  return $this->formFieldParser->fetchDefaultFormFields($content);
358  }

◆ save()

ilCertificateSettingsFormRepository::save ( array  $formFields)
Parameters
array$formFields
Returns
mixed|void

Implements ilCertificateFormRepository.

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

348  {
349  }

Field Documentation

◆ $access

ilCertificateSettingsFormRepository::$access
private

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

Referenced by __construct().

◆ $controller

ilCertificateSettingsFormRepository::$controller
private

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

Referenced by __construct().

◆ $formFieldParser

ilCertificateSettingsFormRepository::$formFieldParser
private

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

Referenced by __construct().

◆ $importAction

ilCertificateSettingsFormRepository::$importAction
private

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

Referenced by __construct().

◆ $language

ilCertificateSettingsFormRepository::$language
private

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

Referenced by __construct().

◆ $objectId

ilCertificateSettingsFormRepository::$objectId
private

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

Referenced by __construct().

◆ $pageFormats

ilCertificateSettingsFormRepository::$pageFormats
private

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

Referenced by __construct().

◆ $placeholderDescriptionObject

ilCertificateSettingsFormRepository::$placeholderDescriptionObject
private

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

Referenced by __construct().

◆ $template

ilCertificateSettingsFormRepository::$template
private

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

Referenced by __construct().

◆ $templateRepository

ilCertificateSettingsFormRepository::$templateRepository
private

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

Referenced by __construct().

◆ $toolbar

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: