generated from FriendsOfREDAXO/rex_repo_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.php
72 lines (53 loc) · 2.34 KB
/
boot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php // Boot code
rex_yform::addTemplatePath(rex_path::addon('formslider', 'ytemplates'));
if (rex::isBackend()) {
rex_extension::register('PACKAGES_INCLUDED', function ($params) {
$plugin = rex_plugin::get('yform', 'manager');
if ($plugin) {
$pages = $plugin->getProperty('pages');
$dataset = rex_yform_manager_table::getAll();
$searchword = 'formslider';
$ycom_tables = array_filter($dataset, function($var) use ($searchword) { return str_contains($var["table_name"], $searchword); });
// $ycom_tables = ['rex_formslider_awo'];
if (isset($pages) && is_array($pages)) {
foreach ($pages as $page) {
if (in_array($page->getKey(), $ycom_tables)) {
$page->setBlock('formslider');
}
}
}
}
});
}
function formsliderGeneratePDF($params, $template = '') {
Locale::setDefault('de-DE');
$valuePool = $params['value_pool']['sql'];
$addon = rex_addon::get('formslider');
// Speichere den Template-Inhalt in eine temporäre Datei, um sie als PHP einzubinden
$tempTemplatePath = rex_path::addonData('formslider', 'temp_template'.date('Y-m-d_H-i-s').'_'.random_int(0, 9999999).'.php');
rex_file::put($tempTemplatePath, $template, LOCK_EX);
$values = $params['values'];
extract($values);
// Das Template mit den übergebenen Parametern rendern
ob_start();
include $tempTemplatePath;
$renderedContent = ob_get_clean();
// Die temporäre Datei löschen
unlink($tempTemplatePath);
$pdf = new PdfOut();
$pdf->setName(rex_yform_manager_table::get($params['main_table'])->getName().'_'.date('Y-m-d_H-i-s').'_'.random_int(0, 9999999))
->setFont('Helvetica')
->setHtml($renderedContent, true)
->setOrientation('portrait')
->setPaper('A4')
->setAttachment(true)
->setRemoteFiles(true)
->setDpi(300);
// $font = $pdf->getFontMetrics()->get_font("helvetica", "bold");
// $pdf->getCanvas()->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", $font, 10, array(0,0,0));
// Save File to path and send File
$dataPath = $addon->getDataPath();
$pdf->setSaveToPath($dataPath)->setSaveAndSend(true);
// execute and generate
$pdf->run();
}