ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCoursePlaceholderDescription.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 {
13 
21  private $language;
22 
26  private $placeholder;
27 
35  public function __construct(
36  int $objectId,
37  ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
38  ilLanguage $language = null,
39  ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null,
41  ) {
42  global $DIC;
43 
44  if (null === $language) {
45  $language = $DIC->language();
46  $language->loadLanguageModule('certificate');
47  }
48  $this->language = $language;
49 
50  if (null === $defaultPlaceholderDescriptionObject) {
51  $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription($language, $userDefinedFieldPlaceHolderDescriptionObject);
52  }
53  $this->defaultPlaceHolderDescriptionObject = $defaultPlaceholderDescriptionObject;
54 
57  }
58  $this->customUserFieldsPlaceholderDescriptionObject = $customUserFieldsPlaceholderDescriptionObject;
59 
60  $customUserFieldsPlaceholderHtmlDescription = $this->customUserFieldsPlaceholderDescriptionObject->getPlaceholderDescriptions();
61  $defaultPlaceholderDescription = $this->defaultPlaceHolderDescriptionObject->getPlaceholderDescriptions();
62 
63  $this->placeholder = array_merge($defaultPlaceholderDescription, $customUserFieldsPlaceholderHtmlDescription);
64  $this->placeholder['COURSE_TITLE'] = $this->language->txt('crs_title');
65  $this->placeholder['DATE_COMPLETED'] = ilUtil::prepareFormOutput($language->txt('certificate_ph_date_completed'));
66  $this->placeholder['DATETIME_COMPLETED'] = ilUtil::prepareFormOutput($language->txt('certificate_ph_datetime_completed'));
67  }
68 
75  public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string
76  {
77  if (null === $template) {
78  $template = new ilTemplate('tpl.default_description.html', true, true, 'Services/Certificate');
79  }
80 
81  $template->setVariable("PLACEHOLDER_INTRODUCTION", $this->language->txt('certificate_ph_introduction'));
82 
83  $template->setCurrentBlock("items");
84  foreach ($this->placeholder as $id => $caption) {
85  $template->setVariable("ID", $id);
86  $template->setVariable("TXT", $caption);
87  $template->parseCurrentBlock();
88  }
89 
90  return $template->get();
91  }
92 
98  public function getPlaceholderDescriptions() : array
99  {
100  return $this->placeholder;
101  }
102 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value...
createPlaceholderHtmlDescription(ilTemplate $template=null)
This methods MUST return an array containing an array with the the description as array value...
global $DIC
Definition: goto.php:24
__construct(int $objectId, ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject=null, ilLanguage $language=null, ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null, ilObjectCustomUserFieldsPlaceholderDescription $customUserFieldsPlaceholderDescriptionObject=null)
Collection of basic placeholder values that can be used.
language()
Definition: language.php:2