From 6841f76bd3bdc9b22567f46e7d41cf810d817bfd Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 13 Mar 2017 20:57:56 +1300 Subject: [PATCH] CRM-20251 Make it easier to overwrite front end form help text regarding recurring --- CRM/Contribute/Form/Contribution/Main.php | 5 +++ CRM/Core/Payment.php | 36 +++++++++++++++++++ .../CRM/Contribute/Form/Contribution/Main.tpl | 8 +---- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index c2e38e902d..293c3ced01 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -567,6 +567,11 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $form->assign('is_recur_interval', CRM_Utils_Array::value('is_recur_interval', $form->_values)); $form->assign('is_recur_installments', CRM_Utils_Array::value('is_recur_installments', $form->_values)); + $form->assign('recurringHelpText', $form->_paymentObject->getText('contributionPageRecurringHelp', array( + 'is_recur_installments' => !empty($form->_values['is_recur_installments']), + 'is_email_receipt' => !empty($form->_values['is_email_receipt']), + ))); + $form->add('checkbox', 'is_recur', ts('I want to contribute this amount'), NULL); if (!empty($form->_values['is_recur_interval']) || $className == 'CRM_Contribute_Form_Contribution') { diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index d87e378ace..7d08cbd2b0 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -412,6 +412,42 @@ abstract class CRM_Core_Payment { return $this->_paymentForm; } + /** + * Get help text information (help, description, etc.) about this payment, + * to display to the user. + * + * @param string $context + * Context of the text. + * Only explicitly supported contexts are handled without error. + * Currently supported: + * - contributionPageRecurringHelp (params: is_recur_installments, is_email_receipt) + * + * @param array $params + * Parameters for the field, context specific. + * + * @return string + */ + public function getText($context, $params) { + // I have deliberately added a noisy fail here. + // The function is intended to be extendable, but not by changes + // not documented clearly above. + switch ($context) { + case 'contributionPageRecurringHelp': + // require exactly two parameters + if (array_keys($params) == array('is_recur_installments', 'is_email_receipt')) { + $gotText = ts('Your recurring contribution will be processed automatically.'); + if ($params['is_recur_installments']) { + $gotText .= ts(' You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.'); + } + if ($params['is_email_receipt']) { + $gotText .= ts(' You will receive an email receipt for each recurring contribution.'); + } + } + break; + } + return $gotText; + } + /** * Getter for accessing member vars. * diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index cce60043ed..7de97eaae7 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -162,13 +162,7 @@ {/if}
- {ts}Your recurring contribution will be processed automatically.{/ts} - {if $is_recur_installments} - {ts}You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.{/ts} - {/if} - {if $is_email_receipt} - {ts}You will receive an email receipt for each recurring contribution.{/ts} - {/if} + {$recurringHelpText}
-- 2.25.1