ILIAS  release_4-4 Revision
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", "transl"));
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  if ($_GET["to_page"]== 1)
91  {
92  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $_GET["obj_id"]);
93  $this->ctrl->redirectByClass(array("ilobjlearningmodulegui", "illmpageobjectgui"), "edit");
94  }
95 
96  if ($cmd != "showTree")
97  {
98  $this->showTree();
99  }
100 
101  $next_class = $this->ctrl->getNextClass($this);
102 //echo "lmeditorgui:$next_class:".$this->ctrl->getCmdClass().":$cmd:<br>";
103 
104  if ($next_class == "" && ($cmd != "explorer")
105  && ($cmd != "showImageMap"))
106  {
107  switch($this->lm_obj->getType())
108  {
109  case "lm":
110  //$this->ctrl->setCmdClass("ilObjLearningModuleGUI");
111  $next_class = "ilobjlearningmodulegui";
112  break;
113 
114  case "dbk":
115  //$this->ctrl->setCmdClass("ilObjDlBookGUI");
116  $next_class = "ilobjdlbookgui";
117  break;
118  }
119  //$next_class = $this->ctrl->getNextClass($this);
120  }
121 
122  // show footer
123  $show_footer = ($cmd == "explorer")
124  ? false
125  : true;
126 
127 // if ($this->lm_obj->getType()
128  switch($next_class)
129  {
130  case "ilobjdlbookgui":
131  include_once ("./Modules/LearningModule/classes/class.ilObjDlBook.php");
132  include_once ("./Modules/LearningModule/classes/class.ilObjDlBookGUI.php");
133 
134  $this->main_header($this->lm_obj->getType());
135  $book_gui =& new ilObjDlBookGUI("", $_GET["ref_id"], true, false);
136  //$ret =& $book_gui->executeCommand();
137  $ret =& $this->ctrl->forwardCommand($book_gui);
138  if (strcmp($cmd, "explorer") != 0)
139  {
140  // don't call the locator in the explorer frame
141  // this prevents a lot of log errors
142  // Helmut Schottmüller, 2006-07-21
143  $this->displayLocator();
144  }
145 
146  // (horrible) workaround for preventing template engine
147  // from hiding paragraph text that is enclosed
148  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
149 // $this->tpl->fillTabs();
150  $output = $this->tpl->get("DEFAULT", true, true, $show_footer,true);
151  $output = str_replace("&#123;", "{", $output);
152  $output = str_replace("&#125;", "}", $output);
153  header('Content-type: text/html; charset=UTF-8');
154  echo $output;
155  break;
156 
157  case "ilobjlearningmodulegui":
158  include_once ("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
159  include_once ("./Modules/LearningModule/classes/class.ilObjLearningModuleGUI.php");
160  $this->main_header($this->lm_obj->getType());
161  $lm_gui =& new ilObjLearningModuleGUI("", $_GET["ref_id"], true, false);
162  //$ret =& $lm_gui->executeCommand();
163  $ret =& $this->ctrl->forwardCommand($lm_gui);
164  if (strcmp($cmd, "explorer") != 0)
165  {
166  // don't call the locator in the explorer frame
167  // this prevents a lot of log errors
168  // Helmut Schottmüller, 2006-07-21
169  $this->displayLocator();
170  }
171 //echo "*".$this->tpl->get()."*";
172  // (horrible) workaround for preventing template engine
173  // from hiding paragraph text that is enclosed
174  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
175 // $this->tpl->fillTabs();
176  $output = $this->tpl->get("DEFAULT", true, true, $show_footer,true);
177  $output = str_replace("&#123;", "{", $output);
178  $output = str_replace("&#125;", "}", $output);
179  header('Content-type: text/html; charset=UTF-8');
180  echo $output;
181  break;
182 
183  default:
184  $ret = $this->$cmd();
185  break;
186  }
187  }
188 
195  function showTree()
196  {
197  global $tpl;
198 
199  include_once("./Modules/LearningModule/classes/class.ilLMEditorExplorerGUI.php");
200  $exp = new ilLMEditorExplorerGUI($this, "showTree", $this->lm_obj);
201  if (!$exp->handleCommand())
202  {
203  $tpl->setLeftNavContent($exp->getHTML());
204  }
205  }
206 
210  function main_header($a_type)
211  {
212  global $lng;
213 
214  $this->tpl->getStandardTemplate();
215 
216  // content style
217  $this->tpl->setCurrentBlock("ContentStyle");
218  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
219  ilObjStyleSheet::getContentStylePath($this->lm_obj->getStyleSheetId()));
220  $this->tpl->parseCurrentBlock();
221 
222  // syntax style
223  $this->tpl->setCurrentBlock("SyntaxStyle");
224  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
226  $this->tpl->parseCurrentBlock();
227 
228  }
229 
230 
234  function displayLocator()
235  {
236  global $lng;
237 
238  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
239 
240  $modifier = 1;
241 
242  $locations = $this->ctrl->getLocations();
243 
244  foreach ($locations as $key => $row)
245  {
246  if ($key < count($locations)-$modifier)
247  {
248  $this->tpl->touchBlock("locator_separator");
249  }
250 
251  if ($row["ref_id"]> 0 && $row["ref_id"] != ROOT_FOLDER_ID)
252  {
253  $oid = ilObject::_lookupObjId($row["ref_id"]);
254  $t = ilObject::_lookupType($oid);
255  $this->tpl->setCurrentBlock("locator_img");
256  $this->tpl->setVariable("IMG_SRC",
257  ilUtil::getImagePath("icon_".$t."_s.png"));
258  $this->tpl->setVariable("IMG_ALT",
259  $lng->txt("obj_".$type));
260  $this->tpl->parseCurrentBlock();
261  }
262 
263  if ($row["link"] != "")
264  {
265  $this->tpl->setCurrentBlock("locator_item");
266  $this->tpl->setVariable("ITEM", $row["title"]);
267  $this->tpl->setVariable("LINK_ITEM", $row["link"]);
268  if ($row["target"] != "")
269  {
270  $this->tpl->setVariable("LINK_TARGET", ' target="'.$row["target"].'" ');
271  }
272  $this->tpl->parseCurrentBlock();
273  }
274  else
275  {
276  $this->tpl->setCurrentBlock("locator_item");
277  $this->tpl->setVariable("PREFIX", $row["title"]);
278  $this->tpl->parseCurrentBlock();
279  }
280  }
281 
282  $this->tpl->setCurrentBlock("locator");
283  $this->tpl->parseCurrentBlock();
284 
285  }
286 
287 }
288 ?>
main_header($a_type)
output main header (title and locator)
GUI class for learning module editor.
$_GET["client_id"]
$cmd
Definition: sahs_server.php:35
getSyntaxStylePath()
get syntax style path
LM editor explorer GUI class.
Class ilLearningModuleGUI.
global $ilCtrl
Definition: ilias.php:18
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
redirection script todo: (a better solution should control the processing via a xml file) ...
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be &#39;obj_id&#39; You may use...
displayLocator()
display locator
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilObjDlBookGUI.
getContentStylePath($a_style_id)
get content style path
ilLMEditorGUI()
Constructor public.
& executeCommand()
execute command
showTree()
Show tree.