1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved |
4
|
|
|
* |
5
|
|
|
* This file is a part of Codendi. |
6
|
|
|
* |
7
|
|
|
* Codendi is free software; you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* Codendi is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with Codendi. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* SurveySingleton object for Codendi Surveys |
23
|
|
|
*/ |
24
|
|
|
class SurveySingleton { |
25
|
|
|
|
26
|
|
|
// simply containing the |
27
|
|
|
var $data_array = array(); |
28
|
|
|
var $ranked_array = array(); |
29
|
|
|
|
30
|
|
|
var $RADIO_BUTTON_1_5 = 1; |
31
|
|
|
var $TEXT_AREA = 2; |
32
|
|
|
var $RADIO_BUTTON_YES_NO = 3; |
33
|
|
|
var $COMMENT_ONLY = 4; |
34
|
|
|
var $TEXT_FIELD = 5; |
35
|
|
|
var $RADIO_BUTTON = 6; |
36
|
|
|
var $SELECT_BOX = 7; |
37
|
|
|
var $NONE = 100; |
38
|
|
|
|
39
|
|
|
function SurveySingleton() { |
40
|
|
|
$this->update(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function &instance() { |
44
|
|
|
static $survey_instance; |
45
|
|
|
if (isset($GLOBALS['Language'])) { |
46
|
|
|
} |
47
|
|
|
if (!$survey_instance) { |
48
|
|
|
$survey_instance = new SurveySingleton(); |
49
|
|
|
} |
50
|
|
|
return $survey_instance; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function getLabel($question_type) { |
54
|
|
|
return $GLOBALS['Language']->getText('survey_common_survey',$this->data_array[$question_type]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function update() { |
58
|
|
|
$db_res=db_query("SELECT id,type FROM survey_question_types"); |
59
|
|
|
$this->data_array=array(); |
60
|
|
|
$rows=db_numrows($db_res); |
61
|
|
|
for ($i=0; $i<$rows; $i++) { |
62
|
|
|
$this->data_array[db_result($db_res,$i,'id')] = db_result($db_res,$i,'type'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$db_res=db_query("SELECT * FROM survey_question_types ORDER BY rank"); |
66
|
|
|
$this->ranked_array=array(); |
67
|
|
|
$rows=db_numrows($db_res); |
68
|
|
|
for ($i=0; $i<$rows; $i++) { |
69
|
|
|
$this->ranked_array[db_result($db_res,$i,'rank')] = db_result($db_res,$i,'id'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
function showTypeBox($name='question_type',$checked_val='xzxz') { |
75
|
|
|
$ranked_ids = array(); |
76
|
|
|
$localizedTypes = array(); |
77
|
|
|
foreach ($this->ranked_array as $val) { |
78
|
|
|
$ranked_ids[] = $val; |
79
|
|
|
$localizedTypes[] = $this->getLabel($val); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return html_build_select_box_from_arrays ($ranked_ids,$localizedTypes,$name,$checked_val,false); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
function getSurveyTitle($title) { |
87
|
|
|
global $Language; |
88
|
|
|
if (preg_match('/_title_key$/',$title)) { |
89
|
|
|
return $Language->getText('survey_common_survey',$title); |
90
|
|
|
} else { |
91
|
|
|
return $title; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
?> |
This function has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.