ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLMEditorGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once ("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
5 include_once ("./Services/Utilities/classes/class.ilDOMUtil.php");
6 include_once ("./Services/COPage/classes/class.ilPageEditorGUI.php");
7 include_once ("./Services/Style/classes/class.ilObjStyleSheet.php");
8 include_once ("./Modules/LearningModule/classes/class.ilEditClipboard.php");
9 
10 
23 {
29  var $ilias;
30  var $tpl;
31  var $lng;
33  var $ref_id;
34  var $lm_obj;
35 
36  var $tree;
37  var $obj_id;
38 
43  function ilLMEditorGUI()
44  {
46  $rbacsystem, $ilNavigationHistory;
47 
48  // init module (could be done in ilctrl)
49  //define("ILIAS_MODULE", "content");
50  $lng->loadLanguageModule("content");
51 
52  // check write permission
53  if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
54  {
55  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
56  }
57 
58 
59  $this->ctrl =& $ilCtrl;
60 
61  //$this->ctrl->saveParameter($this, array("ref_id", "obj_id"));
62  $this->ctrl->saveParameter($this, array("ref_id"));
63 
64  // initiate variables
65  $this->ilias =& $ilias;
66  $this->tpl =& $tpl;
67  $this->lng =& $lng;
68  $this->objDefinition =& $objDefinition;
69  $this->ref_id = $_GET["ref_id"];
70  $this->obj_id = $_GET["obj_id"];
71 
72  $this->lm_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->ref_id);
73  $this->tree = new ilTree($this->lm_obj->getId());
74  $this->tree->setTableNames('lm_tree','lm_data');
75  $this->tree->setTreeTablePK("lm_id");
76 
77  $ilNavigationHistory->addItem($_GET["ref_id"],
78  "ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"], "lm");
79 
80  }
81 
85  function &executeCommand()
86  {
87 
88  global $ilHelp;
89 
90  $ilHelp->setTarget("lm_intro");
91 
92  $cmd = $this->ctrl->getCmd("frameset");
93 
94  $next_class = $this->ctrl->getNextClass($this);
95 //echo "lmeditorgui:$next_class:".$this->ctrl->getCmdClass().":$cmd:<br>";
96  $cmd = $this->ctrl->getCmd("frameset");
97 
98  if ($next_class == "" && ($cmd != "explorer") && ($cmd != "frameset")
99  && ($cmd != "showImageMap"))
100  {
101  switch($this->lm_obj->getType())
102  {
103  case "lm":
104  //$this->ctrl->setCmdClass("ilObjLearningModuleGUI");
105  $next_class = "ilobjlearningmodulegui";
106  break;
107 
108  case "dbk":
109  //$this->ctrl->setCmdClass("ilObjDlBookGUI");
110  $next_class = "ilobjdlbookgui";
111  break;
112  }
113  //$next_class = $this->ctrl->getNextClass($this);
114  }
115 
116  // show footer
117  $show_footer = ($cmd == "explorer")
118  ? false
119  : true;
120 
121 // if ($this->lm_obj->getType()
122  switch($next_class)
123  {
124  case "ilobjdlbookgui":
125  include_once ("./Modules/LearningModule/classes/class.ilObjDlBook.php");
126  include_once ("./Modules/LearningModule/classes/class.ilObjDlBookGUI.php");
127 
128  $this->main_header($this->lm_obj->getType());
129  $book_gui =& new ilObjDlBookGUI("", $_GET["ref_id"], true, false);
130  //$ret =& $book_gui->executeCommand();
131  $ret =& $this->ctrl->forwardCommand($book_gui);
132  if (strcmp($cmd, "explorer") != 0)
133  {
134  // don't call the locator in the explorer frame
135  // this prevents a lot of log errors
136  // Helmut Schottmüller, 2006-07-21
137  $this->displayLocator();
138  }
139 
140  // (horrible) workaround for preventing template engine
141  // from hiding paragraph text that is enclosed
142  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
143 // $this->tpl->fillTabs();
144  $output = $this->tpl->get("DEFAULT", true, true, $show_footer,true);
145  $output = str_replace("&#123;", "{", $output);
146  $output = str_replace("&#125;", "}", $output);
147  header('Content-type: text/html; charset=UTF-8');
148  echo $output;
149  break;
150 
151  case "ilobjlearningmodulegui":
152  include_once ("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
153  include_once ("./Modules/LearningModule/classes/class.ilObjLearningModuleGUI.php");
154  $this->main_header($this->lm_obj->getType());
155  $lm_gui =& new ilObjLearningModuleGUI("", $_GET["ref_id"], true, false);
156  //$ret =& $lm_gui->executeCommand();
157  $ret =& $this->ctrl->forwardCommand($lm_gui);
158  if (strcmp($cmd, "explorer") != 0)
159  {
160  // don't call the locator in the explorer frame
161  // this prevents a lot of log errors
162  // Helmut Schottmüller, 2006-07-21
163  $this->displayLocator();
164  }
165 //echo "*".$this->tpl->get()."*";
166  // (horrible) workaround for preventing template engine
167  // from hiding paragraph text that is enclosed
168  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
169 // $this->tpl->fillTabs();
170  $output = $this->tpl->get("DEFAULT", true, true, $show_footer,true);
171  $output = str_replace("&#123;", "{", $output);
172  $output = str_replace("&#125;", "}", $output);
173  header('Content-type: text/html; charset=UTF-8');
174  echo $output;
175  break;
176 
177  default:
178  $ret =& $this->$cmd();
179  break;
180  }
181  }
182 
188  function frameset()
189  {
190  include_once("./Services/Frameset/classes/class.ilFramesetGUI.php");
191  $fs_gui = new ilFramesetGUI();
192 
193  $fs_gui->setFramesetTitle($this->lng->txt("editor"));
194  $fs_gui->setMainFrameName("content");
195  $fs_gui->setSideFrameName("tree");
196  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
197 
198  if ($this->lm_obj->getType() == "dbk")
199  {
200  $fs_gui->setSideFrameSource(
201  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer"));
202  if ($_GET["to_page"]== 1)
203  {
204  $fs_gui->setMainFrameSource(
205  $this->ctrl->getLinkTargetByClass(
206  array("ilobjdlbookgui", "illmpageobjectgui"),
207  "edit"));
208  }
209  else
210  {
211  $fs_gui->setMainFrameSource(
212  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "chapters"));
213  }
214  }
215  else
216  {
217  $fs_gui->setSideFrameSource(
218  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer"));
219  if ($_GET["to_page"]== 1)
220  {
221  $fs_gui->setMainFrameSource(
222  $this->ctrl->getLinkTargetByClass(
223  array("ilobjlearningmodulegui", "illmpageobjectgui"),
224  "edit"));
225  }
226  else
227  {
228  $fs_gui->setMainFrameSource(
229  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "chapters"));
230  }
231  }
232  $fs_gui->show();
233  exit;
234  }
235 
236 
237 
241  function main_header($a_type)
242  {
243  global $lng;
244 
245  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
246  //$this->tpl->setVariable("HEADER", $a_header_title);
247  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
248  //$this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
249  //$this->displayLocator($a_type);
250 
251  // content style
252  $this->tpl->setCurrentBlock("ContentStyle");
253  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
254  ilObjStyleSheet::getContentStylePath($this->lm_obj->getStyleSheetId()));
255  $this->tpl->parseCurrentBlock();
256 
257  // syntax style
258  $this->tpl->setCurrentBlock("SyntaxStyle");
259  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
261  $this->tpl->parseCurrentBlock();
262 
263  }
264 
265 
269  function displayLocator()
270  {
271  global $lng;
272 
273  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
274 
275  $modifier = 1;
276 
277  $locations = $this->ctrl->getLocations();
278 
279  foreach ($locations as $key => $row)
280  {
281  if ($key < count($locations)-$modifier)
282  {
283  $this->tpl->touchBlock("locator_separator");
284  }
285 
286  if ($row["ref_id"]> 0 && $row["ref_id"] != ROOT_FOLDER_ID)
287  {
288  $oid = ilObject::_lookupObjId($row["ref_id"]);
289  $t = ilObject::_lookupType($oid);
290  $this->tpl->setCurrentBlock("locator_img");
291  $this->tpl->setVariable("IMG_SRC",
292  ilUtil::getImagePath("icon_".$t."_s.gif"));
293  $this->tpl->setVariable("IMG_ALT",
294  $lng->txt("obj_".$type));
295  $this->tpl->parseCurrentBlock();
296  }
297 
298  if ($row["link"] != "")
299  {
300  $this->tpl->setCurrentBlock("locator_item");
301  $this->tpl->setVariable("ITEM", $row["title"]);
302  $this->tpl->setVariable("LINK_ITEM", $row["link"]);
303  if ($row["target"] != "")
304  {
305  $this->tpl->setVariable("LINK_TARGET", ' target="'.$row["target"].'" ');
306  }
307  $this->tpl->parseCurrentBlock();
308  }
309  else
310  {
311  $this->tpl->setCurrentBlock("locator_item");
312  $this->tpl->setVariable("PREFIX", $row["title"]);
313  $this->tpl->parseCurrentBlock();
314  }
315  }
316 
317  $this->tpl->setCurrentBlock("locator");
318  $this->tpl->parseCurrentBlock();
319 
320  }
321 
322 }
323 ?>