ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHelpGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once ("Services/Help/classes/class.ilHelp.php");
6 
13 class ilHelpGUI
14 {
15  var $help_sections = array();
16  const ID_PART_SCREEN = "screen";
17  const ID_PART_SUB_SCREEN = "sub_screen";
18  const ID_PART_COMPONENT = "component";
19  var $def_screen_id = array();
20  var $screen_id = array();
21 
25  function ilHelpGUI()
26  {
27  global $ilCtrl;
28 
29  $this->ctrl =& $ilCtrl;
30  }
31 
38  function setDefaultScreenId($a_part, $a_id)
39  {
40  $this->def_screen_id[$a_part] = $a_id;
41  }
42 
48  function setScreenId($a_id)
49  {
50  $this->screen_id[self::ID_PART_SCREEN] = $a_id;
51  }
52 
58  function setSubScreenId($a_id)
59  {
60  $this->screen_id[self::ID_PART_SUB_SCREEN] = $a_id;
61  }
62 
69  function setScreenIdComponent($a_comp)
70  {
71  $this->screen_id_component = $a_comp;
72  }
73 
74 
81  function getScreenId()
82  {
83  $comp = ($this->screen_id_component != "")
84  ? $this->screen_id_component
85  : $this->def_screen_id[self::ID_PART_COMPONENT];
86 
87  if ($comp == "")
88  {
89  return "";
90  }
91 
92  $scr_id = ($this->screen_id[self::ID_PART_SCREEN] != "")
93  ? $this->screen_id[self::ID_PART_SCREEN]
94  : $this->def_screen_id[self::ID_PART_SCREEN];
95 
96  $sub_scr_id = ($this->screen_id[self::ID_PART_SUB_SCREEN] != "")
97  ? $this->screen_id[self::ID_PART_SUB_SCREEN]
98  : $this->def_screen_id[self::ID_PART_SUB_SCREEN];
99 
100  $screen_id = $comp."/".
101  $scr_id."/".
102  $sub_scr_id;
103 
104  return $screen_id;
105  }
106 
107 
114  function addHelpSection($a_help_id, $a_level = 1)
115  {
116  $this->help_sections[] = array("help_id" => $a_help_id, $a_level);
117  }
118 
125  function hasSections()
126  {
127  global $ilSetting;
128 
129  include_once("./Services/Help/classes/class.ilHelpMapping.php");
131  }
132 
139  function getHelpSections()
140  {
141  include_once("./Services/Help/classes/class.ilHelpMapping.php");
142  return ilHelpMapping::getHelpSectionsForId($this->getScreenId(), (int) $_GET["ref_id"]);
143  }
144 
151  function setCtrlPar()
152  {
153  global $ilCtrl;
154 
155  /*$h_ids = $sep = "";
156  foreach ($this->getHelpSections() as $hs)
157  {
158  $h_ids.= $sep.$hs;
159  $sep = ",";
160  }*/
161  $ilCtrl->setParameterByClass("ilhelpgui", "help_screen_id", $this->getScreenId().".".$_GET["ref_id"]);
162  }
163 
164 
168  function executeCommand()
169  {
170  $cmd = $this->ctrl->getCmd("showHelp");
171  $next_class = $this->ctrl->getNextClass($this);
172 
173  switch($next_class)
174  {
175  default:
176  return $this->$cmd();
177  break;
178  }
179  }
180 
184  function showHelp()
185  {
186  global $ilHelp, $lng, $ilSetting;
187 
188  if ($_GET["help_screen_id"] != "")
189  {
190  ilSession::set("help_screen_id", $_GET["help_screen_id"]);
191  $help_screen_id = $_GET["help_screen_id"];
192  }
193  else
194  {
195  $help_screen_id = ilSession::get("help_screen_id");
196  }
197 
198  $this->resetCurrentPage();
199 
200  $id_arr = explode(".", $help_screen_id);
201  include_once("./Services/Help/classes/class.ilHelpMapping.php");
202  $help_arr = ilHelpMapping::getHelpSectionsForId($id_arr[0], $id_arr[1]);
203 
204  $hm = (int) $ilSetting->get("help_module");
205 
206  if ((OH_REF_ID > 0 || $hm > 0) && count($help_arr) > 0)
207  {
208  if (OH_REF_ID > 0)
209  {
210  $oh_lm_id = ilObject::_lookupObjId(OH_REF_ID);
211  }
212  else
213  {
214  include_once("./Services/Help/classes/class.ilObjHelpSettings.php");
215  $oh_lm_id = ilObjHelpSettings::lookupModuleLmId($hm);
216  }
217 
218  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
219  $acc = new ilAccordionGUI();
220  $acc->setId("oh_acc");
221  $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
222 
223  foreach ($help_arr as $h_id)
224  {
225  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
226  $st_id = $h_id;
227 
228  if (!ilLMObject::_exists($st_id))
229  {
230  continue;
231  }
232 
233  $pages = ilLMObject::getPagesOfChapter($oh_lm_id, $st_id);
234  include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
235  $grp_list = new ilGroupedListGUI();
236  foreach ($pages as $pg)
237  {
238  $grp_list->addEntry(ilLMObject::_lookupTitle($pg["child"]), "#", "",
239  "return il.Help.showPage(".$pg["child"].");");
240  }
241 
242  $acc->addItem(ilLMObject::_lookupTitle($st_id), $grp_list->getHTML());
243  }
244  $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
245  $h_tpl->setVariable("HEAD", $lng->txt("help"));
246  $h_tpl->setVariable("CONTENT", $acc->getHTML());
247  $h_tpl->setVariable("CLOSE_IMG", ilUtil::img(ilUtil::getImagePath("icon_close2_s.png")));
248  echo $h_tpl->get();
249  }
250  exit;
251  }
252 
259  function showPage()
260  {
261  global $lng;
262 
263  $page_id = (int) $_GET["help_page"];
264 
265  $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
266  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
267 
268  $h_tpl->setCurrentBlock("backlink");
269  $h_tpl->setVariable("TXT_BACK", $lng->txt("back"));
270  $h_tpl->setVariable("ONCLICK_BACK",
271  "return il.Help.listHelp(event, true);");
272  $h_tpl->parseCurrentBlock();
273 
274 
275  $h_tpl->setVariable("HEAD", $lng->txt("help")." - ".
276  ilLMObject::_lookupTitle($page_id));
277 
278  include_once("./Services/COPage/classes/class.ilPageUtil.php");
279  if (!ilPageUtil::_existsAndNotEmpty("lm", $page_id))
280  {
281  exit;
282  }
283  include_once("./Services/COPage/classes/class.ilPageObject.php");
284  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
285 
286  // get page object
287  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
288  $page_gui =& new ilPageObjectGUI("lm", $page_id);
289  $page_gui->setPresentationTitle("");
290  $page_gui->setTemplateOutput(false);
291  $page_gui->setHeader("");
292  $page_gui->setEnabledFileLists(false);
293  $page_gui->setEnabledPCTabs(false);
294  $page_gui->setFileDownloadLink(".");
295  $page_gui->setFullscreenLink(".");
296  $page_gui->setSourcecodeDownloadScript(".");
297  $page_gui->setRawPageContent(true);
298  $page_gui->setEnabledMaps(false);
299  $ret = $page_gui->showPage();
300 
301  $h_tpl->setVariable("CONTENT", $ret);
302  $h_tpl->setVariable("CLOSE_IMG", ilUtil::img(ilUtil::getImagePath("icon_close2_s.png")));
303 
304  ilSession::set("help_pg", $page_id);
305 
306  $page = $h_tpl->get();
307 
308  // replace style classes
309  //$page = str_replace("ilc_text_inline_Strong", "ilHelpStrong", $page);
310 
311  echo $page;
312  exit;
313  }
314 
321  function resetCurrentPage()
322  {
323  ilSession::clear("help_pg");
324  }
325 
326 
333  function getTabTooltipText($a_tab_id)
334  {
335  global $lng;
336 
337  include_once("./Services/Help/classes/class.ilHelp.php");
338  if ($this->screen_id_component != "")
339  {
340  return ilHelp::getTooltipPresentationText($this->screen_id_component."_".$a_tab_id);
341  //return $lng->txt("help_tt_".$this->screen_id_component."_".$a_tab_id);
342  }
343  return "";
344  }
345 
352  function initHelp($a_tpl)
353  {
354  global $ilUser;
355 
356  if (ilSession::get("help_pg") > 0)
357  {
358  $a_tpl->addOnLoadCode("il.Help.showCurrentPage(".ilSession::get("help_pg").");", 3);
359  }
360  if ($ilUser->getPref("hide_help_tt"))
361  {
362  $a_tpl->addOnLoadCode("il.Help.switchTooltips();", 3);
363  }
364  }
365 
373  {
374  global $ilUser;
375 
376  $ilUser->writePref("hide_help_tt", "1");
377  }
378 
385  function activateTooltips()
386  {
387  global $ilUser;
388 
389  $ilUser->writePref("hide_help_tt", "0");
390  }
391 
392 }
393 ?>