Minor cleanup
[civicrm-core.git] / CRM / Contribute / Form / ContributionBase.php
index 340e8f5098a5d4a19fd0932e82f4c822200e7888..cb9e64d40a1cb0a6270a01a0b8e0319749133dd5 100644 (file)
  */
 
 /**
- * This class generates form components for processing a ontribution
+ * This class generates form components for processing a contribution
  *
  */
 class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
   /**
-   * the id of the contribution page that we are proceessing
+   * the id of the contribution page that we are processsing
    *
    * @var int
    * @public
@@ -88,6 +88,11 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
    */
   public $_membershipBlock = NULL;
 
+  /**
+   * Does this form support a separate membership payment
+   * @var bool
+   */
+  protected $_separateMembershipPayment;
   /**
    * the default values for the form
    *
@@ -110,7 +115,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
    * @var array
    * @public
    */
-  public $_fields;
+  public $_fields = array();
 
   /**
    * The billing location id for this contribiution page
@@ -195,6 +200,17 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
    */
   public $_honor_block_is_active = FALSE;
 
+  /**
+   * Contribution mode e.g express for payment express, notify for off-site + notification back to CiviCRM
+   * @var string
+   */
+  public $_contributeMode;
+
+  /**
+   * contribution page supports memberships
+   * @var boolean
+   */
+  public $_useForMember;
   /**
    * Function to set variables up before form is built
    *
@@ -653,12 +669,16 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
   /**
    * Function to add the custom fields
    *
+   * @param $id
+   * @param $name
+   * @param bool $viewOnly
+   * @param null $profileContactType
+   * @param null $fieldTypes
+   *
    * @return void
    * @access public
    */
   function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL) {
-    $stateCountryMap = array();
-
     if ($id) {
       $contactID = $this->getContactID();
 
@@ -717,33 +737,6 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
             continue;
           }
 
-          list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
-          if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') {
-            if (!array_key_exists($index, $stateCountryMap)) {
-              $stateCountryMap[$index] = array();
-            }
-            $stateCountryMap[$index][$prefixName] = $key;
-
-            if ($prefixName == "state_province") {
-              if ($profileContactType == 'onbehalf') {
-                //CRM-11881: Bypass required-ness check for state/province on Contribution Confirm page
-                //as already done during Contribution registration via onBehalf's quickForm
-                $field['is_required'] = FALSE;
-              }
-              else {
-                if (count($this->_submitValues)) {
-                  $locationTypeId = $field['location_type_id'];
-                  if (array_key_exists("country-{$locationTypeId}", $fields) &&
-                  array_key_exists("state_province-{$locationTypeId}", $fields) &&
-                    !empty($this->_submitValues["country-{$locationTypeId}"])) {
-                    $field['is_required'] =
-                      CRM_Core_Payment_Form::checkRequiredStateProvince($this, "country-{$locationTypeId}");
-                  }
-                }
-              }
-            }
-          }
-
           if ($profileContactType) {
             //Since we are showing honoree name separately so we are removing it from honoree profile just for display
             $honoreeNamefields = array('prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name');
@@ -784,8 +777,6 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
         $this->assign($name, $fields);
 
-        CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
-
         if ($addCaptcha && !$viewOnly) {
           $captcha = CRM_Utils_ReCAPTCHA::singleton();
           $captcha->add($this);
@@ -795,6 +786,12 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
     }
   }
 
+  /**
+   * Check template file exists
+   * @param null $suffix
+   *
+   * @return null|string
+   */
   function checkTemplateFileExists($suffix = NULL) {
     if ($this->_id) {
       $templateFile = "CRM/Contribute/Form/Contribution/{$this->_id}/{$this->_name}.{$suffix}tpl";
@@ -806,11 +803,30 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
     return NULL;
   }
 
+  /**
+   * Use the form name to create the tpl file name
+   *
+   * @return string
+   * @access public
+   */
+  /**
+   * @return string
+   */
   function getTemplateFileName() {
     $fileName = $this->checkTemplateFileExists();
     return $fileName ? $fileName : parent::getTemplateFileName();
   }
 
+  /**
+   * Default extra tpl file basically just replaces .tpl with .extra.tpl
+   * i.e. we dont override
+   *
+   * @return string
+   * @access public
+   */
+  /**
+   * @return string
+   */
   function overrideExtraTemplateFileName() {
     $fileName = $this->checkTemplateFileExists('extra.');
     return $fileName ? $fileName : parent::overrideExtraTemplateFileName();