ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  if(!$quota_exceeded)
192  {
193  $i_tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice")." ".
194  $this->getMaxFileSizeString().$quota_legend);
195 
196  $this->outputSuffixes($i_tpl, "allowed_image_suffixes");
197  }
198  else
199  {
200  $i_tpl->setVariable("TXT_MAX_SIZE", $quota_exceeded);
201  }
202 
203  if ($this->getDisabled() || $quota_exceeded)
204  {
205  $i_tpl->setVariable("DISABLED",
206  " disabled=\"disabled\"");
207  }
208 
209  $a_tpl->setCurrentBlock("prop_generic");
210  $a_tpl->setVariable("PROP_GENERIC", $i_tpl->get());
211  $a_tpl->parseCurrentBlock();
212  }
213 
217  function getDeletionFlag()
218  {
219  if ($_POST[$this->getPostVar()."_delete"])
220  {
221  return true;
222  }
223  return false;
224  }
225 
226 }