ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTextAreaInputGUI.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 
24 include_once("./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
25 
34 {
35  protected $value;
36  protected $cols;
37  protected $rows;
38  protected $usert;
39  protected $rtetags;
40  protected $plugins;
41  protected $buttons;
42  protected $rtesupport;
43 
44  protected $rte_tag_set = array(
45  "standard" => array ("strong", "em", "u", "ol", "li", "ul", "p", "div",
46  "i", "b", "code", "sup", "sub", "pre", "strike", "gap"),
47  "extended" => array (
48  "a","blockquote","br","cite","code","div","em","h1","h2","h3",
49  "h4","h5","h6","hr","li","ol","p",
50  "pre","span","strike","strong","sub","sup","u","ul",
51  "i", "b", "gap"),
52  "extended_img" => array (
53  "a","blockquote","br","cite","code","div","em","h1","h2","h3",
54  "h4","h5","h6","hr","img","li","ol","p",
55  "pre","span","strike","strong","sub","sup","u","ul",
56  "i", "b", "gap"),
57  "extended_table" => array (
58  "a","blockquote","br","cite","code","div","em","h1","h2","h3",
59  "h4","h5","h6","hr","li","ol","p",
60  "pre","span","strike","strong","sub","sup","table","td",
61  "tr","u","ul", "i", "b", "gap"),
62  "extended_table_img" => array (
63  "a","blockquote","br","cite","code","div","em","h1","h2","h3",
64  "h4","h5","h6","hr","img","li","ol","p",
65  "pre","span","strike","strong","sub","sup","table","td",
66  "tr","u","ul", "i", "b", "gap"),
67  "full" => array (
68  "a","blockquote","br","cite","code","div","em","h1","h2","h3",
69  "h4","h5","h6","hr","img","li","ol","p",
70  "pre","span","strike","strong","sub","sup","table","td",
71  "tr","u","ul","ruby","rbc","rtc","rb","rt","rp", "i", "b", "gap"));
72 
73 
80  function __construct($a_title = "", $a_postvar = "")
81  {
82  parent::__construct($a_title, $a_postvar);
83  $this->setType("textarea");
84  $this->setRteTagSet("standard");
85  $this->plugins = array();
86  $this->buttons = array();
87  $this->rteSupport = array();
88  }
89 
95  function setValue($a_value)
96  {
97  $this->value = $a_value;
98  }
99 
105  function getValue()
106  {
107  return $this->value;
108  }
109 
115  function setCols($a_cols)
116  {
117  $this->cols = $a_cols;
118  }
119 
125  function getCols()
126  {
127  return $this->cols;
128  }
129 
135  function setRows($a_rows)
136  {
137  $this->rows = $a_rows;
138  }
139 
145  function getRows()
146  {
147  return $this->rows;
148  }
149 
155  function setUseRte($a_usert)
156  {
157  $this->usert = $a_usert;
158  }
159 
165  function getUseRte()
166  {
167  return $this->usert;
168  }
169 
175  function addPlugin($a_plugin)
176  {
177  $this->plugins[$a_plugin] = $a_plugin;
178  }
179 
185  function removePlugin($a_plugin)
186  {
187  unset($this->plugins[$a_plugin]);
188  }
189 
195  function addButton($a_button)
196  {
197  $this->buttons[$a_button] = $a_button;
198  }
199 
205  function removeButton($a_button)
206  {
207  unset($this->buttons[$a_button]);
208  }
209 
217  function setRTESupport($obj_id, $obj_type, $module)
218  {
219  $this->rteSupport = array("obj_id" => $obj_id, "obj_type" => $obj_type, "module" => $module);
220  }
221 
225  function removeRTESupport()
226  {
227  $this->rteSupport = array();
228  }
229 
235  function setRteTags($a_rtetags)
236  {
237  $this->rtetags = $a_rtetags;
238  }
239 
245  function getRteTags()
246  {
247  return $this->rtetags;
248  }
249 
256  function setRteTagSet($a_set_name)
257  {
258  $this->setRteTags($this->rte_tag_set[$a_set_name]);
259  }
260 
267  function getRteTagSet($a_set_name)
268  {
269  return $this->rte_tag_set[$a_set_name];
270  }
271 
272 
276  function getRteTagString()
277  {
278  $result = "";
279  foreach ($this->getRteTags() as $tag)
280  {
281  $result .= "<$tag>";
282  }
283  return $result;
284  }
285 
291  function setValueByArray($a_values)
292  {
293  $this->setValue($a_values[$this->getPostVar()]);
294  }
295 
301  function checkInput()
302  {
303  global $lng;
304 
305  include_once("./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php");
306 
307  $_POST[$this->getPostVar()] = ($this->getUseRte())
308  ? ilUtil::stripSlashes($_POST[$this->getPostVar()], true,
309  $this->getRteTagString())
310  : ilUtil::stripSlashes($_POST[$this->getPostVar()]);
311 
312  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
313  {
314  $this->setAlert($lng->txt("msg_input_is_required"));
315 
316  return false;
317  }
318  return $this->checkSubItemsInput();
319  }
320 
326  function insert(&$a_tpl)
327  {
328  if ($this->getUseRte())
329  {
330  include_once "./Services/RTE/classes/class.ilRTE.php";
331  $rtestring = ilRTE::_getRTEClassname();
332  include_once "./Services/RTE/classes/class.$rtestring.php";
333  $rte = new $rtestring();
334 
335  // @todo: Check this.
336  $rte->addPlugin("emotions");
337  foreach ($this->plugins as $plugin)
338  {
339  if (strlen($plugin))
340  {
341  $rte->addPlugin($plugin);
342  }
343  }
344 
345  foreach ($this->buttons as $button)
346  {
347  if (strlen($button))
348  {
349  $rte->addButton($button);
350  }
351  }
352  if (count($this->rteSupport) == 3)
353  {
354  $rte->addRTESupport($this->rteSupport["obj_id"], $this->rteSupport["obj_type"], $this->rteSupport["module"]);
355  }
356  else
357  {
358  $rte->addCustomRTESupport(0, "", $this->getRteTags());
359  }
360 
361  $a_tpl->touchBlock("prop_ta_w");
362  $a_tpl->setCurrentBlock("prop_textarea");
363  $a_tpl->setVariable("ROWS", $this->getRows());
364  }
365  else
366  {
367  $a_tpl->touchBlock("no_rteditor");
368 
369  if ($this->getCols() > 5)
370  {
371  $a_tpl->setCurrentBlock("prop_ta_c");
372  $a_tpl->setVariable("COLS", $this->getCols());
373  $a_tpl->parseCurrentBlock();
374  }
375  else
376  {
377  $a_tpl->touchBlock("prop_ta_w");
378  }
379 
380  $a_tpl->setCurrentBlock("prop_textarea");
381  $a_tpl->setVariable("ROWS", $this->getRows());
382  }
383  $a_tpl->setVariable("POST_VAR",
385  $a_tpl->setVariable("ID", $this->getFieldId());
386  if($this->getDisabled())
387  {
388  $a_tpl->setVariable('DISABLED','disabled="disabled" ');
389  }
390  $a_tpl->setVariable("PROPERTY_VALUE", $this->getValue());
391  $a_tpl->parseCurrentBlock();
392  }
393 
394 }