ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilLMPresentationLinker Class Reference

Learning module presentation linker. More...

+ Inheritance diagram for ilLMPresentationLinker:
+ Collaboration diagram for ilLMPresentationLinker:

Public Member Functions

 __construct (ilObjLearningModule $lm, ilLMTree $lm_tree, int $current_page, int $ref_id, string $lang, string $back_pg, string $from_pg, bool $offline, string $export_format, bool $export_all_languages, ?ilCtrl $ctrl=null, bool $embed_mode=false, string $frame="", int $obj_id=0)
 
 setOffline (bool $offline=true)
 
 setProfileBackUrl (string $url)
 
 getLink (string $a_cmd="", int $a_obj_id=0, string $a_frame="", string $a_type="", string $a_back_link="append", string $a_anchor="", string $a_srcstring="")
 handles links for learning module presentation More...
 
 getLayoutLinkTargets ()
 
 getLinkTargetsXML ()
 Get XMl for Link Targets. More...
 
 getLinkXML (array $int_links)
 get xml for links More...
 
 getFullscreenLink ()
 
 setOffline (bool $offline=true)
 
 getLayoutLinkTargets ()
 
 setProfileBackUrl (string $url)
 
 getLinkXML (array $int_links)
 
 getFullscreenLink ()
 

Data Fields

const TARGET_GUI = "illmpresentationgui"
 

Protected Attributes

int $obj_id
 
string $frame
 
int $requested_ref_id
 
string $profile_back_url = ""
 
bool $offline
 
bool $embed_mode
 
ilCtrl $ctrl
 
ilLMTree $lm_tree
 
ilObjLearningModule $lm
 
int $current_page
 
string $back_pg
 
string $from_page
 
bool $export_all_languages
 
string $lang
 
string $export_format
 
ILIAS StaticURL Services $static_url
 

Detailed Description

Learning module presentation linker.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.ilLMPresentationLinker.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMPresentationLinker::__construct ( ilObjLearningModule  $lm,
ilLMTree  $lm_tree,
int  $current_page,
int  $ref_id,
string  $lang,
string  $back_pg,
string  $from_pg,
bool  $offline,
string  $export_format,
bool  $export_all_languages,
?ilCtrl  $ctrl = null,
bool  $embed_mode = false,
string  $frame = "",
int  $obj_id = 0 
)

Definition at line 46 of file class.ilLMPresentationLinker.php.

61 {
62 global $DIC;
63
64 $this->ctrl = is_null($ctrl)
65 ? $DIC->ctrl()
66 : $ctrl;
67
68 $this->lm_tree = $lm_tree;
69 $this->lm = $lm;
70 $this->current_page = $current_page;
71 $this->back_pg = $back_pg;
72 $this->from_page = $from_pg;
73 $this->export_all_languages = $export_all_languages;
74 $this->lang = $lang;
75 $this->requested_ref_id = $ref_id;
76 $this->offline = $offline;
77 $this->export_format = $export_format;
78 $this->embed_mode = $embed_mode;
79 $this->frame = $frame;
80 $this->obj_id = $obj_id;
81 $this->static_url = $DIC["static_url"];
82 }
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26

References $back_pg, $ctrl, $current_page, $DIC, $embed_mode, $export_all_languages, $export_format, $frame, $lang, $lm, $lm_tree, $obj_id, $offline, $ref_id, and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

Member Function Documentation

◆ getFullscreenLink()

ilLMPresentationLinker::getFullscreenLink ( )

Implements ILIAS\COPage\PageLinker.

Definition at line 541 of file class.ilLMPresentationLinker.php.

541 : string
542 {
543 return $this->getLink("fullscreen");
544 }
getLink(string $a_cmd="", int $a_obj_id=0, string $a_frame="", string $a_type="", string $a_back_link="append", string $a_anchor="", string $a_srcstring="")
handles links for learning module presentation

◆ getLayoutLinkTargets()

