ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMPresentationStatus.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $lang;
17
21 protected $concrete_lang;
22
26 protected $focus_id = null;
27
31 public function __construct(
32 ilObjUser $user,
34 ilLMTree $lm_tree,
35 string $requested_transl = "",
36 string $requested_focus_id = "",
37 string $requested_focus_return = "",
38 string $requested_search_string = "",
39 string $offline,
40 bool $export_all_languages,
41 string $export_format,
42 bool $embed_mode = false
43 ) {
44 $this->lm = $lm;
45 $this->ot = ilObjectTranslation::getInstance($lm->getId());
46 $this->requested_transl = (string) $requested_transl;
47 $this->requested_focus_id = $requested_focus_id;
48 $this->requested_focus_return = $requested_focus_return;
49 $this->requested_search_string = $requested_search_string;
50 $this->user = $user;
51 $this->lm_tree = $lm_tree;
52 $this->offline = $offline;
53 $this->export_all_languages = $export_all_languages;
54 $this->export_format = $export_format;
55 $this->embed_mode = $embed_mode;
56 $this->init();
57 }
58
62 protected function init()
63 {
64 // determine language
65 $this->lang = "-";
66 $this->concrete_lang = "-";
67 if ($this->ot->getContentActivated()) {
68 $langs = $this->ot->getLanguages();
69 if (isset($langs[$this->requested_transl]) || $this->requested_transl == $this->ot->getMasterLanguage()) {
70 $this->lang = $this->requested_transl;
71 } else {
72 $this->lang = $this->user->getCurrentLanguage();
73 }
74 $this->concrete_lang = $this->lang;
75 if ($this->lang == $this->ot->getMasterLanguage()) {
76 $this->lang = "-";
77 }
78 }
79
80 // determin focus id
81 if ($this->requested_focus_id > 0 && $this->lm_tree->isInTree($this->requested_focus_id)) {
82 $this->focus_id = $this->requested_focus_id;
83 }
84 }
85
91 public function getLang() : string
92 {
93 return $this->lang;
94 }
95
100 public function getConcreteLang() : string
101 {
103 }
104
108 public function getFocusId()
109 {
110 return $this->focus_id;
111 }
112
116 public function getFocusReturn()
117 {
118 return $this->requested_focus_return;
119 }
120
124 public function getSearchString()
125 {
126 return $this->requested_search_string;
127 }
128
132 public function offline() : bool
133 {
134 return $this->offline;
135 }
136
137 public function getEmbedMode() : bool
138 {
139 return $this->embed_mode;
140 }
141
145 public function exportAllLanguages() : bool
146 {
147 return $this->export_all_languages;
148 }
149
153 public function getExportFormat() : bool
154 {
155 return $this->export_format;
156 }
157
163 public function getLMPresentationTitle()
164 {
165 if ($this->offline() && $this->lang != "" && $this->lang != "-") {
166 $ot = $this->ot;
167 $data = $ot->getLanguages();
168 $ltitle = $data[$this->lang]["title"];
169 if ($ltitle != "") {
170 return $ltitle;
171 }
172 $ltitle = $data[$ot->getFallbackLanguage()]["title"];
173 if ($ltitle != "") {
174 return $ltitle;
175 }
176 }
177 return $this->lm->getTitle();
178 }
179
185 public function isTocNecessary() : bool
186 {
187 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
188 if (count($childs) == 0) { // no chapter -> false
189 return false;
190 }
191 if (count($childs) > 1) { // more than one chapter -> true
192 return true;
193 }
194 if ($this->lm->getTOCMode() != "pages") { // one chapter TOC does not show pages -> false
195 return false;
196 }
197 $current_chapter = current($childs);
198 $childs = $this->lm_tree->getChilds($current_chapter["child"]);
199 if (count($childs) > 1) {
200 return true; // more than one page -> true
201 }
202 return false; // zero or one page -> false
203 }
204}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Contains info on offline mode, focus, translation, etc.
isTocNecessary()
Is TOC necessary, see #30027 Check if at least two entries will be shown.
getLMPresentationTitle()
Get lm presentationtitle.
__construct(ilObjUser $user, ilObjLearningModule $lm, ilLMTree $lm_tree, string $requested_transl="", string $requested_focus_id="", string $requested_focus_return="", string $requested_search_string="", string $offline, bool $export_all_languages, string $export_format, bool $embed_mode=false)
Constructor.
getConcreteLang()
Only difference to getLang(): if current language is the master lang the language key will be returne...
Class ilObjLearningModule.
static getInstance($a_obj_id)
Get instance.
getId()
get object id @access public
$data
Definition: storeScorm.php:23