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_pres_row.html", true);
00150
00151 $num = 2;
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("cont_definitions")));
00165
00166 $cols = array("term", "definitions");
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("30%", "70%"));
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 = ilPCParagraph::xml2output($def["short_text"]);
00222
00223
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
00378 function media()
00379 {
00380 $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "content");
00381 include_once("classes/class.ilObjStyleSheet.php");
00382 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00383 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00384 ilObjStyleSheet::getContentStylePath(0));
00385
00386
00387 $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
00388
00389
00390
00391
00392 $link_xlm = "";
00393
00394 require_once("content/classes/Media/class.ilObjMediaObject.php");
00395 $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
00396
00397 $xml = "<dummy>";
00398
00399
00400 $xml.= $media_obj->getXML(IL_MODE_ALIAS);
00401 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
00402 $xml.= $link_xml;
00403 $xml.="</dummy>";
00404
00405 $xsl = file_get_contents("./content/page.xsl");
00406 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
00407 $xh = xslt_create();
00408
00409 $wb_path = ilUtil::getWebspaceDir("output");
00410
00411 $mode = "media";
00412 $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output");
00413 $fullscreen_link = "glossary_presentation.php?ref_id=".$_GET["ref_id"]."&obj_type=MediaObject&cmd=fullscreen"
00414 ;
00415 $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
00416 'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
00417 'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
00418 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
00419 echo xslt_error($xh);
00420 xslt_free($xh);
00421
00422
00423 $this->tpl->setVariable("MEDIA_CONTENT", $output);
00424
00425 $this->tpl->parseCurrentBlock();
00426 $this->tpl->show();
00427
00428 }
00429
00430
00431
00432
00440 function setLocator($a_tree = "", $a_id = "")
00441 {
00442 global $ilias_locator;
00443
00444
00445 require_once ("content/classes/class.ilGlossaryLocatorGUI.php");
00446 $gloss_loc =& new ilGlossaryLocatorGUI();
00447 $gloss_loc->setMode("presentation");
00448 if (!empty($_GET["term_id"]))
00449 {
00450 $term =& new ilGlossaryTerm($_GET["term_id"]);
00451 $gloss_loc->setTerm($term);
00452 }
00453 $gloss_loc->setGlossary($this->glossary);
00454
00455 $gloss_loc->display();
00456 return;
00457
00458
00459
00460 $i = 1;
00461
00462
00463
00464 if (!empty($_GET["term_id"]))
00465 {
00466 $this->tpl->touchBlock("locator_separator");
00467 }
00468
00469 $this->tpl->setCurrentBlock("locator_item");
00470 $this->tpl->setVariable("ITEM", $this->glossary->getTitle());
00471
00472 $this->tpl->setVariable("LINK_ITEM", "glossary_presentation.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
00473 $this->tpl->parseCurrentBlock();
00474
00475
00476
00477 $ilias_locator->navigate($i++,$this->glossary->getTitle(),"glossary_presentation.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms"."&offset=".$_GET["offset"],"bottom");
00478
00479 if (!empty($_GET["term_id"]))
00480 {
00481 $term =& new ilGlossaryTerm($_GET["term_id"]);
00482 $this->tpl->setCurrentBlock("locator_item");
00483 $this->tpl->setVariable("ITEM", $term->getTerm());
00484 $this->tpl->setVariable("LINK_ITEM", "glossary_presentation.php?ref_id=".$_GET["ref_id"].
00485 "&cmd=listDefinitions&term_id=".$term->getId()."&offset=".$_GET["offset"]);
00486 $this->tpl->parseCurrentBlock();
00487
00488
00489
00490 $ilias_locator->navigate($i++,$term->getTerm(),"glossary_edit.php?ref_id=".$_GET["ref_id"].
00491 "&cmd=listDefinitions&term_id=".$term->getId()."&offset=".$_GET["offset"],"bottom");
00492 }
00493
00494
00495
00496 $this->tpl->setCurrentBlock("locator");
00497 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00498 $this->tpl->parseCurrentBlock();
00499
00500 }
00501
00505 function downloadFile()
00506 {
00507 $file = explode("_", $_GET["file_id"]);
00508 require_once("classes/class.ilObjFile.php");
00509 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00510 $fileObj->sendFile();
00511 exit;
00512 }
00513
00517 function setTabs()
00518 {
00519
00520
00521 include_once("classes/class.ilTabsGUI.php");
00522 $tabs_gui =& new ilTabsGUI();
00523 $this->getTabs($tabs_gui);
00524
00525 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00526
00527 }
00528
00532 function getLinkXML($a_int_links)
00533 {
00534 if ($a_layoutframes == "")
00535 {
00536 $a_layoutframes = array();
00537 }
00538 $link_info = "<IntLinkInfos>";
00539 foreach ($a_int_links as $int_link)
00540 {
00541 $target = $int_link["Target"];
00542 if (substr($target, 0, 4) == "il__")
00543 {
00544 $target_arr = explode("_", $target);
00545 $target_id = $target_arr[count($target_arr) - 1];
00546 $type = $int_link["Type"];
00547 $targetframe = ($int_link["TargetFrame"] != "")
00548 ? $int_link["TargetFrame"]
00549 : "None";
00550
00551 switch($type)
00552 {
00553 case "PageObject":
00554 case "StructureObject":
00555 $lm_id = ilLMObject::_lookupContObjID($target_id);
00556 $cont_obj =& $this->content_object;
00557 if ($type == "PageObject")
00558 {
00559 $href = "../goto.php?target=pg_".$target_id;
00560 }
00561 else
00562 {
00563 $href = "../goto.php?target=st_".$target_id;
00564 }
00565 $ltarget = "ilContObj".$lm_id;
00566 break;
00567
00568 case "GlossaryItem":
00569
00570 $href = "glossary_presentation.php?cmd=listDefinitions&ref_id=".$_GET["ref_id"].
00571 "&term_id=".$target_id;
00572 break;
00573
00574 case "MediaObject":
00575 $ltarget = $nframe = "_new";
00576 $href = "glossary_presentation.php?obj_type=$type&cmd=media&ref_id=".$_GET["ref_id"].
00577 "&mob_id=".$target_id;
00578 break;
00579 }
00580 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00581 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00582 }
00583 }
00584 $link_info.= "</IntLinkInfos>";
00585
00586 return $link_info;
00587 }
00588
00589
00590
00594 function getTabs(&$tabs_gui)
00595 {
00596
00597 if (!empty ($_REQUEST["term"])) {
00598 $append = "&cmd=searchTerms&term=".$_REQUEST["term"]."&oldoffset=".$_GET["oldoffset"];
00599 }
00600
00601 $tabs_gui->addTarget("cont_back",
00602 "glossary_presentation.php?ref_id=".$_GET["ref_id"]."&offset=".$_GET["offset"].$append, "",
00603 "");
00604
00605 }
00606
00607 function download_paragraph () {
00608 require_once("content/classes/Pages/class.ilPageObject.php");
00609 $pg_obj =& new ilPageObject("gdf", $_GET["pg_id"]);
00610 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
00611 }
00612
00613
00614 }
00615
00616 ?>