ilLMPresentationLinker::getLayoutLinkTargets ( )

Implements ILIAS\COPage\PageLinker.

Definition at line 282 of file class.ilLMPresentationLinker.php.

282 : array
283 {
284 $targets = [
285 "New" => [
286 "Type" => "New",
287 "Frame" => "_blank",
288 "OnClick" => ""],
289 "FAQ" => [
290 "Type" => "FAQ",
291 "Frame" => "faq",
292 "OnClick" => "return il.LearningModule.showContentFrame(event, 'faq');"],
293 "Glossary" => [
294 "Type" => "Glossary",
295 "OnClick" => "return il.LearningModule.showContentFrame(event, 'glossary');"],
296 "Media" => [
297 "Type" => "Media",
298 "Frame" => "media",
299 "OnClick" => "return il.LearningModule.showContentFrame(event, 'media');"]
300 ];
301
302 return $targets;
303 }

◆ getLink()

ilLMPresentationLinker::getLink ( string  $a_cmd = "",
int  $a_obj_id = 0,
string  $a_frame = "",
string  $a_type = "",
string  $a_back_link = "append",
string  $a_anchor = "",
string  $a_srcstring = "" 
)

handles links for learning module presentation

Definition at line 98 of file class.ilLMPresentationLinker.php.

106 : string {
107 if ($a_cmd == "") {
108 $a_cmd = "layout";
109 }
110
111 $link = "";
112
113 // handling of free pages
114 $cur_page_id = $this->current_page;
116 if ($a_obj_id !== 0 && !$this->lm_tree->isInTree($a_obj_id) && $cur_page_id !== 0 &&
117 $a_back_link == "append") {
118 if ($back_pg != "") {
119 $back_pg = $cur_page_id . ":" . $back_pg;
120 } else {
121 $back_pg = $cur_page_id;
122 }
123 } else {
124 if ($a_back_link == "reduce") {
125 $limpos = strpos($this->back_pg, ":");
126
127 if ($limpos > 0) {
128 $back_pg = substr($back_pg, strpos($back_pg, ":") + 1);
129 } else {
130 $back_pg = "";
131 }
132 } elseif ($a_back_link != "keep") {
133 $back_pg = "";
134 }
135 }
136
137 // handle kiosk mode links
138 if ($this->embed_mode && in_array($a_cmd, ["downloadFile", "download_paragraph", "fullscreen"])) {
139 $this->ctrl->setParameterByClass(\ilLMPresentationGUI::class, "ref_id", $this->lm->getRefId());
140 $base = $this->ctrl->getLinkTargetByClass([
141 \ilLMPresentationGUI::class, \ilLMPageGUI::class
142 ]);
143 switch ($a_cmd) {
144 case "downloadFile":
145 return $base . "&cmd=downloadFile";
146 case "download_paragraph":
147 return $base . "&cmd=download_paragraph";
148 case "fullscreen":
149 return $base . "&cmd=displayMediaFullscreen";
150 }
151 return "";
152 // handle online links
153 } elseif (!$this->offline) {
154 if ($this->from_page == "") {
155 // added if due to #23216 (from page has been set in lots of usual navigation links)
156 if (!in_array($a_frame, array("", "_blank"))) {
157 $this->ctrl->setParameterByClass(self::TARGET_GUI, "from_page", $cur_page_id);
158 }
159 } else {
160 // faq link on page (in faq frame) includes faq link on other page
161 // if added due to bug #11007
162 if (!in_array($a_frame, array("", "_blank"))) {
163 $this->ctrl->setParameterByClass(self::TARGET_GUI, "from_page", $this->from_page);
164 }
165 }
166
167 if ($a_anchor != "") {
168 $this->ctrl->setParameterByClass(self::TARGET_GUI, "anchor", rawurlencode($a_anchor));
169 }
170 if ($a_srcstring != "") {
171 $this->ctrl->setParameterByClass(self::TARGET_GUI, "srcstring", $a_srcstring);
172 }
173 $this->ctrl->setParameterByClass(self::TARGET_GUI, "ref_id", $this->lm->getRefId());
174 switch ($a_cmd) {
175 case "fullscreen":
176 $link = $this->ctrl->getLinkTargetByClass(self::TARGET_GUI, "fullscreen", "", false, false);
177 break;
178
179 case "sourcecodeDownload":
180 case "download_paragraph":
181 $this->ctrl->setParameterByClass(self::TARGET_GUI, "obj_id", $this->current_page);
182 $link = $this->ctrl->getLinkTargetByClass([self::TARGET_GUI, "ilLMPageGUI"], "", "", false, false);
183 break;
184
185 default:
186 $link = "";
187 if ($back_pg != "") {
188 $this->ctrl->setParameterByClass(self::TARGET_GUI, "back_pg", $back_pg);
189 }
190 if ($a_frame != "") {
191 $this->ctrl->setParameterByClass(self::TARGET_GUI, "frame", $a_frame);
192 }
193 if ($a_obj_id > 0) {
194 switch ($a_type) {
195 case "MediaObject":
196 $this->ctrl->setParameterByClass(self::TARGET_GUI, "mob_id", $a_obj_id);
197 break;
198
199 default:
200 $this->ctrl->setParameterByClass(self::TARGET_GUI, "obj_id", $a_obj_id);
201 $link .= "&obj_id=" . $a_obj_id;
202 break;
203 }
204 }
205 if ($a_type != "") {
206 $this->ctrl->setParameterByClass(self::TARGET_GUI, "obj_type", $a_type);
207 }
208 if ($a_anchor !== "") {
209 $a_anchor = "copganc_" . $a_anchor;
210 }
211 $link = $this->ctrl->getLinkTargetByClass(
212 self::TARGET_GUI,
213 $a_cmd,
214 $a_anchor,
215 false,
216 true
217 );
218 // $link = str_replace("&", "&", $link);
219
220 $this->ctrl->setParameterByClass(self::TARGET_GUI, "frame", null);
221 $this->ctrl->setParameterByClass(self::TARGET_GUI, "obj_id", null);
222 $this->ctrl->setParameterByClass(self::TARGET_GUI, "mob_id", null);
223 break;
224 }
225 } else { // handle offline links
226 $lang_suffix = "";
227 if ($this->export_all_languages) {
228 if ($this->lang != "" && $this->lang != "-") {
229 $lang_suffix = "_" . $this->lang;
230 }
231 }
232
233 switch ($a_cmd) {
234 case "fullscreen":
235 $link = "fullscreen.html"; // id is handled by xslt
236 break;
237
238 case "layout":
239
240 if ($a_obj_id === 0) {
241 $a_obj_id = $this->lm_tree->getRootId();
242 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
243 $a_obj_id = $pg_node["obj_id"];
244 }
245 if ($a_type == "StructureObject") {
246 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
247 $a_obj_id = $pg_node["obj_id"];
248 }
249 if ($a_frame != "" && $a_frame != "_blank") {
250 if ($a_frame != "toc") {
251 $link = "frame_" . $a_obj_id . "_" . $a_frame . $lang_suffix . ".html";
252 } else { // don't save multiple toc frames (all the same)
253 $link = "frame_" . $a_frame . $lang_suffix . ".html";
254 }
255 } else {
256 //if ($nid = ilLMObject::_lookupNID($this->lm->getId(), $a_obj_id, "pg"))
257 if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_obj_id)) {
258 $link = "lm_pg_" . $nid . $lang_suffix . ".html";
259 } else {
260 $link = "lm_pg_" . $a_obj_id . $lang_suffix . ".html";
261 }
262 }
263 break;
264
265 case "glossary":
266 $link = "term_" . $a_obj_id . ".html";
267 break;
268
269 case "media":
270 $link = "media_" . $a_obj_id . ".html";
271 break;
272
273 case "downloadFile":
274 default:
275 break;
276 }
277 }
278 $this->ctrl->clearParametersByClass(self::TARGET_GUI);
279 return $link;
280 }
static getExportId(int $a_lm_id, int $a_lmobj_id, string $a_type="pg")

