protected function initForm()
 {
     $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
     $this->setTitle($this->pl->txt('certificate_placeholders'));
     // Each placeholder can define values for each language defined in the type
     $languages = $this->definition->getType()->getLanguages();
     $label_lang = in_array($this->user->getLanguage(), $languages) ? $this->user->getLanguage() : $this->definition->getDefaultLanguage();
     /** @var $placeholder_value srCertificatePlaceholderValue */
     foreach ($this->definition->getPlaceholderValues() as $placeholder_value) {
         $section = new ilFormSectionHeaderGUI();
         $section->setTitle($placeholder_value->getPlaceholder()->getLabel($label_lang));
         $this->addItem($section);
         foreach ($languages as $lang) {
             $this->addItem($this->getInputField($placeholder_value, $lang));
         }
     }
     if ($signatures = $this->definition->getType()->getSignatures()) {
         $section = new ilFormSectionHeaderGUI();
         $section->setTitle($this->pl->txt('signature'));
         $this->addItem($section);
         $select_input = new ilSelectInputGUI($this->pl->txt('signature'), 'signature');
         $options = array(0 => '');
         foreach ($signatures as $signature) {
             $options[$signature->getId()] = $signature->getFirstName() . ' ' . $signature->getLastName();
         }
         $select_input->setOptions($options);
         $select_input->setValue($this->definition->getSignatureId());
         $this->addItem($select_input);
     }
     $this->addCommandButton('updatePlaceholders', $this->pl->txt('save'));
     return;
 }
 /**
  * Load all the placeholders (standard and custom) with key => value
  * Custom placeholders are loaded in the correct language
  * All placeholders are passed to the hook class to do custom logic.
  * Finally keys are wrapped with the start/end symbols, e.g. [[key]]
  *
  * @param bool $anonymized
  */
 protected function loadPlaceholders($anonymized = false)
 {
     $placeholders = $this->getStandardPlaceholders($anonymized)->getParsedPlaceholders();
     $available_langs = $this->definition->getType()->getLanguages();
     $user_lang = $this->getUser()->getLanguage();
     $default_lang = $this->definition->getSettingByIdentifier(srCertificateTypeSetting::IDENTIFIER_DEFAULT_LANG);
     $lang = in_array($user_lang, $available_langs) ? $user_lang : $default_lang;
     /** @var $ph_value srCertificatePlaceholderValue */
     foreach ($this->definition->getPlaceholderValues() as $ph_value) {
         $placeholders[$ph_value->getPlaceholder()->getIdentifier()] = $ph_value->getValue($lang);
     }
     // Hacky: Add signature placeholders
     if ($this->definition->getSignatureId()) {
         $signature = $this->definition->getSignature();
         $placeholders['SIGNATURE_NAME'] = $signature->getFirstName() . ' ' . $signature->getLastName();
         $placeholders['SIGNATURE_FIRSTNAME'] = $signature->getFirstName();
         $placeholders['SIGNATURE_LASTNAME'] = $signature->getLastName();
         $placeholders['SIGNATURE_IMAGE'] = $signature->getFilePath(true);
         $placeholders['SIGNATURE_IMAGE_SUFFIX'] = $signature->getSuffix();
     }
     $this->placeholders = $this->pl->getHooks()->processPlaceholders($this, $placeholders);
     $this->placeholders = srCertificatePlaceholder::getFormattedPlaceholders($this->placeholders);
 }