Change setting name to new settings style
authorBenjamin Bock <bb@users.noreply.github.com>
Thu, 23 Nov 2023 20:44:43 +0000 (21:44 +0100)
committerBenjamin Bock <bb@users.noreply.github.com>
Tue, 19 Dec 2023 08:05:18 +0000 (09:05 +0100)
CRM/Admin/Form/Setting/Miscellaneous.php
CRM/Utils/PDF/Utils.php
settings/Core.setting.php
templates/CRM/Admin/Form/Setting/Miscellaneous.tpl

index 889434be98426ea1142b9d79bd4ec49228c0783f..76c80cf4f245b6494b28d2cee90409947b79858b 100644 (file)
@@ -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'])) {
index cb7e42c438f921f0e660bfaa83971762834bc668..5b5f06fc736f95aa0d503a21c744d7a99d0b198e 100644 (file)
@@ -101,7 +101,7 @@ class CRM_Utils_PDF_Utils {
     </div>
   </body>
 </html>";
-    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);
index fdf1fcd97deb60a0fe6dd0b40b8c99cf0c1d8325..14a754db3c88e636f8e2e73bce5fcdcb1d5b8699 100644 (file)
@@ -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' => [
index 4aa45bb8bdcd7acf1c36932adf86e6f1e666775b..ee031fb8e8a34000aa5cee9c06776a4f3384d057 100644 (file)
@@ -74,9 +74,9 @@
           <p class="description">{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}</p>
         </td>
       </tr>
-      <tr class="crm-miscellaneous-form-block-weasyprintPath">
-        <td class="label">{$form.weasyprintPath.label}</td>
-        <td>{$form.weasyprintPath.html}<br />
+      <tr class="crm-miscellaneous-form-block-weasyprint_path">
+        <td class="label">{$form.weasyprint_path.label}</td>
+        <td>{$form.weasyprint_path.html}<br />
           <p class="description">{ts 1="https://weasyprint.org/"}<a href="%1">weasyprint is an alternative utility for generating PDFs</a> 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}</p>
         </td>
       </tr>