ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTextWizardInputGUI.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{
33 protected $values = array();
34 protected $allowMove = false;
35
42 function __construct($a_title = "", $a_postvar = "")
43 {
44 parent::__construct($a_title, $a_postvar);
45 $this->validationRegexp = "";
46 }
47
53 function setValues($a_values)
54 {
55 $this->values = $a_values;
56 }
57
63 function setValue($a_value)
64 {
65 $this->values = $a_value;
66 }
67
73 function getValues()
74 {
75 return $this->values;
76 }
77
83 function setAllowMove($a_allow_move)
84 {
85 $this->allowMove = $a_allow_move;
86 }
87
93 function getAllowMove()
94 {
95 return $this->allowMove;
96 }
97
103 function checkInput()
104 {
105 global $lng;
106
107 $foundvalues = $_POST[$this->getPostVar()];
108 if (is_array($foundvalues))
109 {
110 foreach ($foundvalues as $idx => $value)
111 {
112 $_POST[$this->getPostVar()][$idx] = ilUtil::stripSlashes($value);
113 if ($this->getRequired() && trim($value) == "")
114 {
115 $this->setAlert($lng->txt("msg_input_is_required"));
116
117 return false;
118 }
119 else if (strlen($this->getValidationRegexp()))
120 {
121 if (!preg_match($this->getValidationRegexp(), $value))
122 {
123 $this->setAlert($lng->txt("msg_wrong_format"));
124 return FALSE;
125 }
126 }
127 }
128 }
129 else if($this->getRequired())
130 {
131 $this->setAlert($lng->txt("msg_input_is_required"));
132 return FALSE;
133 }
134
135 return $this->checkSubItemsInput();
136 }
137
143 function insert(&$a_tpl)
144 {
145 $tpl = new ilTemplate("tpl.prop_textwizardinput.html", true, true, "Services/Form");
146 $i = 0;
147 foreach ($this->values as $value)
148 {
149 if (strlen($value))
150 {
151 $tpl->setCurrentBlock("prop_text_propval");
152 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value));
153 $tpl->parseCurrentBlock();
154 }
155 if ($this->getAllowMove())
156 {
157 $tpl->setCurrentBlock("move");
158 $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
159 $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
160 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
161 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
162 $tpl->setVariable("UP_BUTTON", ilGlyphGUI::get(ilGlyphGUI::UP));
163 $tpl->setVariable("DOWN_BUTTON", ilGlyphGUI::get(ilGlyphGUI::DOWN));
164 $tpl->parseCurrentBlock();
165 }
166 $tpl->setCurrentBlock("row");
167 $tpl->setVariable("POST_VAR", $this->getPostVar() . "[$i]");
168 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
169 $tpl->setVariable("SIZE", $this->getSize());
170 $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
171
172 if ($this->getDisabled())
173 {
174 $tpl->setVariable("DISABLED",
175 " disabled=\"disabled\"");
176 }
177 else
178 {
179 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
180 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
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 }
185
186 $tpl->parseCurrentBlock();
187 $i++;
188 }
189 $tpl->setVariable("ELEMENT_ID", $this->getFieldId());
190
191 $a_tpl->setCurrentBlock("prop_generic");
192 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
193 $a_tpl->parseCurrentBlock();
194
195 if (!$this->getDisabled())
196 {
197 global $tpl;
198 $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
199 $tpl->addJavascript("./Services/Form/templates/default/textwizard.js");
200 }
201 }
202}
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.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
getMaxLength()
Get Max Length.
getValidationRegexp()
Get validation regexp.
This class represents a text wizard property in a property form.
insert(&$a_tpl)
Insert property html.
setAllowMove($a_allow_move)
Set allow move.
__construct($a_title="", $a_postvar="")
Constructor.
setValues($a_values)
Set Values.
checkInput()
Check input, strip slashes etc.
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