◆ getLinkTargetsXML()

ilLMPresentationLinker::getLinkTargetsXML ( )

Get XMl for Link Targets.

Definition at line 308 of file class.ilLMPresentationLinker.php.

308 : string
309 {
310 $link_info = "<LinkTargets>";
311 foreach ($this->getLayoutLinkTargets() as $k => $t) {
312 $link_info .= "<LinkTarget TargetFrame=\"" . $t["Type"] . "\" LinkTarget=\"" . ($t["Frame"] ?? "") . "\" OnClick=\"" . $t["OnClick"] . "\" />";
313 }
314 $link_info .= "</LinkTargets>";
315 return $link_info;
316 }

◆ getLinkXML()

ilLMPresentationLinker::getLinkXML ( array  $int_links)

get xml for links

Implements ILIAS\COPage\PageLinker.

Definition at line 321 of file class.ilLMPresentationLinker.php.

323 : string {
324 $ilCtrl = $this->ctrl;
325 $a_layoutframes = $this->getLayoutLinkTargets();
326
327 // Determine whether the view of a learning resource should
328 // be shown in the frameset of ilias, or in a separate window.
329 $showViewInFrameset = true;
330
331 if ($a_layoutframes == "") {
332 $a_layoutframes = array();
333 }
334 $link_info = "<IntLinkInfos>";
335 foreach ($int_links as $int_link) {
336 $back = "";
337 $href = "";
338 $ltarget = "";
339 $target = $int_link["Target"];
340 if (substr($target, 0, 4) == "il__") {
341 $target_arr = explode("_", $target);
342 $target_id = $target_arr[count($target_arr) - 1];
343 $type = $int_link["Type"];
344 $targetframe = ($int_link["TargetFrame"] != "")
345 ? $int_link["TargetFrame"]
346 : "None";
347
348 // anchor
349 $anc = $anc_add = "";
350 if (($int_link["Anchor"] ?? "") != "") {
351 $anc = $int_link["Anchor"];
352 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
353 }
354 $lcontent = "";
355 switch ($type) {
356 case "PageObject":
357 case "StructureObject":
358 $lm_id = ilLMObject::_lookupContObjID($target_id);
359 if ($lm_id == $this->lm->getId() ||
360 ($targetframe != "None" && $targetframe != "New")) {
361 $ltarget = $a_layoutframes[$targetframe]["Frame"] ?? "";
362 $nframe = ($ltarget == "")
363 ? ""
364 : $ltarget;
365 if ($ltarget == "") {
366 $ltarget = "_parent";
367 }
368 $cmd = "layout";
369 // page command is for displaying in the slate
370 if ($nframe != "" && $nframe != "_blank") {
371 $cmd = "page";
372 }
373 $href =
374 $this->getLink(
375 $cmd,
376 $target_id,
377 $nframe,
378 $type,
379 "append",
380 $anc
381 );
382 if ($lm_id === 0) {
383 $href = "";
384 }
385 if ($this->embed_mode) {
386 $ltarget = "_blank";
387 }
388 } else {
389 if ($type == "PageObject") {
390 $href = (string) $this->static_url->builder()->build(
391 "pg",
392 null,
393 [$target_id]
394 ) . $anc_add;
395 } else {
396 $href = (string) $this->static_url->builder()->build(
397 "st",
398 null,
399 [$target_id]
400 ) . $anc_add;
401 }
402 $ltarget = "";
403 if ($targetframe == "New" || $this->embed_mode) {
404 $ltarget = "_blank";
405 }
406 }
407 break;
408
409 case "GlossaryItem":
410 if ($targetframe == "None") {
411 $targetframe = "Glossary";
412 }
413 $ltarget = $a_layoutframes[$targetframe]["Frame"] ?? "";
414 $nframe = ($ltarget == "")
415 ? $this->frame
416 : $ltarget;
417 $href = "";
418 if (ilGlossaryTerm::_exists((int) $target_id)) {
419 $href =
420 $this->getLink($a_cmd = "glossary", (int) $target_id, $nframe, $type);
421 }
422 break;
423
424 case "MediaObject":
425 $ltarget = $a_layoutframes[$targetframe]["Frame"] ?? "";
426 $nframe = ($ltarget == "")
427 ? $this->frame
428 : $ltarget;
429 $href =
430 $this->getLink($a_cmd = "media", $target_id, $nframe, $type);
431 if ($this->offline) {
432 $href = "media_" . $target_id . ".html";
433 } else {
434 $this->ctrl->setParameterByClass("illmpagegui", "ref_id", $this->lm->getRefId());
435 $this->ctrl->setParameterByClass("illmpagegui", "mob_id", $target_id);
436 $this->ctrl->setParameterByClass(self::TARGET_GUI, "obj_id", $this->current_page);
437 $href = $this->ctrl->getLinkTargetByClass(
438 "illmpagegui",
439 "displayMedia",
440 "",
441 false,
442 true
443 );
444 $this->ctrl->setParameterByClass("illmpagegui", "mob_id", "");
445 $ilCtrl->setParameterByClass(self::TARGET_GUI, "obj_id", $this->obj_id);
446 }
447 break;
448
449 case "RepositoryItem":
450 $obj_type = ilObject::_lookupType((int) $target_id, true);
451 if ((int) $target_id > 0) {
452 $href = (string) $this->static_url->builder()->build(
453 $obj_type,
454 new \ILIAS\Data\ReferenceId($target_id)
455 );
456 } else {
457 $href = "#";
458 }
459 if ($this->embed_mode) {
460 $ltarget = "_blank";
461 }
462 break;
463
464 case "WikiPage":
465 $wiki_anc = "";
466 if (($int_link["Anchor"] ?? "") != "") {
467 $wiki_anc = "#" . rawurlencode($int_link["Anchor"]);
468 }
469 $href = ilWikiPage::getGotoForWikiPageTarget($target_id) . $wiki_anc;
470 if ($this->embed_mode) {
471 $ltarget = "_blank";
472 }
473 break;
474
475 case "File":
476 if (!$this->offline) {
477 $ilCtrl->setParameterByClass(self::TARGET_GUI, "obj_id", $this->current_page);
478 $ilCtrl->setParameterByClass(self::TARGET_GUI, "file_id", "il__file_" . $target_id);
479 $href = $ilCtrl->getLinkTargetByClass(
480 self::TARGET_GUI,
481 "downloadFile",
482 "",
483 false,
484 true
485 );
486 $ilCtrl->setParameterByClass(self::TARGET_GUI, "file_id", "");
487 $ilCtrl->setParameterByClass(self::TARGET_GUI, "obj_id", $this->obj_id);
488 }
489 break;
490
491 case "User":
492 $obj_type = ilObject::_lookupType((int) $target_id);
493 if ($obj_type == "usr") {
494 if (!$this->embed_mode) {
495 $this->ctrl->setParameterByClass(self::TARGET_GUI, "obj_id", $this->current_page);
496 $back = $this->ctrl->getLinkTargetByClass(
497 self::TARGET_GUI,
498 "layout",
499 "",
500 false,
501 true
502 );
503 }
504 //var_dump($back); exit;
505 $this->ctrl->setParameterByClass(PublicProfileGUI::class, "user_id", $target_id);
506 $this->ctrl->setParameterByClass(
507 PublicProfileGUI::class,
508 "back_url",
509 rawurlencode($back)
510 );
511 $href = "";
512 if (ilUserUtil::hasPublicProfile($target_id)) {
513 $href = $this->ctrl->getLinkTargetByClass(
514 [ilPublicProfileBaseClassGUI::class, PublicProfileGUI::class],
515 "getHTML",
516 "",
517 false,
518 true
519 );
520 }
521 $this->ctrl->setParameterByClass(PublicProfileGUI::class, "user_id", "");
522 $lcontent = ilUserUtil::getNamePresentation($target_id, false, false);
523 }
524 break;
525 }
526
527 $anc_par = 'Anchor="' . $anc . '"';
528
529 if ($href != "") {
530 $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " .
531 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" LinkContent=\"$lcontent\" $anc_par/>";
532 }
533 }
534 }
535 $link_info .= "</IntLinkInfos>";
536
537 $link_info .= $this->getLinkTargetsXML();
538 return $link_info;
539 }
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
static _lookupContObjID(int $a_id)
get learning module id for lm object
getLinkTargetsXML()
Get XMl for Link Targets.
static _lookupType(int $id, bool $reference=false)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static hasPublicProfile(int $a_user_id)
static getGotoForWikiPageTarget(string $a_target, bool $a_offline=false)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ setOffline()

