00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
00025
00036 class ilGlossaryTermGUI
00037 {
00038 var $ilias;
00039 var $lng;
00040 var $tpl;
00041 var $glossary;
00042 var $term;
00043 var $link_xml;
00044
00049 function ilGlossaryTermGUI($a_id = 0)
00050 {
00051 global $lng, $ilias, $tpl, $ilCtrl;
00052
00053 $this->lng =& $lng;
00054 $this->ilias =& $ilias;
00055 $this->tpl =& $tpl;
00056 $this->ctrl =& $ilCtrl;
00057 $this->ctrl->saveParameter($this, array("term_id"));
00058
00059 if($a_id != 0)
00060 {
00061 $this->term =& new ilGlossaryTerm($a_id);
00062 }
00063 }
00064
00068 function executeCommand()
00069 {
00070 $next_class = $this->ctrl->getNextClass($this);
00071 $cmd = $this->ctrl->getCmd();
00072
00073 switch ($next_class)
00074 {
00075
00076 case "iltermdefinitioneditorgui":
00077
00078 $def_edit =& new ilTermDefinitionEditorGUI();
00079
00080 $ret =& $this->ctrl->forwardCommand($def_edit);
00081 break;
00082
00083 default:
00084 $ret =& $this->$cmd();
00085 break;
00086 }
00087 }
00088
00094 function setOfflineDirectory ($offdir) {
00095 $this->offline_directory = $offdir;
00096 }
00097
00098
00103 function getOfflineDirectory () {
00104 return $this->offline_directory;
00105 }
00106
00107
00108 function setGlossary(&$a_glossary)
00109 {
00110 $this->glossary =& $a_glossary;
00111 }
00112
00113 function setLinkXML($a_link_xml)
00114 {
00115 $this->link_xml = $a_link_xml;
00116 }
00117
00118 function getLinkXML()
00119 {
00120 return $this->link_xml;
00121 }
00122
00126 function create()
00127 {
00128 global $ilUser;
00129
00130 $this->getTemplate();
00131 $this->displayLocator();
00132 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_new_term"));
00133 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00134 $this->setTabs();
00135
00136
00137 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_new.html", true);
00138 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00139 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_new_term"));
00140 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00141 $this->tpl->setVariable("INPUT_TERM", "term");
00142 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00143 $lang = ilMDLanguageItem::_getLanguages();
00144
00145 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00146 {
00147 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00148 }
00149 else
00150 {
00151 $s_lang = $ilUser->getLanguage();
00152 }
00153
00154 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00155 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00156 $this->tpl->setVariable("BTN_NAME", "saveTerm");
00157 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00158 }
00159
00163 function saveTerm()
00164 {
00165 $term =& new ilGlossaryTerm();
00166 $term->setGlossary($this->glossary);
00167 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00168 $term->setLanguage($_POST["term_language"]);
00169 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00170 $term->create();
00171
00172 ilUtil::sendInfo($this->lng->txt("cont_added_term"),true);
00173 $this->ctrl->returnToParent($this);
00174 }
00175
00176
00180 function editTerm()
00181 {
00182
00183 $this->getTemplate();
00184 $this->displayLocator();
00185 $this->setTabs();
00186
00187 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00188 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00189
00190
00191 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00192 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "updateTerm"));
00193 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00194 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00195 $this->tpl->setVariable("INPUT_TERM", "term");
00196 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($this->term->getTerm()));
00197 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00198 $lang = ilMDLanguageItem::_getLanguages();
00199 $select_language = ilUtil::formSelect ($this->term->getLanguage(),"term_language",$lang,false,true);
00200 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00201 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00202 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00203 }
00204
00205
00209 function updateTerm()
00210 {
00211 $this->term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00212 $this->term->setLanguage($_POST["term_language"]);
00213 $this->term->update();
00214 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
00215 $this->ctrl->redirect($this, "editTerm");
00216 }
00217
00223 function output($a_offline = false)
00224 {
00225 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
00226 require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00227
00228 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00229
00230 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00231
00232 for($j=0; $j<count($defs); $j++)
00233 {
00234 $def = $defs[$j];
00235 $page =& new ilPageObject("gdf", $def["id"]);
00236 $page_gui =& new ilPageObjectGUI($page);
00237 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"]);
00238 if (!$a_offline)
00239 {
00240 $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&cmd=fullscreen&ref_id=".$_GET["ref_id"]);
00241 }
00242 else
00243 {
00244 $page_gui->setFullscreenLink("fullscreen.html");
00245 }
00246 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&cmd=downloadFile&ref_id=".$_GET["ref_id"]);
00247
00248 if (!$a_offline)
00249 {
00250 $page_gui->setOutputMode("presentation");
00251 }
00252 else
00253 {
00254 $page_gui->setOutputMode("offline");
00255 $page_gui->setOfflineDirectory($this->getOfflineDirectory());
00256 }
00257
00258
00259
00260 $page_gui->setLinkXML($this->getLinkXML());
00261 $page_gui->setTemplateOutput(false);
00262 $output = $page_gui->presentation($page_gui->getOutputMode());
00263
00264 if (count($defs) > 1)
00265 {
00266 $this->tpl->setCurrentBlock("definition_header");
00267 $this->tpl->setVariable("TXT_DEFINITION",
00268 $this->lng->txt("cont_definition")." ".($j+1));
00269 $this->tpl->parseCurrentBlock();
00270 }
00271
00272 $this->tpl->setCurrentBlock("definition");
00273 $this->tpl->setVariable("PAGE_CONTENT", $output);
00274 $this->tpl->parseCurrentBlock();
00275 }
00276 }
00277
00281 function getInternalLinks()
00282 {
00283 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
00284 require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00285
00286 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00287
00288 $term_links = array();
00289 for($j=0; $j<count($defs); $j++)
00290 {
00291 $def = $defs[$j];
00292 $page =& new ilPageObject("gdf", $def["id"]);
00293 $page->buildDom();
00294 $page_links = $page->getInternalLinks();
00295 foreach($page_links as $key => $page_link)
00296 {
00297 $term_links[$key] = $page_link;
00298 }
00299 }
00300
00301 return $term_links;
00302 }
00303
00307 function listDefinitions()
00308 {
00309 $this->getTemplate();
00310 $this->displayLocator();
00311 $this->setTabs();
00312
00313 require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00314
00315
00316 $this->tpl->setCurrentBlock("ContentStyle");
00317 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00318 ilObjStyleSheet::getContentStylePath(0));
00319 $this->tpl->parseCurrentBlock();
00320
00321
00322 $this->tpl->setCurrentBlock("SyntaxStyle");
00323 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00324 ilObjStyleSheet::getSyntaxStylePath());
00325 $this->tpl->parseCurrentBlock();
00326
00327
00328 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", true);
00329
00330
00331 $this->tpl->addBlockfile("STATUSLINE", "statusline", "tpl.statusline.html");
00332 $this->tpl->setVariable("HEADER",
00333 $this->lng->txt("cont_term").": ".$this->term->getTerm());
00334 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00335
00336 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00337
00338 $this->tpl->setCurrentBlock("add_def");
00339 $this->tpl->setVariable("TXT_ADD_DEFINITION",
00340 $this->lng->txt("cont_add_definition"));
00341 $this->tpl->setVariable("BTN_ADD", "addDefinition");
00342 $this->tpl->parseCurrentBlock();
00343 $this->tpl->setCurrentBlock("def_list");
00344
00345 $defs = ilGlossaryDefinition::getDefinitionList($_GET["term_id"]);
00346
00347 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00348
00349 for($j=0; $j<count($defs); $j++)
00350 {
00351 $def = $defs[$j];
00352 $page =& new ilPageObject("gdf", $def["id"]);
00353 $page_gui =& new ilPageObjectGUI($page);
00354 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"]);
00355 $page_gui->setTemplateOutput(false);
00356 $output = $page_gui->preview();
00357
00358 if (count($defs) > 1)
00359 {
00360 $this->tpl->setCurrentBlock("definition_header");
00361 $this->tpl->setVariable("TXT_DEFINITION",
00362 $this->lng->txt("cont_definition")." ".($j+1));
00363 $this->tpl->parseCurrentBlock();
00364 }
00365
00366 if ($j > 0)
00367 {
00368 $this->tpl->setCurrentBlock("up");
00369 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00370 $this->ctrl->setParameter($this, "def", $def["id"]);
00371 $this->tpl->setVariable("LINK_UP",
00372 $this->ctrl->getLinkTarget($this, "moveUp"));
00373 $this->tpl->parseCurrentBlock();
00374 }
00375
00376 if ($j+1 < count($defs))
00377 {
00378 $this->tpl->setCurrentBlock("down");
00379 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00380 $this->ctrl->setParameter($this, "def", $def["id"]);
00381 $this->tpl->setVariable("LINK_DOWN",
00382 $this->ctrl->getLinkTarget($this, "moveDown"));
00383 $this->tpl->parseCurrentBlock();
00384 }
00385 $this->tpl->setCurrentBlock("submit_btns");
00386 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00387 $this->ctrl->setParameter($this, "def", $def["id"]);
00388 $this->ctrl->setParameterByClass("ilTermDefinitionEditorGUI", "def", $def["id"]);
00389 $this->tpl->setVariable("LINK_EDIT",
00390 $this->ctrl->getLinkTargetByClass(array("ilTermDefinitionEditorGUI", "ilPageObjectGUI"), "view"));
00391 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00392 $this->tpl->setVariable("LINK_DELETE",
00393 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00394 $this->tpl->parseCurrentBlock();
00395
00396 $this->tpl->setCurrentBlock("definition");
00397 $this->tpl->setVariable("PAGE_CONTENT", $output);
00398 $this->tpl->parseCurrentBlock();
00399 }
00400
00401
00402
00403 }
00404
00405
00409 function confirmDefinitionDeletion()
00410 {
00411 $this->getTemplate();
00412 $this->displayLocator();
00413 $this->setTabs();
00414
00415
00416 $this->tpl->setCurrentBlock("ContentStyle");
00417 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00418 ilObjStyleSheet::getContentStylePath(0));
00419 $this->tpl->parseCurrentBlock();
00420
00421
00422 $this->tpl->setCurrentBlock("SyntaxStyle");
00423 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00424 ilObjStyleSheet::getSyntaxStylePath());
00425 $this->tpl->parseCurrentBlock();
00426
00427 $this->tpl->setVariable("HEADER",
00428 $this->lng->txt("cont_term").": ".$this->term->getTerm());
00429 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00430
00431 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00432 ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
00433
00434 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00435
00436 $definition =& new ilGlossaryDefinition($_GET["def"]);
00437 $page =& new ilPageObject("gdf", $definition->getId());
00438 $page_gui =& new ilPageObjectGUI($page);
00439 $page_gui->setTemplateOutput(false);
00440 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"]);
00441 $output = $page_gui->preview();
00442
00443 $this->tpl->setCurrentBlock("definition");
00444 $this->tpl->setVariable("PAGE_CONTENT", $output);
00445 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00446 $this->tpl->setVariable("LINK_CANCEL",
00447 $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00448 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00449 $this->ctrl->setParameter($this, "def", $definition->getId());
00450 $this->tpl->setVariable("LINK_CONFIRM",
00451 $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00452 $this->tpl->parseCurrentBlock();
00453 }
00454
00455 function cancelDefinitionDeletion()
00456 {
00457 $this->ctrl->redirect($this, "listDefinitions");
00458 }
00459
00460
00461 function deleteDefinition()
00462 {
00463 $definition =& new ilGlossaryDefinition($_GET["def"]);
00464 $definition->delete();
00465 $this->ctrl->redirect($this, "listDefinitions");
00466 }
00467
00468
00472 function moveUp()
00473 {
00474 $definition =& new ilGlossaryDefinition($_GET["def"]);
00475 $definition->moveUp();
00476 $this->ctrl->redirect($this, "listDefinitions");
00477 }
00478
00479
00483 function moveDown()
00484 {
00485 $definition =& new ilGlossaryDefinition($_GET["def"]);
00486 $definition->moveDown();
00487 $this->ctrl->redirect($this, "listDefinitions");
00488 }
00489
00490
00494 function addDefinition()
00495 {
00496
00497 $this->getTemplate();
00498 $this->displayLocator();
00499 $this->setTabs();
00500 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00501 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00502
00503 $term_id = $_GET["term_id"];
00504
00505 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_edit.html");
00506 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveDefinition"));
00507 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("gdf_new"));
00508 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00509 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("gdf_add"));
00510 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00511 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00512 $this->tpl->setVariable("CMD_SUBMIT", "saveDefinition");
00513
00514 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00515 $this->tpl->parseCurrentBlock();
00516
00517 }
00518
00522 function cancel()
00523 {
00524 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00525 $this->ctrl->redirect($this, "listDefinitions");
00526 }
00527
00531 function saveDefinition()
00532 {
00533 $def =& new ilGlossaryDefinition();
00534 $def->setTermId($_GET["term_id"]);
00535 $def->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));#"content object ".$newObj->getId());
00536 $def->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00537 $def->create();
00538
00539 $this->ctrl->redirect($this, "listDefinitions");
00540 }
00541
00542
00546 function getTemplate()
00547 {
00548 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00549 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00550 ilUtil::sendInfo();
00551 }
00552
00556 function setTabs()
00557 {
00558 global $ilTabs;
00559
00560
00561 #include_once("classes/class.ilTabsGUI.php");
00562 #$tabs_gui =& new ilTabsGUI();
00563 $this->getTabs($ilTabs);
00564
00565 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00566
00567 }
00568
00572 function displayLocator()
00573 {
00574 require_once ("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
00575 $gloss_loc =& new ilGlossaryLocatorGUI();
00576 $gloss_loc->setTerm($this->term);
00577 $gloss_loc->setGlossary($this->glossary);
00578
00579 $gloss_loc->display();
00580 }
00581
00582
00586 function getTabs(&$tabs_gui)
00587 {
00588
00589 if ($_GET["term_id"] != "")
00590 {
00591 $tabs_gui->addTarget("properties",
00592 $this->ctrl->getLinkTarget($this, "editTerm"), array("editTerm"),
00593 get_class($this));
00594
00595 $tabs_gui->addTarget("cont_definitions",
00596 $this->ctrl->getLinkTarget($this, "listDefinitions"),
00597 "listDefinitions",
00598 get_class($this));
00599 }
00600
00601
00602 $tabs_gui->setBackTarget($this->lng->txt("glossary"),
00603 $this->ctrl->getLinkTargetByClass("ilobjglossarygui", "listTerms"));
00604 }
00605
00611 function _goto($a_target, $a_ref_id = "")
00612 {
00613 global $rbacsystem, $ilErr, $lng, $ilAccess;
00614
00615 $glo_id = ilGlossaryTerm::_lookGlossaryID($a_target);
00616
00617
00618 if ($a_ref_id > 0)
00619 {
00620 $ref_ids = array($a_ref_id);
00621 }
00622 else
00623 {
00624 $ref_ids = ilObject::_getAllReferences($glo_id);
00625 }
00626
00627
00628 foreach ($ref_ids as $ref_id)
00629 {
00630
00631 if ($ilAccess->checkAccess("read", "", $ref_id))
00632 {
00633 $_GET["baseClass"] = "ilGlossaryPresentationGUI";
00634 $_GET["term_id"] = $a_target;
00635 $_GET["ref_id"] = $ref_id;
00636 $_GET["cmd"] = "listDefinitions";
00637 include_once("ilias.php");
00638 exit;
00639 }
00640 }
00641 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00642 {
00643 $_GET["cmd"] = "frameset";
00644 $_GET["target"] = "";
00645 $_GET["ref_id"] = ROOT_FOLDER_ID;
00646 ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00647 ilObject::_lookupTitle($glo_id)), true);
00648 include("repository.php");
00649 exit;
00650 }
00651
00652
00653 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00654 }
00655
00656 }
00657
00658 ?>