ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  function __construct($a_title = "", $a_postvar = "")
22  {
23  global $lng;
24 
25  parent::__construct($a_title, $a_postvar);
26  $this->setType("image_file");
27  $this->setAllowDeletion(true);
28  $this->setSuffixes(array("jpg", "jpeg", "png", "gif"));
29  $this->setHiddenTitle("(".$lng->txt("form_image_file_input").")");
30  $this->cache = true;
31  }
32 
38  function setALlowDeletion($a_val)
39  {
40  $this->allow_deletion = $a_val;
41  }
42 
48  function getALlowDeletion()
49  {
50  return $this->allow_deletion;
51  }
58  public function setUseCache($a_cache)
59  {
60  $this->cache = ($a_cache) ? true : false;
61  }
62 
68  public function getUseCache()
69  {
70  return $this->cache;
71  }
72 
78  function setImage($a_image)
79  {
80  $this->image = $a_image;
81  }
82 
88  function getImage()
89  {
90  return $this->image;
91  }
92 
98  function setAlt($a_alt)
99  {
100  $this->alt = $a_alt;
101  }
102 
108  function getAlt()
109  {
110  return $this->alt;
111  }
112 
116  function insert($a_tpl)
117  {
118  global $lng;
119 
120  $quota_exceeded = $quota_legend = false;
121  if(self::$check_wsp_quota)
122  {
123  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
125  {
126  $lng->loadLanguageModule("file");
127  $quota_exceeded = $lng->txt("personal_workspace_quota_exceeded_warning");
128  }
129  else
130  {
131  $quota_legend = ilDiskQuotaHandler::getStatusLegend();
132  if($quota_legend)
133  {
134  $quota_legend = "<br />".$quota_legend;
135  }
136  }
137  }
138 
139  $i_tpl = new ilTemplate("tpl.prop_image_file.html", true, true, "Services/Form");
140 
141  if ($this->getImage() != "")
142  {
143  if (!$this->getDisabled() && $this->getALlowDeletion())
144  {
145  $i_tpl->setCurrentBlock("delete_bl");
146  $i_tpl->setVariable("POST_VAR_D", $this->getPostVar());
147  $i_tpl->setVariable("TXT_DELETE_EXISTING",
148  $lng->txt("delete_existing_file"));
149  $i_tpl->parseCurrentBlock();
150  }
151 
152  if (strlen($this->getValue()))
153  {
154  $i_tpl->setCurrentBlock("has_value");
155  $i_tpl->setVariable("TEXT_IMAGE_NAME", $this->getValue());
156  $i_tpl->parseCurrentBlock();
157  }
158  $i_tpl->setCurrentBlock("image");
159  if (!$this->getUseCache())
160  {
161  $pos = strpos($this->getImage(), '?');
162  if ($pos !== false)
163  {
164  $i_tpl->setVariable("SRC_IMAGE", $this->getImage() . "&amp;time=" . time());
165  }
166  else
167  {
168  $i_tpl->setVariable("SRC_IMAGE", $this->getImage() . "?time=" . time());
169  }
170  }
171  else
172  {
173  $i_tpl->setVariable("SRC_IMAGE", $this->getImage());
174  }
175  $i_tpl->setVariable("ALT_IMAGE", $this->getAlt());
176  $i_tpl->parseCurrentBlock();
177  }
178 
179  $pending = $this->getPending();
180  if($pending)
181  {
182  $i_tpl->setCurrentBlock("pending");
183  $i_tpl->setVariable("TXT_PENDING", $lng->txt("file_upload_pending").
184  ": ".$pending);
185  $i_tpl->parseCurrentBlock();
186  }
187 
188  $i_tpl->setVariable("POST_VAR", $this->getPostVar());
189  $i_tpl->setVariable("ID", $this->getFieldId());
190 
191 
192  /* experimental: bootstrap'ed file upload */
193  $i_tpl->setVariable("TXT_BROWSE", $lng->txt("select_file"));
194 
195 
196  if(!$quota_exceeded)
197  {
198  $i_tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice")." ".
199  $this->getMaxFileSizeString().$quota_legend);
200 
201  $this->outputSuffixes($i_tpl, "allowed_image_suffixes");
202  }
203  else
204  {
205  $i_tpl->setVariable("TXT_MAX_SIZE", $quota_exceeded);
206  }
207 
208  if ($this->getDisabled() || $quota_exceeded)
209  {
210  $i_tpl->setVariable("DISABLED",
211  " disabled=\"disabled\"");
212  }
213 
214  $a_tpl->setCurrentBlock("prop_generic");
215  $a_tpl->setVariable("PROP_GENERIC", $i_tpl->get());
216  $a_tpl->parseCurrentBlock();
217  }
218 
222  function getDeletionFlag()
223  {
224  if ($_POST[$this->getPostVar()."_delete"])
225  {
226  return true;
227  }
228  return false;
229  }
230 
231 }
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.
Generate an image
insert($a_tpl)
Insert property html.
setImage($a_image)
Set Image.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
static isUploadPossible($a_additional_size=null)
setHiddenTitle($a_val)
Set hidden title (for screenreaders)
outputSuffixes($a_tpl, $a_block="allowed_suffixes")
Create styles array
The data for the language used.
getDeletionFlag()
Get deletion flag.
This class represents an image file property in a property form.
global $lng
Definition: privfeed.php:17
__construct($a_title="", $a_postvar="")
Constructor.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
$_POST["username"]