/** * See formatDate() method * * @param $identifier * @param int $timestamp * @return string */ protected function formatDateTime($identifier, $timestamp = 0) { $timestamp = $timestamp ? $timestamp : time(); $utc = ilCertificateConfig::get('time_format_utc'); $format = ilCertificateConfig::get('str_format_datetime'); // Check if a hook wants to modify the date format $format_custom = $this->pl->getHooks()->formatDate($this->certificate, $identifier); if ($format_custom) { $format = $format_custom; } $value = $utc ? gmdate($format, $timestamp) : date($format, $timestamp); return $value; }
/** * 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); }