3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
37 * Helper class to build navigation links
39 class CRM_Contribute_Form_ContributionPage_TabHeader
{
45 static function build(&$form) {
46 $tabs = $form->get('tabHeader');
47 if (!$tabs ||
empty($_GET['reset'])) {
48 $tabs = self
::process($form);
49 $form->set('tabHeader', $tabs);
51 $form->assign_by_ref('tabHeader', $tabs);
52 CRM_Core_Resources
::singleton()
53 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')
54 ->addSetting(array('tabSettings' => array(
55 'active' => self
::getCurrentTab($tabs),
65 static function process(&$form) {
66 if ($form->getVar('_id') <= 0) {
71 'settings' => array('title' => ts('Title'),
77 'amount' => array('title' => ts('Amounts'),
83 'membership' => array('title' => ts('Memberships'),
89 'thankyou' => array('title' => ts('Receipt'),
95 'friend' => array('title' => ts('Tell a Friend'),
101 'custom' => array('title' => ts('Profiles'),
107 'premium' => array('title' => ts('Premiums'),
113 'widget' => array('title' => ts('Widgets'),
119 'pcp' => array('title' => ts('Personal Campaigns'),
127 $contribPageId = $form->getVar('_id');
128 $fullName = $form->getVar('_name');
129 $className = CRM_Utils_String
::getClassName($fullName);
131 // Hack for special cases.
132 switch ($className) {
134 $attributes = $form->getVar('_attributes');
135 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
138 case 'MembershipBlock':
139 $class = 'membership';
143 $class = strtolower($className);
147 if (array_key_exists($class, $tabs)) {
148 $tabs[$class]['current'] = TRUE;
149 $qfKey = $form->get('qfKey');
151 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
155 if ($contribPageId) {
156 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
158 foreach ($tabs as $key => $value) {
159 if (!isset($tabs[$key]['qfKey'])) {
160 $tabs[$key]['qfKey'] = NULL;
163 $tabs[$key]['link'] =
164 CRM_Utils_System
::url(
165 "civicrm/admin/contribute/{$key}",
166 "{$reset}action=update&id={$contribPageId}{$tabs[$key]['qfKey']}"
168 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
170 //get all section info.
171 $contriPageInfo = CRM_Contribute_BAO_ContributionPage
::getSectionInfo(array($contribPageId));
173 foreach ($contriPageInfo[$contribPageId] as $section => $info) {
175 $tabs[$section]['valid'] = FALSE;
185 static function reset(&$form) {
186 $tabs = self
::process($form);
187 $form->set('tabHeader', $tabs);
195 static function getCurrentTab($tabs) {
196 static $current = FALSE;
202 if (is_array($tabs)) {
203 foreach ($tabs as $subPage => $pageVal) {
204 if ($pageVal['current'] === TRUE) {
211 $current = $current ?
$current : 'settings';