ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMatrixRowWizardInputGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
32{
36 protected $tpl;
37
38 protected $values = array();
39 protected $allowMove = false;
40 protected $show_wizard = false;
41 protected $show_save_phrase = false;
42 protected $categorytext;
43 protected $labeltext;
45
52 public function __construct($a_title = "", $a_postvar = "")
53 {
54 global $DIC;
55
56 $this->lng = $DIC->language();
57 $this->tpl = $DIC["tpl"];
58 $lng = $DIC->language();
59
60 parent::__construct($a_title, $a_postvar);
61
62 $this->show_wizard = false;
63 $this->show_save_phrase = false;
64 $this->categorytext = $lng->txt('row_text');
65 $this->use_other_answer = false;
66
67 $this->setMaxLength(1000); // #6803
68 }
69
70 public function getUseOtherAnswer()
71 {
73 }
74
75 public function setUseOtherAnswer($a_value)
76 {
77 $this->use_other_answer = ($a_value) ? true : false;
78 }
79
85 public function setValue($a_value)
86 {
87 $this->values = new SurveyCategories();
88 if (is_array($a_value)) {
89 if (is_array($a_value['answer'])) {
90 foreach ($a_value['answer'] as $index => $value) {
91 $this->values->addCategory($value, $a_value['other'][$index]);
92 }
93 }
94 }
95 }
96
102 public function setValues($a_values)
103 {
104 $this->values = $a_values;
105 }
106
112 public function getValues()
113 {
114 return $this->values;
115 }
116
122 public function setAllowMove($a_allow_move)
123 {
124 $this->allowMove = $a_allow_move;
125 }
126
132 public function getAllowMove()
133 {
134 return $this->allowMove;
135 }
136
137 public function setShowWizard($a_value)
138 {
139 $this->show_wizard = $a_value;
140 }
141
142 public function getShowWizard()
143 {
144 return $this->show_wizard;
145 }
146
147 public function setCategoryText($a_text)
148 {
149 $this->categorytext = $a_text;
150 }
151
152 public function getCategoryText()
153 {
154 return $this->categorytext;
155 }
156
157 public function setLabelText($a_text)
158 {
159 $this->labeltext = $a_text;
160 }
161
162 public function getLabelText()
163 {
164 return $this->labeltext;
165 }
166
167 public function setShowSavePhrase($a_value)
168 {
169 $this->show_save_phrase = $a_value;
170 }
171
172 public function getShowSavePhrase()
173 {
175 }
176
182 public function checkInput()
183 {
185 if (is_array($_POST[$this->getPostVar()])) {
187 }
188 $foundvalues = $_POST[$this->getPostVar()];
189 if (is_array($foundvalues)) {
190 // check answers
191 if (is_array($foundvalues['answer'])) {
192 foreach ($foundvalues['answer'] as $idx => $answervalue) {
193 if (((strlen($answervalue)) == 0) && ($this->getRequired() && (!$foundvalues['other'][$idx]))) {
194 $this->setAlert($lng->txt("msg_input_is_required"));
195 return false;
196 }
197 }
198 }
199 } else {
200 $this->setAlert($lng->txt("msg_input_is_required"));
201 return false;
202 }
203
204 return $this->checkSubItemsInput();
205 }
206
212 public function insert($a_tpl)
213 {
215
216 $tpl = new ilTemplate("tpl.prop_matrixrowwizardinput.html", true, true, "Modules/SurveyQuestionPool");
217 $i = 0;
218 if (is_object($this->values)) {
219 for ($i = 0; $i < $this->values->getCategoryCount(); $i++) {
220 $cat = $this->values->getCategory($i);
221 $tpl->setCurrentBlock("prop_text_propval");
222 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($cat->title));
223 $tpl->parseCurrentBlock();
224 $tpl->setCurrentBlock("prop_label_propval");
225 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($cat->label));
226 $tpl->parseCurrentBlock();
227
228 if ($this->getUseOtherAnswer()) {
229 $tpl->setCurrentBlock("other_answer_checkbox");
230 $tpl->setVariable("POST_VAR", $this->getPostVar());
231 $tpl->setVariable("OTHER_ID", $this->getPostVar() . "[other][$i]");
232 $tpl->setVariable("ROW_NUMBER", $i);
233 if ($cat->other) {
234 $tpl->setVariable("CHECKED_OTHER", ' checked="checked"');
235 }
236 $tpl->parseCurrentBlock();
237 }
238
239 if ($this->getAllowMove()) {
240 $tpl->setCurrentBlock("move");
241 $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
242 $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
243 $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
244 $tpl->setVariable("UP_BUTTON", ilGlyphGUI::get(ilGlyphGUI::UP));
245 $tpl->setVariable("DOWN_BUTTON", ilGlyphGUI::get(ilGlyphGUI::DOWN));
246 $tpl->parseCurrentBlock();
247 }
248
249 $tpl->setCurrentBlock("row");
250 $tpl->setVariable("POST_VAR", $this->getPostVar());
251 $tpl->setVariable("ROW_NUMBER", $i);
252 $tpl->setVariable("ID", $this->getPostVar() . "[answer][$i]");
253 $tpl->setVariable("ID_LABEL", $this->getPostVar() . "[label][$i]");
254 $tpl->setVariable("SIZE", $this->getSize());
255 $tpl->setVariable("SIZE_LABEL", 15);
256 $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
257 if ($this->getDisabled()) {
258 $tpl->setVariable("DISABLED", " disabled=\"disabled\"");
259 $tpl->setVariable("DISABLED_LABEL", " disabled=\"disabled\"");
260 }
261
262 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
263 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
264 $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
265 $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
266 $tpl->parseCurrentBlock();
267 }
268 }
269
270 if ($this->getShowWizard()) {
271 $tpl->setCurrentBlock("wizard");
272 $tpl->setVariable("CMD_WIZARD", 'cmd[wizard' . $this->getFieldId() . ']');
273 $tpl->setVariable("WIZARD_BUTTON", ilUtil::getImagePath('wizard.svg'));
274 $tpl->setVariable("WIZARD_TEXT", $lng->txt('add_phrase'));
275 $tpl->parseCurrentBlock();
276 }
277
278 if ($this->getShowSavePhrase()) {
279 $tpl->setCurrentBlock('savephrase');
280 $tpl->setVariable("POST_VAR", $this->getPostVar());
281 $tpl->setVariable("VALUE_SAVE_PHRASE", $lng->txt('save_phrase'));
282 $tpl->parseCurrentBlock();
283 }
284
285 if ($this->getUseOtherAnswer()) {
286 $tpl->setCurrentBlock('other_answer_title');
287 $tpl->setVariable("OTHER_TEXT", $lng->txt('use_other_answer'));
288 $tpl->parseCurrentBlock();
289 }
290
291 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
292 $tpl->setVariable("ANSWER_TEXT", $this->getCategoryText());
293 $tpl->setVariable("LABEL_TEXT", $this->getLabelText());
294 $tpl->setVariable("ACTIONS_TEXT", $lng->txt('actions'));
295
296 $a_tpl->setCurrentBlock("prop_generic");
297 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
298 $a_tpl->parseCurrentBlock();
299
301 $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
302 $tpl->addJavascript("./Modules/SurveyQuestionPool/templates/default/matrixrowwizard.js");
303 }
304}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class SurveyCategories.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
static get($a_glyph, $a_text="")
Get glyph html.
This class represents a survey question category wizard property in a property form.
setAllowMove($a_allow_move)
Set allow move.
checkInput()
Check input, strip slashes etc.
__construct($a_title="", $a_postvar="")
Constructor.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
setMaxLength($a_maxlength)
Set Max Length.
getMaxLength()
Get Max Length.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $DIC
Definition: goto.php:24
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc