ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGlossaryGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("classes/class.ilObjectGUI.php");
25 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
26 require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
27 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
28 require_once("./Modules/Glossary/classes/class.ilTermDefinitionEditorGUI.php");
29 require_once("./Services/COPage/classes/class.ilPCParagraph.php");
30 
45 {
47  var $mode;
48  var $term;
49 
54  function ilObjGlossaryGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
55  {
56  global $ilCtrl, $lng;
57 
58  $this->ctrl =& $ilCtrl;
59  $this->ctrl->saveParameter($this, array("ref_id", "offset"));
60  $lng->loadLanguageModule("content");
61 
62  $this->type = "glo";
63  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
64  //if ($a_prepare_output)
65  //{
66  // $this->prepareOutput();
67  //}
68  }
69 
73  function &executeCommand()
74  {
75  global $lng, $ilAccess;
76 
77  $cmd = $this->ctrl->getCmd();
78  $next_class = $this->ctrl->getNextClass($this);
79 
80  switch ($next_class)
81  {
82  case 'ilmdeditorgui':
83  $this->getTemplate();
84  $this->setTabs();
85  $this->setLocator();
86 
87  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
88 
89  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
90  $md_gui->addObserver($this->object,'MDUpdateListener','General');
91 
92  $this->ctrl->forwardCommand($md_gui);
93  break;
94 
95  case "ilglossarytermgui":
96  $this->ctrl->setReturn($this, "listTerms");
97  $term_gui =& new ilGlossaryTermGUI($_GET["term_id"]);
98  $term_gui->setGlossary($this->object);
99  //$ret =& $term_gui->executeCommand();
100  $ret =& $this->ctrl->forwardCommand($term_gui);
101  break;
102 
103  case "ilinfoscreengui":
104  $this->getTemplate();
105  $this->setTabs();
106  $this->setLocator();
107  $this->lng->loadLanguageModule("meta");
108  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
109 
110  $info = new ilInfoScreenGUI($this);
111  $info->enablePrivateNotes();
112  $info->enableNews();
113  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
114  {
115  $info->enableNewsEditing();
116  $news_set = new ilSetting("news");
117  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
118  if ($enable_internal_rss)
119  {
120  $info->setBlockProperty("news", "settings", true);
121  }
122  }
123  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
124  $this->ctrl->forwardCommand($info);
125  break;
126 
127  case 'ilpermissiongui':
128  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
129  {
130  $this->prepareOutput();
131  }
132  else
133  {
134  $this->getTemplate();
135  $this->setTabs();
136  $this->setLocator();
137  }
138  include_once("./classes/class.ilPermissionGUI.php");
139  $perm_gui =& new ilPermissionGUI($this);
140  $ret =& $this->ctrl->forwardCommand($perm_gui);
141  break;
142 
143  default:
144  $cmd = $this->ctrl->getCmd("frameset");
145 
146  if (($cmd == "create") && ($_POST["new_type"] == "term"))
147  {
148  $this->ctrl->setCmd("create");
149  $this->ctrl->setCmdClass("ilGlossaryTermGUI");
150  $ret =& $this->executeCommand();
151  return;
152  }
153  else
154  {
155  if (!in_array($cmd, array("frameset", "quickList")))
156  {
157  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
158  $this->getCreationMode() == true)
159  {
160  $this->prepareOutput();
161  $cmd.= "Object";
162  }
163  else
164  {
165  $this->getTemplate();
166  $this->setTabs();
167  $this->setLocator();
168  }
169  }
170  $ret =& $this->$cmd();
171  }
172  break;
173  }
174 
175  if (!in_array($cmd, array("frameset", "quickList")))
176  {
177  if (strtolower($_GET["baseClass"]) != "iladministrationgui")
178  {
179  if (!$this->getCreationMode())
180  {
181  $this->tpl->show();
182  }
183  }
184  }
185  else
186  {
187  $this->tpl->show(false);
188  }
189  }
190 
191  function assignObject()
192  {
193  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
194 
195  $this->object =& new ilObjGlossary($this->id, true);
196  }
197 
198 
202  function createObject()
203  {
204  global $rbacsystem;
205 
206  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
207 
208  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
209  {
210  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
211  }
212 
213  $stati = array(
214  "none"=>$this->lng->txt("glo_mode_normal"),
215  "level"=>$this->lng->txt("glo_mode_level"),
216  "subtree"=>$this->lng->txt("glo_mode_subtree")
217  );
218 
219  $glo_type = $_SESSION["error_post_vars"]["glo_type"];
220 
221  $opts = ilUtil::formSelect("none","glo_mode",$stati,false,true);
222 
223  // fill in saved values in case of error
224  $data = array();
225  $data["fields"] = array();
226  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
227  $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
228 
229  $this->getTemplateFile("create", $new_type);
230 
231  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_glo.gif'));
232  $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_glo"));
233 
234  foreach ($data["fields"] as $key => $val)
235  {
236  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
237  $this->tpl->setVariable(strtoupper($key), $val);
238 
239  if ($this->prepare_output)
240  {
241  $this->tpl->parseCurrentBlock();
242  }
243  }
244 
245  $this->ctrl->setParameter($this, "new_type", $new_type);
246  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "save"));
247 
248  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
249  // $_GET["ref_id"]."&new_type=".$new_type));
250  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
251  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
252  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
253  $this->tpl->setVariable("CMD_SUBMIT", "save");
254  $this->tpl->setVariable("TARGET", ' target="'.
255  ilFrameTargetInfo::_getFrame("MainContent").'" ');
256  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
257 
258  $this->tpl->setVariable("SELECT_GLO_MODE", $opts);
259  $this->tpl->setVariable("TXT_GLO_MODE", $this->lng->txt("glo_mode"));
260  $this->tpl->setVariable("TXT_GLO_MODE_DESC", $this->lng->txt("glo_mode_desc"));
261 
262  $this->tpl->setVariable("TXT_IMPORT_GLO", $this->lng->txt("import_glossary"));
263  $this->tpl->setVariable("TXT_GLO_FILE", $this->lng->txt("glo_upload_file"));
264  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
265  }
266 
267  function importObject()
268  {
269  $this->createObject();
270  }
271 
275  function saveObject()
276  {
277  global $rbacadmin, $rbacsystem;
278 
279  // always call parent method first to create an object_data entry & a reference
280  //$newObj = parent::saveObject();
281  // TODO: fix MetaDataGUI implementation to make it compatible to use parent call
282  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
283  {
284  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
285  }
286 
287  // check required fields
288  if (empty($_POST["Fobject"]["title"]))
289  {
290  $this->ilErr->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilErr->MESSAGE);
291  }
292 
293  // create and insert object in objecttree
294  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
295  $newObj = new ilObjGlossary();
296  $newObj->setType($this->type);
297  $newObj->setTitle($_POST["Fobject"]["title"]);
298  $newObj->setDescription($_POST["Fobject"]["desc"]);
299  $newObj->setVirtualMode($_POST["glo_mode"]);
300  $newObj->create();
301  $newObj->createReference();
302  $newObj->putInTree($_GET["ref_id"]);
303  $newObj->setPermissions($_GET["ref_id"]);
304  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
305 
306  // always send a message
307  ilUtil::sendInfo($this->lng->txt("glo_added"),true);
308  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
309 
310  //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
311  }
312 
319  function importFileObject()
320  {
321  global $_FILES, $rbacsystem;
322 
323  // check if file was uploaded
324  $source = $_FILES["xmldoc"]["tmp_name"];
325  if (($source == 'none') || (!$source))
326  {
327  $this->ilias->raiseError($this->lng->txt("msg_no_file"),$this->ilias->error_obj->MESSAGE);
328  }
329  // check create permission
330  /*
331  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
332  {
333  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
334  }*/
335 
336  // check correct file type
337  // check correct file type
338  $info = pathinfo($_FILES["xmldoc"]["name"]);
339  if (strtolower($info["extension"]) != "zip")
340  {
341  $this->ilias->raiseError($this->lng->txt("cont_no_zip_file"),
342  $this->ilias->error_obj->MESSAGE);
343  }
344 
345  // create and insert object in objecttree
346  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
347  $newObj = new ilObjGlossary();
348  $newObj->setType($_GET["new_type"]);
349  $newObj->setTitle($_FILES["xmldoc"]["name"]);
350  $newObj->create(true);
351  $newObj->createReference();
352  $newObj->putInTree($_GET["ref_id"]);
353  $newObj->setPermissions($_GET["ref_id"]);
354  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
355 
356  // create import directory
357  $newObj->createImportDirectory();
358 
359  // copy uploaded file to import directory
360  $file = pathinfo($_FILES["xmldoc"]["name"]);
361  $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
362 
363  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
364  $_FILES["xmldoc"]["name"], $full_path);
365 
366  // unzip file
367  ilUtil::unzip($full_path);
368 
369  // determine filename of xml file
370  $subdir = basename($file["basename"],".".$file["extension"]);
371  $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
372 
373  // check whether subdirectory exists within zip file
374  if (!is_dir($newObj->getImportDirectory()."/".$subdir))
375  {
376  $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir),
377  $this->ilias->error_obj->MESSAGE);
378  }
379 
380  // check whether xml file exists within zip file
381  if (!is_file($xml_file))
382  {
383  $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"),
384  $this->ilias->error_obj->MESSAGE);
385  }
386 
387  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
388  $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
389  $contParser->startParsing();
390  ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
391 
392  // delete import directory
393  ilUtil::delDir($newObj->getImportDirectory());
394 
395  ilUtil::sendInfo($this->lng->txt("glo_added"),true);
396  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
397  //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
398  }
399 
400 
401  function viewObject()
402  {
403  global $rbacsystem;
404 
405  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
406  {
408  return;
409  }
410 
411  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
412  {
413  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
414  }
415 
416  // edit button
417  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
418 
419  $this->tpl->setCurrentBlock("btn_cell");
420  $this->tpl->setVariable("BTN_LINK",
421  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID());
422  $this->tpl->setVariable("BTN_TARGET"," target=\"".
423  ilFrameTargetInfo::_getFrame("MainContent")."\" ");
424  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
425  $this->tpl->parseCurrentBlock();
426 
427  //parent::viewObject();
428  }
429 
435  function properties()
436  {
437  global $rbacsystem, $tree, $tpl;
438 
439  // glossary properties
440  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glossary_properties.html", true);
441  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this,"saveProperties"));
442  $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_glo_properties"));
443 
444  // online
445  $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
446  $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
447  $this->tpl->setVariable("VAL_ONLINE", "y");
448 
449  if ($this->object->getOnline())
450  {
451  $this->tpl->setVariable("CHK_ONLINE", "checked");
452  }
453 
454  // glossary mode
455  $stati = array(
456  "none"=>$this->lng->txt("glo_mode_normal"),
457  "level"=>$this->lng->txt("glo_mode_level"),
458  "subtree"=>$this->lng->txt("glo_mode_subtree")
459  );
460 
461  $opts = ilUtil::formSelect($this->object->getVirtualMode(),"glo_mode",$stati,false,true);
462 
463  $this->tpl->setVariable("SELECT_GLO_MODE", $opts);
464  $this->tpl->setVariable("TXT_GLO_MODE", $this->lng->txt("glo_mode"));
465  $this->tpl->setVariable("TXT_GLO_MODE_DESC", $this->lng->txt("glo_mode_desc"));
466 
467  // glossary menu
468  $this->tpl->setVariable("TXT_GLO_MENU", $this->lng->txt("cont_glo_menu"));
469  $this->tpl->setVariable("TXT_ACT_MENU", $this->lng->txt("cont_active"));
470  $this->tpl->setVariable("CBOX_GLO_MENU", "glo_act_menu");
471  $this->tpl->setVariable("VAL_GLO_MENU", "y");
472 
473  if ($this->object->isActiveGlossaryMenu())
474  {
475  $this->tpl->setVariable("CHK_GLO_MENU", "checked");
476  }
477 
478  // downloads
479  $this->tpl->setVariable("TXT_DOWNLOADS", $this->lng->txt("cont_downloads"));
480  $this->tpl->setVariable("TXT_DOWNLOADS_DESC", $this->lng->txt("cont_downloads_desc"));
481  $this->tpl->setVariable("CBOX_DOWNLOADS", "glo_act_downloads");
482  $this->tpl->setVariable("VAL_DOWNLOADS", "y");
483  if ($this->object->isActiveDownloads())
484  {
485  $this->tpl->setVariable("CHK_DOWNLOADS", "checked");
486  }
487 
488 
489  $this->tpl->setCurrentBlock("commands");
490  $this->tpl->setVariable("BTN_NAME", "saveProperties");
491  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
492  $this->tpl->parseCurrentBlock();
493 
494  }
495 
499  function saveProperties()
500  {
501  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
502  $this->object->setVirtualMode($_POST["glo_mode"]);
503  $this->object->setActiveGlossaryMenu(ilUtil::yn2tf($_POST["glo_act_menu"]));
504  $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["glo_act_downloads"]));
505  $this->object->update();
506  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
507  $this->ctrl->redirect($this, "properties");
508  }
509 
513  function frameset()
514  {
515  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
516  $fs_gui = new ilFramesetGUI();
517  $fs_gui->setFramesetTitle($this->object->getTitle());
518  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "listTerms"));
519  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this, "quickList"));
520  $fs_gui->setMainFrameName("content");
521  $fs_gui->setSideFrameName("tree");
522  $fs_gui->show();
523  exit;
524  }
525 
529  function quickList()
530  {
531  global $ilUser;
532 
533  $this->tpl->addBlockFile("CONTENT", "content", "tpl.glossary_short_list.html",
534  "Modules/Glossary");
535 
536  $this->tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
537  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
538 
539  $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
540  $this->tpl->setVariable("CMD_REFR", "quickList");
541  $this->tpl->setVariable("TXT_REFR", $this->lng->txt("refresh"));
542 
543  include_once "./Services/Table/classes/class.ilTableGUI.php";
544 
545  // glossary term list template
546 
547  // load template for table
548  $this->tpl->addBlockfile("SHORT_LIST", "list", "tpl.table.html");
549 
550  // load template for table content data
551  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_short_tbl_row.html", true);
552 
553  $num = 0;
554 
555  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
556 
557  // create table
558  $tbl = new ilTableGUI();
559 
560  // title & header columns
561  $tbl->setTitle($this->lng->txt("cont_terms"));
562  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
563 
564  $tbl->setHeaderNames(array($this->lng->txt("cont_term")));
565 
566  $cols = array("term");
567  $header_params = $this->ctrl->getParameterArrayByClass("ilobjglossarygui", "listTerms");
568  $header_params["cmd"] = "quickList";
569  $tbl->setHeaderVars($cols, $header_params);
570  $tbl->setColumnWidth(array("100%"));
571 
572  // control
573  $tbl->setOrderColumn($_GET["sort_by"]);
574  $tbl->setOrderDirection($_GET["sort_order"]);
575  $tbl->setLimit($_GET["limit"]);
576  $tbl->setOffset($_GET["offset"]);
577  $tbl->disable("header");
578 
579  $term_list = $this->object->getTermList();
580  $tbl->setMaxCount(count($term_list));
581 
582  $this->tpl->setVariable("COLUMN_COUNT", 1);
583 
584  // footer
585  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
586 
587 
588  // sorting array
589  $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
590 
591  // render table
592  $tbl->render();
593 
594  if (count($term_list) > 0)
595  {
596  $i=1;
597  foreach($term_list as $key => $term)
598  {
600 
601  $sep = ": ";
602  for($j=0; $j<count($defs); $j++)
603  {
604  $def = $defs[$j];
605 
606  // edit
607  $this->tpl->setCurrentBlock("definition");
608  $this->tpl->setVariable("SEP", $sep);
609  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
610  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
611  $this->tpl->setVariable("LINK_EDIT_DEF",
612  $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
613  "iltermdefinitioneditorgui",
614  "ilpageobjectgui"), "edit"));
615  $this->tpl->setVariable("TEXT_DEF", $this->lng->txt("glo_definition_abbr").($j+1));
616  $this->tpl->parseCurrentBlock();
617  $sep = ", ";
618  }
619 
620  $this->tpl->setCurrentBlock("tbl_content");
621  $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
622 
623  // edit term link
624  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
625  $this->ctrl->setParameter($this, "term_id", $term["id"]);
626  $this->tpl->setVariable("LINK_EDIT_TERM",
627  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
628 
629  $this->tpl->setVariable("CSS_ROW", $css_row);
630  $this->tpl->parseCurrentBlock();
631  }
632  } //if is_array
633  else
634  {
635  $this->tpl->setCurrentBlock("notfound");
636  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
637  $this->tpl->setVariable("NUM_COLS", $num);
638  $this->tpl->parseCurrentBlock();
639  }
640  }
641 
642 
646  function listTerms()
647  {
648  global $ilUser;
649 
650  //$this->getTemplate();
651  //$this->setTabs();
652  //$this->setLocator();
653  $this->lng->loadLanguageModule("meta");
654  include_once "./Services/Table/classes/class.ilTableGUI.php";
655 
656 
657  // view button
658  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
659 
660  $this->tpl->setCurrentBlock("btn_cell");
661  $this->tpl->setVariable("BTN_LINK",
662  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID());
663  $this->tpl->setVariable("BTN_TARGET"," target=\"".
664  ilFrameTargetInfo::_getFrame("MainContent")."\" ");
665  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
666  $this->tpl->parseCurrentBlock();
667 
668  // glossary term list template
669  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_list.html", true);
670  $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this, "addTerm"));
671  $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
672  $this->tpl->setVariable("TXT_ADD2", $this->lng->txt("add"));
673  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
675 
676  if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
677  {
678  $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
679  }
680  else
681  {
682  $s_lang = $ilUser->getLanguage();
683  }
684 
685  $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
686  $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
687 
688 
689  // load template for table
690  $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
691 
692  // load template for table content data
693  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_row.html", true);
694 
695  $num = 0;
696 
697  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
698 
699  // create table
700  $tbl = new ilTableGUI();
701 
702  // title & header columns
703  $tbl->setTitle($this->lng->txt("cont_terms"));
704  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
705 
706  $tbl->setHeaderNames(array("", $this->lng->txt("cont_term"),
707  $this->lng->txt("language"), $this->lng->txt("cont_definitions")));
708 
709  $cols = array("", "term", "language", "definitions", "id");
710  // get all ilCtrl parameters to feed the table urls
711  $header_params = $this->ctrl->getParameterArrayByClass("ilobjglossarygui", "listTerms");
712  $tbl->setHeaderVars($cols, $header_params);
713  $tbl->setColumnWidth(array("1%","24%","15%","60%"));
714 
715  // control
716  $tbl->setOrderColumn($_GET["sort_by"]);
717  $tbl->setOrderDirection($_GET["sort_order"]);
718  $tbl->setLimit($_GET["limit"]);
719  $tbl->setOffset($_GET["offset"]);
720  $tbl->disable("sort");
721 
722  $term_list = $this->object->getTermList();
723  $tbl->setMaxCount(count($term_list));
724 
725 //echo "maxcount:".count($term_list).":";
726 //echo "+".$_GET["offset"]."+".$_GET["limit"]."+";
727 
728  $this->setActions(array("confirmTermDeletion" => "delete", "addDefinition" => "cont_add_definition"));
729  //$this->setSubObjects(array("term" => array()));
730 
731  // footer
732  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
733 
734  // sorting array
735  //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
736  $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
737 
738  // render table
739  $tbl->render();
740 
741  if (count($term_list) > 0)
742  {
743  $this->tpl->setVariable("COLUMN_COUNTS", 4);
744  $this->showActions(true);
745 
746  $i=1;
747  foreach($term_list as $key => $term)
748  {
749  $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
751  for($j=0; $j<count($defs); $j++)
752  {
753  $def = $defs[$j];
754 
755  // up
756  if ($j > 0)
757  {
758  $this->tpl->setCurrentBlock("move_up");
759  $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
760  $this->ctrl->setParameter($this, "term_id", $term["id"]);
761  $this->ctrl->setParameter($this, "def", $def["id"]);
762  $this->tpl->setVariable("LINK_UP",
763  $this->ctrl->getLinkTarget($this, "moveDefinitionUp"));
764  $this->tpl->parseCurrentBlock();
765  }
766 
767  // down
768  if ($j+1 < count($defs))
769  {
770  $this->tpl->setCurrentBlock("move_down");
771  $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
772  $this->ctrl->setParameter($this, "term_id", $term["id"]);
773  $this->ctrl->setParameter($this, "def", $def["id"]);
774  $this->tpl->setVariable("LINK_DOWN",
775  $this->ctrl->getLinkTarget($this, "moveDefinitionDown"));
776  $this->tpl->parseCurrentBlock();
777  }
778 
779  // delete
780  $this->tpl->setCurrentBlock("delete");
781  $this->ctrl->setParameter($this, "term_id", $term["id"]);
782  $this->ctrl->setParameter($this, "def", $def["id"]);
783  $this->tpl->setVariable("LINK_DELETE",
784  $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
785  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
786  $this->tpl->parseCurrentBlock();
787 
788  // edit
789  $this->tpl->setCurrentBlock("edit");
790  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
791  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
792  $this->tpl->setVariable("LINK_EDIT",
793  $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
794  "iltermdefinitioneditorgui",
795  "ilpageobjectgui"), "edit"));
796  $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
797  $this->tpl->parseCurrentBlock();
798 
799  // text
800  $this->tpl->setCurrentBlock("definition");
801  $short_str = $def["short_text"];
802 
803  // replace tex
804  // if a tex end tag is missing a tex end tag
805  $ltexs = strrpos($short_str, "[tex]");
806  $ltexe = strrpos($short_str, "[/tex]");
807  if ($ltexs > $ltexe)
808  {
809  $page =& new ilPageObject("gdf", $def["id"]);
810  $page->buildDom();
811  $short_str = $page->getFirstParagraphText();
812  $short_str = strip_tags($short_str, "<br>");
813  $ltexe = strpos($short_str, "[/tex]", $ltexs);
814  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
815  }
816  $short_str = ilUtil::insertLatexImages($short_str);
817  $short_str = ilPCParagraph::xml2output($short_str);
818  $this->tpl->setVariable("DEF_SHORT", $short_str);
819  $this->tpl->parseCurrentBlock();
820 
821  $this->tpl->setCurrentBlock("definition_row");
822  $this->tpl->parseCurrentBlock();
823  }
824 
825  $this->tpl->setCurrentBlock("check_col");
826  $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
827  $this->tpl->setVariable("CSS_ROW", $css_row);
828  $this->tpl->parseCurrentBlock();
829 
830  // edit term link
831  $this->tpl->setCurrentBlock("edit_term");
832  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
833  $this->ctrl->setParameter($this, "term_id", $term["id"]);
834  $this->tpl->setVariable("LINK_EDIT_TERM",
835  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
836  $this->tpl->setVariable("TXT_EDIT_TERM", $this->lng->txt("edit"));
837  $this->tpl->parseCurrentBlock();
838 
839  $this->tpl->setCurrentBlock("tbl_content");
840 
841  // output term and language
842  $this->tpl->setVariable("CSS_ROW", $css_row);
843  $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
844  $this->tpl->setCurrentBlock("tbl_content");
845  $this->tpl->parseCurrentBlock();
846  }
847  } //if is_array
848  else
849  {
850  $this->tpl->setCurrentBlock("notfound");
851  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
852  $this->tpl->setVariable("NUM_COLS", $num);
853  $this->tpl->parseCurrentBlock();
854  }
855  }
856 
860  function addTerm()
861  {
862  // add term
863  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
864  $term =& new ilGlossaryTerm();
865  $term->setGlossary($this->object);
866  $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
867  $term->setLanguage($_POST["term_language"]);
868  $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
869  $term->create();
870 
871  // add first definition
872  $def =& new ilGlossaryDefinition();
873  $def->setTermId($term->getId());
874  $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
875  $def->create();
876 
877  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
878  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
879  $this->ctrl->redirectByClass(array("ilglossarytermgui",
880  "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit");
881  }
882 
886  function moveDefinitionUp()
887  {
888  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
889 
890  $definition =& new ilGlossaryDefinition($_GET["def"]);
891  $definition->moveUp();
892 
893  $this->ctrl->redirect($this, "listTerms");
894  }
895 
900  {
901  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
902 
903  $definition =& new ilGlossaryDefinition($_GET["def"]);
904  $definition->moveDown();
905 
906  $this->ctrl->redirect($this, "listTerms");
907  }
908 
913  {
914  //$this->getTemplate();
915  //$this->displayLocator();
916  //$this->setTabs();
917 
918  $term = new ilGlossaryTerm($_GET["term_id"]);
919 
920  // content style
921  $this->tpl->setCurrentBlock("ContentStyle");
922  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
924  $this->tpl->parseCurrentBlock();
925 
926  // syntax style
927  $this->tpl->setCurrentBlock("SyntaxStyle");
928  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
930  $this->tpl->parseCurrentBlock();
931 
932 
933  //$this->tpl->setVariable("HEADER",
934  // $this->lng->txt("cont_term").": ".$term->getTerm());
935 
936  $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
937  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
938 
939  $this->tpl->setVariable("TXT_TERM", $term->getTerm());
940 
941  $definition =& new ilGlossaryDefinition($_GET["def"]);
942  //$page =& new ilPageObject("gdf", $definition->getId());
943  $page_gui =& new ilPageObjectGUI("gdf", $definition->getId());
944  $page_gui->setTemplateOutput(false);
945  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
946  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
947  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
948  $output = $page_gui->preview();
949 
950  $this->tpl->setCurrentBlock("definition");
951  $this->tpl->setVariable("PAGE_CONTENT", $output);
952  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
953  $this->tpl->setVariable("LINK_CANCEL",
954  $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
955  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
956  $this->ctrl->setParameter($this, "def", $definition->getId());
957  $this->tpl->setVariable("LINK_CONFIRM",
958  $this->ctrl->getLinkTarget($this, "deleteDefinition"));
959  $this->tpl->parseCurrentBlock();
960  }
961 
967  function cancelObject($in_rep = false)
968  {
969  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
970  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
971  //$this->ctrl->redirectByClass("ilrepositorygui", "frameset");
972  }
973 
975  {
976  $this->ctrl->redirect($this, "listTerms");
977  }
978 
979 
980  function deleteDefinition()
981  {
982  $definition =& new ilGlossaryDefinition($_GET["def"]);
983  $definition->delete();
984  $this->ctrl->redirect($this, "listTerms");
985  }
986 
990  function editTerm()
991  {
992  /*
993  $term = new ilGlossaryTerm($_GET["term_id"]);
994  //$this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$term->getTerm());
995 
996  // load template for table
997  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
998  $this->ctrl->setParameter($this, "term_id", $_GET["term_id"]);
999  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1000  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
1001  $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
1002  $this->tpl->setVariable("INPUT_TERM", "term");
1003  $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($term->getTerm()));
1004  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
1005  $lang = ilMDLanguageItem::_getLanguages();
1006  $select_language = ilUtil::formSelect ($term->getLanguage(),"term_language",$lang,false,true);
1007  $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
1008  $this->tpl->setVariable("BTN_NAME", "updateTerm");
1009  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
1010  */
1011  }
1012 
1013 
1017  function updateTerm()
1018  {
1019  $term = new ilGlossaryTerm($_GET["term_id"]);
1020 
1021  $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
1022  $term->setLanguage($_POST["term_language"]);
1023  $term->update();
1024  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
1025  $this->ctrl->redirect($this, "listTerms");
1026  }
1027 
1028 
1029  /*
1030  * list all export files
1031  */
1032  function exportList()
1033  {
1034  global $tree;
1035 
1036  //$this->setTabs();
1037 
1038  //add template for view button
1039  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1040 
1041  // create export file button (xml)
1042  $this->tpl->setCurrentBlock("btn_cell");
1043  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
1044  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
1045  $this->tpl->parseCurrentBlock();
1046 
1047  // create export file button (html)
1048  $this->tpl->setCurrentBlock("btn_cell");
1049  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportHTML"));
1050  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_html"));
1051  $this->tpl->parseCurrentBlock();
1052 
1053  // view last export log button
1054  if (is_file($this->object->getExportDirectory()."/export.log"))
1055  {
1056  $this->tpl->setCurrentBlock("btn_cell");
1057  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
1058  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
1059  $this->tpl->parseCurrentBlock();
1060  }
1061 
1062 
1063  $export_dir = $this->object->getExportDirectory();
1064 
1065  $export_files = $this->object->getExportFiles();
1066 
1067  // create table
1068  require_once("./Services/Table/classes/class.ilTableGUI.php");
1069  $tbl = new ilTableGUI();
1070 
1071  // load files templates
1072  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1073 
1074  // load template for table content data
1075  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.glo_export_file_row.html", true);
1076 
1077  $num = 0;
1078 
1079  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1080 
1081  $tbl->setTitle($this->lng->txt("cont_export_files"));
1082 
1083  $tbl->setHeaderNames(array("", $this->lng->txt("type"),
1084  $this->lng->txt("cont_file"),
1085  $this->lng->txt("cont_size"), $this->lng->txt("date") ));
1086 
1087  $cols = array("", "type", "file", "size", "date");
1088  $header_params = array("ref_id" => $_GET["ref_id"],
1089  "cmd" => "exportList", "cmdClass" => get_class($this));
1090  $tbl->setHeaderVars($cols, $header_params);
1091  $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
1092  $tbl->disable("sort");
1093 
1094  // control
1095  $tbl->setOrderColumn($_GET["sort_by"]);
1096  $tbl->setOrderDirection($_GET["sort_order"]);
1097  $tbl->setLimit($_GET["limit"]);
1098  $tbl->setOffset($_GET["offset"]);
1099  $tbl->setMaxCount($this->maxcount); // ???
1100 
1101  $this->tpl->setVariable("COLUMN_COUNTS", 5);
1102 
1103  // delete button
1104  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1105  $this->tpl->setCurrentBlock("tbl_action_btn");
1106  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
1107  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1108  $this->tpl->parseCurrentBlock();
1109 
1110  $this->tpl->setCurrentBlock("tbl_action_btn");
1111  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
1112  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
1113  $this->tpl->parseCurrentBlock();
1114 
1115  // public access
1116  $this->tpl->setCurrentBlock("tbl_action_btn");
1117  $this->tpl->setVariable("BTN_NAME", "publishExportFile");
1118  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_public_access"));
1119  $this->tpl->parseCurrentBlock();
1120 
1121  // footer
1122  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1123  //$tbl->disable("footer");
1124 
1125  $tbl->setMaxCount(count($export_files));
1126  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
1127 
1128  $tbl->render();
1129  if(count($export_files) > 0)
1130  {
1131  $i=0;
1132  foreach($export_files as $exp_file)
1133  {
1134  $this->tpl->setCurrentBlock("tbl_content");
1135  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
1136 
1137  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1138  $this->tpl->setVariable("CSS_ROW", $css_row);
1139 
1140  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
1141 
1142  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
1143  ? " <b>(".$this->lng->txt("public").")<b>"
1144  : "";
1145  $this->tpl->setVariable("TXT_TYPE", $exp_file["type"].$public_str);
1146  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
1147 
1148  $file_arr = explode("__", $exp_file["file"]);
1149  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
1150 
1151  $this->tpl->parseCurrentBlock();
1152  }
1153  } //if is_array
1154  else
1155  {
1156  $this->tpl->setCurrentBlock("notfound");
1157  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1158  $this->tpl->setVariable("NUM_COLS", 3);
1159  $this->tpl->parseCurrentBlock();
1160  }
1161 
1162  $this->tpl->parseCurrentBlock();
1163  }
1164 
1165 
1169  function export()
1170  {
1171  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1172  $glo_exp = new ilGlossaryExport($this->object);
1173  $glo_exp->buildExportFile();
1174  $this->ctrl->redirect($this, "exportList");
1175  }
1176 
1180  function exportHTML()
1181  {
1182  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1183  $glo_exp = new ilGlossaryExport($this->object, "html");
1184  $glo_exp->buildExportFile();
1185 //echo $this->tpl->get();
1186  $this->ctrl->redirect($this, "exportList");
1187  }
1188 
1189 
1194  {
1195  if(!isset($_POST["file"]))
1196  {
1197  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1198  }
1199 
1200  if (count($_POST["file"]) > 1)
1201  {
1202  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1203  }
1204 
1205  $file = explode(":", $_POST["file"][0]);
1206  $export_dir = $this->object->getExportDirectory($file[0]);
1207  ilUtil::deliverFile($export_dir."/".$file[1],
1208  $file[1]);
1209  }
1210 
1215  {
1216  if(!isset($_POST["file"]))
1217  {
1218  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1219  }
1220  if (count($_POST["file"]) > 1)
1221  {
1222  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1223  }
1224 
1225  $file = explode(":", $_POST["file"][0]);
1226  $export_dir = $this->object->getExportDirectory($file[0]);
1227 
1228  if ($this->object->getPublicExportFile($file[0]) ==
1229  $file[1])
1230  {
1231  $this->object->setPublicExportFile($file[0], "");
1232  }
1233  else
1234  {
1235  $this->object->setPublicExportFile($file[0], $file[1]);
1236  }
1237  $this->object->update();
1238  $this->ctrl->redirect($this, "exportList");
1239  }
1240 
1241  /*
1242  * list all export files
1243  */
1244  function viewExportLog()
1245  {
1246  global $tree;
1247 
1248  $this->setTabs();
1249 
1250  //add template for view button
1251  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1252 
1253  // create export file button
1254  $this->tpl->setCurrentBlock("btn_cell");
1255  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
1256  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
1257  $this->tpl->parseCurrentBlock();
1258 
1259  // load files templates
1260  $this->tpl->setVariable("ADM_CONTENT",
1261  nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
1262 
1263  $this->tpl->parseCurrentBlock();
1264  }
1265 
1270  {
1271  if(!isset($_POST["file"]))
1272  {
1273  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1274  }
1275 
1276  $this->setTabs();
1277 
1278  // SAVE POST VALUES
1279  $_SESSION["ilExportFiles"] = $_POST["file"];
1280 
1281  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Glossary");
1282 
1283  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
1284 
1285  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1286 
1287  // BEGIN TABLE HEADER
1288  $this->tpl->setCurrentBlock("table_header");
1289  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1290  $this->tpl->parseCurrentBlock();
1291 
1292  // BEGIN TABLE DATA
1293  $counter = 0;
1294  foreach($_POST["file"] as $file)
1295  {
1296  $file = explode(":", $file);
1297  $this->tpl->setCurrentBlock("table_row");
1298  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1299  $this->tpl->setVariable("TEXT_CONTENT", $file[1]." (".$file[0].")");
1300  $this->tpl->parseCurrentBlock();
1301  }
1302 
1303  // cancel/confirm button
1304  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1305  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
1306  "deleteExportFile" => $this->lng->txt("confirm"));
1307  foreach ($buttons as $name => $value)
1308  {
1309  $this->tpl->setCurrentBlock("operation_btn");
1310  $this->tpl->setVariable("BTN_NAME",$name);
1311  $this->tpl->setVariable("BTN_VALUE",$value);
1312  $this->tpl->parseCurrentBlock();
1313  }
1314  }
1315 
1320  {
1321  session_unregister("ilExportFiles");
1322  $this->ctrl->redirect($this, "exportList");
1323  }
1324 
1328  function deleteExportFile()
1329  {
1330  foreach($_SESSION["ilExportFiles"] as $file)
1331  {
1332  $file = explode(":", $file);
1333  $export_dir = $this->object->getExportDirectory($file[0]);
1334 
1335  $exp_file = $export_dir."/".$file[1];
1336  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
1337  if (@is_file($exp_file))
1338  {
1339  unlink($exp_file);
1340  }
1341  if (@is_dir($exp_dir))
1342  {
1343  ilUtil::delDir($exp_dir);
1344  }
1345  }
1346  $this->ctrl->redirect($this, "exportList");
1347  }
1348 
1353  {
1354  //$this->prepareOutput();
1355  if (!isset($_POST["id"]))
1356  {
1357  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1358  }
1359 
1360  // save values to
1361  $_SESSION["term_delete"] = $_POST["id"];
1362 
1363  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_confirm.html");
1364 
1365  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
1366  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1367 
1368  // output table header
1369  $cols = array("cont_term");
1370  foreach ($cols as $key)
1371  {
1372  $this->tpl->setCurrentBlock("table_header");
1373  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
1374  $this->tpl->parseCurrentBlock();
1375  }
1376 
1377  foreach($_POST["id"] as $id)
1378  {
1379  $term = new ilGlossaryTerm($id);
1380 
1381  // output title
1382  $this->tpl->setCurrentBlock("table_cell");
1383  $this->tpl->setVariable("TEXT_CONTENT", $term->getTerm());
1384  $this->tpl->parseCurrentBlock();
1385 
1386  // output table row
1387  $this->tpl->setCurrentBlock("table_row");
1388  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1389  $this->tpl->parseCurrentBlock();
1390  }
1391 
1392  // cancel and confirm button
1393  $buttons = array( "cancelTermDeletion" => $this->lng->txt("cancel"),
1394  "deleteTerms" => $this->lng->txt("confirm"));
1395  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1396  foreach($buttons as $name => $value)
1397  {
1398  $this->tpl->setCurrentBlock("operation_btn");
1399  $this->tpl->setVariable("BTN_NAME",$name);
1400  $this->tpl->setVariable("BTN_VALUE",$value);
1401  $this->tpl->parseCurrentBlock();
1402  }
1403 
1404  }
1405 
1412  {
1413  session_unregister("term_delete");
1414  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
1415  $this->ctrl->redirect($this, "listTerms");
1416  }
1417 
1421  function deleteTerms()
1422  {
1423  foreach($_SESSION["term_delete"] as $id)
1424  {
1425  $term = new ilGlossaryTerm($id);
1426  $term->delete();
1427  }
1428  session_unregister("term_delete");
1429  $this->ctrl->redirect($this, "listTerms");
1430  }
1431 
1439  function setLocator($a_tree = "", $a_id = "")
1440  {
1441  global $ilias_locator;
1442 
1443  if(strtolower($_GET["baseClass"]) != "ilglossaryeditorgui")
1444  {
1445  parent::setLocator($a_tree, $a_id);
1446  }
1447  else
1448  {
1449  if(is_object($this->object))
1450  {
1451  require_once("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
1452  $gloss_loc =& new ilGlossaryLocatorGUI();
1453  if (is_object($this->term))
1454  {
1455  $gloss_loc->setTerm($this->term);
1456  }
1457  $gloss_loc->setGlossary($this->object);
1458  //$gloss_loc->setDefinition($this->definition);
1459  $gloss_loc->display();
1460  }
1461  }
1462 
1463  }
1464 
1468  function view()
1469  {
1470  //$this->prepareOutput();
1471  $this->viewObject();
1472  }
1473 
1477  function create()
1478  {
1479  switch($_POST["new_type"])
1480  {
1481  case "term":
1482  $term_gui =& new ilGlossaryTermGUI();
1483  $term_gui->create();
1484  break;
1485  }
1486  }
1487 
1488  function saveTerm()
1489  {
1490  $term_gui =& new ilGlossaryTermGUI();
1491  $term_gui->setGlossary($this->object);
1492  $term_gui->save();
1493 
1494  ilUtil::sendInfo($this->lng->txt("cont_added_term"),true);
1495 
1496  //ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
1497  $ilCtrl->redirect($this, "listTerms");
1498  }
1499 
1500 
1504  function addDefinition()
1505  {
1506  if (count($_POST["id"]) < 1)
1507  {
1508  $this->ilias->raiseError($this->lng->txt("cont_select_term"),$this->ilias->error_obj->MESSAGE);
1509  }
1510 
1511  if (count($_POST["id"]) > 1)
1512  {
1513  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_term"),$this->ilias->error_obj->MESSAGE);
1514  }
1515 
1516  // add term
1517  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1518  $term =& new ilGlossaryTerm($_POST["id"][0]);
1519 
1520  // add first definition
1521  $def =& new ilGlossaryDefinition();
1522  $def->setTermId($term->getId());
1523  $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
1524  $def->create();
1525 
1526  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
1527  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
1528  $this->ctrl->redirectByClass(array("ilglossarytermgui",
1529  "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit");
1530 
1531  }
1532 
1533  function getTemplate()
1534  {
1535  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1536  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1537 
1538  $title = $this->object->getTitle();
1539 
1540  // catch feedback message
1541  ilUtil::sendInfo();
1542 
1543  if ($_GET["term_id"] > 0)
1544  {
1545  //$this->tpl->setCurrentBlock("header_image");
1546  //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
1547  //$this->tpl->parseCurrentBlock();
1548  $this->tpl->setVariable("HEADER", $this->lng->txt("term").": ".
1550  }
1551  else
1552  {
1553  $this->tpl->setCurrentBlock("header_image");
1554  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
1555  $this->tpl->parseCurrentBlock();
1556  $this->tpl->setVariable("HEADER", $this->lng->txt("glo").": ".$title);
1557  }
1558 
1559  //$this->setAdminTabs($_POST["new_type"]);
1560  //$this->setLocator();
1561 
1562  }
1563 
1567  function setTabs()
1568  {
1569 
1570  // catch feedback message
1571  #include_once("classes/class.ilTabsGUI.php");
1572  #$tabs_gui =& new ilTabsGUI();
1573  $this->getTabs($this->tabs_gui);
1574 
1575  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
1576 
1577  }
1578 
1582  function getTabs(&$tabs_gui)
1583  {
1584  global $rbacsystem;
1585 
1586  // list terms
1587  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "listTerms")
1588  ? true
1589  : false;
1590  $tabs_gui->addTarget("cont_terms",
1591  $this->ctrl->getLinkTarget($this, "listTerms"), array("listTerms", ""),
1592  get_class($this), "", $force_active);
1593 
1594  $force_active = false;
1595  if ($this->ctrl->getCmd() == "showSummary" ||
1596  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui")
1597  {
1598  $force_active = true;
1599  }
1600  $tabs_gui->addTarget("information_abbr",
1601  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
1602  "ilInfoScreenGUI", "", $force_active);
1603 
1604 
1605  // properties
1606  $tabs_gui->addTarget("properties",
1607  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1608  get_class($this));
1609 
1610  // meta data
1611  $tabs_gui->addTarget("meta_data",
1612  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1613  "", "ilmdeditorgui");
1614 
1615  // export
1616  $tabs_gui->addTarget("export",
1617  $this->ctrl->getLinkTarget($this, "exportList"),
1618  array("exportList", "viewExportLog"), get_class($this));
1619 
1620  // permissions
1621  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1622  {
1623  /*$tabs_gui->addTarget("permission_settings",
1624  $this->ctrl->getLinkTarget($this, "perm"),
1625  array("perm", "info"),
1626  get_class($this));
1627  */
1628  $tabs_gui->addTarget("perm_settings",
1629  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1630 
1631  }
1632  }
1633 
1639  function _goto($a_target)
1640  {
1641  global $rbacsystem, $ilErr, $lng, $ilAccess;
1642 
1643  if ($ilAccess->checkAccess("read", "", $a_target))
1644  {
1645  $_GET["ref_id"] = $a_target;
1646  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1647  include("ilias.php");
1648  exit;
1649  }
1650  else if ($ilAccess->checkAccess("visible", "", $a_target))
1651  {
1652  $_GET["ref_id"] = $a_target;
1653  $_GET["cmd"] = "infoScreen";
1654  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1655  include("ilias.php");
1656  exit;
1657  }
1658  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1659  {
1660  $_GET["cmd"] = "frameset";
1661  $_GET["target"] = "";
1662  $_GET["ref_id"] = ROOT_FOLDER_ID;
1663  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1664  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1665  include("repository.php");
1666  exit;
1667  }
1668 
1669  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1670  }
1671 
1672 }
1673 
1674 ?>