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->setTabs();
00116
00117
00118 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_new.html", true);
00119 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00120 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_new_term"));
00121 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00122 $this->tpl->setVariable("INPUT_TERM", "term");
00123 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00124 $lang = ilMetaData::getLanguages();
00125
00126 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00127 {
00128 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00129 }
00130 else
00131 {
00132 $s_lang = $ilUser->getLanguage();
00133 }
00134
00135 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00136 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00137 $this->tpl->setVariable("BTN_NAME", "saveTerm");
00138 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00139 }
00140
00144 function saveTerm()
00145 {
00146 $term =& new ilGlossaryTerm();
00147 $term->setGlossary($this->glossary);
00148 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00149 $term->setLanguage($_POST["term_language"]);
00150 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00151 $term->create();
00152
00153 sendinfo($this->lng->txt("cont_added_term"),true);
00154 $this->ctrl->returnToParent($this);
00155 }
00156
00157
00161 function editTerm()
00162 {
00163
00164 $this->getTemplate();
00165 $this->displayLocator();
00166 $this->setTabs();
00167
00168 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00169
00170
00171 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00172 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00173 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00174 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00175 $this->tpl->setVariable("INPUT_TERM", "term");
00176 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($this->term->getTerm()));
00177 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00178 $lang = ilMetaData::getLanguages();
00179 $select_language = ilUtil::formSelect ($this->term->getLanguage(),"term_language",$lang,false,true);
00180 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00181 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00182 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00183 }
00184
00185
00189 function updateTerm()
00190 {
00191 $this->term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00192 $this->term->setLanguage($_POST["term_language"]);
00193 $this->term->update();
00194 sendinfo($this->lng->txt("msg_obj_modified"),true);
00195 $this->ctrl->redirect($this, "listDefinitions");
00196 }
00197
00201 function output($a_offline = false)
00202 {
00203 require_once("content/classes/class.ilGlossaryDefinition.php");
00204 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00205
00206 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00207
00208 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00209
00210 for($j=0; $j<count($defs); $j++)
00211 {
00212 $def = $defs[$j];
00213 $page =& new ilPageObject("gdf", $def["id"]);
00214 $page_gui =& new ilPageObjectGUI($page);
00215 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00216 if (!$a_offline)
00217 {
00218 $page_gui->setFullscreenLink("glossary_presentation.php?cmd=fullscreen&ref_id=".$_GET["ref_id"]);
00219 }
00220 else
00221 {
00222 $page_gui->setFullscreenLink("fullscreen.html");
00223 }
00224 $page_gui->setFileDownloadLink("glossary_presentation.php?cmd=downloadFile".
00225 "&ref_id=".$_GET["ref_id"]);
00226
00227 if (!$a_offline)
00228 {
00229 $page_gui->setOutputMode("presentation");
00230 }
00231 else
00232 {
00233 $page_gui->setOutputMode("offline");
00234 }
00235
00236
00237
00238 $page_gui->setLinkXML($this->getLinkXML());
00239 $page_gui->setTemplateOutput(false);
00240 $output = $page_gui->presentation($page_gui->getOutputMode());
00241
00242 if (count($defs) > 1)
00243 {
00244 $this->tpl->setCurrentBlock("definition_header");
00245 $this->tpl->setVariable("TXT_DEFINITION",
00246 $this->lng->txt("cont_definition")." ".($j+1));
00247 $this->tpl->parseCurrentBlock();
00248 }
00249
00250 if ($j > 0)
00251 {
00252 $this->tpl->setCurrentBlock("up");
00253 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00254 $this->tpl->setVariable("LINK_UP",
00255 "glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=moveUp&def=".$def["id"]);
00256 $this->tpl->parseCurrentBlock();
00257 }
00258
00259 if ($j+1 < count($defs))
00260 {
00261 $this->tpl->setCurrentBlock("down");
00262 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00263 $this->tpl->setVariable("LINK_DOWN",
00264 "glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=moveDown&def=".$def["id"]);
00265 $this->tpl->parseCurrentBlock();
00266 }
00267
00268 $this->tpl->setCurrentBlock("definition");
00269 $this->tpl->setVariable("PAGE_CONTENT", $output);
00270 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00271 $this->tpl->setVariable("LINK_EDIT",
00272 "glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=view&def=".$def["id"]);
00273 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00274 $this->tpl->setVariable("LINK_DELETE",
00275 "glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=confirmDefinitionDeletion&def=".$def["id"]);
00276 $this->tpl->parseCurrentBlock();
00277 }
00278 }
00279
00283 function getInternalLinks()
00284 {
00285 require_once("content/classes/class.ilGlossaryDefinition.php");
00286 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00287
00288 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00289
00290 $term_links = array();
00291 for($j=0; $j<count($defs); $j++)
00292 {
00293 $def = $defs[$j];
00294 $page =& new ilPageObject("gdf", $def["id"]);
00295 $page->buildDom();
00296 $page_links = $page->getInternalLinks();
00297 foreach($page_links as $key => $page_link)
00298 {
00299 $term_links[$key] = $page_link;
00300 }
00301 }
00302
00303 return $term_links;
00304 }
00305
00309 function listDefinitions()
00310 {
00311 $this->getTemplate();
00312 $this->displayLocator();
00313 $this->setTabs();
00314
00315 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00316
00317
00318 $this->tpl->setCurrentBlock("ContentStyle");
00319 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00320 ilObjStyleSheet::getContentStylePath(0));
00321 $this->tpl->parseCurrentBlock();
00322
00323
00324 $this->tpl->setCurrentBlock("SyntaxStyle");
00325 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00326 ilObjStyleSheet::getSyntaxStylePath());
00327 $this->tpl->parseCurrentBlock();
00328
00329
00330 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", true);
00331
00332
00333 $this->tpl->addBlockfile("STATUSLINE", "statusline", "tpl.statusline.html");
00334 $this->tpl->setVariable("HEADER",
00335 $this->lng->txt("cont_term").": ".$this->term->getTerm());
00336
00337 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00338
00339 $this->tpl->setCurrentBlock("add_def");
00340 $this->tpl->setVariable("TXT_ADD_DEFINITION",
00341 $this->lng->txt("cont_add_definition"));
00342 $this->tpl->setVariable("BTN_ADD", "addDefinition");
00343 $this->tpl->parseCurrentBlock();
00344 $this->tpl->setCurrentBlock("def_list");
00345
00346 $defs = ilGlossaryDefinition::getDefinitionList($_GET["term_id"]);
00347
00348 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00349
00350 for($j=0; $j<count($defs); $j++)
00351 {
00352 $def = $defs[$j];
00353 $page =& new ilPageObject("gdf", $def["id"]);
00354 $page_gui =& new ilPageObjectGUI($page);
00355 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00356
00357
00358 $page_gui->setTemplateOutput(false);
00359 $output = $page_gui->preview();
00360
00361 if (count($defs) > 1)
00362 {
00363 $this->tpl->setCurrentBlock("definition_header");
00364 $this->tpl->setVariable("TXT_DEFINITION",
00365 $this->lng->txt("cont_definition")." ".($j+1));
00366 $this->tpl->parseCurrentBlock();
00367 }
00368
00369 if ($j > 0)
00370 {
00371 $this->tpl->setCurrentBlock("up");
00372 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00373 $this->ctrl->setParameter($this, "def", $def["id"]);
00374 $this->tpl->setVariable("LINK_UP",
00375 $this->ctrl->getLinkTarget($this, "moveUp"));
00376 $this->tpl->parseCurrentBlock();
00377 }
00378
00379 if ($j+1 < count($defs))
00380 {
00381 $this->tpl->setCurrentBlock("down");
00382 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00383 $this->ctrl->setParameter($this, "def", $def["id"]);
00384 $this->tpl->setVariable("LINK_DOWN",
00385 $this->ctrl->getLinkTarget($this, "moveDown"));
00386 $this->tpl->parseCurrentBlock();
00387 }
00388 $this->tpl->setCurrentBlock("submit_btns");
00389 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00390 $this->ctrl->setParameter($this, "def", $def["id"]);
00391 $this->ctrl->setParameterByClass("ilTermDefinitionEditorGUI", "def", $def["id"]);
00392 $this->tpl->setVariable("LINK_EDIT",
00393 $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "view"));
00394 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00395 $this->tpl->setVariable("LINK_DELETE",
00396 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00397 $this->tpl->parseCurrentBlock();
00398
00399 $this->tpl->setCurrentBlock("definition");
00400 $this->tpl->setVariable("PAGE_CONTENT", $output);
00401 $this->tpl->parseCurrentBlock();
00402 }
00403
00404
00405
00406 }
00407
00408
00412 function confirmDefinitionDeletion()
00413 {
00414 $this->getTemplate();
00415 $this->displayLocator();
00416 $this->setTabs();
00417
00418
00419 $this->tpl->setCurrentBlock("ContentStyle");
00420 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00421 ilObjStyleSheet::getContentStylePath(0));
00422 $this->tpl->parseCurrentBlock();
00423
00424
00425 $this->tpl->setCurrentBlock("SyntaxStyle");
00426 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00427 ilObjStyleSheet::getSyntaxStylePath());
00428 $this->tpl->parseCurrentBlock();
00429
00430 $this->tpl->setVariable("HEADER",
00431 $this->lng->txt("cont_term").": ".$this->term->getTerm());
00432
00433 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00434 sendInfo($this->lng->txt("info_delete_sure"));
00435
00436 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00437
00438 $definition =& new ilGlossaryDefinition($_GET["def"]);
00439 $page =& new ilPageObject("gdf", $definition->getId());
00440 $page_gui =& new ilPageObjectGUI($page);
00441 $page_gui->setTemplateOutput(false);
00442 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00443 $output = $page_gui->preview();
00444
00445 $this->tpl->setCurrentBlock("definition");
00446 $this->tpl->setVariable("PAGE_CONTENT", $output);
00447 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00448 $this->tpl->setVariable("LINK_CANCEL",
00449 $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00450 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00451 $this->ctrl->setParameter($this, "def", $definition->getId());
00452 $this->tpl->setVariable("LINK_CONFIRM",
00453 $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00454 $this->tpl->parseCurrentBlock();
00455 }
00456
00457 function cancelDefinitionDeletion()
00458 {
00459 $this->ctrl->redirect($this, "listDefinitions");
00460 }
00461
00462
00463 function deleteDefinition()
00464 {
00465 $definition =& new ilGlossaryDefinition($_GET["def"]);
00466 $definition->delete();
00467 $this->ctrl->redirect($this, "listDefinitions");
00468 }
00469
00470
00474 function moveUp()
00475 {
00476 $definition =& new ilGlossaryDefinition($_GET["def"]);
00477 $definition->moveUp();
00478 $this->ctrl->redirect($this, "listDefinitions");
00479 }
00480
00481
00485 function moveDown()
00486 {
00487 $definition =& new ilGlossaryDefinition($_GET["def"]);
00488 $definition->moveDown();
00489 $this->ctrl->redirect($this, "listDefinitions");
00490 }
00491
00492
00496 function addDefinition()
00497 {
00498
00499 $this->getTemplate();
00500 $this->displayLocator();
00501 $this->setTabs();
00502 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00503
00504 $term_id = $_GET["term_id"];
00505
00506 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_edit.html");
00507 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00508 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("gdf_new"));
00509 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00510 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("gdf_add"));
00511 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00512 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00513 $this->tpl->setVariable("CMD_SUBMIT", "saveDefinition");
00514
00515 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00516 $this->tpl->parseCurrentBlock();
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 }
00527
00531 function cancel()
00532 {
00533 sendInfo($this->lng->txt("msg_cancel"),true);
00534 $this->ctrl->redirect($this, "listDefinitions");
00535 }
00536
00540 function saveDefinition()
00541 {
00542
00543
00544 $def =& new ilGlossaryDefinition();
00545 $def->setTermId($_GET["term_id"]);
00546 $def->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));#"content object ".$newObj->getId());
00547 $def->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00548 $def->create();
00549
00550 $this->ctrl->redirect($this, "listDefinitions");
00551 }
00552
00553
00557 function getTemplate()
00558 {
00559 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00560 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00561 sendInfo();
00562 }
00563
00567 function setTabs()
00568 {
00569
00570
00571 include_once("classes/class.ilTabsGUI.php");
00572 $tabs_gui =& new ilTabsGUI();
00573 $this->getTabs($tabs_gui);
00574
00575 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00576
00577 }
00578
00582 function displayLocator()
00583 {
00584 require_once ("content/classes/class.ilGlossaryLocatorGUI.php");
00585 $gloss_loc =& new ilGlossaryLocatorGUI();
00586 $gloss_loc->setTerm($this->term);
00587 $gloss_loc->setGlossary($this->glossary);
00588
00589 $gloss_loc->display();
00590 }
00591
00592
00596 function getTabs(&$tabs_gui)
00597 {
00598
00599 if ($_GET["term_id"] != "")
00600 {
00601
00602 $tabs_gui->addTarget("cont_definitions",
00603 $this->ctrl->getLinkTarget($this, "listDefinitions"), "listDefinitions",
00604 get_class($this));
00605
00606
00607 $tabs_gui->addTarget("properties",
00608 $this->ctrl->getLinkTarget($this, "editTerm"), "editTerm",
00609 get_class($this));
00610 }
00611
00612
00613 $tabs_gui->addTarget("cont_back",
00614 $this->ctrl->getParentReturn($this), "",
00615 "");
00616
00617 }
00618
00619 }
00620
00621 ?>