ilLMPresentationLinker::setOffline ( bool  $offline = true)

Implements ILIAS\COPage\PageLinker.

Definition at line 84 of file class.ilLMPresentationLinker.php.

86 : void {
87 $this->offline = $offline;
88 }

◆ setProfileBackUrl()

ilLMPresentationLinker::setProfileBackUrl ( string  $url)

Implements ILIAS\COPage\PageLinker.

Definition at line 90 of file class.ilLMPresentationLinker.php.

90 : void
91 {
92 $this->profile_back_url = $url;
93 }
$url
Definition: shib_logout.php:70

References $url.

Field Documentation

◆ $back_pg

string ilLMPresentationLinker::$back_pg
protected

Definition at line 39 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $ctrl

ilCtrl ilLMPresentationLinker::$ctrl
protected

Definition at line 35 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $current_page

int ilLMPresentationLinker::$current_page
protected

Definition at line 38 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $embed_mode

bool ilLMPresentationLinker::$embed_mode
protected

Definition at line 34 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $export_all_languages

bool ilLMPresentationLinker::$export_all_languages
protected

Definition at line 41 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $export_format

string ilLMPresentationLinker::$export_format
protected

Definition at line 43 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $frame

string ilLMPresentationLinker::$frame
protected

Definition at line 29 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $from_page

