ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function __construct($a_title = "", $a_postvar = "")
30  {
31  global $DIC;
32 
33  $lng = $DIC['lng'];
34 
35  $this->lng = $lng;
36  $this->lng->loadLanguageModule("meta");
37 
38  parent::__construct($a_title, $a_postvar);
39  $this->setType("copyright");
41  }
42 
48  public function setValue($a_value)
49  {
50  $this->value = $a_value;
51  }
52 
58  public function getValue()
59  {
60  return $this->value;
61  }
62 
68  public function setCols($a_cols)
69  {
70  $this->cols = $a_cols;
71  }
72 
78  public function getCols()
79  {
80  return $this->cols;
81  }
82 
88  public function setRows($a_rows)
89  {
90  $this->rows = $a_rows;
91  }
92 
98  public function getRows()
99  {
100  return $this->rows;
101  }
102 
108  public function setValueByArray($a_values)
109  {
110  $this->setValue($a_values[$this->getPostVar()]);
111  }
112 
118  public function checkInput()
119  {
120  global $DIC;
121 
122  $lng = $DIC['lng'];
123 
124  if ($this->usePurifier() && $this->getPurifier()) {
125  $_POST[$this->getPostVar()]["ta"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["ta"]);
126  }
127 
128  // todo: implement setRequired, if needed
129 
130  return true;
131  }
132 
136  public function insert(&$a_tpl)
137  {
138  include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
139 
140  $ttpl = new ilTemplate("tpl.prop_copyright.html", true, true, "Services/MetaData");
142  $use_selection = ($this->settings->isCopyrightSelectionActive() && count($entries));
143  $val = $this->getValue();
144 
145  if ($use_selection) {
146  $default_id = ilMDCopyrightSelectionEntry::_extractEntryId($val["ta"]);
147 
148  include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
149  $found = false;
150  foreach ($entries as $entry) {
151  $ttpl->setCurrentBlock('copyright_selection');
152 
153  if ($entry->getEntryId() == $default_id) {
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  $ttpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"');
167  }
168  $ttpl->setVariable('COPYRIGHT_ID', 0);
169  $ttpl->setVariable('COPYRIGHT_TITLE', $this->lng->txt('meta_cp_own'));
170  $ttpl->setVariable('SPOST_VAR', $this->getPostVar());
171 
172  $ttpl->parseCurrentBlock();
173  }
174 
175 
176  if ($this->getCols() > 5) {
177  $ttpl->setCurrentBlock("prop_ta_c");
178  $ttpl->setVariable("COLS", $this->getCols());
179  $ttpl->parseCurrentBlock();
180  } else {
181  $ttpl->touchBlock("prop_ta_w");
182  }
183 
184  $ttpl->setCurrentBlock("prop_copyright");
185  $ttpl->setVariable("ROWS", $this->getRows());
186  if (!$this->getDisabled()) {
187  $ttpl->setVariable(
188  "POST_VAR",
189  $this->getPostVar()
190  );
191  }
192  $ttpl->setVariable("ID", $this->getFieldId());
193  if ($this->getDisabled()) {
194  $ttpl->setVariable('DISABLED', 'disabled="disabled" ');
195  }
196 
197  if ($this->getDisabled()) {
198  $ttpl->setVariable(
199  "HIDDEN_INPUT",
200  $this->getHiddenTag($this->getPostVar(), $this->getValue())
201  );
202  }
203 
204  if (!$use_selection || !$found) {
205  $ttpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($val["ta"]));
206  }
207  $ttpl->parseCurrentBlock();
208 
209 
210  $a_tpl->setCurrentBlock("prop_generic");
211  $a_tpl->setVariable("PROP_GENERIC", $ttpl->get());
212  $a_tpl->parseCurrentBlock();
213  }
214 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
getPostVar()
Get Post Variable.
setValue($a_value)
Set Value.
__construct($a_title="", $a_postvar="")
Constructor.
This class represents a copyright property in a property form.
insert(&$a_tpl)
Insert property html.
setType($a_type)
Set Type.
static _getInstance()
get instance
checkInput()
Check input, strip slashes etc.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
static _extractEntryId($a_cp_string)
extract entry id
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
This class represents a property in a property form.
setValueByArray($a_values)
Set value by array.
$_POST["username"]