ILIAS  release_7 Revision v7.30-3-g800a261c036
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{
36 protected $tpl;
37
38 protected $values = array();
39 protected $allowMove = false;
40
47 public function __construct($a_title = "", $a_postvar = "")
48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->tpl = $DIC["tpl"];
53 parent::__construct($a_title, $a_postvar);
54 $this->validationRegexp = "";
55 }
56
62 public function setValues($a_values)
63 {
64 $this->values = $a_values;
65 }
66
72 public function setValue($a_value)
73 {
74 $this->values = $a_value;
75 }
76
82 public function getValues()
83 {
84 return $this->values;
85 }
86
92 public function setAllowMove($a_allow_move)
93 {
94 $this->allowMove = $a_allow_move;
95 }
96
102 public function getAllowMove()
103 {
104 return $this->allowMove;
105 }
106
112 public function checkInput()
113 {
115
116 $foundvalues = $_POST[$this->getPostVar()];
117 if (is_array($foundvalues)) {
118 foreach ($foundvalues as $idx => $value) {
119 $_POST[$this->getPostVar()][$idx] = ilUtil::stripSlashes($value);
120 if ($this->getRequired() && trim($value) == "") {
121 $this->setAlert($lng->txt("msg_input_is_required"));
122
123 return false;
124 } elseif (strlen($this->getValidationRegexp())) {
125 if (!preg_match($this->getValidationRegexp(), $value)) {
126 $this->setAlert($lng->txt("msg_wrong_format"));
127 return false;
128 }
129 }
130 }
131 } elseif ($this->getRequired()) {
132 $this->setAlert($lng->txt("msg_input_is_required"));
133 return false;
134 }
135
136 return $this->checkSubItemsInput();
137 }
138
144 public function insert($a_tpl)
145 {
146 $a_tpl->setCurrentBlock("prop_generic");
147 $a_tpl->setVariable("PROP_GENERIC", $this->render());
148 $a_tpl->parseCurrentBlock();
149 }
150
151 public function render($a_mode = "")
152 {
153 $tpl = new ilTemplate("tpl.prop_textwizardinput.html", true, true, "Services/Form");
154 $i = 0;
155 foreach ($this->values as $value) {
156 if (strlen($value)) {
157 $tpl->setCurrentBlock("prop_text_propval");
158 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value));
159 $tpl->parseCurrentBlock();
160 }
161 if ($this->getAllowMove()) {
162 $tpl->setCurrentBlock("move");
163 $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
164 $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
165 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
166 $tpl->setVariable("UP_BUTTON", ilGlyphGUI::get(ilGlyphGUI::UP));
167 $tpl->setVariable("DOWN_BUTTON", ilGlyphGUI::get(ilGlyphGUI::DOWN));
168 $tpl->parseCurrentBlock();
169 }
170 $tpl->setCurrentBlock("row");
171 $tpl->setVariable("POST_VAR", $this->getPostVar() . "[$i]");
172 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
173 $tpl->setVariable("SIZE", $this->getSize());
174 $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
175
176 if ($this->getDisabled()) {
177 $tpl->setVariable(
178 "DISABLED",
179 " disabled=\"disabled\""
180 );
181 } else {
182 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
183 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
184 $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
185 $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
186 }
187
188 $tpl->parseCurrentBlock();
189 $i++;
190 }
191
192 $tpl->setVariable("ELEMENT_ID", $this->getFieldId());
193
194 if (!$this->getDisabled()) {
195 $this->tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
196 $this->tpl->addJavascript("./Services/Form/templates/default/textwizard.js");
197 }
198
199 return $tpl->get();
200 }
201}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
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.
setAllowMove($a_allow_move)
Set allow move.
insert($a_tpl)
Insert property html.
__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
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc