ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCSectionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Services/COPage/classes/class.ilPCSection.php");
5require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6
20{
21
26 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
27 {
28 global $DIC;
29
30 $this->tpl = $DIC["tpl"];
31 $this->lng = $DIC->language();
32 $this->ctrl = $DIC->ctrl();
33 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
34
36 }
37
41 public static function _getStandardCharacteristics()
42 {
43 global $DIC;
44
45 $lng = $DIC->language();
46
47 return array("Block" => $lng->txt("cont_Block"),
48 "Mnemonic" => $lng->txt("cont_Mnemonic"),
49 "Remark" => $lng->txt("cont_Remark"),
50 "Example" => $lng->txt("cont_Example"),
51 "Additional" => $lng->txt("cont_Additional"),
52 "Special" => $lng->txt("cont_Special"),
53 "Excursus" => $lng->txt("cont_Excursus"),
54 "AdvancedKnowledge" => $lng->txt("cont_AdvancedKnowledge"));
55 }
56
60 public static function _getCharacteristics($a_style_id)
61 {
63
64 if ($a_style_id > 0 &&
65 ilObject::_lookupType($a_style_id) == "sty") {
66 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
67 $style = new ilObjStyleSheet($a_style_id);
68 $chars = $style->getCharacteristics("section");
69 $new_chars = array();
70 foreach ($chars as $char) {
71 if ($chars[$char] != "") { // keep lang vars for standard chars
72 $new_chars[$char] = $chars[$char];
73 } else {
74 $new_chars[$char] = $char;
75 }
76 asort($new_chars);
77 }
78 $chars = $new_chars;
79 }
80 return $chars;
81 }
82
86 public function executeCommand()
87 {
88 $this->getCharacteristicsOfCurrentStyle("section"); // scorm-2004
89
90 // get next class that processes or forwards current command
91 $next_class = $this->ctrl->getNextClass($this);
92
93 // get current command
94 $cmd = $this->ctrl->getCmd();
95
96 switch ($next_class) {
97 case "ilpropertyformgui":
98 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
99 $form = $this->initForm(true);
100 $this->ctrl->forwardCommand($form);
101 break;
102
103 default:
104 $ret = $this->$cmd();
105 break;
106 }
107
108 return $ret;
109 }
110
114 public function insert(ilPropertyFormGUI $a_form = null)
115 {
116 $this->edit(true, $a_form);
117 }
118
122 public function edit($a_insert = false, ilPropertyFormGUI $a_form = null)
123 {
125
126 $this->displayValidationError();
127
128 if (!$a_form) {
129 $a_form = $this->initForm($a_insert);
130 }
131
132 $tpl->setContent($a_form->getHTML());
133 }
134
138 public function initForm($a_insert = false)
139 {
142
143 // edit form
144 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
145 $form = new ilPropertyFormGUI();
146 $form->setFormAction($ilCtrl->getFormAction($this));
147 if ($a_insert) {
148 $form->setTitle($this->lng->txt("cont_insert_section"));
149 } else {
150 $form->setTitle($this->lng->txt("cont_update_section"));
151 }
152
153 // characteristic selection
154 require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
155 $char_prop = new ilAdvSelectInputGUI(
156 $this->lng->txt("cont_characteristic"),
157 "characteristic"
158 );
159
160 $chars = $this->getCharacteristics();
161 if (is_object($this->content_obj)) {
162 if ($chars[$a_seleted_value] == "" && ($this->content_obj->getCharacteristic() != "")) {
163 $chars = array_merge(
164 array($this->content_obj->getCharacteristic() => $this->content_obj->getCharacteristic()),
165 $chars
166 );
167 }
168 }
169
170 $selected = ($a_insert)
171 ? "Block"
172 : $this->content_obj->getCharacteristic();
173
174 foreach ($chars as $k => $char) {
175 $html = '<div class="ilCOPgEditStyleSelectionItem"><div class="ilc_section_' . $k . '" style="' . self::$style_selector_reset . '">' .
176 $char . '</div></div>';
177 $char_prop->addOption($k, $char, $html);
178 }
179
180 $char_prop->setValue($selected);
181 $form->addItem($char_prop);
182
183 // link input
184 include_once 'Services/Form/classes/class.ilLinkInputGUI.php';
185 $ac = new ilLinkInputGUI($this->lng->txt('cont_link'), 'link');
186 $ac->setAllowedLinkTypes(ilLinkInputGUI::BOTH);
187 $ac->setRequired(false);
188 $ac->setInfo($this->lng->txt("copg_sec_link_info"));
189 $ac->setInternalLinkDefault(
190 $this->getPageConfig()->getIntLinkHelpDefaultType(),
191 $this->getPageConfig()->getIntLinkHelpDefaultId()
192 );
193 $link_types = array();
194 foreach ($this->getPageConfig()->getIntLinkFilters() as $f) {
195 $link_types[] = $f;
196 }
197 $ac->setInternalLinkFilterTypes($link_types);
198 $ac->setFilterWhiteList(
199 $this->getPageConfig()->getIntLinkFilterWhiteList()
200 );
201
202 if (!$a_insert) {
203 $l = $this->content_obj->getLink();
204 if ($l["LinkType"] == "IntLink") {
205 $ac->setValueByIntLinkAttributes($l["Type"], $l["Target"], $l["TargetFrame"]);
206 }
207 if ($l["LinkType"] == "ExtLink") {
208 $ac->setValue($l["Href"]);
209 }
210 }
211 $form->addItem($ac);
212
213 // activation
214
215 // active from
216 $dt_prop = new ilDateTimeInputGUI($lng->txt("cont_active_from"), "active_from");
217 if (!$a_insert && ($from = $this->content_obj->getActiveFrom()) != "") {
218 $dt_prop->setDate(new ilDateTime($from, IL_CAL_UNIX));
219 }
220 $dt_prop->setShowTime(true);
221 $form->addItem($dt_prop);
222
223 // active to
224 $dt_prop = new ilDateTimeInputGUI($lng->txt("cont_active_to"), "active_to");
225 if (!$a_insert && ($to = $this->content_obj->getActiveTo()) != "") {
226 $dt_prop->setDate(new ilDateTime($to, IL_CAL_UNIX));
227 }
228 $dt_prop->setShowTime(true);
229 $form->addItem($dt_prop);
230
231 // rep selector
232 if ($this->getPageConfig()->getEnablePermissionChecks()) {
233 include_once("./Services/Form/classes/class.ilRepositorySelector2InputGUI.php");
234 $rs = new ilRepositorySelector2InputGUI($lng->txt("cont_permission_object"), "permission_ref_id");
235 $rs->setParent($this);
236 $form->addItem($rs);
237
238 // permission
239 $options = array(
240 "read" => $lng->txt("read"),
241 "write" => $lng->txt("write"),
242 "visible" => $lng->txt("visible"),
243 );
244 $si = new ilSelectInputGUI($lng->txt("permission"), "permission");
245 $si->setInfo($lng->txt("cont_permission_object_desc"));
246 $si->setOptions($options);
247 $form->addItem($si);
248
249 if (!$a_insert) {
250 $si->setValue($this->content_obj->getPermission());
251 $rs->setValue($this->content_obj->getPermissionRefId());
252 }
253 }
254
255 // save/cancel buttons
256 if ($a_insert) {
257 $form->addCommandButton("create_section", $lng->txt("save"));
258 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
259 } else {
260 $form->addCommandButton("update", $lng->txt("save"));
261 $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
262 }
263 return $form;
264 }
265
266
270 public function create()
271 {
272 $form = $this->initForm(true);
273 if ($form->checkInput()) {
274 $this->content_obj = new ilPCSection($this->getPage());
275 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
276
277 $this->setValuesFromForm($form);
278
279 $this->updated = $this->pg_obj->update();
280 if ($this->updated === true) {
281 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
282 }
283 }
284
285 $this->insert($form);
286 }
287
291 public function update()
292 {
293 $form = $this->initForm(false);
294 if ($form->checkInput()) {
295 $this->setValuesFromForm($form);
296
297 $this->updated = $this->pg_obj->update();
298 if ($this->updated === true) {
299 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
300 }
301 }
302
303 $this->pg_obj->addHierIDs();
304 $this->edit(false, $form);
305 }
306
312 public function setValuesFromForm($form)
313 {
314 $this->content_obj->setCharacteristic($_POST["characteristic"]);
315
316 $from = $form->getItemByPostVar("active_from")->getDate();
317 if ($from) {
318 $this->content_obj->setActiveFrom($from->get(IL_CAL_UNIX));
319 } else {
320 $this->content_obj->setActiveFrom(0);
321 }
322
323 $to = $form->getItemByPostVar("active_to")->getDate();
324 if ($to) {
325 $this->content_obj->setActiveTo($to->get(IL_CAL_UNIX));
326 } else {
327 $this->content_obj->setActiveTo(0);
328 }
329
330 if ($this->getPageConfig()->getEnablePermissionChecks()) {
331 $this->content_obj->setPermissionRefId($_POST["permission_ref_id"]);
332 $this->content_obj->setPermission($_POST["permission"]);
333 }
334
335 if ($_POST["link_mode"] == "ext" && $_POST["link"] != "") {
336 $this->content_obj->setExtLink($_POST["link"]);
337 } elseif ($_POST["link_mode"] == "int" && $_POST["link"] != "") {
338 // $_POST["link"] is "crs|96", "chap|2", "term|1", "wpage|1"
339 // var_dump($_POST);
340 $la = $form->getItemByPostVar("link")->getIntLinkAttributes();
341 // echo "<br>";
342 // var_dump($la); exit;
343 if ($la["Type"] != "") {
344 $this->content_obj->setIntLink($la["Type"], $la["Target"], $la["TargetFrame"]);
345 }
346 } else {
347 $this->content_obj->setNoLink();
348 }
349 }
350}
global $l
Definition: afr.php:30
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
This class represents an advanced selection list property in a property form.
This class represents a date/time property in a property form.
@classDescription Date and time handling
This class represents a external and/or internal link in a property form.
Class ilObjStyleSheet.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilPCSectionGUI.
update()
Update Section.
create()
Create new Section.
initForm($a_insert=false)
Init editing form.
static _getCharacteristics($a_style_id)
Get characteristics.
edit($a_insert=false, ilPropertyFormGUI $a_form=null)
Edit section form.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
setValuesFromForm($form)
Set values from form.
static _getStandardCharacteristics()
Get standard characteristics.
executeCommand()
execute command
insert(ilPropertyFormGUI $a_form=null)
Insert new section form.
Class ilPCSection.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
getPageConfig()
Get Page Config.
displayValidationError()
display validation errors
getCharacteristics()
Get characteristics.
setCharacteristics($a_chars)
Set Characteristics.
This class represents a property form user interface.
This class represents a selection list property in a property form.
$html
Definition: example_001.php:87
$style
Definition: example_012.php:70
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$from