[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] add printable pdf settings to ajax service
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <692d72eb44178_2a1834d88791e2@gitlab-sidekiq-low-urgency-cpu-bound-v2-7879b95b78-nhktn.mail> |
Victor Emanouilov pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki
Commits:
806745f7 by Victor Emanouilov at 2025-12-01T12:50:13+02:00
[FIX] add printable pdf settings to ajax service
---
* [FIX] pipeline
* [FIX] add printable pdf settings to ajax service
See merge request tikiwiki/tiki!9158
- - - - -
1 changed file:
- lib/core/Services/PDF/Controller.php
Changes:
=====================================
lib/core/Services/PDF/Controller.php
=====================================
@@ -13,6 +13,8 @@ class Services_PDF_Controller
public function action_get_pdf($input)
{
+ global $prefs;
+
// edit permission is needed to convert arbitrary text to PDF
if (! Perms::get()->edit) {
throw new Services_Exception_Denied();
@@ -21,6 +23,23 @@ class Services_PDF_Controller
$contents = $input->contents->html();
$filename = $input->filename->text();
+ $pdfsettings = $input->pdfsettings->json();
+ if ($pdfsettings) {
+ $pdfsettings = json_decode($pdfsettings, true);
+ }
+ if ($pdfsettings) {
+ $allowed_keys = [];
+ foreach ($prefs as $key => $_) {
+ if (str_starts_with($key, 'print_pdf_mpdf_')) {
+ $allowed_keys[] = str_replace('print_pdf_mpdf_', '', $key);
+ }
+ }
+ $pdfsettings = array_intersect_key($pdfsettings, array_flip($allowed_keys));
+ $contents = "<pdfsettings " . implode('', array_map(function ($key) use ($pdfsettings) {
+ return $key . '="' . htmlspecialchars($pdfsettings[$key]) . '" ';
+ }, array_keys($pdfsettings))) . "></pdfsettings>" . $contents;
+ }
+
if (empty($filename)) {
$filename = 'contents.pdf';
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/806745f7c0b9ccae6bba42def50b56df7fe0f55e
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/806745f7c0b9ccae6bba42def50b56df7fe0f55e
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs