ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLMPageObjectGUI.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("./Modules/LearningModule/classes/class.ilLMObjectGUI.php");
5require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
6require_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
7require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
8
22{
23 var $obj;
24
31 function __construct(&$a_content_obj)
32 {
33 parent::__construct($a_content_obj);
34
35 }
36
37
41 function setLMPageObject($a_pg_obj)
42 {
43 $this->obj = $a_pg_obj;
44 $this->obj->setLMId($this->content_object->getId());
45 }
46
50 function executeCommand()
51 {
52 global $tpl, $ilCtrl, $ilTabs, $ilSetting;
53
54 $next_class = $this->ctrl->getNextClass($this);
55 $cmd = $this->ctrl->getCmd();
56
57//echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":".
58// ":nextClass:".$next_class.":"; flush();
59
60 switch($next_class)
61 {
62 case "illmpagegui":
63
64 // Determine whether the view of a learning resource should
65 // be shown in the frameset of ilias, or in a separate window.
66 //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
67 $showViewInFrameset = true;
68 $lm_set = new ilSetting("lm");
69
70 $this->ctrl->setReturn($this, "edit");
71 if (!ilPageObject::_exists("lm", $this->obj->getId(), $_GET["transl"]) &&
72 ilPageObject::_exists("lm", $this->obj->getId(), "-"))
73 {
74 if ($_GET["totransl"] == "")
75 {
76 $_GET["totransl"] = $_GET["transl"];
77 $ilCtrl->setCmd("switchToLanguage");
78 }
79 $ilCtrl->setCmdClass("illmpagegui");
80 $page_gui = new ilLMPageGUI($this->obj->getId(), 0, false, "-");
81 }
82 else
83 {
84 $page_gui = new ilLMPageGUI($this->obj->getId());
85 }
86 $page_gui->setEditPreview(true);
87 $page_gui->activateMetaDataEditor($this->content_object,
88 $this->obj->getType(), $this->obj->getId(),
89 $this->obj, "MDUpdateListener");
90 if ($ilSetting->get("block_activated_news"))
91 {
92 $page_gui->setEnabledNews(true, $this->obj->content_object->getId(),
93 $this->obj->content_object->getType());
94 }
95
96 // set page view link
97 if ($showViewInFrameset)
98 {
99 $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
100 }
101 else
102 {
103 $view_frame = "ilContObj".$this->content_object->getID();
104 }
105 $page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId().
106 "_".$_GET["ref_id"],
107 $view_frame);
108
109 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
111 $this->content_object->getStyleSheetId(), "lm"));
112 $page_gui->setTemplateTargetVar("ADM_CONTENT");
113 $page_gui->getPageObject()->buildDom();
114 $int_links = $page_gui->getPageObject()->getInternalLinks();
115 $link_xml = $this->getLinkXML($int_links);
116 $page_gui->setLinkXML($link_xml);
117
118 $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
119 $page_gui->setFileDownloadLink("ilias.php?cmd=downloadFile&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
120 $page_gui->setFullscreenLink("ilias.php?cmd=fullscreen&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
121 $page_gui->setLinkParams("ref_id=".$this->content_object->getRefId());
122 $page_gui->setSourcecodeDownloadScript("ilias.php?ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
123 $page_gui->setPresentationTitle(
124 ilLMPageObject::_getPresentationTitle($this->obj->getId(),
125 $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
126 $page_gui->setLocator($contObjLocator);
127 $page_gui->setHeader($this->lng->txt("page").": ".$this->obj->getTitle());
128 $page_gui->setActivationListener($this, "activatePage");
129
130 $up_gui = "ilobjlearningmodulegui";
131 $ilCtrl->setParameterByClass($up_gui, "active_node", $this->obj->getId());
132
133 $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg.svg"));
134 $tpl->setTitle($this->lng->txt("page").": ".$this->obj->getTitle());
135 if ($this->content_object->getLayoutPerPage())
136 {
137 $page_gui->setTabHook($this, "addPageTabs");
138 }
139 $ret = $this->ctrl->forwardCommand($page_gui);
140 $tpl->setContent($ret);
141 break;
142
143 default:
144 $ret = $this->$cmd();
145 break;
146 }
147 }
148
149
150 /*
151 * display content of page (edit view)
152 */
153 function edit()
154 {
155//echo "<br>umschuss";
156 $this->ctrl->setCmdClass("ilLMPageGUI");
157 $this->ctrl->setCmd("edit");
158 $this->executeCommand();
159 //$this->setTabs();
160 }
161
162 /*
163 * display content of page (edit view)
164 */
165 function preview()
166 {
167 $this->ctrl->setCmdClass("ilLMPageGUI");
168 $this->ctrl->setCmd("preview");
169 $this->executeCommand();
170// $this->setTabs();
171 }
172
176 function save()
177 {
178 $this->obj = new ilLMPageObject($this->content_object);
179 $this->obj->setType("pg");
180 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
181 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
182 $this->obj->setLMId($this->content_object->getId());
183 $this->obj->create();
184
185 // obj_id is empty, if page is created from "all pages" screen
186 // -> a free page is created (not in the tree)
187//echo "<br>savePage:".$_GET["obj_id"].":";
188 if ($_GET["obj_id"] != 0)
189 {
190 $this->putInTree();
191
192 // check the tree
193 $this->checkTree();
194
195 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
196 "edit", "", true));
197 }
198 $up_gui = "ilobjlearningmodulegui";
199 $this->ctrl->redirectByClass($up_gui, "pages");
200 }
201
205 function cancel()
206 {
207 if ($_GET["obj_id"] != 0)
208 {
209 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
210 "view", "", true));
211 }
212 $up_gui = "ilobjlearningmodulegui";
213 $this->ctrl->redirectByClass($up_gui, "pages");
214 }
215
219 function getLinkXML($a_int_links)
220 {
221 if ($a_layoutframes == "")
222 {
223 $a_layoutframes = array();
224 }
225 $link_info = "<IntLinkInfos>";
226 foreach ($a_int_links as $int_link)
227 {
228 $target = $int_link["Target"];
229 if (substr($target, 0, 4) == "il__")
230 {
231 $target_arr = explode("_", $target);
232 $target_id = $target_arr[count($target_arr) - 1];
233 $type = $int_link["Type"];
234 $targetframe = ($int_link["TargetFrame"] != "")
235 ? $int_link["TargetFrame"]
236 : "None";
237
238 // anchor
239 $anc = $anc_add = "";
240 if ($int_link["Anchor"] != "")
241 {
242 $anc = $int_link["Anchor"];
243 $anc_add = "_".rawurlencode($int_link["Anchor"]);
244 }
245
246 switch($type)
247 {
248 case "PageObject":
249 case "StructureObject":
251 $cont_obj = $this->content_object;
252 if ($lm_id == $cont_obj->getId())
253 {
254 $ltarget = "";
255 if ($type == "PageObject")
256 {
257 $this->ctrl->setParameter($this, "obj_id", $target_id);
258 $href = $this->ctrl->getLinkTargetByClass(get_class($this), "edit");
259 }
260 else
261 {
262 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $target_id);
263 $href = $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view");
264 }
265 $href = str_replace("&", "&amp;", $href);
266 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
267 }
268 else
269 {
270 if ($type == "PageObject")
271 {
272 $href = "goto.php?target=pg_".$target_id.$anc_add;
273 }
274 else
275 {
276 $href = "goto.php?target=st_".$target_id;
277 }
278 $ltarget = "ilContObj".$lm_id;
279 }
280 if ($lm_id == "")
281 {
282 $href = "";
283 }
284 break;
285
286 case "GlossaryItem":
287 $ltarget = $nframe = "_blank";
288 $href = "ilias.php?cmdClass=illmpresentationgui&amp;baseClass=ilLMPresentationGUI&amp;".
289 "obj_type=$type&amp;cmd=glossary&amp;ref_id=".$_GET["ref_id"].
290 "&amp;obj_id=".$target_id."&amp;frame=$nframe";
291 break;
292
293 case "MediaObject":
294 $ltarget = $nframe = "_blank";
295 $href = "ilias.php?cmdClass=illmpresentationgui&amp;baseClass=ilLMPresentationGUI&amp;obj_type=$type&amp;cmd=media&amp;ref_id=".$_GET["ref_id"].
296 "&amp;mob_id=".$target_id."&amp;frame=$nframe";
297 break;
298
299 case "RepositoryItem":
300 $obj_type = ilObject::_lookupType($target_id, true);
302 $href = "./goto.php?target=".$obj_type."_".$target_id;
303 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
304 $ltarget = $t_frame;
305 break;
306
307 case "File":
308 $this->ctrl->setParameter($this, "file_id", "il__file_".$target_id);
309 $href = $this->ctrl->getLinkTarget($this, "downloadFile");
310 $this->ctrl->setParameter($this, "file_id", "");
311 break;
312
313 }
314
315 if ($href != "")
316 {
317 $anc_par = 'Anchor="' . $anc . '"';
318 $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " .
319 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" $anc_par/>";
320 }
321 }
322 }
323 $link_info.= "</IntLinkInfos>";
324//echo ":".htmlentities($link_info).":";
325 return $link_info;
326 }
327
331 function updateHistory()
332 {
333 require_once("./Services/History/classes/class.ilHistory.php");
334 ilHistory::_createEntry($this->obj->getId(), "update",
335 "", $this->content_object->getType().":pg",
336 "", true);
337 }
338
344 public static function _goto($a_target)
345 {
346 global $rbacsystem, $ilErr, $lng, $ilAccess;
347
348 $first = strpos($a_target, "_");
349 $second = strpos($a_target, "_", $first + 1);
350 $page_id = substr($a_target, 0, $first);
351 if ($first > 0)
352 {
353 $page_id = substr($a_target, 0, $first);
354 if ($second > 0)
355 {
356 $ref_id = substr($a_target, $first + 1, $second - ($first + 1));
357 $anchor = substr($a_target, $second + 1);
358 }
359 else
360 {
361 $ref_id = substr($a_target, $first + 1);
362 }
363 }
364 else
365 {
366 $page_id = $a_target;
367 }
368
369 // determine learning object
370 $lm_id = ilLMObject::_lookupContObjID($page_id);
371
372 // get all references
373 $ref_ids = ilObject::_getAllReferences($lm_id);
374
375 // always try passed ref id first
376 if (in_array($ref_id, $ref_ids))
377 {
378 $ref_ids = array_merge(array($ref_id), $ref_ids);
379 }
380
381 // check read permissions
382 foreach ($ref_ids as $ref_id)
383 {
384 // check read permissions
385 if ($ilAccess->checkAccess("read", "", $ref_id))
386 {
387 // don't redirect anymore, just set parameters
388 // (goto.php includes "ilias.php")
389 $_GET["baseClass"] = "ilLMPresentationGUI";
390 $_GET["obj_id"] = $page_id;
391 $_GET["ref_id"] = $ref_id;
392 $_GET["anchor"] = $anchor;
393 include_once("ilias.php");
394 exit;
395 }
396 }
397
398 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
399 {
400 if ($lm_id > 0)
401 {
402 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
403 ilObject::_lookupTitle($lm_id)), true);
404 }
405 else
406 {
407 $lng->loadLanguageModule("content");
408 ilUtil::sendFailure($lng->txt("page_does_not_exist"), true);
409 }
410 include_once("./Services/Object/classes/class.ilObjectGUI.php");
412 }
413
414 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
415 }
416
420 function editLayout()
421 {
422 global $tpl, $ilCtrl, $ilTabs;
423
424 $page_gui = new ilLMPageGUI($this->obj->getId());
425 $page_gui->setEditPreview(true);
426 $page_gui->activateMetaDataEditor($this->content_object,
427 $this->obj->getType(), $this->obj->getId(),
428 $this->obj, "MDUpdateListener");
429 $page_gui->setActivationListener($this, "activatePage");
430 $page_gui->setTabHook($this, "addPageTabs");
431 $lm_set = new ilSetting("lm");
432 $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg.svg"));
433 $tpl->setTitle($this->lng->txt("page").": ".$this->obj->getTitle());
434 $ilCtrl->getHTML($page_gui);
435 $ilTabs->setTabActive("cont_layout");
436 $this->initEditLayoutForm();
437 $tpl->setContent($this->form->getHTML());
438 }
439
445 public function initEditLayoutForm()
446 {
447 global $lng, $ilCtrl;
448
449 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
450 $this->form = new ilPropertyFormGUI();
451
452 // default layout
453 $layout = new ilRadioGroupInputGUI($lng->txt("cont_layout"), "layout");
454
455 if (is_file($im = ilUtil::getImagePath("layout_".$this->content_object->getLayout().".png")))
456 {
457 $im_tag = ilUtil::img($im, $this->content_object->getLayout());
458 }
459 $layout->addOption(new ilRadioOption("<table><tr><td>".$im_tag."</td><td><b>".
460 $lng->txt("cont_lm_default_layout").
461 "</b>: ".$lng->txt("cont_layout_".$this->content_object->getLayout()).
462 "</td></tr></table>", ""));
463
465 {
466 $im_tag = "";
467 if (is_file($im = ilUtil::getImagePath("layout_".$l.".png")))
468 {
469 $im_tag = ilUtil::img($im, $l);
470 }
471 $layout->addOption(new ilRadioOption("<table><tr><td>".$im_tag."</td><td><b>".
472 $lng->txt("cont_layout_".$l)."</b>: ".$lng->txt("cont_layout_".$l."_desc").
473 "</td></tr></table>", $l));
474 }
475
476 $layout->setValue($this->obj->getLayout());
477 $this->form->addItem($layout);
478
479 $this->form->addCommandButton("saveLayout", $lng->txt("save"));
480
481 $this->form->setTitle($lng->txt("cont_page_layout"));
482 $this->form->setFormAction($ilCtrl->getFormAction($this));
483
484 }
485
490 public function saveLayout()
491 {
492 global $tpl, $lng, $ilCtrl;
493
494 $this->initEditLayoutForm();
495 if ($this->form->checkInput())
496 {
497 ilLMObject::writeLayout($this->obj->getId(), $this->form->getInput("layout"));
498 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
499 $ilCtrl->redirect($this, "editLayout");
500 }
501 $this->form->setValuesByPost();
502 $tpl->setContent($this->form->getHtml());
503 }
504
508 function addPageTabs()
509 {
510 global $ilTabs, $ilCtrl;
511
512 $ilTabs->addTarget("cont_layout",
513 $ilCtrl->getLinkTarget($this, 'editLayout'), "editLayout");
514 }
515
519 function downloadFile()
520 {
521 $pg_obj = $this->obj->getPageObject();
522 $pg_obj->buildDom();
523 $int_links = $pg_obj->getInternalLinks();
524 foreach ($int_links as $il)
525 {
526 if ($il["Target"] == str_replace("_file_", "_dfile_", $_GET["file_id"]))
527 {
528 $file = explode("_", $_GET["file_id"]);
529 $file_id = (int) $file[count($file) - 1];
530 require_once("./Modules/File/classes/class.ilObjFile.php");
531 $fileObj = new ilObjFile($file_id, false);
532 $fileObj->sendFile();
533 exit;
534 }
535 }
536 }
537
538}
539?>
sprintf('%.4f', $callTime)
global $l
Definition: afr.php:30
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _getFrame($a_class, $a_type='')
Get content frame name.
static _createEntry($a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
Class ilLMObject.
putInTree()
put this object into content object tree
checkTree()
check the content object tree
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static writeLayout($a_obj_id, $a_layout, $a_lm=null)
Write layout setting.
Extension of ilPageObjectGUI for learning modules.
Class ilLMPageObjectGUI.
__construct(&$a_content_obj)
Constructor.
editLayout()
Edit layout of page.
initEditLayoutForm()
Init edit layout form.
setLMPageObject($a_pg_obj)
Set content object dependent page object (co page)
downloadFile()
download file of file lists
executeCommand()
execute command
save()
save co page object
static _goto($a_target)
redirect script
getLinkXML($a_int_links)
get link targets
Class ilLMPageObject.
static _getPresentationTitle($a_pg_id, $a_mode=IL_CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-")
presentation title doesn't have to be page title, it may be chapter title + page title or chapter tit...
static getAvailableLayouts()
get all available lm layouts
Class ilObjFile.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$target_id
Definition: goto.php:51
$target_arr
Definition: goto.php:49
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
$lm_set