From 2c0eb0ad400a462ebe19bb29e60586160fb4d8e6 Mon Sep 17 00:00:00 2001 From: Benjamin Bock Date: Thu, 23 Nov 2023 21:44:43 +0100 Subject: [PATCH] Change setting name to new settings style --- CRM/Admin/Form/Setting/Miscellaneous.php | 10 +++++----- CRM/Utils/PDF/Utils.php | 4 ++-- settings/Core.setting.php | 4 ++-- templates/CRM/Admin/Form/Setting/Miscellaneous.tpl | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 889434be98..76c80cf4f2 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -35,7 +35,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'dompdf_font_dir' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'dompdf_chroot' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'dompdf_enable_remote' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'weasyprintPath' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'weasyprint_path' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'wkhtmltopdfPath' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'recentItemsMaxCount' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'recentItemsProviders' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, @@ -119,18 +119,18 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { $errors['recentItemsMaxCount'] = ts("Illegal stack size. Use values between 1 and %1.", [1 => CRM_Utils_Recent::MAX_ITEMS]); } - if (!empty($fields['weasyprintPath'])) { + if (!empty($fields['weasyprint_path'])) { // check and ensure that this path leads to the weasyprint binary // and it is a valid executable binary // Only check the first space separated piece to allow for a value - // such as /usr/bin/xvfb-run -- weasyprintPath (CRM-13292) - $pieces = explode(' ', $fields['weasyprintPath']); + // such as /usr/bin/xvfb-run -- weasyprint (CRM-13292) + $pieces = explode(' ', $fields['weasyprint_path']); $path = $pieces[0]; if ( !file_exists($path) || !is_executable($path) ) { - $errors['weasyprintPath'] = ts('The weasyprintPath does not exist or is not valid'); + $errors['weasyprint_path'] = ts('The path for %1 does not exist or is not valid', [1 => 'weasyprint']); } } if (!empty($fields['wkhtmltopdfPath'])) { diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index cb7e42c438..5b5f06fc73 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -101,7 +101,7 @@ class CRM_Utils_PDF_Utils { "; - if (\Civi::settings()->get('weasyprintPath')) { + if (\Civi::settings()->get('weasyprint_path')) { return self::_html2pdf_weasyprint($paper_size, $orientation, $margins, $html, $output, $fileName); } elseif (\Civi::settings()->get('wkhtmltopdfPath')) { @@ -155,7 +155,7 @@ class CRM_Utils_PDF_Utils { */ public static function _html2pdf_weasyprint($paper_size, $orientation, $margins, $html, $output, $fileName) { require_once 'php-weasyprint/src/autoload.php'; - $weasyprint = new Pontedilana\PhpWeasyPrint\Pdf(\Civi::settings()->get('weasyprintPath')); + $weasyprint = new Pontedilana\PhpWeasyPrint\Pdf(\Civi::settings()->get('weasyprint_path')); $weasyprint->setOption("page-width", $paper_size[2] . "pt"); $weasyprint->setOption("page-height", $paper_size[3] . "pt"); $weasyprint->setOption("orientation", $orientation); diff --git a/settings/Core.setting.php b/settings/Core.setting.php index fdf1fcd97d..14a754db3c 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -617,10 +617,10 @@ return [ 'help_text' => NULL, 'add' => '5.43', ], - 'weasyprintPath' => [ + 'weasyprint_path' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', - 'name' => 'weasyprintPath', + 'name' => 'weasyprint_path', 'type' => 'String', 'quick_form_type' => 'Element', 'html_attributes' => [ diff --git a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl index 4aa45bb8bd..ee031fb8e8 100644 --- a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl +++ b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl @@ -74,9 +74,9 @@

{ts}Enable the use of remote images. By default this is enabled, but if not using remote images you may wish to turn it off for security reasons.{/ts}

- - {$form.weasyprintPath.label} - {$form.weasyprintPath.html}
+ + {$form.weasyprint_path.label} + {$form.weasyprint_path.html}

{ts 1="https://weasyprint.org/"}weasyprint is an alternative utility for generating PDFs which is a successor to the discontinued wkhtmltopdf. Your system administrator will need to download and install this utility, and enter the executable path here.{/ts}

-- 2.25.1