ILIAS  Release_4_0_x_branch Revision 61816
 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-2009 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("Services/AccessControl/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::sendSuccess($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::sendSuccess($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::sendSuccess($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  // footer
726  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
727 
728  // sorting array
729  //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
730  $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
731 
732  // render table
733  $tbl->render();
734 
735  if (count($term_list) > 0)
736  {
737  $this->tpl->setVariable("COLUMN_COUNTS", 4);
738  $this->showActions(array("confirmTermDeletion" => "delete", "addDefinition" => "cont_add_definition"));
739 
740  $i=1;
741  foreach($term_list as $key => $term)
742  {
743  $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
745  for($j=0; $j<count($defs); $j++)
746  {
747  $def = $defs[$j];
748 
749  // up
750  if ($j > 0)
751  {
752  $this->tpl->setCurrentBlock("move_up");
753  $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
754  $this->ctrl->setParameter($this, "term_id", $term["id"]);
755  $this->ctrl->setParameter($this, "def", $def["id"]);
756  $this->tpl->setVariable("LINK_UP",
757  $this->ctrl->getLinkTarget($this, "moveDefinitionUp"));
758  $this->tpl->parseCurrentBlock();
759  }
760 
761  // down
762  if ($j+1 < count($defs))
763  {
764  $this->tpl->setCurrentBlock("move_down");
765  $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
766  $this->ctrl->setParameter($this, "term_id", $term["id"]);
767  $this->ctrl->setParameter($this, "def", $def["id"]);
768  $this->tpl->setVariable("LINK_DOWN",
769  $this->ctrl->getLinkTarget($this, "moveDefinitionDown"));
770  $this->tpl->parseCurrentBlock();
771  }
772 
773  // delete
774  $this->tpl->setCurrentBlock("delete");
775  $this->ctrl->setParameter($this, "term_id", $term["id"]);
776  $this->ctrl->setParameter($this, "def", $def["id"]);
777  $this->tpl->setVariable("LINK_DELETE",
778  $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
779  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
780  $this->tpl->parseCurrentBlock();
781 
782  // edit
783  $this->tpl->setCurrentBlock("edit");
784  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
785  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
786  $this->tpl->setVariable("LINK_EDIT",
787  $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
788  "iltermdefinitioneditorgui",
789  "ilpageobjectgui"), "edit"));
790  $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
791  $this->tpl->parseCurrentBlock();
792 
793  // text
794  $this->tpl->setCurrentBlock("definition");
795  $short_str = $def["short_text"];
796 
797  // replace tex
798  // if a tex end tag is missing a tex end tag
799  $ltexs = strrpos($short_str, "[tex]");
800  $ltexe = strrpos($short_str, "[/tex]");
801  if ($ltexs > $ltexe)
802  {
803  $page =& new ilPageObject("gdf", $def["id"]);
804  $page->buildDom();
805  $short_str = $page->getFirstParagraphText();
806  $short_str = strip_tags($short_str, "<br>");
807  $ltexe = strpos($short_str, "[/tex]", $ltexs);
808  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
809  }
810  $short_str = ilUtil::insertLatexImages($short_str);
811  $short_str = ilPCParagraph::xml2output($short_str);
812  $this->tpl->setVariable("DEF_SHORT", $short_str);
813  $this->tpl->parseCurrentBlock();
814 
815  $this->tpl->setCurrentBlock("definition_row");
816  $this->tpl->parseCurrentBlock();
817  }
818 
819  $this->tpl->setCurrentBlock("check_col");
820  $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
821  $this->tpl->setVariable("CSS_ROW", $css_row);
822  $this->tpl->parseCurrentBlock();
823 
824  // edit term link
825  $this->tpl->setCurrentBlock("edit_term");
826  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
827  $this->ctrl->setParameter($this, "term_id", $term["id"]);
828  $this->tpl->setVariable("LINK_EDIT_TERM",
829  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
830  $this->tpl->setVariable("TXT_EDIT_TERM", $this->lng->txt("edit"));
831  $this->tpl->parseCurrentBlock();
832 
833  $this->tpl->setCurrentBlock("tbl_content");
834 
835  // output term and language
836  $this->tpl->setVariable("CSS_ROW", $css_row);
837  $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
838  $this->tpl->setCurrentBlock("tbl_content");
839  $this->tpl->parseCurrentBlock();
840  }
841  } //if is_array
842  else
843  {
844  $this->tpl->setCurrentBlock("notfound");
845  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
846  $this->tpl->setVariable("NUM_COLS", $num);
847  $this->tpl->parseCurrentBlock();
848  }
849  }
850 
856  function showActions($a_actions)
857  {
858  foreach ($a_actions as $name => $lng)
859  {
860  $d[$name] = array("name" => $name, "lng" => $lng);
861  }
862 
863  $notoperations = array();
864  $operations = array();
865 
866  $operations = $d;
867 
868  if (count($operations) > 0)
869  {
870  foreach ($operations as $val)
871  {
872  $this->tpl->setCurrentBlock("tbl_action_btn");
873  $this->tpl->setVariable("BTN_NAME", $val["name"]);
874  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
875  $this->tpl->parseCurrentBlock();
876  }
877 
878  $this->tpl->setCurrentBlock("tbl_action_row");
879  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
880  $this->tpl->parseCurrentBlock();
881  }
882  }
883 
887  function addTerm()
888  {
889  global $lng, $ilCtrl;
890 
891  if (trim($_POST["new_term"]) == "")
892  {
893  ilUtil::sendFailure($lng->txt("cont_please_enter_a_term"), true);
894  $ilCtrl->redirect($this, "listTerms");
895  }
896 
897  // add term
898  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
899  $term =& new ilGlossaryTerm();
900  $term->setGlossary($this->object);
901  $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
902  $term->setLanguage($_POST["term_language"]);
903  $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
904  $term->create();
905 
906  // add first definition
907  $def =& new ilGlossaryDefinition();
908  $def->setTermId($term->getId());
909  $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
910  $def->create();
911 
912  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
913  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
914  $this->ctrl->redirectByClass(array("ilglossarytermgui",
915  "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit");
916  }
917 
921  function moveDefinitionUp()
922  {
923  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
924 
925  $definition =& new ilGlossaryDefinition($_GET["def"]);
926  $definition->moveUp();
927 
928  $this->ctrl->redirect($this, "listTerms");
929  }
930 
935  {
936  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
937 
938  $definition =& new ilGlossaryDefinition($_GET["def"]);
939  $definition->moveDown();
940 
941  $this->ctrl->redirect($this, "listTerms");
942  }
943 
948  {
949  //$this->getTemplate();
950  //$this->displayLocator();
951  //$this->setTabs();
952 
953  $term = new ilGlossaryTerm($_GET["term_id"]);
954 
955  // content style
956  $this->tpl->setCurrentBlock("ContentStyle");
957  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
959  $this->tpl->parseCurrentBlock();
960 
961  // syntax style
962  $this->tpl->setCurrentBlock("SyntaxStyle");
963  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
965  $this->tpl->parseCurrentBlock();
966 
967 
968  //$this->tpl->setVariable("HEADER",
969  // $this->lng->txt("cont_term").": ".$term->getTerm());
970 
971  $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
972  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
973 
974  $this->tpl->setVariable("TXT_TERM", $term->getTerm());
975 
976  $definition =& new ilGlossaryDefinition($_GET["def"]);
977  //$page =& new ilPageObject("gdf", $definition->getId());
978  $page_gui =& new ilPageObjectGUI("gdf", $definition->getId());
979  $page_gui->setTemplateOutput(false);
980  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
981  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
982  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
983  $output = $page_gui->preview();
984 
985  $this->tpl->setCurrentBlock("definition");
986  $this->tpl->setVariable("PAGE_CONTENT", $output);
987  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
988  $this->tpl->setVariable("LINK_CANCEL",
989  $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
990  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
991  $this->ctrl->setParameter($this, "def", $definition->getId());
992  $this->tpl->setVariable("LINK_CONFIRM",
993  $this->ctrl->getLinkTarget($this, "deleteDefinition"));
994  $this->tpl->parseCurrentBlock();
995  }
996 
1002  function cancelObject($in_rep = false)
1003  {
1004  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
1005  //$this->ctrl->redirectByClass("ilrepositorygui", "frameset");
1006  }
1007 
1009  {
1010  $this->ctrl->redirect($this, "listTerms");
1011  }
1012 
1013 
1014  function deleteDefinition()
1015  {
1016  $definition =& new ilGlossaryDefinition($_GET["def"]);
1017  $definition->delete();
1018  $this->ctrl->redirect($this, "listTerms");
1019  }
1020 
1024  function editTerm()
1025  {
1026  /*
1027  $term = new ilGlossaryTerm($_GET["term_id"]);
1028  //$this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$term->getTerm());
1029 
1030  // load template for table
1031  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
1032  $this->ctrl->setParameter($this, "term_id", $_GET["term_id"]);
1033  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1034  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
1035  $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
1036  $this->tpl->setVariable("INPUT_TERM", "term");
1037  $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($term->getTerm()));
1038  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
1039  $lang = ilMDLanguageItem::_getLanguages();
1040  $select_language = ilUtil::formSelect ($term->getLanguage(),"term_language",$lang,false,true);
1041  $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
1042  $this->tpl->setVariable("BTN_NAME", "updateTerm");
1043  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
1044  */
1045  }
1046 
1047 
1051  function updateTerm()
1052  {
1053  $term = new ilGlossaryTerm($_GET["term_id"]);
1054 
1055  $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
1056  $term->setLanguage($_POST["term_language"]);
1057  $term->update();
1058  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1059  $this->ctrl->redirect($this, "listTerms");
1060  }
1061 
1062 
1063  /*
1064  * list all export files
1065  */
1066  function exportList()
1067  {
1068  global $tree;
1069 
1070  //$this->setTabs();
1071 
1072  //add template for view button
1073  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1074 
1075  // create export file button (xml)
1076  $this->tpl->setCurrentBlock("btn_cell");
1077  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
1078  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
1079  $this->tpl->parseCurrentBlock();
1080 
1081  // create export file button (html)
1082  $this->tpl->setCurrentBlock("btn_cell");
1083  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportHTML"));
1084  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_html"));
1085  $this->tpl->parseCurrentBlock();
1086 
1087  // view last export log button
1088  if (is_file($this->object->getExportDirectory()."/export.log"))
1089  {
1090  $this->tpl->setCurrentBlock("btn_cell");
1091  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
1092  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
1093  $this->tpl->parseCurrentBlock();
1094  }
1095 
1096 
1097  $export_dir = $this->object->getExportDirectory();
1098 
1099  $export_files = $this->object->getExportFiles();
1100 
1101  // create table
1102  require_once("./Services/Table/classes/class.ilTableGUI.php");
1103  $tbl = new ilTableGUI();
1104 
1105  // load files templates
1106  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1107 
1108  // load template for table content data
1109  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.glo_export_file_row.html", true);
1110 
1111  $num = 0;
1112 
1113  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1114 
1115  $tbl->setTitle($this->lng->txt("cont_export_files"));
1116 
1117  $tbl->setHeaderNames(array("", $this->lng->txt("type"),
1118  $this->lng->txt("cont_file"),
1119  $this->lng->txt("cont_size"), $this->lng->txt("date") ));
1120 
1121  $cols = array("", "type", "file", "size", "date");
1122  $header_params = array("ref_id" => $_GET["ref_id"],
1123  "cmd" => "exportList", "cmdClass" => get_class($this));
1124  $tbl->setHeaderVars($cols, $header_params);
1125  $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
1126  $tbl->disable("sort");
1127 
1128  // control
1129  $tbl->setOrderColumn($_GET["sort_by"]);
1130  $tbl->setOrderDirection($_GET["sort_order"]);
1131  $tbl->setLimit($_GET["limit"]);
1132  $tbl->setOffset($_GET["offset"]);
1133  $tbl->setMaxCount($this->maxcount); // ???
1134 
1135  $this->tpl->setVariable("COLUMN_COUNTS", 5);
1136 
1137  // delete button
1138  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1139  $this->tpl->setCurrentBlock("tbl_action_btn");
1140  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
1141  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1142  $this->tpl->parseCurrentBlock();
1143 
1144  $this->tpl->setCurrentBlock("tbl_action_btn");
1145  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
1146  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
1147  $this->tpl->parseCurrentBlock();
1148 
1149  // public access
1150  $this->tpl->setCurrentBlock("tbl_action_btn");
1151  $this->tpl->setVariable("BTN_NAME", "publishExportFile");
1152  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_public_access"));
1153  $this->tpl->parseCurrentBlock();
1154 
1155  // footer
1156  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1157  //$tbl->disable("footer");
1158 
1159  $tbl->setMaxCount(count($export_files));
1160  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
1161 
1162  $tbl->render();
1163  if(count($export_files) > 0)
1164  {
1165  $i=0;
1166  foreach($export_files as $exp_file)
1167  {
1168  $this->tpl->setCurrentBlock("tbl_content");
1169  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
1170 
1171  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1172  $this->tpl->setVariable("CSS_ROW", $css_row);
1173 
1174  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
1175 
1176  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
1177  ? " <b>(".$this->lng->txt("public").")<b>"
1178  : "";
1179  $this->tpl->setVariable("TXT_TYPE", $exp_file["type"].$public_str);
1180  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
1181 
1182  $file_arr = explode("__", $exp_file["file"]);
1183  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
1184 
1185  $this->tpl->parseCurrentBlock();
1186  }
1187  } //if is_array
1188  else
1189  {
1190  $this->tpl->setCurrentBlock("notfound");
1191  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1192  $this->tpl->setVariable("NUM_COLS", 3);
1193  $this->tpl->parseCurrentBlock();
1194  }
1195 
1196  $this->tpl->parseCurrentBlock();
1197  }
1198 
1199 
1203  function export()
1204  {
1205  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1206  $glo_exp = new ilGlossaryExport($this->object);
1207  $glo_exp->buildExportFile();
1208  $this->ctrl->redirect($this, "exportList");
1209  }
1210 
1214  function exportHTML()
1215  {
1216  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1217  $glo_exp = new ilGlossaryExport($this->object, "html");
1218  $glo_exp->buildExportFile();
1219 //echo $this->tpl->get();
1220  $this->ctrl->redirect($this, "exportList");
1221  }
1222 
1223 
1228  {
1229  if(!isset($_POST["file"]))
1230  {
1231  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1232  }
1233 
1234  if (count($_POST["file"]) > 1)
1235  {
1236  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1237  }
1238 
1239  $file = explode(":", $_POST["file"][0]);
1240  $export_dir = $this->object->getExportDirectory($file[0]);
1241  ilUtil::deliverFile($export_dir."/".$file[1],
1242  $file[1]);
1243  }
1244 
1249  {
1250  if(!isset($_POST["file"]))
1251  {
1252  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1253  }
1254  if (count($_POST["file"]) > 1)
1255  {
1256  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1257  }
1258 
1259  $file = explode(":", $_POST["file"][0]);
1260  $export_dir = $this->object->getExportDirectory($file[0]);
1261 
1262  if ($this->object->getPublicExportFile($file[0]) ==
1263  $file[1])
1264  {
1265  $this->object->setPublicExportFile($file[0], "");
1266  }
1267  else
1268  {
1269  $this->object->setPublicExportFile($file[0], $file[1]);
1270  }
1271  $this->object->update();
1272  $this->ctrl->redirect($this, "exportList");
1273  }
1274 
1275  /*
1276  * list all export files
1277  */
1278  function viewExportLog()
1279  {
1280  global $tree;
1281 
1282  $this->setTabs();
1283 
1284  //add template for view button
1285  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1286 
1287  // create export file button
1288  $this->tpl->setCurrentBlock("btn_cell");
1289  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
1290  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
1291  $this->tpl->parseCurrentBlock();
1292 
1293  // load files templates
1294  $this->tpl->setVariable("ADM_CONTENT",
1295  nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
1296 
1297  $this->tpl->parseCurrentBlock();
1298  }
1299 
1304  {
1305  if(!isset($_POST["file"]))
1306  {
1307  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1308  }
1309 
1310  $this->setTabs();
1311 
1312  // SAVE POST VALUES
1313  $_SESSION["ilExportFiles"] = $_POST["file"];
1314 
1315  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Glossary");
1316 
1317  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1318 
1319  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1320 
1321  // BEGIN TABLE HEADER
1322  $this->tpl->setCurrentBlock("table_header");
1323  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1324  $this->tpl->parseCurrentBlock();
1325 
1326  // BEGIN TABLE DATA
1327  $counter = 0;
1328  foreach($_POST["file"] as $file)
1329  {
1330  $file = explode(":", $file);
1331  $this->tpl->setCurrentBlock("table_row");
1332  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1333  $this->tpl->setVariable("TEXT_CONTENT", $file[1]." (".$file[0].")");
1334  $this->tpl->parseCurrentBlock();
1335  }
1336 
1337  // cancel/confirm button
1338  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1339  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
1340  "deleteExportFile" => $this->lng->txt("confirm"));
1341  foreach ($buttons as $name => $value)
1342  {
1343  $this->tpl->setCurrentBlock("operation_btn");
1344  $this->tpl->setVariable("BTN_NAME",$name);
1345  $this->tpl->setVariable("BTN_VALUE",$value);
1346  $this->tpl->parseCurrentBlock();
1347  }
1348  }
1349 
1354  {
1355  session_unregister("ilExportFiles");
1356  $this->ctrl->redirect($this, "exportList");
1357  }
1358 
1362  function deleteExportFile()
1363  {
1364  foreach($_SESSION["ilExportFiles"] as $file)
1365  {
1366  $file = explode(":", $file);
1367  $export_dir = $this->object->getExportDirectory($file[0]);
1368 
1369  $exp_file = $export_dir."/".$file[1];
1370  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
1371  if (@is_file($exp_file))
1372  {
1373  unlink($exp_file);
1374  }
1375  if (@is_dir($exp_dir))
1376  {
1377  ilUtil::delDir($exp_dir);
1378  }
1379  }
1380  $this->ctrl->redirect($this, "exportList");
1381  }
1382 
1387  {
1388  //$this->prepareOutput();
1389  if (!isset($_POST["id"]))
1390  {
1391  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1392  }
1393 
1394  // save values to
1395  $_SESSION["term_delete"] = $_POST["id"];
1396 
1397  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_confirm.html");
1398 
1399  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1400  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1401 
1402  // output table header
1403  $cols = array("cont_term");
1404  foreach ($cols as $key)
1405  {
1406  $this->tpl->setCurrentBlock("table_header");
1407  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
1408  $this->tpl->parseCurrentBlock();
1409  }
1410 
1411  foreach($_POST["id"] as $id)
1412  {
1413  $term = new ilGlossaryTerm($id);
1414 
1415  // output title
1416  $this->tpl->setCurrentBlock("table_cell");
1417  $this->tpl->setVariable("TEXT_CONTENT", $term->getTerm());
1418  $this->tpl->parseCurrentBlock();
1419 
1420  // output table row
1421  $this->tpl->setCurrentBlock("table_row");
1422  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1423  $this->tpl->parseCurrentBlock();
1424  }
1425 
1426  // cancel and confirm button
1427  $buttons = array( "cancelTermDeletion" => $this->lng->txt("cancel"),
1428  "deleteTerms" => $this->lng->txt("confirm"));
1429  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1430  foreach($buttons as $name => $value)
1431  {
1432  $this->tpl->setCurrentBlock("operation_btn");
1433  $this->tpl->setVariable("BTN_NAME",$name);
1434  $this->tpl->setVariable("BTN_VALUE",$value);
1435  $this->tpl->parseCurrentBlock();
1436  }
1437 
1438  }
1439 
1446  {
1447  session_unregister("term_delete");
1448  $this->ctrl->redirect($this, "listTerms");
1449  }
1450 
1454  function deleteTerms()
1455  {
1456  foreach($_SESSION["term_delete"] as $id)
1457  {
1458  $term = new ilGlossaryTerm($id);
1459  $term->delete();
1460  }
1461  session_unregister("term_delete");
1462  $this->ctrl->redirect($this, "listTerms");
1463  }
1464 
1472  function setLocator($a_tree = "", $a_id = "")
1473  {
1474  global $ilias_locator;
1475 
1476  if(strtolower($_GET["baseClass"]) != "ilglossaryeditorgui")
1477  {
1478  parent::setLocator($a_tree, $a_id);
1479  }
1480  else
1481  {
1482  if(is_object($this->object))
1483  {
1484  require_once("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
1485  $gloss_loc =& new ilGlossaryLocatorGUI();
1486  if (is_object($this->term))
1487  {
1488  $gloss_loc->setTerm($this->term);
1489  }
1490  $gloss_loc->setGlossary($this->object);
1491  //$gloss_loc->setDefinition($this->definition);
1492  $gloss_loc->display();
1493  }
1494  }
1495 
1496  }
1497 
1501  function view()
1502  {
1503  //$this->prepareOutput();
1504  $this->viewObject();
1505  }
1506 
1510  function create()
1511  {
1512  switch($_POST["new_type"])
1513  {
1514  case "term":
1515  $term_gui =& new ilGlossaryTermGUI();
1516  $term_gui->create();
1517  break;
1518  }
1519  }
1520 
1521  function saveTerm()
1522  {
1523  $term_gui =& new ilGlossaryTermGUI();
1524  $term_gui->setGlossary($this->object);
1525  $term_gui->save();
1526 
1527  ilUtil::sendSuccess($this->lng->txt("cont_added_term"),true);
1528 
1529  //ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
1530  $ilCtrl->redirect($this, "listTerms");
1531  }
1532 
1533 
1537  function addDefinition()
1538  {
1539  global $ilCtrl;
1540 
1541  if (count($_POST["id"]) < 1)
1542  {
1543  ilUtil::sendFailure($this->lng->txt("cont_select_term"), true);
1544  $ilCtrl->redirect($this, "listTerms");
1545  }
1546 
1547  if (count($_POST["id"]) > 1)
1548  {
1549  ilUtil::sendFailure($this->lng->txt("cont_select_max_one_term"), true);
1550  $ilCtrl->redirect($this, "listTerms");
1551  }
1552 
1553  // add term
1554  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1555  $term =& new ilGlossaryTerm($_POST["id"][0]);
1556 
1557  // add first definition
1558  $def =& new ilGlossaryDefinition();
1559  $def->setTermId($term->getId());
1560  $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
1561  $def->create();
1562 
1563  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
1564  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
1565  $this->ctrl->redirectByClass(array("ilglossarytermgui",
1566  "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit");
1567 
1568  }
1569 
1570  function getTemplate()
1571  {
1572  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1573  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1574 
1575  $title = $this->object->getTitle();
1576 
1577 
1578  if ($_GET["term_id"] > 0)
1579  {
1580  //$this->tpl->setCurrentBlock("header_image");
1581  //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
1582  //$this->tpl->parseCurrentBlock();
1583  $this->tpl->setVariable("HEADER", $this->lng->txt("term").": ".
1585  }
1586  else
1587  {
1588  $this->tpl->setCurrentBlock("header_image");
1589  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
1590  $this->tpl->parseCurrentBlock();
1591  $this->tpl->setVariable("HEADER", $this->lng->txt("glo").": ".$title);
1592  }
1593 
1594  //$this->setAdminTabs($_POST["new_type"]);
1595  //$this->setLocator();
1596 
1597  }
1598 
1602  function setTabs()
1603  {
1604 
1605  // catch feedback message
1606  #include_once("classes/class.ilTabsGUI.php");
1607  #$tabs_gui =& new ilTabsGUI();
1608  $this->getTabs($this->tabs_gui);
1609 
1610  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
1611 
1612  }
1613 
1617  function getTabs(&$tabs_gui)
1618  {
1619  global $rbacsystem;
1620 
1621  // list terms
1622  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "listTerms")
1623  ? true
1624  : false;
1625  $tabs_gui->addTarget("cont_terms",
1626  $this->ctrl->getLinkTarget($this, "listTerms"), array("listTerms", ""),
1627  get_class($this), "", $force_active);
1628 
1629  $force_active = false;
1630  if ($this->ctrl->getCmd() == "showSummary" ||
1631  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui")
1632  {
1633  $force_active = true;
1634  }
1635  $tabs_gui->addTarget("information_abbr",
1636  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
1637  "ilInfoScreenGUI", "", $force_active);
1638 
1639 
1640  // properties
1641  $tabs_gui->addTarget("properties",
1642  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1643  get_class($this));
1644 
1645  // meta data
1646  $tabs_gui->addTarget("meta_data",
1647  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1648  "", "ilmdeditorgui");
1649 
1650  // export
1651  $tabs_gui->addTarget("export",
1652  $this->ctrl->getLinkTarget($this, "exportList"),
1653  array("exportList", "viewExportLog"), get_class($this));
1654 
1655  // permissions
1656  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1657  {
1658  /*$tabs_gui->addTarget("permission_settings",
1659  $this->ctrl->getLinkTarget($this, "perm"),
1660  array("perm", "info"),
1661  get_class($this));
1662  */
1663  $tabs_gui->addTarget("perm_settings",
1664  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1665 
1666  }
1667  }
1668 
1674  function _goto($a_target)
1675  {
1676  global $rbacsystem, $ilErr, $lng, $ilAccess;
1677 
1678  if ($ilAccess->checkAccess("read", "", $a_target))
1679  {
1680  $_GET["ref_id"] = $a_target;
1681  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1682  include("ilias.php");
1683  exit;
1684  }
1685  else if ($ilAccess->checkAccess("visible", "", $a_target))
1686  {
1687  $_GET["ref_id"] = $a_target;
1688  $_GET["cmd"] = "infoScreen";
1689  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1690  include("ilias.php");
1691  exit;
1692  }
1693  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1694  {
1695  $_GET["cmd"] = "frameset";
1696  $_GET["target"] = "";
1697  $_GET["ref_id"] = ROOT_FOLDER_ID;
1698  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1699  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1700  include("repository.php");
1701  exit;
1702  }
1703 
1704  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1705  }
1706 
1707 }
1708 
1709 ?>