ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBackgroundImageInputGUI.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 $user;
37 
38  protected $value;
39 
46  public function __construct($a_title = "", $a_postvar = "")
47  {
48  global $DIC;
49 
50  $this->lng = $DIC->language();
51  $this->user = $DIC->user();
52  parent::__construct($a_title, $a_postvar);
53  $this->setType("background_image");
54  }
55 
61  public function setValue($a_value)
62  {
63  $this->value = $a_value;
64  }
65 
71  public function getValue()
72  {
73  return $this->value;
74  }
75 
81  public function setImages($a_images)
82  {
83  $this->images = $a_images;
84  }
85 
91  public function getImages()
92  {
93  return $this->images;
94  }
95 
101  public function checkInput()
102  {
103  $lng = $this->lng;
104 
105  $type = $_POST[$this->getPostVar()]["type"] =
106  ilUtil::stripSlashes($_POST[$this->getPostVar()]["type"]);
107  $int_value = $_POST[$this->getPostVar()]["int_value"] =
108  ilUtil::stripSlashes($_POST[$this->getPostVar()]["int_value"]);
109  $ext_value = $_POST[$this->getPostVar()]["ext_value"] =
110  ilUtil::stripSlashes($_POST[$this->getPostVar()]["ext_value"]);
111 
112  if ($this->getRequired() && $type == "ext" && trim($ext_value) == "") {
113  $this->setAlert($lng->txt("msg_input_is_required"));
114 
115  return false;
116  }
117 
118  if ($type == "external") {
119  $this->setValue($ext_value);
120  } else {
121  $this->setValue($int_value);
122  }
123 
124  return true;
125  }
126 
130  public function insert(&$a_tpl)
131  {
132  $tpl = new ilTemplate("tpl.prop_background_image.html", true, true, "Services/Style/Content");
133 
134  $tpl->setVariable("POSTVAR", $this->getPostVar());
135 
136  $int_options = array_merge(array("" => ""), $this->getImages());
137 
138  $value = trim($this->getValue());
139 
140  if (is_int(strpos($value, "/"))) {
141  $current_type = "ext";
142  $tpl->setVariable("EXTERNAL_SELECTED", 'checked="checked"');
143  $tpl->setVariable("VAL_EXT", ilUtil::prepareFormOutput($value));
144  } else {
145  $current_type = "int";
146  $tpl->setVariable("INTERNAL_SELECTED", 'checked="checked"');
147  }
148 
149  foreach ($int_options as $option) {
150  $tpl->setCurrentBlock("int_option");
151  $tpl->setVariable("VAL_INT", $option);
152  $tpl->setVariable("TXT_INT", $option);
153 
154  if ($current_type == "int" && $value == $option) {
155  $tpl->setVariable("INT_SELECTED", 'selected="selected"');
156  }
157  $tpl->parseCurrentBlock();
158  }
159 
160  $a_tpl->setCurrentBlock("prop_generic");
161  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
162  $a_tpl->parseCurrentBlock();
163  }
164 
170  public function setValueByArray($a_values)
171  {
173 
174  if ($a_values[$this->getPostVar()]["type"] == "internal") {
175  $this->setValue($a_values[$this->getPostVar()]["int_value"]);
176  } else {
177  $this->setValue($a_values[$this->getPostVar()]["ext_value"]);
178  }
179  }
180 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
checkInput()
Check input, strip slashes etc.
__construct($a_title="", $a_postvar="")
Constructor.
setValueByArray($a_values)
Set value by array.
insert(&$a_tpl)
Insert property html.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
user()
Definition: user.php:4
setAlert($a_alert)
Set Alert Text.
setType($a_type)
Set Type.
Done rendering charts as images
special template class to simplify handling of ITX/PEAR
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
This class represents a property in a property form.
This class represents a background image property in a property form.
$_POST["username"]