3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
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_Campaign_Form_Survey_TabHeader
{
41 static function build(&$form) {
42 $tabs = $form->get('tabHeader');
43 if (!$tabs ||
!CRM_Utils_Array
::value('reset', $_GET)) {
44 $tabs = self
::process($form);
45 $form->set('tabHeader', $tabs);
47 $form->assign_by_ref('tabHeader', $tabs);
48 $selectedTab = self
::getCurrentTab($tabs);
49 $form->assign_by_ref('selectedTab', $selectedTab);
53 static function process(&$form) {
54 if ($form->getVar('_surveyId') <= 0) {
59 'main' => array('title' => ts('Main Information'),
65 'questions' => array('title' => ts('Questions'),
71 'results' => array('title' => ts('Results'),
79 $surveyID = $form->getVar('_surveyId');
80 $class = $form->getVar('_name');
81 $class = CRM_Utils_String
::getClassName($class);
82 $class = strtolower($class);
84 if (array_key_exists($class, $tabs)) {
85 $tabs[$class]['current'] = TRUE;
86 $qfKey = $form->get('qfKey');
88 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
93 $reset = CRM_Utils_Array
::value('reset', $_GET) ?
'reset=1&' : '';
95 foreach ($tabs as $key => $value) {
96 if (!isset($tabs[$key]['qfKey'])) {
97 $tabs[$key]['qfKey'] = NULL;
100 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/survey/configure/{$key}",
101 "{$reset}action=update&snippet=5&id={$surveyID}{$tabs[$key]['qfKey']}"
103 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
109 static function reset(&$form) {
110 $tabs = self
::process($form);
111 $form->set('tabHeader', $tabs);
114 static function getCurrentTab($tabs) {
115 static $current = FALSE;
121 if (is_array($tabs)) {
122 foreach ($tabs as $subPage => $pageVal) {
123 if ($pageVal['current'] === TRUE) {
130 $current = $current ?
$current : 'main';
134 static function getNextTab(&$form) {
135 static $next = FALSE;
139 $tabs = $form->get('tabHeader');
140 if (is_array($tabs)) {
142 foreach ($tabs as $subPage => $pageVal) {
147 if ($pageVal['current'] === TRUE) {
153 $next = $next ?
$next : 'main';