ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilImageFileInputGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  protected $cache;
14 
21  public function __construct($a_title = "", $a_postvar = "")
22  {
23  global $DIC;
24 
25  $this->lng = $DIC->language();
26  $lng = $DIC->language();
27 
28  parent::__construct($a_title, $a_postvar);
29  $this->setType("image_file");
30  $this->setAllowDeletion(true);
31  $this->setSuffixes(array("jpg", "jpeg", "png", "gif"));
32  $this->setHiddenTitle("(" . $lng->txt("form_image_file_input") . ")");
33  $this->cache = true;
34  }
35 
41  public function setALlowDeletion($a_val)
42  {
43  $this->allow_deletion = $a_val;
44  }
45 
51  public function getALlowDeletion()
52  {
53  return $this->allow_deletion;
54  }
61  public function setUseCache($a_cache)
62  {
63  $this->cache = ($a_cache) ? true : false;
64  }
65 
71  public function getUseCache()
72  {
73  return $this->cache;
74  }
75 
81  public function setImage($a_image)
82  {
83  $this->image = $a_image;
84  }
85 
91  public function getImage()
92  {
93  return $this->image;
94  }
95 
101  public function setAlt($a_alt)
102  {
103  $this->alt = $a_alt;
104  }
105 
111  public function getAlt()
112  {
113  return $this->alt;
114  }
115 
119  public function insert($a_tpl)
120  {
121  $lng = $this->lng;
122 
123  $quota_exceeded = $quota_legend = false;
124  $i_tpl = new ilTemplate("tpl.prop_image_file.html", true, true, "Services/Form");
125 
126  if ($this->getImage() != "") {
127  if (!$this->getDisabled() && $this->getALlowDeletion()) {
128  $i_tpl->setCurrentBlock("delete_bl");
129  $i_tpl->setVariable("POST_VAR_D", $this->getPostVar());
130  $i_tpl->setVariable(
131  "TXT_DELETE_EXISTING",
132  $lng->txt("delete_existing_file")
133  );
134  $i_tpl->parseCurrentBlock();
135  }
136 
137  if (strlen($this->getValue())) {
138  $i_tpl->setCurrentBlock("has_value");
139  $i_tpl->setVariable("TEXT_IMAGE_NAME", $this->getValue());
140  $i_tpl->parseCurrentBlock();
141  }
142  $i_tpl->setCurrentBlock("image");
143  if (!$this->getUseCache()) {
144  $pos = strpos($this->getImage(), '?');
145  if ($pos !== false) {
146  $i_tpl->setVariable("SRC_IMAGE", $this->getImage() . "&amp;time=" . time());
147  } else {
148  $i_tpl->setVariable("SRC_IMAGE", $this->getImage() . "?time=" . time());
149  }
150  } else {
151  $i_tpl->setVariable("SRC_IMAGE", $this->getImage());
152  }
153  $i_tpl->setVariable("ALT_IMAGE", $this->getAlt());
154  $i_tpl->parseCurrentBlock();
155  }
156 
157  $pending = $this->getPending();
158  if ($pending) {
159  $i_tpl->setCurrentBlock("pending");
160  $i_tpl->setVariable("TXT_PENDING", $lng->txt("file_upload_pending") .
161  ": " . htmlentities($pending));
162  $i_tpl->parseCurrentBlock();
163  }
164 
165  $i_tpl->setVariable("POST_VAR", $this->getPostVar());
166  $i_tpl->setVariable("ID", $this->getFieldId());
167 
168 
169  /* experimental: bootstrap'ed file upload */
170  $i_tpl->setVariable("TXT_BROWSE", $lng->txt("select_file"));
171 
172 
173  if (!$quota_exceeded) {
174  $i_tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " .
175  $this->getMaxFileSizeString() . $quota_legend);
176 
177  $this->outputSuffixes($i_tpl, "allowed_image_suffixes");
178  } else {
179  $i_tpl->setVariable("TXT_MAX_SIZE", $quota_exceeded);
180  }
181 
182  if ($this->getDisabled() || $quota_exceeded) {
183  $i_tpl->setVariable(
184  "DISABLED",
185  " disabled=\"disabled\""
186  );
187  }
188 
189  $a_tpl->setCurrentBlock("prop_generic");
190  $a_tpl->setVariable("PROP_GENERIC", $i_tpl->get());
191  $a_tpl->parseCurrentBlock();
192  }
193 
197  public function getDeletionFlag()
198  {
199  if ($_POST[$this->getPostVar() . "_delete"]) {
200  return true;
201  }
202  return false;
203  }
204 }
setALlowDeletion($a_val)
Set allow deletion.
getAlt()
Get Alternative Text.
getPostVar()
Get Post Variable.
setAlt($a_alt)
Set Alternative Text.
This class represents a file property in a property form.
getPending()
Get pending filename.
getALlowDeletion()
Get allow deletion.
setUseCache($a_cache)
Set cache.
setType($a_type)
Set Type.
insert($a_tpl)
Insert property html.
setImage($a_image)
Set Image.
getFieldId()
Get Post Variable.
global $DIC
Definition: goto.php:24
setHiddenTitle($a_val)
Set hidden title (for screenreaders)
outputSuffixes($a_tpl, $a_block="allowed_suffixes")
getDeletionFlag()
Get deletion flag.
This class represents an image file property in a property form.
__construct(Container $dic, ilPlugin $plugin)
__construct($a_title="", $a_postvar="")
Constructor.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
$_POST["username"]