string ilLMPresentationLinker::$from_page
protected

Definition at line 40 of file class.ilLMPresentationLinker.php.

◆ $lang

string ilLMPresentationLinker::$lang
protected

Definition at line 42 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $lm

ilObjLearningModule ilLMPresentationLinker::$lm
protected

Definition at line 37 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $lm_tree

ilLMTree ilLMPresentationLinker::$lm_tree
protected

Definition at line 36 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $obj_id

int ilLMPresentationLinker::$obj_id
protected

Definition at line 28 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $offline

bool ilLMPresentationLinker::$offline
protected

Definition at line 33 of file class.ilLMPresentationLinker.php.

Referenced by __construct().

◆ $profile_back_url

string ilLMPresentationLinker::$profile_back_url = ""
protected

Definition at line 31 of file class.ilLMPresentationLinker.php.

◆ $requested_ref_id

int ilLMPresentationLinker::$requested_ref_id
protected

Definition at line 30 of file class.ilLMPresentationLinker.php.

◆ $static_url

ILIAS StaticURL Services ilLMPresentationLinker::$static_url
protected

Definition at line 44 of file class.ilLMPresentationLinker.php.

◆ TARGET_GUI

const ilLMPresentationLinker::TARGET_GUI = "illmpresentationgui"

Definition at line 27 of file class.ilLMPresentationLinker.php.


The documentation for this class was generated from the following file: