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 {
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 {
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}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a file property in a property form.
outputSuffixes($a_tpl, $a_block="allowed_suffixes")
setSuffixes($a_suffixes)
Set Accepted Suffixes.
getPending()
Get pending filename.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
getFieldId()
Get Post Variable.
setHiddenTitle($a_val)
Set hidden title (for screenreaders)
This class represents an image file property in a property form.
getDeletionFlag()
Get deletion flag.
setImage($a_image)
Set Image.
setAlt($a_alt)
Set Alternative Text.
setUseCache($a_cache)
Set cache.
getAlt()
Get Alternative Text.
setALlowDeletion($a_val)
Set allow deletion.
insert($a_tpl)
Insert property html.
getALlowDeletion()
Get allow deletion.
__construct($a_title="", $a_postvar="")
Constructor.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc