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("classes/class.ilObjectGUI.php");
00025 require_once("classes/class.ilMetaDataGUI.php");
00026 require_once("content/classes/class.ilObjGlossary.php");
00027 require_once("content/classes/class.ilGlossaryTermGUI.php");
00028 require_once("content/classes/class.ilGlossaryDefinition.php");
00029 require_once("content/classes/class.ilTermDefinitionEditorGUI.php");
00030 require_once("content/classes/Pages/class.ilPCParagraph.php");
00031
00042 class ilGlossaryPresentationGUI
00043 {
00044 var $admin_tabs;
00045 var $glossary;
00046 var $ilias;
00047 var $tpl;
00048 var $lng;
00049
00054 function ilGlossaryPresentationGUI()
00055 {
00056 global $lng, $ilias, $tpl;
00057
00058 $this->tpl =& $tpl;
00059 $this->lng =& $lng;
00060 $this->ilias =& $ilias;
00061
00062
00063 $this->glossary =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]);
00064
00065 }
00066
00067
00071 function executeCommand()
00072 {
00073 $cmd = $_GET["cmd"];
00074 if ($cmd != "listDefinitions")
00075 {
00076 $this->prepareOutput();
00077 }
00078 if($cmd == "")
00079 {
00080 $cmd = "listTerms";
00081 }
00082
00083 $this->$cmd();
00084
00085 $this->tpl->show();
00086 }
00087
00088 function prepareOutput()
00089 {
00090 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00091 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00092 $title = $this->glossary->getTitle();
00093
00094
00095 sendInfo();
00096
00097 if (!empty($title))
00098 {
00099 $this->tpl->setVariable("HEADER", $title);
00100 }
00101
00102 $this->setLocator();
00103 }
00104
00105 function searchTerms () {
00106 if (isset ($_POST["clear"]))
00107 {
00108 $searchterm ="";
00109 $_GET["offset"] = $_GET["oldoffset"];
00110 } else
00111 {
00112 $searchterm = $_REQUEST ["term"];
00113 }
00114 $term_list = $this->glossary->getTermList($searchterm);
00115 $this->listTermByGiven($term_list, $searchterm);
00116
00117 }
00118
00119
00120 function listTerms()
00121 {
00122 $term_list = $this->glossary->getTermList();
00123 $this->listTermByGiven($term_list);
00124 }
00125
00129 function listTermByGiven($term_list, $filter ="")
00130 {
00131 $this->lng->loadLanguageModule("meta");
00132 include_once "./classes/class.ilTableGUI.php";
00133
00134
00135
00136
00137 $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
00138
00139 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_search_term.html", true);
00140 $this->tpl->setVariable("FORMACTION1", "glossary_presentation.php?ref_id=".$_GET["ref_id"]."&cmd=searchTerms&offset=0&oldoffset=$oldoffset");
00141 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00142 $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
00143 $this->tpl->setVariable("TXT_CLEAR", $this->lng->txt("clear"));
00144 $this->tpl->setVariable("TERM", $filter);
00145
00146
00147 $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
00148
00149 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_row.html", true);
00150
00151 $num = 0;
00152
00153 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00154 $this->tpl->setVariable("FORMACTION", "glossary_edit.php?ref_id=".$this->ref_id."$obj_str&cmd=post&offset=".$_GET["offset"]);
00155
00156
00157 $tbl = new ilTableGUI();
00158
00159
00160 $tbl->setTitle($this->lng->txt("cont_terms").(($filter=="")?"":"*"));
00161
00162
00163 $tbl->setHeaderNames(array($this->lng->txt("cont_term"),
00164 $this->lng->txt("language"), $this->lng->txt("cont_definitions")));
00165
00166 $cols = array("term", "language", "definitions", "id");
00167
00168 $header_params = array("ref_id" => $_GET["ref_id"], "cmd" => "listTerms");
00169
00170 if (!empty ($filter)) {
00171 $header_params ["cmd"] = "searchTerms";
00172 $header_params ["term"] = $filter;
00173 $header_params ["oldoffset"] = $_GET["oldoffset"];
00174 }
00175
00176 $tbl->setHeaderVars($cols, $header_params);
00177 $tbl->setColumnWidth(array("25%","15%","60%"));
00178
00179
00180 $tbl->setOrderColumn($_GET["sort_by"]);
00181 $tbl->setOrderDirection($_GET["sort_order"]);
00182 $tbl->setLimit($_GET["limit"]);
00183 $tbl->setOffset($_GET["offset"]);
00184 $tbl->setMaxCount($this->maxcount);
00185
00186
00187
00188
00189 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00190
00191
00192
00193 $tbl->setMaxCount(count($term_list));
00194
00195
00196
00197 $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
00198
00199
00200 $tbl->render();
00201
00202 if (count($term_list) > 0)
00203 {
00204 $i=1;
00205 foreach($term_list as $key => $term)
00206 {
00207 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00208 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
00209 for($j=0; $j<count($defs); $j++)
00210 {
00211 $def = $defs[$j];
00212 if (count($defs) > 1)
00213 {
00214 $this->tpl->setCurrentBlock("definition");
00215 $this->tpl->setVariable("DEF_TEXT", $this->lng->txt("cont_definition")." ".($j + 1));
00216 $this->tpl->parseCurrentBlock();
00217 }
00218
00219
00220 $this->tpl->setCurrentBlock("definition");
00221 $short_str = strip_tags(ilPCParagraph::xml2output($def["short_text"]));
00222 $short_str = str_replace("<", "<", $short_str);
00223 $short_str = str_replace(">", ">", $short_str);
00224 $this->tpl->setVariable("DEF_SHORT", $short_str);
00225 $this->tpl->parseCurrentBlock();
00226
00227 $this->tpl->setCurrentBlock("definition_row");
00228 $this->tpl->parseCurrentBlock();
00229 }
00230
00231 $this->tpl->setCurrentBlock("view_term");
00232 $this->tpl->setVariable("TEXT_TERM", $term["term"]);
00233 if (!empty ($filter)) {
00234 $append = "&term=$filter&oldoffset=".$_GET["oldoffset"];
00235 }
00236 $this->tpl->setVariable("LINK_VIEW_TERM", "glossary_presentation.php?ref_id=".
00237 $_GET["ref_id"]."&cmd=listDefinitions&term_id=".$term["id"]."&offset=".$_GET["offset"].$append);
00238 $this->tpl->parseCurrentBlock();
00239
00240 $this->tpl->setVariable("CSS_ROW", $css_row);
00241 $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
00242 $this->tpl->setCurrentBlock("tbl_content");
00243 $this->tpl->parseCurrentBlock();
00244 }
00245 }
00246 else
00247 {
00248 $this->tpl->setCurrentBlock("notfound");
00249 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00250 $this->tpl->setVariable("NUM_COLS", $num);
00251 $this->tpl->parseCurrentBlock();
00252 }
00253 }
00254
00258 function listDefinitions()
00259 {
00260 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00261 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00262 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00263 $this->setLocator();
00264 $this->setTabs();
00265
00266
00267 $this->tpl->setCurrentBlock("ContentStyle");
00268 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00269 ilObjStyleSheet::getContentStylePath(0));
00270 $this->tpl->parseCurrentBlock();
00271
00272
00273 $this->tpl->setCurrentBlock("SyntaxStyle");
00274 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00275 ilObjStyleSheet::getSyntaxStylePath());
00276 $this->tpl->parseCurrentBlock();
00277
00278 $term =& new ilGlossaryTerm($_GET["term_id"]);
00279 $this->tpl->setVariable("HEADER",
00280 $this->lng->txt("cont_term").": ".$term->getTerm());
00281
00282
00283
00284 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", true);
00285
00286
00287 $this->tpl->setVariable("FORMACTION", "glossary_edit.php?ref_id=".$_GET["ref_id"].
00288 "&cmd=post&term_id=".$_GET["term_id"]."&offset=".$_GET["offset"]);
00289
00290
00291
00292
00293
00294 $defs = ilGlossaryDefinition::getDefinitionList($_GET["term_id"]);
00295
00296 $this->tpl->setVariable("TXT_TERM", $term->getTerm());
00297
00298 for($j=0; $j<count($defs); $j++)
00299 {
00300 $def = $defs[$j];
00301 $page =& new ilPageObject("gdf", $def["id"]);
00302 $page_gui =& new ilPageObjectGUI($page);
00303
00304
00305 $page->buildDom();
00306 $int_links = $page->getInternalLinks();
00307 $link_xml = $this->getLinkXML($int_links);
00308 $page_gui->setLinkXML($link_xml);
00309
00310 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00311 $page_gui->setFullscreenLink("glossary_presentation.php?cmd=fullscreen".
00312 "&ref_id=".$_GET["ref_id"]."&def_id=".$def["id"]);
00313
00314
00315
00316 $page_gui->setTemplateOutput(false);
00317 $page_gui->setFileDownloadLink("glossary_presentation.php?cmd=downloadFile".
00318 "&ref_id=".$_GET["ref_id"]);
00319 $output = $page_gui->preview();
00320
00321 if (count($defs) > 1)
00322 {
00323 $this->tpl->setCurrentBlock("definition_header");
00324 $this->tpl->setVariable("TXT_DEFINITION",
00325 $this->lng->txt("cont_definition")." ".($j+1));
00326 $this->tpl->parseCurrentBlock();
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 $this->tpl->setCurrentBlock("definition");
00349 $this->tpl->setVariable("PAGE_CONTENT", $output);
00350
00351
00352
00353
00354
00355
00356
00357 $this->tpl->parseCurrentBlock();
00358 }
00359
00360
00361
00362 }
00363
00367 function fullscreen()
00368 {
00369 $page =& new ilPageObject("gdf", $_GET["def_id"]);
00370 $page_gui =& new ilPageObjectGUI($page);
00371 $page_gui->showMediaFullscreen();
00372
00373 }
00374
00375
00383 function setLocator($a_tree = "", $a_id = "")
00384 {
00385 global $ilias_locator;
00386
00387
00388 require_once ("content/classes/class.ilGlossaryLocatorGUI.php");
00389 $gloss_loc =& new ilGlossaryLocatorGUI();
00390 $gloss_loc->setMode("presentation");
00391 if (!empty($_GET["term_id"]))
00392 {
00393 $term =& new ilGlossaryTerm($_GET["term_id"]);
00394 $gloss_loc->setTerm($term);
00395 }
00396 $gloss_loc->setGlossary($this->glossary);
00397
00398 $gloss_loc->display();
00399 return;
00400
00401
00402
00403 $i = 1;
00404
00405
00406
00407 if (!empty($_GET["term_id"]))
00408 {
00409 $this->tpl->touchBlock("locator_separator");
00410 }
00411
00412 $this->tpl->setCurrentBlock("locator_item");
00413 $this->tpl->setVariable("ITEM", $this->glossary->getTitle());
00414
00415 $this->tpl->setVariable("LINK_ITEM", "glossary_presentation.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
00416 $this->tpl->parseCurrentBlock();
00417
00418
00419
00420 $ilias_locator->navigate($i++,$this->glossary->getTitle(),"glossary_presentation.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms"."&offset=".$_GET["offset"],"bottom");
00421
00422 if (!empty($_GET["term_id"]))
00423 {
00424 $term =& new ilGlossaryTerm($_GET["term_id"]);
00425 $this->tpl->setCurrentBlock("locator_item");
00426 $this->tpl->setVariable("ITEM", $term->getTerm());
00427 $this->tpl->setVariable("LINK_ITEM", "glossary_presentation.php?ref_id=".$_GET["ref_id"].
00428 "&cmd=listDefinitions&term_id=".$term->getId()."&offset=".$_GET["offset"]);
00429 $this->tpl->parseCurrentBlock();
00430
00431
00432
00433 $ilias_locator->navigate($i++,$term->getTerm(),"glossary_edit.php?ref_id=".$_GET["ref_id"].
00434 "&cmd=listDefinitions&term_id=".$term->getId()."&offset=".$_GET["offset"],"bottom");
00435 }
00436
00437
00438
00439 $this->tpl->setCurrentBlock("locator");
00440 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00441 $this->tpl->parseCurrentBlock();
00442
00443 }
00444
00448 function downloadFile()
00449 {
00450 $file = explode("_", $_GET["file_id"]);
00451 require_once("classes/class.ilObjFile.php");
00452 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00453 $fileObj->sendFile();
00454 exit;
00455 }
00456
00460 function setTabs()
00461 {
00462
00463
00464 include_once("classes/class.ilTabsGUI.php");
00465 $tabs_gui =& new ilTabsGUI();
00466 $this->getTabs($tabs_gui);
00467
00468 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00469
00470 }
00471
00475 function getLinkXML($a_int_links)
00476 {
00477 if ($a_layoutframes == "")
00478 {
00479 $a_layoutframes = array();
00480 }
00481 $link_info = "<IntLinkInfos>";
00482 foreach ($a_int_links as $int_link)
00483 {
00484 $target = $int_link["Target"];
00485 if (substr($target, 0, 4) == "il__")
00486 {
00487 $target_arr = explode("_", $target);
00488 $target_id = $target_arr[count($target_arr) - 1];
00489 $type = $int_link["Type"];
00490 $targetframe = ($int_link["TargetFrame"] != "")
00491 ? $int_link["TargetFrame"]
00492 : "None";
00493
00494 switch($type)
00495 {
00496 case "PageObject":
00497 case "StructureObject":
00498 $lm_id = ilLMObject::_lookupContObjID($target_id);
00499 $cont_obj =& $this->content_object;
00500 if ($type == "PageObject")
00501 {
00502 $href = "../goto.php?target=pg_".$target_id;
00503 }
00504 else
00505 {
00506 $href = "../goto.php?target=st_".$target_id;
00507 }
00508 $ltarget = "ilContObj".$lm_id;
00509 break;
00510
00511 case "GlossaryItem":
00512
00513 $href = "glossary_presentation.php?cmd=listDefinitions&ref_id=".$_GET["ref_id"].
00514 "&term_id=".$target_id;
00515 break;
00516
00517 case "MediaObject":
00518 $ltarget = $nframe = "_new";
00519 $href = "glossary_presentation.php?obj_type=$type&cmd=media&ref_id=".$_GET["ref_id"].
00520 "&mob_id=".$target_id;
00521 break;
00522 }
00523 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00524 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00525 }
00526 }
00527 $link_info.= "</IntLinkInfos>";
00528
00529 return $link_info;
00530 }
00531
00532
00533
00537 function getTabs(&$tabs_gui)
00538 {
00539
00540 if (!empty ($_REQUEST["term"])) {
00541 $append = "&cmd=searchTerms&term=".$_REQUEST["term"]."&oldoffset=".$_GET["oldoffset"];
00542 }
00543
00544 $tabs_gui->addTarget("cont_back",
00545 "glossary_presentation.php?ref_id=".$_GET["ref_id"]."&offset=".$_GET["offset"].$append, "",
00546 "");
00547
00548 }
00549
00550 function download_paragraph () {
00551 require_once("content/classes/Pages/class.ilPageObject.php");
00552 $pg_obj =& new ilPageObject("gdf", $_GET["pg_id"]);
00553 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
00554 }
00555
00556
00557 }
00558
00559 ?>