ILIAS  release_4-3 Revision
 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  $cmd = $this->ctrl->getCmd("frameset");
91 
92  $next_class = $this->ctrl->getNextClass($this);
93 //echo "lmeditorgui:$next_class:".$this->ctrl->getCmdClass().":$cmd:<br>";
94  $cmd = $this->ctrl->getCmd("frameset");
95 
96  if ($next_class == "" && ($cmd != "explorer") && ($cmd != "frameset")
97  && ($cmd != "showImageMap"))
98  {
99  switch($this->lm_obj->getType())
100  {
101  case "lm":
102  //$this->ctrl->setCmdClass("ilObjLearningModuleGUI");
103  $next_class = "ilobjlearningmodulegui";
104  break;
105 
106  case "dbk":
107  //$this->ctrl->setCmdClass("ilObjDlBookGUI");
108  $next_class = "ilobjdlbookgui";
109  break;
110  }
111  //$next_class = $this->ctrl->getNextClass($this);
112  }
113 
114  // show footer
115  $show_footer = ($cmd == "explorer")
116  ? false
117  : true;
118 
119 // if ($this->lm_obj->getType()
120  switch($next_class)
121  {
122  case "ilobjdlbookgui":
123  include_once ("./Modules/LearningModule/classes/class.ilObjDlBook.php");
124  include_once ("./Modules/LearningModule/classes/class.ilObjDlBookGUI.php");
125 
126  $this->main_header($this->lm_obj->getType());
127  $book_gui =& new ilObjDlBookGUI("", $_GET["ref_id"], true, false);
128  //$ret =& $book_gui->executeCommand();
129  $ret =& $this->ctrl->forwardCommand($book_gui);
130  if (strcmp($cmd, "explorer") != 0)
131  {
132  // don't call the locator in the explorer frame
133  // this prevents a lot of log errors
134  // Helmut Schottmüller, 2006-07-21
135  $this->displayLocator();
136  }
137 
138  // (horrible) workaround for preventing template engine
139  // from hiding paragraph text that is enclosed
140  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
141 // $this->tpl->fillTabs();
142  $output = $this->tpl->get("DEFAULT", true, true, $show_footer,true);
143  $output = str_replace("&#123;", "{", $output);
144  $output = str_replace("&#125;", "}", $output);
145  header('Content-type: text/html; charset=UTF-8');
146  echo $output;
147  break;
148 
149  case "ilobjlearningmodulegui":
150  include_once ("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
151  include_once ("./Modules/LearningModule/classes/class.ilObjLearningModuleGUI.php");
152  $this->main_header($this->lm_obj->getType());
153  $lm_gui =& new ilObjLearningModuleGUI("", $_GET["ref_id"], true, false);
154  //$ret =& $lm_gui->executeCommand();
155  $ret =& $this->ctrl->forwardCommand($lm_gui);
156  if (strcmp($cmd, "explorer") != 0)
157  {
158  // don't call the locator in the explorer frame
159  // this prevents a lot of log errors
160  // Helmut Schottmüller, 2006-07-21
161  $this->displayLocator();
162  }
163 //echo "*".$this->tpl->get()."*";
164  // (horrible) workaround for preventing template engine
165  // from hiding paragraph text that is enclosed
166  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
167 // $this->tpl->fillTabs();
168  $output = $this->tpl->get("DEFAULT", true, true, $show_footer,true);
169  $output = str_replace("&#123;", "{", $output);
170  $output = str_replace("&#125;", "}", $output);
171  header('Content-type: text/html; charset=UTF-8');
172  echo $output;
173  break;
174 
175  default:
176  $ret =& $this->$cmd();
177  break;
178  }
179  }
180 
186  function frameset()
187  {
188  include_once("./Services/Frameset/classes/class.ilFramesetGUI.php");
189  $fs_gui = new ilFramesetGUI();
190 
191  $fs_gui->setFramesetTitle($this->lng->txt("editor"));
192  $fs_gui->setMainFrameName("content");
193  $fs_gui->setSideFrameName("tree");
194  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
195 
196  if ($this->lm_obj->getType() == "dbk")
197  {
198  $fs_gui->setSideFrameSource(
199  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer"));
200  if ($_GET["to_page"]== 1)
201  {
202  $fs_gui->setMainFrameSource(
203  $this->ctrl->getLinkTargetByClass(
204  array("ilobjdlbookgui", "illmpageobjectgui"),
205  "edit"));
206  }
207  else
208  {
209  $fs_gui->setMainFrameSource(
210  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "chapters"));
211  }
212  }
213  else
214  {
215  $fs_gui->setSideFrameSource(
216  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer"));
217  if ($_GET["to_page"]== 1)
218  {
219  $fs_gui->setMainFrameSource(
220  $this->ctrl->getLinkTargetByClass(
221  array("ilobjlearningmodulegui", "illmpageobjectgui"),
222  "edit"));
223  }
224  else
225  {
226  if ($_GET["to_props"] == 1)
227  {
228  $fs_gui->setMainFrameSource(
229  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "properties"));
230  }
231  else
232  {
233  $fs_gui->setMainFrameSource(
234  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "chapters"));
235  }
236  }
237  }
238  $fs_gui->show();
239  exit;
240  }
241 
242 
243 
247  function main_header($a_type)
248  {
249  global $lng;
250 
251  $this->tpl->getStandardTemplate();
252 
253  // content style
254  $this->tpl->setCurrentBlock("ContentStyle");
255  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
256  ilObjStyleSheet::getContentStylePath($this->lm_obj->getStyleSheetId()));
257  $this->tpl->parseCurrentBlock();
258 
259  // syntax style
260  $this->tpl->setCurrentBlock("SyntaxStyle");
261  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
263  $this->tpl->parseCurrentBlock();
264 
265  }
266 
267 
271  function displayLocator()
272  {
273  global $lng;
274 
275  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
276 
277  $modifier = 1;
278 
279  $locations = $this->ctrl->getLocations();
280 
281  foreach ($locations as $key => $row)
282  {
283  if ($key < count($locations)-$modifier)
284  {
285  $this->tpl->touchBlock("locator_separator");
286  }
287 
288  if ($row["ref_id"]> 0 && $row["ref_id"] != ROOT_FOLDER_ID)
289  {
290  $oid = ilObject::_lookupObjId($row["ref_id"]);
291  $t = ilObject::_lookupType($oid);
292  $this->tpl->setCurrentBlock("locator_img");
293  $this->tpl->setVariable("IMG_SRC",
294  ilUtil::getImagePath("icon_".$t."_s.png"));
295  $this->tpl->setVariable("IMG_ALT",
296  $lng->txt("obj_".$type));
297  $this->tpl->parseCurrentBlock();
298  }
299 
300  if ($row["link"] != "")
301  {
302  $this->tpl->setCurrentBlock("locator_item");
303  $this->tpl->setVariable("ITEM", $row["title"]);
304  $this->tpl->setVariable("LINK_ITEM", $row["link"]);
305  if ($row["target"] != "")
306  {
307  $this->tpl->setVariable("LINK_TARGET", ' target="'.$row["target"].'" ');
308  }
309  $this->tpl->parseCurrentBlock();
310  }
311  else
312  {
313  $this->tpl->setCurrentBlock("locator_item");
314  $this->tpl->setVariable("PREFIX", $row["title"]);
315  $this->tpl->parseCurrentBlock();
316  }
317  }
318 
319  $this->tpl->setCurrentBlock("locator");
320  $this->tpl->parseCurrentBlock();
321 
322  }
323 
324 }
325 ?>