3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2018
35 * Helper class to build navigation links.
37 class CRM_Contribute_Form_ContributionPage_TabHeader
{
39 * @param CRM_Core_Form $form
43 public static function build(&$form) {
44 $tabs = $form->get('tabHeader');
45 if (!$tabs ||
empty($_GET['reset'])) {
46 $tabs = self
::process($form);
47 $form->set('tabHeader', $tabs);
49 $form->assign_by_ref('tabHeader', $tabs);
50 CRM_Core_Resources
::singleton()
51 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')
53 'tabSettings' => array(
54 'active' => self
::getCurrentTab($tabs),
61 * @param CRM_Core_Form $form
65 public static function process(&$form) {
66 if ($form->getVar('_id') <= 0) {
72 'title' => ts('Title'),
79 'title' => ts('Amounts'),
85 'membership' => array(
86 'title' => ts('Memberships'),
93 'title' => ts('Receipt'),
100 'title' => ts('Tell a Friend'),
107 'title' => ts('Profiles'),
114 'title' => ts('Premiums'),
121 'title' => ts('Widgets'),
128 'title' => ts('Personal Campaigns'),
136 $contribPageId = $form->getVar('_id');
137 CRM_Utils_Hook
::tabset('civicrm/admin/contribute', $tabs, array('contribution_page_id' => $contribPageId));
138 $fullName = $form->getVar('_name');
139 $className = CRM_Utils_String
::getClassName($fullName);
141 // Hack for special cases.
142 switch ($className) {
144 $attributes = $form->getVar('_attributes');
145 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
148 case 'MembershipBlock':
149 $class = 'membership';
153 $class = strtolower($className);
157 if (array_key_exists($class, $tabs)) {
158 $tabs[$class]['current'] = TRUE;
159 $qfKey = $form->get('qfKey');
161 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
165 if ($contribPageId) {
166 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
168 foreach ($tabs as $key => $value) {
169 if (!isset($tabs[$key]['qfKey'])) {
170 $tabs[$key]['qfKey'] = NULL;
173 $tabs[$key]['link'] = CRM_Utils_System
::url(
174 "civicrm/admin/contribute/{$key}",
175 "{$reset}action=update&id={$contribPageId}{$tabs[$key]['qfKey']}"
177 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
179 //get all section info.
180 $contriPageInfo = CRM_Contribute_BAO_ContributionPage
::getSectionInfo(array($contribPageId));
182 foreach ($contriPageInfo[$contribPageId] as $section => $info) {
184 $tabs[$section]['valid'] = FALSE;
194 public static function reset(&$form) {
195 $tabs = self
::process($form);
196 $form->set('tabHeader', $tabs);
204 public static function getCurrentTab($tabs) {
205 static $current = FALSE;
211 if (is_array($tabs)) {
212 foreach ($tabs as $subPage => $pageVal) {
213 if ($pageVal['current'] === TRUE) {
220 $current = $current ?
$current : 'settings';