ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCopyrightInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
6 include_once('Services/MetaData/classes/class.ilMDSettings.php');
7 include_once('Services/MetaData/classes/class.ilMDRights.php');
8 
17 {
18  protected $value;
19  protected $cols;
20  protected $rows;
21  protected $settings;
22 
29  function __construct($a_title = "", $a_postvar = "")
30  {
31  global $lng;
32 
33  $this->lng = $lng;
34  $this->lng->loadLanguageModule("meta");
35 
36  parent::__construct($a_title, $a_postvar);
37  $this->setType("copyright");
38  $this->settings = ilMDSettings::_getInstance();
39  }
40 
46  function setValue($a_value)
47  {
48  $this->value = $a_value;
49  }
50 
56  function getValue()
57  {
58  return $this->value;
59  }
60 
66  function setCols($a_cols)
67  {
68  $this->cols = $a_cols;
69  }
70 
76  function getCols()
77  {
78  return $this->cols;
79  }
80 
86  function setRows($a_rows)
87  {
88  $this->rows = $a_rows;
89  }
90 
96  function getRows()
97  {
98  return $this->rows;
99  }
100 
106  function setValueByArray($a_values)
107  {
108  $this->setValue($a_values[$this->getPostVar()]);
109  }
110 
116  function checkInput()
117  {
118  global $lng;
119 
120  if($this->usePurifier() && $this->getPurifier())
121  {
122  $_POST[$this->getPostVar()]["ta"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["ta"]);
123  }
124 
125  // todo: implement setRequired, if needed
126 
127  return true;
128  }
129 
133  function insert(&$a_tpl)
134  {
135  include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
136 
137  $ttpl = new ilTemplate("tpl.prop_copyright.html", true, true, "Services/MetaData");
139  $use_selection = ($this->settings->isCopyrightSelectionActive() && count($entries));
140  $val = $this->getValue();
141 
142  if ($use_selection)
143  {
144  $default_id = ilMDCopyrightSelectionEntry::_extractEntryId($val["ta"]);
145 
146  include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
147  $found = false;
148  foreach($entries as $entry)
149  {
150  $ttpl->setCurrentBlock('copyright_selection');
151 
152  if($entry->getEntryId() == $default_id)
153  {
154  $found = true;
155  $ttpl->setVariable('COPYRIGHT_CHECKED','checked="checked"');
156  }
157  $ttpl->setVariable('COPYRIGHT_ID',$entry->getEntryId());
158  $ttpl->setVariable('COPYRIGHT_TITLE',$entry->getTitle());
159  $ttpl->setVariable('COPYRIGHT_DESCRIPTION',$entry->getDescription());
160  $ttpl->setVariable('SPOST_VAR', $this->getPostVar());
161  $ttpl->parseCurrentBlock();
162  }
163 
164  $ttpl->setCurrentBlock('copyright_selection');
165  if(!$found)
166  {
167  $ttpl->setVariable('COPYRIGHT_CHECKED','checked="checked"');
168  }
169  $ttpl->setVariable('COPYRIGHT_ID',0);
170  $ttpl->setVariable('COPYRIGHT_TITLE',$this->lng->txt('meta_cp_own'));
171  $ttpl->setVariable('SPOST_VAR', $this->getPostVar());
172 
173  $ttpl->parseCurrentBlock();
174  }
175 
176 
177  if ($this->getCols() > 5)
178  {
179  $ttpl->setCurrentBlock("prop_ta_c");
180  $ttpl->setVariable("COLS", $this->getCols());
181  $ttpl->parseCurrentBlock();
182  }
183  else
184  {
185  $ttpl->touchBlock("prop_ta_w");
186  }
187 
188  $ttpl->setCurrentBlock("prop_copyright");
189  $ttpl->setVariable("ROWS", $this->getRows());
190  if (!$this->getDisabled())
191  {
192  $ttpl->setVariable("POST_VAR",
193  $this->getPostVar());
194  }
195  $ttpl->setVariable("ID", $this->getFieldId());
196  if ($this->getDisabled())
197  {
198  $ttpl->setVariable('DISABLED','disabled="disabled" ');
199  }
200 
201  if ($this->getDisabled())
202  {
203  $ttpl->setVariable("HIDDEN_INPUT",
204  $this->getHiddenTag($this->getPostVar(), $this->getValue()));
205  }
206 
207  if (!$use_selection || !$found)
208  {
209  $ttpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($val["ta"]));
210  }
211  $ttpl->parseCurrentBlock();
212 
213 
214  $a_tpl->setCurrentBlock("prop_generic");
215  $a_tpl->setVariable("PROP_GENERIC", $ttpl->get());
216  $a_tpl->parseCurrentBlock();
217  }
218 }