ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSelectBuilderInputGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14
15 protected $open_answer_indexes = array();
16
17
18 // constructor
19 public function __construct($a_title = "", $a_postvar = "")
20 {
21 parent::__construct($a_title, $a_postvar);
22 }
23
24
28 public function getOpenAnswerIndexes()
29 {
31 }
32
36 public function setOpenAnswerIndexes($a_indexes)
37 {
38 $this->open_answer_indexes = $a_indexes;
39 }
40
44 public function addOpenAnswerIndex($a_idx)
45 {
46 $this->open_answer_indexes[] = $a_idx;
47 }
48
54 public function isOpenAnswerIndex($a_idx)
55 {
56 return in_array($a_idx,(array) $this->open_answer_indexes);
57 }
58
64 public function checkInput()
65 {
66 global $lng;
67
68 $foundvalues = $_POST[$this->getPostVar()];
69
70
71
72 $this->setOpenAnswerIndexes(array());
73 if (is_array($foundvalues))
74 {
75 foreach ($foundvalues as $idx => $value)
76 {
78 if ($this->getRequired() && trim($value) == "")
79 {
80 $this->setAlert($lng->txt("msg_input_is_required"));
81
82 return false;
83 }
84 else if (strlen($this->getValidationRegexp()))
85 {
86 if (!preg_match($this->getValidationRegexp(), $value))
87 {
88 $this->setAlert($lng->txt("msg_wrong_format"));
89 return FALSE;
90 }
91 }
92 }
93 }
94 else
95 {
96 $this->setAlert($lng->txt("msg_input_is_required"));
97 return FALSE;
98 }
99
100 foreach((array) $_POST[$this->getPostVar().'_open'] as $oindex => $ovalue)
101 {
102 $this->addOpenAnswerIndex($oindex);
103 }
104
105
106 return $this->checkSubItemsInput();
107 }
108
109 public function setValueByArray($a_values)
110 {
111 parent::setValueByArray($a_values);
112
113 foreach((array) $_POST[$this->getPostVar().'_open'] as $oindex => $ovalue)
114 {
115 $this->addOpenAnswerIndex($oindex);
116 }
117 }
118
124 public function insert($a_tpl)
125 {
126 global $lng;
127
128 $tpl = new ilTemplate("tpl.prop_selectbuilder.html", true, true, "Services/Form");
129 $i = 0;
130 foreach ($this->values as $value)
131 {
132 if(!is_string($value))
133 {
134 continue;
135 }
136
137 if (strlen((string) $value))
138 {
139 $tpl->setCurrentBlock("prop_text_propval");
140 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput((string) $value));
141 $tpl->parseCurrentBlock();
142 }
143 if ($this->getAllowMove())
144 {
145 $tpl->setCurrentBlock("move");
146 $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
147 $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
148 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
149 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
150 $tpl->setVariable("UP_BUTTON", ilGlyphGUI::get(ilGlyphGUI::UP));
151 $tpl->setVariable("DOWN_BUTTON", ilGlyphGUI::get(ilGlyphGUI::DOWN));
152
153 $tpl->parseCurrentBlock();
154 }
155 $tpl->setCurrentBlock("row");
156 $tpl->setVariable("POST_VAR", $this->getPostVar() . "[$i]");
157 #$tpl->setVariable('POST_VAR_OPEN',$this->getPostVar().'[open]'.'['.$i.']');
158 $tpl->setVariable('POST_VAR_OPEN',$this->getPostVar().'_open'.'['.$i.']');
159 $tpl->setVariable('POST_VAR_OPEN_ID', $this->getPostVar().'_open['.$i.']');
160 $tpl->setVariable('TXT_OPEN', $lng->txt("form_open_answer"));
161
162 if($this->isOpenAnswerIndex($i))
163 {
164 $tpl->setVariable('PROP_OPEN_CHECKED','checked="checked"');
165 }
166 if($this->getDisabled())
167 {
168 $tpl->setVariable('PROP_OPEN_DISABLED','disabled="disabled"');
169 }
170
171 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
172 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
173 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
174 $tpl->setVariable("SIZE", $this->getSize());
175 $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
176 if ($this->getDisabled())
177 {
178 $tpl->setVariable("DISABLED",
179 " disabled=\"disabled\"");
180 }
181 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
182 $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
183 $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
184 $tpl->parseCurrentBlock();
185 $i++;
186 }
187 $tpl->setVariable("ELEMENT_ID", $this->getFieldId());
188
189 $a_tpl->setCurrentBlock("prop_generic");
190 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
191 $a_tpl->parseCurrentBlock();
192
193 global $tpl;
194 $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
195 $tpl->addJavascript("./Services/Form/templates/default/textwizard.js");
196 }
197
198
199}
global $tpl
Definition: ilias.php:8
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
static get($a_glyph, $a_text="")
Get glyph html.
Input GUI for the configuration of select input elements.
isOpenAnswerIndex($a_idx)
Check if an index is an open answer index.
checkInput()
Check input, strip slashes etc.
insert($a_tpl)
Insert property html.
setValueByArray($a_values)
Set value by array.
getOpenAnswerIndexes()
Get open answer indexes.
setOpenAnswerIndexes($a_indexes)
Set open answer indexes.
addOpenAnswerIndex($a_idx)
Mark an index as open answer.
__construct($a_title="", $a_postvar="")
Constructor.
special template class to simplify handling of ITX/PEAR
getMaxLength()
Get Max Length.
getValidationRegexp()
Get validation regexp.
This class represents a text wizard property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40