ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFlashFileInputGUI.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 {
33  protected $applet;
34  protected $width;
35  protected $height;
36  protected $parameters;
37 
44  function __construct($a_title = "", $a_postvar = "")
45  {
46  parent::__construct($a_title, $a_postvar);
47  $this->setType("flash_file");
48  $this->setSuffixes(array("swf"));
49  $this->width = 550;
50  $this->height = 400;
51  $this->parameters = array();
52  }
53 
59  function setApplet($a_applet)
60  {
61  $this->setFilename($a_applet);
62  }
63 
69  function getApplet()
70  {
71  return $this->getFilename();
72  }
73 
79  function getWidth()
80  {
81  return $this->width;
82  }
83 
89  function setWidth($a_width)
90  {
91  $this->width = $a_width;
92  }
93 
99  function getHeight()
100  {
101  return $this->height;
102  }
103 
109  function setHeight($a_height)
110  {
111  $this->height = $a_height;
112  }
113 
119  function getParameters()
120  {
121  return $this->parameters;
122  }
123 
129  function setParameters($a_parameters)
130  {
131  $this->parameters = $a_parameters;
132  }
133 
140  function addParameter($name, $value)
141  {
142  $this->parameters[$name] = $value;
143  }
144 
150  function removeParameter($name)
151  {
152  unset($this->parameters[$name]);
153  }
154 
158  function clearParameters()
159  {
160  $this->parameters = array();
161  }
162 
166  function insert(&$a_tpl)
167  {
168  global $lng;
169 
170  if ($this->getApplet() != "")
171  {
172  if (count($this->getParameters()))
173  {
174  $index = 0;
175  $params = array();
176  foreach ($this->getParameters() as $name => $value)
177  {
178  array_push($params, urlencode($name) . "=" . urlencode($value));
179  $a_tpl->setCurrentBlock("applet_param_input");
180  $a_tpl->setVariable("TEXT_NAME", $lng->txt("name"));
181  $a_tpl->setVariable("TEXT_VALUE", $lng->txt("value"));
182  $a_tpl->setVariable("PARAM_INDEX", $index);
183  $a_tpl->setVariable("POST_VAR_P", $this->getPostVar());
184  $a_tpl->setVariable("VALUE_NAME", "value=\"" . ilUtil::prepareFormOutput($name) . "\"");
185  $a_tpl->setVariable("VALUE_VALUE", "value=\"" . ilUtil::prepareFormOutput($value) . "\"");
186  $a_tpl->setVariable("TEXT_DELETE_PARAM", $lng->txt("delete_parameter"));
187  $a_tpl->parseCurrentBlock();
188  $index++;
189  }
190  $a_tpl->setCurrentBlock("applet_parameter");
191  $a_tpl->setVariable("PARAM_VALUE", join($params, "&"));
192  $a_tpl->parseCurrentBlock();
193  $a_tpl->setCurrentBlock("flash_vars");
194  $a_tpl->setVariable("PARAM_VALUE", join($params, "&"));
195  $a_tpl->parseCurrentBlock();
196  }
197  $a_tpl->setCurrentBlock("applet");
198  $a_tpl->setVariable("TEXT_ADD_PARAM", $lng->txt("add_parameter"));
199  $a_tpl->setVariable("APPLET_WIDTH", $this->getWidth());
200  $a_tpl->setVariable("APPLET_HEIGHT", $this->getHeight());
201  $a_tpl->setVariable("POST_VAR_D", $this->getPostVar());
202  $a_tpl->setVariable("TEXT_WIDTH", $lng->txt("width"));
203  $a_tpl->setVariable("TEXT_HEIGHT", $lng->txt("height"));
204  $a_tpl->setVariable("APPLET_FILE", str_replace(ILIAS_ABSOLUTE_PATH, ILIAS_HTTP_PATH, $this->getApplet()));
205  $a_tpl->setVariable("APPLET_PATH", str_replace(ILIAS_ABSOLUTE_PATH, ILIAS_HTTP_PATH, $this->getApplet()));
206  if ($this->getWidth()) $a_tpl->setVariable("VALUE_WIDTH", "value=\"" . $this->getWidth() . "\"");
207  if ($this->getHeight()) $a_tpl->setVariable("VALUE_HEIGHT", "value=\"" . $this->getHeight() . "\"");
208  $a_tpl->setVariable("ID", $this->getFieldId());
209  $a_tpl->setVariable("TXT_DELETE_EXISTING",
210  $lng->txt("delete_existing_file"));
211  $a_tpl->parseCurrentBlock();
212  }
213 
214  $js_tpl = new ilTemplate('tpl.flashAddParam.js', true, true, 'Services/Form');
215  $js_tpl->setVariable("TEXT_NAME", $lng->txt("name"));
216  $js_tpl->setVariable("TEXT_VALUE", $lng->txt("value"));
217  $js_tpl->setVariable("POST_VAR", $this->getPostVar());
218  $js_tpl->setVariable("TEXT_DELETE_PARAM", $lng->txt("delete_parameter"));
219  $js_tpl->setVariable("TEXT_CONFIRM_DELETE_PARAMETER", $lng->txt("confirm_delete_parameter"));
220 
221  $a_tpl->setCurrentBlock("prop_flash_file");
222  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
223  $a_tpl->setVariable("ID", $this->getFieldId());
224  $a_tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice")." ".
225  $this->getMaxFileSizeString());
226  $a_tpl->setVariable("JAVASCRIPT_FLASH", $js_tpl->get());
227  $a_tpl->parseCurrentBlock();
228 
229  include_once "./Services/YUI/classes/class.ilYuiUtil.php";
231  }
232 
236  function getDeletionFlag()
237  {
238  if ($_POST[$this->getPostVar()."_delete"])
239  {
240  return true;
241  }
242  return false;
243  }
244 
245 }