3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
35 * Helper class to build navigation links
37 class CRM_Campaign_Form_Survey_TabHeader
{
42 * @param CRM_Core_Form $form
46 public 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')
56 'tabSettings' => array(
57 'active' => self
::getCurrentTab($tabs),
64 * @param CRM_Core_Form $form
68 public static function process(&$form) {
69 if ($form->getVar('_surveyId') <= 0) {
75 'title' => ts('Main Information'),
82 'title' => ts('Questions'),
89 'title' => ts('Results'),
97 $surveyID = $form->getVar('_surveyId');
98 $class = $form->getVar('_name');
99 $class = CRM_Utils_String
::getClassName($class);
100 $class = strtolower($class);
102 if (array_key_exists($class, $tabs)) {
103 $tabs[$class]['current'] = TRUE;
104 $qfKey = $form->get('qfKey');
106 $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
111 $reset = !empty($_GET['reset']) ?
'reset=1&' : '';
113 foreach ($tabs as $key => $value) {
114 if (!isset($tabs[$key]['qfKey'])) {
115 $tabs[$key]['qfKey'] = NULL;
118 $tabs[$key]['link'] = CRM_Utils_System
::url("civicrm/survey/configure/{$key}",
119 "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}"
121 $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
128 * @param CRM_Core_Form $form
130 public static function reset(&$form) {
131 $tabs = self
::process($form);
132 $form->set('tabHeader', $tabs);
140 public static function getCurrentTab($tabs) {
141 static $current = FALSE;
147 if (is_array($tabs)) {
148 foreach ($tabs as $subPage => $pageVal) {
149 if ($pageVal['current'] === TRUE) {
156 $current = $current ?
$current : 'main';
165 public static function getNextTab(&$form) {
166 static $next = FALSE;
171 $tabs = $form->get('tabHeader');
172 if (is_array($tabs)) {
174 foreach ($tabs as $subPage => $pageVal) {
179 if ($pageVal['current'] === TRUE) {
185 $next = $next ?
$next : 'main';