/** * Generate the report for given certificate * * @param srCertificate $cert * @throws ilException * @return bool */ public function generate(srCertificate $cert) { if (!$this->isAvailable()) { throw new ilException("Generating certificates with TemplateTypeHtml is only available for ILIAS > 4.4"); } $template = $cert->getDefinition()->getType()->getCertificateTemplatesPath(true); // A template is required, so quit early if it does not exist for some reason if (!is_file($template)) { return false; } require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php'; // Get HTML markup by parsing the template and replace placeholders $markup = file_get_contents($template); $markup = srCertificatePlaceholdersParser::getInstance()->parse($markup, $cert->getPlaceholders()); try { $job = new ilPDFGenerationJob(); $job->setMarginLeft('20'); $job->setMarginBottom('20'); $job->setMarginRight('20'); $job->setMarginTop('20'); $job->setOutputMode('F'); // Save to disk $job->setFilename($cert->getFilePath()); $job->addPage($markup); ilPDFGeneration::doJob($job); return true; // Method above gives no feedback so assume true -.- } catch (Exception $e) { $this->log->write("srCertificateTemplyteTypeHtml::generate() : " . $e->getMessage()); return false; } }
/** * @param srCertificate $certificate * @param string $email */ public function __construct(srCertificate $certificate, $email = '') { parent::__construct($certificate, $email); $this->setSubject($this->pl->txt('callback_email_subject')); $parser = srCertificatePlaceholdersParser::getInstance(); $body = $parser->parse($this->pl->txt('callback_email_message'), $this->certificate->getPlaceholders()); $this->setBody($body); }
/** * @param srCertificate $certificate * @param string $email */ public function __construct(srCertificate $certificate, $email = '') { parent::__construct($certificate, $email); $this->setEmail(ilSetting::_lookupValue('common', 'admin_email')); $this->setSubject($this->pl->txt('cert_failed_subject')); $parser = srCertificatePlaceholdersParser::getInstance(); $body = $parser->parse($this->pl->txt('cert_failed_message'), $this->certificate->getPlaceholders()); $this->setBody($body); }
/** * @param srCertificate $certificate * @param string $email */ public function __construct(srCertificate $certificate, $email = '') { parent::__construct($certificate, $email); $parser = srCertificatePlaceholdersParser::getInstance(); $subject = $parser->parse($this->pl->config('notification_others_subject'), $certificate->getPlaceholders()); $body = $parser->parse($this->pl->config('notification_others_body'), $certificate->getPlaceholders()); $this->setSubject($subject); $this->setBody($body); $this->setAttachCertificate(true); }