ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 $focus_id = null;
22 
26  public function __construct(
27  ilObjUser $user,
29  ilLMTree $lm_tree,
30  string $requested_transl = "",
31  string $requested_focus_id = "",
32  string $requested_focus_return = "",
33  string $requested_search_string = "",
34  string $offline,
35  bool $export_all_languages,
36  string $export_format
37  ) {
38  $this->lm = $lm;
39  $this->ot = ilObjectTranslation::getInstance($lm->getId());
40  $this->requested_transl = (string) $requested_transl;
41  $this->requested_focus_id = $requested_focus_id;
42  $this->requested_focus_return = $requested_focus_return;
43  $this->requested_search_string = $requested_search_string;
44  $this->user = $user;
45  $this->lm_tree = $lm_tree;
46  $this->offline = $offline;
47  $this->export_all_languages = $export_all_languages;
48  $this->export_format = $export_format;
49  $this->init();
50  }
51 
55  protected function init()
56  {
57  // determine language
58  $this->lang = "-";
59  if ($this->ot->getContentActivated()) {
60  $langs = $this->ot->getLanguages();
61  if (isset($langs[$this->requested_transl]) || $this->requested_transl == $this->ot->getMasterLanguage()) {
62  $this->lang = $this->requested_transl;
63  } elseif (isset($langs[$this->user->getCurrentLanguage()])) {
64  $this->lang = $this->user->getCurrentLanguage();
65  }
66  if ($this->lang == $this->ot->getMasterLanguage()) {
67  $this->lang = "-";
68  }
69  }
70 
71  // determin focus id
72  if ($this->requested_focus_id > 0 && $this->lm_tree->isInTree($this->requested_focus_id)) {
73  $this->focus_id = $this->requested_focus_id;
74  }
75  }
76 
82  public function getLang() : string
83  {
84  return $this->lang;
85  }
86 
90  public function getFocusId()
91  {
92  return $this->focus_id;
93  }
94 
98  public function getFocusReturn()
99  {
100  return $this->requested_focus_return;
101  }
102 
106  public function getSearchString()
107  {
108  return $this->requested_search_string;
109  }
110 
114  public function offline() : bool
115  {
116  return $this->offline;
117  }
118 
122  public function exportAllLanguages() : bool
123  {
124  return $this->export_all_languages;
125  }
126 
130  public function getExportFormat() : bool
131  {
132  return $this->export_format;
133  }
134 
140  public function getLMPresentationTitle()
141  {
142  if ($this->offline() && $this->lang != "" && $this->lang != "-") {
143  $ot = $this->ot;
144  $data = $ot->getLanguages();
145  $ltitle = $data[$this->lang]["title"];
146  if ($ltitle != "") {
147  return $ltitle;
148  }
149  }
150  return $this->lm->getTitle();
151  }
152 
158  public function isTocNecessary() : bool
159  {
160  $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
161  if (count($childs) == 0) { // no chapter -> false
162  return false;
163  }
164  if (count($childs) > 1) { // more than one chapter -> true
165  return true;
166  }
167  if ($this->lm->getTOCMode() != "pages") { // one chapter TOC does not show pages -> false
168  return false;
169  }
170  $current_chapter = current($childs);
171  $childs = $this->lm_tree->getChilds($current_chapter["child"]);
172  if (count($childs) > 1) {
173  return true; // more than one page -> true
174  }
175  return false; // zero or one page -> false
176  }
177 
178 }
Class ilObjLearningModule.
__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)
Constructor.
getLMPresentationTitle()
Get lm presentationtitle.
$data
Definition: storeScorm.php:23
Contains info on offline mode, focus, translation, etc.
isTocNecessary()
Is TOC necessary, see #30027 Check if at least two entries will be shown.
user()
Definition: user.php:4
getId()
get object id public
static getInstance($a_obj_id)
Get instance.