ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
6include_once('Services/MetaData/classes/class.ilMDSettings.php');
7include_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 $lng;
32
33 $this->lng = $lng;
34 $this->lng->loadLanguageModule("meta");
35
36 parent::__construct($a_title, $a_postvar);
37 $this->setType("copyright");
39 }
40
46 public function setValue($a_value)
47 {
48 $this->value = $a_value;
49 }
50
56 public function getValue()
57 {
58 return $this->value;
59 }
60
66 public function setCols($a_cols)
67 {
68 $this->cols = $a_cols;
69 }
70
76 public function getCols()
77 {
78 return $this->cols;
79 }
80
86 public function setRows($a_rows)
87 {
88 $this->rows = $a_rows;
89 }
90
96 public function getRows()
97 {
98 return $this->rows;
99 }
100
106 public function setValueByArray($a_values)
107 {
108 $this->setValue($a_values[$this->getPostVar()]);
109 }
110
116 public function checkInput()
117 {
118 global $lng;
119
120 if ($this->usePurifier() && $this->getPurifier()) {
121 $_POST[$this->getPostVar()]["ta"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["ta"]);
122 }
123
124 // todo: implement setRequired, if needed
125
126 return true;
127 }
128
132 public function insert(&$a_tpl)
133 {
134 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
135
136 $ttpl = new ilTemplate("tpl.prop_copyright.html", true, true, "Services/MetaData");
138 $use_selection = ($this->settings->isCopyrightSelectionActive() && count($entries));
139 $val = $this->getValue();
140
141 if ($use_selection) {
142 $default_id = ilMDCopyrightSelectionEntry::_extractEntryId($val["ta"]);
143
144 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
145 $found = false;
146 foreach ($entries as $entry) {
147 $ttpl->setCurrentBlock('copyright_selection');
148
149 if ($entry->getEntryId() == $default_id) {
150 $found = true;
151 $ttpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"');
152 }
153 $ttpl->setVariable('COPYRIGHT_ID', $entry->getEntryId());
154 $ttpl->setVariable('COPYRIGHT_TITLE', $entry->getTitle());
155 $ttpl->setVariable('COPYRIGHT_DESCRIPTION', $entry->getDescription());
156 $ttpl->setVariable('SPOST_VAR', $this->getPostVar());
157 $ttpl->parseCurrentBlock();
158 }
159
160 $ttpl->setCurrentBlock('copyright_selection');
161 if (!$found) {
162 $ttpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"');
163 }
164 $ttpl->setVariable('COPYRIGHT_ID', 0);
165 $ttpl->setVariable('COPYRIGHT_TITLE', $this->lng->txt('meta_cp_own'));
166 $ttpl->setVariable('SPOST_VAR', $this->getPostVar());
167
168 $ttpl->parseCurrentBlock();
169 }
170
171
172 if ($this->getCols() > 5) {
173 $ttpl->setCurrentBlock("prop_ta_c");
174 $ttpl->setVariable("COLS", $this->getCols());
175 $ttpl->parseCurrentBlock();
176 } else {
177 $ttpl->touchBlock("prop_ta_w");
178 }
179
180 $ttpl->setCurrentBlock("prop_copyright");
181 $ttpl->setVariable("ROWS", $this->getRows());
182 if (!$this->getDisabled()) {
183 $ttpl->setVariable(
184 "POST_VAR",
185 $this->getPostVar()
186 );
187 }
188 $ttpl->setVariable("ID", $this->getFieldId());
189 if ($this->getDisabled()) {
190 $ttpl->setVariable('DISABLED', 'disabled="disabled" ');
191 }
192
193 if ($this->getDisabled()) {
194 $ttpl->setVariable(
195 "HIDDEN_INPUT",
196 $this->getHiddenTag($this->getPostVar(), $this->getValue())
197 );
198 }
199
200 if (!$use_selection || !$found) {
201 $ttpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($val["ta"]));
202 }
203 $ttpl->parseCurrentBlock();
204
205
206 $a_tpl->setCurrentBlock("prop_generic");
207 $a_tpl->setVariable("PROP_GENERIC", $ttpl->get());
208 $a_tpl->parseCurrentBlock();
209 }
210}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a copyright property in a property form.
checkInput()
Check input, strip slashes etc.
__construct($a_title="", $a_postvar="")
Constructor.
insert(&$a_tpl)
Insert property html.
setValue($a_value)
Set Value.
setValueByArray($a_values)
Set value by array.
This class represents a property in a property form.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
getFieldId()
Get Post Variable.
static _extractEntryId($a_cp_string)
extract entry id
static _getInstance()
get instance
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
settings()
Definition: settings.php:2