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("content/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
00089
00090 function setGlossary(&$a_glossary)
00091 {
00092 $this->glossary =& $a_glossary;
00093 }
00094
00095 function setLinkXML($a_link_xml)
00096 {
00097 $this->link_xml = $a_link_xml;
00098 }
00099
00100 function getLinkXML()
00101 {
00102 return $this->link_xml;
00103 }
00104
00108 function create()
00109 {
00110 global $ilUser;
00111
00112 $this->getTemplate();
00113 $this->displayLocator();
00114 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_new_term"));
00115 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00116 $this->setTabs();
00117
00118
00119 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_new.html", true);
00120 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00121 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_new_term"));
00122 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00123 $this->tpl->setVariable("INPUT_TERM", "term");
00124 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00125 $lang = ilMetaData::getLanguages();
00126
00127 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00128 {
00129 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00130 }
00131 else
00132 {
00133 $s_lang = $ilUser->getLanguage();
00134 }
00135
00136 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00137 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00138 $this->tpl->setVariable("BTN_NAME", "saveTerm");
00139 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00140 }
00141
00145 function saveTerm()
00146 {
00147 $term =& new ilGlossaryTerm();
00148 $term->setGlossary($this->glossary);
00149 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00150 $term->setLanguage($_POST["term_language"]);
00151 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00152 $term->create();
00153
00154 sendinfo($this->lng->txt("cont_added_term"),true);
00155 $this->ctrl->returnToParent($this);
00156 }
00157
00158
00162 function editTerm()
00163 {
00164
00165 $this->getTemplate();
00166 $this->displayLocator();
00167 $this->setTabs();
00168
00169 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00170 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00171
00172
00173 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00174 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00175 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00176 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00177 $this->tpl->setVariable("INPUT_TERM", "term");
00178 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($this->term->getTerm()));
00179 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00180 $lang = ilMetaData::getLanguages();
00181 $select_language = ilUtil::formSelect ($this->term->getLanguage(),"term_language",$lang,false,true);
00182 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00183 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00184 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00185 }
00186
00187
00191 function updateTerm()
00192 {
00193 $this->term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00194 $this->term->setLanguage($_POST["term_language"]);
00195 $this->term->update();
00196 sendinfo($this->lng->txt("msg_obj_modified"),true);
00197 $this->ctrl->redirect($this, "editTerm");
00198 }
00199
00205 function output($a_offline = false, $dir = "")
00206 {
00207 require_once("content/classes/class.ilGlossaryDefinition.php");
00208 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00209
00210 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00211
00212 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00213
00214 for($j=0; $j<count($defs); $j++)
00215 {
00216 $def = $defs[$j];
00217 $page =& new ilPageObject("gdf", $def["id"]);
00218 $page_gui =& new ilPageObjectGUI($page);
00219 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"]);
00220 if (!$a_offline)
00221 {
00222 $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"] . "&cmd=fullscreen");
00223 }
00224 else
00225 {
00226 $page_gui->setFullscreenLink("fullscreen.html");
00227 }
00228 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"] . "&cmd=downloadFile");
00229
00230 if (!$a_offline)
00231 {
00232 $page_gui->setOutputMode("presentation");
00233 }
00234 else
00235 {
00236 $page_gui->setOutputMode("offline");
00237 }
00238
00239
00240
00241 $page_gui->setLinkXML($this->getLinkXML());
00242 $page_gui->setTemplateOutput(false);
00243 $output = $page_gui->presentation($page_gui->getOutputMode());
00244
00245 if (count($defs) > 1)
00246 {
00247 $this->tpl->setCurrentBlock("definition_header");
00248 $this->tpl->setVariable("TXT_DEFINITION",
00249 $this->lng->txt("cont_definition")." ".($j+1));
00250 $this->tpl->parseCurrentBlock();
00251 }
00252
00253 $this->tpl->setCurrentBlock("definition");
00254 $this->tpl->setVariable("PAGE_CONTENT", $output);
00255 }
00256 }
00257
00261 function getInternalLinks()
00262 {
00263 require_once("content/classes/class.ilGlossaryDefinition.php");
00264 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00265
00266 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00267
00268 $term_links = array();
00269 for($j=0; $j<count($defs); $j++)
00270 {
00271 $def = $defs[$j];
00272 $page =& new ilPageObject("gdf", $def["id"]);
00273 $page->buildDom();
00274 $page_links = $page->getInternalLinks();
00275 foreach($page_links as $key => $page_link)
00276 {
00277 $term_links[$key] = $page_link;
00278 }
00279 }
00280
00281 return $term_links;
00282 }
00283
00287 function listDefinitions()
00288 {
00289 $this->getTemplate();
00290 $this->displayLocator();
00291 $this->setTabs();
00292
00293 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00294
00295
00296 $this->tpl->setCurrentBlock("ContentStyle");
00297 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00298 ilObjStyleSheet::getContentStylePath(0));
00299 $this->tpl->parseCurrentBlock();
00300
00301
00302 $this->tpl->setCurrentBlock("SyntaxStyle");
00303 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00304 ilObjStyleSheet::getSyntaxStylePath());
00305 $this->tpl->parseCurrentBlock();
00306
00307
00308 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", true);
00309
00310
00311 $this->tpl->addBlockfile("STATUSLINE", "statusline", "tpl.statusline.html");
00312 $this->tpl->setVariable("HEADER",
00313 $this->lng->txt("cont_term").": ".$this->term->getTerm());
00314 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00315
00316 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00317
00318 $this->tpl->setCurrentBlock("add_def");
00319 $this->tpl->setVariable("TXT_ADD_DEFINITION",
00320 $this->lng->txt("cont_add_definition"));
00321 $this->tpl->setVariable("BTN_ADD", "addDefinition");
00322 $this->tpl->parseCurrentBlock();
00323 $this->tpl->setCurrentBlock("def_list");
00324
00325 $defs = ilGlossaryDefinition::getDefinitionList($_GET["term_id"]);
00326
00327 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00328
00329 for($j=0; $j<count($defs); $j++)
00330 {
00331 $def = $defs[$j];
00332 $page =& new ilPageObject("gdf", $def["id"]);
00333 $page_gui =& new ilPageObjectGUI($page);
00334 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"]);
00335 $page_gui->setTemplateOutput(false);
00336 $output = $page_gui->preview();
00337
00338 if (count($defs) > 1)
00339 {
00340 $this->tpl->setCurrentBlock("definition_header");
00341 $this->tpl->setVariable("TXT_DEFINITION",
00342 $this->lng->txt("cont_definition")." ".($j+1));
00343 $this->tpl->parseCurrentBlock();
00344 }
00345
00346 if ($j > 0)
00347 {
00348 $this->tpl->setCurrentBlock("up");
00349 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00350 $this->ctrl->setParameter($this, "def", $def["id"]);
00351 $this->tpl->setVariable("LINK_UP",
00352 $this->ctrl->getLinkTarget($this, "moveUp"));
00353 $this->tpl->parseCurrentBlock();
00354 }
00355
00356 if ($j+1 < count($defs))
00357 {
00358 $this->tpl->setCurrentBlock("down");
00359 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00360 $this->ctrl->setParameter($this, "def", $def["id"]);
00361 $this->tpl->setVariable("LINK_DOWN",
00362 $this->ctrl->getLinkTarget($this, "moveDown"));
00363 $this->tpl->parseCurrentBlock();
00364 }
00365 $this->tpl->setCurrentBlock("submit_btns");
00366 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00367 $this->ctrl->setParameter($this, "def", $def["id"]);
00368 $this->ctrl->setParameterByClass("ilTermDefinitionEditorGUI", "def", $def["id"]);
00369 $this->tpl->setVariable("LINK_EDIT",
00370 $this->ctrl->getLinkTargetByClass(array("ilTermDefinitionEditorGUI", "ilPageObjectGUI"), "view"));
00371 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00372 $this->tpl->setVariable("LINK_DELETE",
00373 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00374 $this->tpl->parseCurrentBlock();
00375
00376 $this->tpl->setCurrentBlock("definition");
00377 $this->tpl->setVariable("PAGE_CONTENT", $output);
00378 $this->tpl->parseCurrentBlock();
00379 }
00380
00381
00382
00383 }
00384
00385
00389 function confirmDefinitionDeletion()
00390 {
00391 $this->getTemplate();
00392 $this->displayLocator();
00393 $this->setTabs();
00394
00395
00396 $this->tpl->setCurrentBlock("ContentStyle");
00397 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00398 ilObjStyleSheet::getContentStylePath(0));
00399 $this->tpl->parseCurrentBlock();
00400
00401
00402 $this->tpl->setCurrentBlock("SyntaxStyle");
00403 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00404 ilObjStyleSheet::getSyntaxStylePath());
00405 $this->tpl->parseCurrentBlock();
00406
00407 $this->tpl->setVariable("HEADER",
00408 $this->lng->txt("cont_term").": ".$this->term->getTerm());
00409 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00410
00411 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00412 sendInfo($this->lng->txt("info_delete_sure"));
00413
00414 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00415
00416 $definition =& new ilGlossaryDefinition($_GET["def"]);
00417 $page =& new ilPageObject("gdf", $definition->getId());
00418 $page_gui =& new ilPageObjectGUI($page);
00419 $page_gui->setTemplateOutput(false);
00420 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$_GET["ref_id"]);
00421 $output = $page_gui->preview();
00422
00423 $this->tpl->setCurrentBlock("definition");
00424 $this->tpl->setVariable("PAGE_CONTENT", $output);
00425 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00426 $this->tpl->setVariable("LINK_CANCEL",
00427 $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00428 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00429 $this->ctrl->setParameter($this, "def", $definition->getId());
00430 $this->tpl->setVariable("LINK_CONFIRM",
00431 $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00432 $this->tpl->parseCurrentBlock();
00433 }
00434
00435 function cancelDefinitionDeletion()
00436 {
00437 $this->ctrl->redirect($this, "listDefinitions");
00438 }
00439
00440
00441 function deleteDefinition()
00442 {
00443 $definition =& new ilGlossaryDefinition($_GET["def"]);
00444 $definition->delete();
00445 $this->ctrl->redirect($this, "listDefinitions");
00446 }
00447
00448
00452 function moveUp()
00453 {
00454 $definition =& new ilGlossaryDefinition($_GET["def"]);
00455 $definition->moveUp();
00456 $this->ctrl->redirect($this, "listDefinitions");
00457 }
00458
00459
00463 function moveDown()
00464 {
00465 $definition =& new ilGlossaryDefinition($_GET["def"]);
00466 $definition->moveDown();
00467 $this->ctrl->redirect($this, "listDefinitions");
00468 }
00469
00470
00474 function addDefinition()
00475 {
00476
00477 $this->getTemplate();
00478 $this->displayLocator();
00479 $this->setTabs();
00480 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00481 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00482
00483 $term_id = $_GET["term_id"];
00484
00485 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_edit.html");
00486 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00487 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("gdf_new"));
00488 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00489 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("gdf_add"));
00490 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00491 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00492 $this->tpl->setVariable("CMD_SUBMIT", "saveDefinition");
00493
00494 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00495 $this->tpl->parseCurrentBlock();
00496
00497 }
00498
00502 function cancel()
00503 {
00504 sendInfo($this->lng->txt("msg_cancel"),true);
00505 $this->ctrl->redirect($this, "listDefinitions");
00506 }
00507
00511 function saveDefinition()
00512 {
00513
00514
00515 $def =& new ilGlossaryDefinition();
00516 $def->setTermId($_GET["term_id"]);
00517 $def->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));#"content object ".$newObj->getId());
00518 $def->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00519 $def->create();
00520
00521 $this->ctrl->redirect($this, "listDefinitions");
00522 }
00523
00524
00528 function getTemplate()
00529 {
00530 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00531 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00532 sendInfo();
00533 }
00534
00538 function setTabs()
00539 {
00540 global $ilTabs;
00541
00542
00543 #include_once("classes/class.ilTabsGUI.php");
00544 #$tabs_gui =& new ilTabsGUI();
00545 $this->getTabs($ilTabs);
00546
00547 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00548
00549 }
00550
00554 function displayLocator()
00555 {
00556 require_once ("content/classes/class.ilGlossaryLocatorGUI.php");
00557 $gloss_loc =& new ilGlossaryLocatorGUI();
00558 $gloss_loc->setTerm($this->term);
00559 $gloss_loc->setGlossary($this->glossary);
00560
00561 $gloss_loc->display();
00562 }
00563
00564
00568 function getTabs(&$tabs_gui)
00569 {
00570
00571 if ($_GET["term_id"] != "")
00572 {
00573 $tabs_gui->addTarget("properties",
00574 $this->ctrl->getLinkTarget($this, "editTerm"), array("editTerm"),
00575 get_class($this));
00576
00577 $tabs_gui->addTarget("cont_definitions",
00578 $this->ctrl->getLinkTarget($this, "listDefinitions"),
00579 "listDefinitions",
00580 get_class($this));
00581 }
00582
00583
00584 $tabs_gui->setBackTarget($this->lng->txt("glossary"),
00585 $this->ctrl->getLinkTargetByClass("ilobjglossarygui", "listTerms"));
00586 }
00587
00593 function _goto($a_target, $a_ref_id = "")
00594 {
00595 global $rbacsystem, $ilErr, $lng, $ilAccess;
00596
00597 $glo_id = ilGlossaryTerm::_lookGlossaryID($a_target);
00598
00599
00600 if ($a_ref_id > 0)
00601 {
00602 $ref_ids = array($a_ref_id);
00603 }
00604 else
00605 {
00606 $ref_ids = ilObject::_getAllReferences($glo_id);
00607 }
00608
00609
00610 foreach ($ref_ids as $ref_id)
00611 {
00612
00613 if ($ilAccess->checkAccess("read", "", $ref_id))
00614 {
00615 $_GET["baseClass"] = "ilGlossaryPresentationGUI";
00616 $_GET["term_id"] = $a_target;
00617 $_GET["ref_id"] = $ref_id;
00618 $_GET["cmd"] = "listDefinitions";
00619 include_once("ilias.php");
00620 exit;
00621 }
00622 }
00623 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00624 {
00625 $_GET["cmd"] = "frameset";
00626 $_GET["target"] = "";
00627 $_GET["ref_id"] = ROOT_FOLDER_ID;
00628 sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00629 ilObject::_lookupTitle($glo_id)), true);
00630 include("repository.php");
00631 exit;
00632 }
00633
00634
00635 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00636 }
00637
00638 }
00639
00640 ?>