3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * Helper class to build navigation links
39 class CRM_Contribute_Form_ContributionPage_TabHeader
{
40 static function build(&$form) {
41 $tabs = $form->get('tabHeader');
42 if (!$tabs ||
!CRM_Utils_Array
::value('reset', $_GET)) {
43 $tabs = self
::process($form);
44 $form->set('tabHeader', $tabs);
46 $form->assign_by_ref('tabHeader', $tabs);
47 CRM_Core_Resources
::singleton()
48 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')
49 ->addSetting(array('tabSettings' => array(
50 'active' => self
::getCurrentTab($tabs),
55 static function process(&$form) {
56 if ($form->getVar('_id') <= 0) {
61 'settings' => array('title' => ts('Title'),
67 'amount' => array('title' => ts('Amounts'),
73 'membership' => array('title' => ts('Memberships'),
79 'thankyou' => array('title' => ts('Receipt'),
85 'friend' => array('title' => ts('Tell a Friend'),
91 'custom' => array('title' => ts('Profiles'),
97 'premium' => array('title' => ts('Premiums'),
103 'widget' => array('title' => ts('Widgets'),
109 'pcp' => array('title' => ts('Personal Campaigns'),
117 $contribPageId = $form->getVar('_id');
118 $fullName = $form->getVar('_name');
119 $className = CRM_Utils_String
::getClassName($fullName);
121 // Hack for special cases.
122 switch ($className) {
124 $attributes = $form->getVar('_attributes');
125 $class = strtolower(basename(CRM_Utils_Array
::value('action', $attributes)));
128 case 'MembershipBlock':
129 $class = 'membership';
133 $class = strtolower($className);
137 if (array_key_exists($class, $tabs)) {
138 $tabs[$class]['current'] = TRUE;
139 $qfKey = $form->get('qfKey');
141 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
145 if ($contribPageId) {
146 $reset = CRM_Utils_Array
::value('reset', $_GET) ?
'reset=1&' : '';
148 foreach ($tabs as $key => $value) {
149 if (!isset($tabs[$key]['qfKey'])) {
150 $tabs[$key]['qfKey'] = NULL;
153 $tabs[$key]['link'] =
154 CRM_Utils_System
::url(
155 "civicrm/admin/contribute/{$key}",
156 "{$reset}action=update&id={$contribPageId}{$tabs[$key]['qfKey']}"
158 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
160 //get all section info.
161 $contriPageInfo = CRM_Contribute_BAO_ContributionPage
::getSectionInfo(array($contribPageId));
163 foreach ($contriPageInfo[$contribPageId] as $section => $info) {
165 $tabs[$section]['valid'] = FALSE;
172 static function reset(&$form) {
173 $tabs = self
::process($form);
174 $form->set('tabHeader', $tabs);
177 static function getCurrentTab($tabs) {
178 static $current = FALSE;
184 if (is_array($tabs)) {
185 foreach ($tabs as $subPage => $pageVal) {
186 if ($pageVal['current'] === TRUE) {
193 $current = $current ?
$current : 'settings';