Simple cleanup of tabset code for contributionpages
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sun, 23 Jun 2019 12:05:24 +0000 (13:05 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Thu, 4 Jul 2019 13:59:51 +0000 (14:59 +0100)
CRM/Contribute/Form/ContributionPage/TabHeader.php

index c24edb0726e83f886923e5d7a5089678246b536f..0bf6b9373698bd1f3f45103ec41567d0910c98f2 100644 (file)
@@ -68,73 +68,45 @@ class CRM_Contribute_Form_ContributionPage_TabHeader {
       return NULL;
     }
 
+    $default = [
+      'link' => NULL,
+      'valid' => FALSE,
+      'active' => FALSE,
+      'current' => FALSE,
+    ];
+
     $tabs = [
       'settings' => [
         'title' => ts('Title'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'amount' => [
         'title' => ts('Amounts'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'membership' => [
         'title' => ts('Memberships'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'thankyou' => [
         'title' => ts('Receipt'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'friend' => [
         'title' => ts('Tell a Friend'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'custom' => [
         'title' => ts('Profiles'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'premium' => [
         'title' => ts('Premiums'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'widget' => [
         'title' => ts('Widgets'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
       'pcp' => [
         'title' => ts('Personal Campaigns'),
-        'link' => NULL,
-        'valid' => FALSE,
-        'active' => FALSE,
-        'current' => FALSE,
-      ],
+      ] + $default,
     ];
 
     $contribPageId = $form->getVar('_id');
+    // Call tabset hook to add/remove custom tabs
     CRM_Utils_Hook::tabset('civicrm/admin/contribute', $tabs, ['contribution_page_id' => $contribPageId]);
     $fullName = $form->getVar('_name');
     $className = CRM_Utils_String::getClassName($fullName);