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_Campaign_Form_Survey_TabHeader
{
46 static function build(&$form) {
47 $tabs = $form->get('tabHeader');
48 if (!$tabs ||
empty($_GET['reset'])) {
49 $tabs = self
::process($form);
50 $form->set('tabHeader', $tabs);
52 $form->assign_by_ref('tabHeader', $tabs);
53 CRM_Core_Resources
::singleton()
54 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')
55 ->addSetting(array('tabSettings' => array(
56 'active' => self
::getCurrentTab($tabs),
66 static function process(&$form) {
67 if ($form->getVar('_surveyId') <= 0) {
72 'main' => array('title' => ts('Main Information'),
78 'questions' => array('title' => ts('Questions'),
84 'results' => array('title' => ts('Results'),
92 $surveyID = $form->getVar('_surveyId');
93 $class = $form->getVar('_name');
94 $class = CRM_Utils_String
::getClassName($class);
95 $class = strtolower($class);
97 if (array_key_exists($class, $tabs)) {
98 $tabs[$class]['current'] = TRUE;
99 $qfKey = $form->get('qfKey');
101 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
106 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
108 foreach ($tabs as $key => $value) {
109 if (!isset($tabs[$key]['qfKey'])) {
110 $tabs[$key]['qfKey'] = NULL;
113 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/survey/configure/{$key}",
114 "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}"
116 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
125 static function reset(&$form) {
126 $tabs = self
::process($form);
127 $form->set('tabHeader', $tabs);
135 static function getCurrentTab($tabs) {
136 static $current = FALSE;
142 if (is_array($tabs)) {
143 foreach ($tabs as $subPage => $pageVal) {
144 if ($pageVal['current'] === TRUE) {
151 $current = $current ?
$current : 'main';
160 static function getNextTab(&$form) {
161 static $next = FALSE;
165 $tabs = $form->get('tabHeader');
166 if (is_array($tabs)) {
168 foreach ($tabs as $subPage => $pageVal) {
173 if ($pageVal['current'] === TRUE) {
179 $next = $next ?
$next : 'main';