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
{
41 static function build(&$form) {
42 $tabs = $form->get('tabHeader');
43 if (!$tabs ||
empty($_GET['reset'])) {
44 $tabs = self
::process($form);
45 $form->set('tabHeader', $tabs);
47 $form->assign_by_ref('tabHeader', $tabs);
48 CRM_Core_Resources
::singleton()
49 ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')
50 ->addSetting(array('tabSettings' => array(
51 'active' => self
::getCurrentTab($tabs),
56 static function process(&$form) {
57 if ($form->getVar('_surveyId') <= 0) {
62 'main' => array('title' => ts('Main Information'),
68 'questions' => array('title' => ts('Questions'),
74 'results' => array('title' => ts('Results'),
82 $surveyID = $form->getVar('_surveyId');
83 $class = $form->getVar('_name');
84 $class = CRM_Utils_String
::getClassName($class);
85 $class = strtolower($class);
87 if (array_key_exists($class, $tabs)) {
88 $tabs[$class]['current'] = TRUE;
89 $qfKey = $form->get('qfKey');
91 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
96 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
98 foreach ($tabs as $key => $value) {
99 if (!isset($tabs[$key]['qfKey'])) {
100 $tabs[$key]['qfKey'] = NULL;
103 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/survey/configure/{$key}",
104 "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}"
106 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
112 static function reset(&$form) {
113 $tabs = self
::process($form);
114 $form->set('tabHeader', $tabs);
117 static function getCurrentTab($tabs) {
118 static $current = FALSE;
124 if (is_array($tabs)) {
125 foreach ($tabs as $subPage => $pageVal) {
126 if ($pageVal['current'] === TRUE) {
133 $current = $current ?
$current : 'main';
137 static function getNextTab(&$form) {
138 static $next = FALSE;
142 $tabs = $form->get('tabHeader');
143 if (is_array($tabs)) {
145 foreach ($tabs as $subPage => $pageVal) {
150 if ($pageVal['current'] === TRUE) {
156 $next = $next ?
$next : 'main';