• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 require_once("classes/class.ilObjectGUI.php");
00025 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
00026 require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
00027 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
00028 require_once("./Modules/Glossary/classes/class.ilTermDefinitionEditorGUI.php");
00029 require_once("./Services/COPage/classes/class.ilPCParagraph.php");
00030 
00043 class ilGlossaryPresentationGUI
00044 {
00045         var $admin_tabs;
00046         var $glossary;
00047         var $ilias;
00048         var $tpl;
00049         var $lng;
00050 
00055         function ilGlossaryPresentationGUI()
00056         {
00057                 global $lng, $ilias, $tpl, $ilCtrl;
00058 
00059                 $this->tpl =& $tpl;
00060                 $this->lng =& $lng;
00061                 $this->ilias =& $ilias;
00062                 $this->ctrl =& $ilCtrl;
00063                 $this->offline = false;
00064                 $this->ctrl->saveParameter($this, array("ref_id"));
00065 
00066                 // Todo: check lm id
00067                 include_once("./Modules/Glossary/classes/class.ilObjGlossaryGUI.php");
00068                 $this->glossary_gui =& new ilObjGlossaryGUI("", $_GET["ref_id"], true, "");
00069                 $this->glossary =& $this->glossary_gui->object;
00070 
00071         }
00072         
00073         
00077         function setOfflineMode($a_offline = true)
00078         {
00079                 $this->offline = $a_offline;
00080         }
00081         
00082         
00086         function offlineMode()
00087         {
00088                 return $this->offline;
00089         }
00090 
00094         function setOfflineDirectory($a_dir)
00095         {
00096                 $this->offline_dir = $a_dir;
00097         }
00098         
00099         
00103         function getOfflineDirectory()
00104         {
00105                 return $this->offline_dir;
00106         }
00107 
00108 
00112         function &executeCommand()
00113         {
00114                 global $lng, $ilAccess, $ilias;
00115                 
00116                 $lng->loadLanguageModule("content");
00117 
00118                 $next_class = $this->ctrl->getNextClass($this);
00119                 $cmd = $this->ctrl->getCmd("listTerms");
00120 
00121                 // check write permission
00122                 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
00123                         !($ilAccess->checkAccess("visible", "", $_GET["ref_id"]) &&
00124                                 ($cmd == "infoScreen" || strtolower($next_class) == "ilinfoscreengui")))
00125                 {
00126                         $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
00127                 }
00128                 
00129                 if ($cmd != "listDefinitions")
00130                 {
00131                         $this->prepareOutput();
00132                 }
00133 
00134                 switch($next_class)
00135                 {
00136                         case "ilnotegui":
00137                                 $this->setTabs();
00138                                 $ret =& $this->listDefinitions();
00139                                 break;
00140                                 
00141                         case "ilinfoscreengui":
00142                                 $ret =& $this->outputInfoScreen();
00143                                 break;
00144                                 
00145                         default: 
00146                                 $ret =& $this->$cmd();
00147                                 break;
00148                 }
00149 
00150                 $this->tpl->show();
00151         }
00152 
00153         function prepareOutput()
00154         {
00155                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00156                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00157                 $title = $this->glossary->getTitle();
00158 
00159                 // catch feedback message
00160                 ilUtil::sendInfo();
00161 
00162                 $this->tpl->setTitle($title);
00163                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.gif"));
00164 
00165                 $this->setLocator();
00166         }
00167 
00168         function clearTerms()
00169         {
00170                 $_REQUEST["term"] = "";
00171                 $_GET["offset"] = $_GET["oldoffset"];
00172                 $this->searchTerms();
00173         }
00174         
00175         function searchTerms ()
00176         {
00177                 $term_list = $this->glossary->getTermList($_REQUEST["term"]);
00178                 $this->listTermByGiven($term_list, $_REQUEST["term"]);
00179         }
00180 
00181 
00182         function listTerms()
00183         {
00184                 global $ilNavigationHistory;
00185                 
00186                 if (!$this->offlineMode())
00187                 {
00188                         $ilNavigationHistory->addItem($_GET["ref_id"],
00189                                 $this->ctrl->getLinkTarget($this, "listTerms"), "glo");
00190                 }
00191                 
00192                 $term_list = $this->glossary->getTermList();            
00193                 
00194                 return $this->listTermByGiven($term_list);
00195         }
00196 
00200         function listTermByGiven($term_list, $filter ="")
00201         {
00202                 global $ilCtrl, $ilAccess;
00203                 
00204                 $this->lng->loadLanguageModule("meta");
00205                 include_once "./Services/Table/classes/class.ilTableGUI.php";
00206 
00207                 $this->setTabs();
00208                 
00209                 // load template for table
00210 //              $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00211                 
00212                 $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
00213 
00214                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_presentation.html", "Modules/Glossary");
00215                 
00216                 // search form
00217                 if (!$this->offlineMode())
00218                 {
00219                         $this->tpl->setCurrentBlock("search_form");
00220                         $this->ctrl->setParameter($this, "offset", 0);
00221                         $this->ctrl->setParameter($this, "oldoffset", $oldoffset);
00222                         $this->tpl->setVariable("FORMACTION1",
00223                                 $this->ctrl->getFormAction($this, "searchTerms"));
00224                         $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00225                         $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
00226                         $this->tpl->setVariable("TXT_CLEAR", $this->lng->txt("clear"));
00227                         $this->tpl->setVariable("TERM", $filter);
00228                         $this->tpl->parseCurrentBlock();
00229                 }
00230                 
00231 
00232                 // load template for table
00233                 $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
00234                 // load template for table content data
00235                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_pres_row.html", "Modules/Glossary");
00236 
00237                 $num = 2;
00238 
00239                 // create table
00240                 $tbl = new ilTableGUI();
00241 
00242                 // title & header columns
00243                 $tbl->setTitle($this->lng->txt("cont_terms").(($filter=="")?"":"*"));
00244                 $tbl->disable("sort");
00245                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00246 
00247                 // display additional column 'glossary' for meta glossaries
00248                 if ($this->glossary->isVirtual())
00249                 {
00250                         $tbl->setHeaderNames(array($this->lng->txt("cont_term"),
00251                                  $this->lng->txt("cont_definitions"),$this->lng->txt("obj_glo")));
00252 
00253                         $cols = array("term", "definitions", "glossary");
00254                         
00255                         $tbl->setColumnWidth(array("30%", "35%", "35%"));
00256                 }
00257                 else
00258                 {
00259                         $tbl->setHeaderNames(array($this->lng->txt("cont_term"),
00260                                  $this->lng->txt("cont_definitions")));
00261         
00262                         $cols = array("term", "definitions");
00263                         
00264                         $tbl->setColumnWidth(array("30%", "70%"));
00265                 }
00266                 
00267                 if (!$this->offlineMode())
00268                 {
00269                         $header_params = $this->ctrl->getParameterArrayByClass("ilglossarypresentationgui", "listTerms");
00270                 }
00271                 //$header_params = array("ref_id" => $_GET["ref_id"], "cmd" => "listTerms");
00272 
00273                 if (!empty ($filter)) {
00274                         $header_params ["cmd"] = "searchTerms";
00275                         $header_params ["term"] = $filter;
00276                         $header_params ["oldoffset"] = $_GET["oldoffset"];
00277                 }
00278 
00279                 $tbl->setHeaderVars($cols, $header_params);
00280 
00281                 // control
00282                 $tbl->setOrderColumn($_GET["sort_by"]);
00283                 $tbl->setOrderDirection($_GET["sort_order"]);
00284                 if ($this->offlineMode())
00285                 {
00286                         $_GET["limit"] = 99999;
00287                         $_GET["offset"] = 0;
00288                         $tbl->disable("sort");
00289                         $tbl->disable("footer");
00290                 }
00291                 $tbl->setOffset($_GET["offset"]);
00292                 $tbl->setLimit($_GET["limit"]);
00293 
00294                 // footer
00295                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00296 
00297 //              $term_list = $this->glossary->getTermList();
00298                 $tbl->setMaxCount(count($term_list));
00299 
00300                 // sorting array
00301                 //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
00302 
00303                 $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
00304                 // render table
00305                 
00306                 $tbl->setBase("ilias.php");
00307                 $tbl->render();
00308 
00309                 if (count($term_list) > 0)
00310                 {
00311                         $i=1;
00312                         foreach($term_list as $key => $term)
00313                         {
00314                                 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00315                                 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
00316 
00317                                 for($j=0; $j<count($defs); $j++)
00318                                 {
00319                                         $def = $defs[$j];
00320                                         if (count($defs) > 1)
00321                                         {
00322                                                 $this->tpl->setCurrentBlock("definition");
00323                                                 $this->tpl->setVariable("DEF_TEXT", $this->lng->txt("cont_definition")." ".($j + 1));
00324                                                 $this->tpl->parseCurrentBlock();
00325                                         }
00326 
00327                                         //
00328                                         $this->tpl->setCurrentBlock("definition");
00329                                         $short_str = $def["short_text"];
00330                                         // replace tex
00331                                         // if a tex end tag is missing a tex end tag
00332                                         $ltexs = strrpos($short_str, "[tex]");
00333                                         $ltexe = strrpos($short_str, "[/tex]");
00334                                         if ($ltexs > $ltexe)
00335                                         {
00336                                                 $page =& new ilPageObject("gdf", $def["id"]);
00337                                                 $page->buildDom();
00338                                                 $short_str = $page->getFirstParagraphText();
00339                                                 $short_str = strip_tags($short_str, "<br>");
00340                                                 $ltexe = strpos($short_str, "[/tex]", $ltexs);
00341                                                 $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
00342                                         }
00343                                         if (!$this->offlineMode())
00344                                         {
00345                                                 $short_str = ilUtil::insertLatexImages($short_str);
00346                                         }
00347                                         else
00348                                         {
00349                                                 $short_str = ilUtil::buildLatexImages($short_str,
00350                                                         $this->getOfflineDirectory());
00351                                         }
00352                                         $short_str = ilPCParagraph::xml2output($short_str);
00353                                         
00354                                         $this->tpl->setVariable("DEF_SHORT", $short_str);
00355                                         $this->tpl->parseCurrentBlock();
00356 
00357                                         $this->tpl->setCurrentBlock("definition_row");
00358                                         $this->tpl->parseCurrentBlock();
00359                                 }
00360                                 
00361                                 // display additional column 'glossary' for meta glossaries
00362                                 if ($this->glossary->isVirtual())
00363                                 {
00364                                         $this->tpl->setCurrentBlock("glossary_row");
00365                                         $glo_title = ilObject::_lookupTitle($term["glo_id"]);
00366                                         $this->tpl->setVariable("GLO_TITLE", $glo_title);
00367                                         $this->tpl->parseCurrentBlock();
00368                                 }
00369 
00370                                 $this->tpl->setCurrentBlock("view_term");
00371                                 $this->tpl->setVariable("TEXT_TERM", $term["term"]);
00372                                 if (!$this->offlineMode())
00373                                 {
00374                                         if (!empty ($filter))
00375                                         {
00376                                                 $this->ctrl->setParameter($this, "term", $filter);
00377                                                 $this->ctrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
00378                                         }
00379                                         $this->ctrl->setParameter($this, "term_id", $term["id"]);
00380                                         $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
00381                                         $this->tpl->setVariable("LINK_VIEW_TERM",
00382                                                 $this->ctrl->getLinkTarget($this, "listDefinitions"));
00383                                         $this->ctrl->clearParameters($this);
00384                                 }
00385                                 else
00386                                 {
00387                                         $this->tpl->setVariable("LINK_VIEW_TERM", "term_".$term["id"].".html");
00388                                 }
00389                                 $this->tpl->setVariable("ANCHOR_TERM", "term_".$term["id"]);
00390                                 $this->tpl->parseCurrentBlock();
00391 
00392                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00393                                 $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
00394                                 $this->tpl->setCurrentBlock("tbl_content");
00395                                 $this->tpl->parseCurrentBlock();
00396                                 
00397                                 $this->ctrl->clearParameters($this);
00398                         }
00399                 } //if is_array
00400                 else
00401                 {
00402                         $this->tpl->setCurrentBlock("notfound");
00403                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00404                         $this->tpl->setVariable("NUM_COLS", $num);
00405                         $this->tpl->parseCurrentBlock();
00406                 }
00407                 
00408                 // edit link
00409                 if (!$this->offlineMode() && $ilAccess->checkAccess("write", "", $_GET["ref_id"]))
00410                 {
00411                         $this->tpl->setCurrentBlock("edit_glossary");
00412                         $this->tpl->setVariable("EDIT_TXT", $this->lng->txt("edit"));
00413                         $this->tpl->setVariable("EDIT_LINK",
00414                                 "ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$_GET["ref_id"]);
00415                         $this->tpl->setVariable("EDIT_TARGET", "_top");
00416                         $this->tpl->parseCurrentBlock();
00417                 }
00418                 
00419                 // permanent link
00420                 $this->tpl->setCurrentBlock("perma_link");
00421                 $this->tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
00422                         "/goto.php?target=glo_".$_GET["ref_id"]."&client_id=".CLIENT_ID);
00423                 $this->tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
00424                 $this->tpl->setVariable("PERMA_TARGET", "_top");
00425                 $this->tpl->parseCurrentBlock();
00426 
00427                 if ($this->offlineMode())
00428                 {
00429                         return $this->tpl->get();
00430                 }
00431         }
00432 
00436         function listDefinitions()
00437         {
00438                 global $ilUser, $ilAccess;
00439                 
00440                 require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00441                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00442                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00443                 //$this->setLocator();
00444                 $this->setTabs();
00445                 
00446                 if ($this->offlineMode())
00447                 {
00448                         $style_name = $ilUser->prefs["style"].".css";;
00449                         $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00450                 }
00451                 else
00452                 {
00453                         $this->setLocator();
00454                 }
00455 
00456                 // content style
00457                 $this->tpl->setCurrentBlock("ContentStyle");
00458                 if (!$this->offlineMode())
00459                 {
00460                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00461                                 ilObjStyleSheet::getContentStylePath(0));
00462                 }
00463                 else
00464                 {
00465                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","content.css");
00466                 }
00467                 $this->tpl->parseCurrentBlock();
00468 
00469                 // syntax style
00470                 $this->tpl->setCurrentBlock("SyntaxStyle");
00471                 if (!$this->offlineMode())
00472                 {
00473                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00474                                 ilObjStyleSheet::getSyntaxStylePath());
00475                 }
00476                 else
00477                 {
00478                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00479                                 "syntaxhighlight.css");
00480                 }
00481                 $this->tpl->parseCurrentBlock();
00482 
00483                 $term =& new ilGlossaryTerm($_GET["term_id"]);
00484                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00485                 $this->tpl->setTitle($this->lng->txt("cont_term").": ".$term->getTerm());
00486 
00487                 // load template for table
00488                 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", "Modules/Glossary");
00489                 //$this->tpl->addBlockfile("STATUSLINE", "statusline", "tpl.statusline.html");
00490 
00491                 $defs = ilGlossaryDefinition::getDefinitionList($_GET["term_id"]);
00492 
00493                 $this->tpl->setVariable("TXT_TERM", $term->getTerm());
00494                 $this->mobs = array();
00495 
00496                 for($j=0; $j<count($defs); $j++)
00497                 {
00498                         $def = $defs[$j];
00499                         $page =& new ilPageObject("gdf", $def["id"]);
00500                         $page_gui =& new ilPageObjectGUI($page);
00501 
00502                         // internal links
00503                         $page->buildDom();
00504                         $int_links = $page->getInternalLinks();
00505                         $link_xml = $this->getLinkXML($int_links);
00506                         $page_gui->setLinkXML($link_xml);
00507 
00508                         if ($this->offlineMode())
00509                         {
00510                                 $page_gui->setOutputMode("offline");
00511                                 $page_gui->setOfflineDirectory($this->getOfflineDirectory());
00512                         }
00513                         $page_gui->setSourcecodeDownloadScript($this->getLink($_GET["ref_id"]));
00514                         $page_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen", $_GET["term_id"], $def["id"]));
00515 
00516                         $page_gui->setTemplateOutput(false);
00517                         $page_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
00518                         if (!$this->offlineMode())
00519                         {
00520                                 $output = $page_gui->preview();
00521                         }
00522                         else
00523                         {
00524                                 $output = $page_gui->presentation($page_gui->getOutputMode());
00525                         }
00526 
00527                         if (count($defs) > 1)
00528                         {
00529                                 $this->tpl->setCurrentBlock("definition_header");
00530                                 $this->tpl->setVariable("TXT_DEFINITION",
00531                                         $this->lng->txt("cont_definition")." ".($j+1));
00532                                 $this->tpl->parseCurrentBlock();
00533                         }
00534                         
00535                         $this->tpl->setCurrentBlock("definition");
00536                         $this->tpl->setVariable("PAGE_CONTENT", $output);
00537                         $this->tpl->parseCurrentBlock();
00538                 }
00539                 
00540                 // display possible backlinks
00541                 $sources = ilInternalLink::_getSourcesOfTarget('git',$_GET['term_id'],0);
00542                 
00543                 if ($sources)
00544                 {
00545                         $backlist_shown = false;
00546                         foreach ($sources as $src)
00547                         {
00548                                 $type = explode(':',$src['type']);
00549                                 
00550                                 if ($type[0] == 'lm')
00551                                 {
00552                                         if ($type[1] == 'pg')
00553                                         {
00554                                                 $title = ilLMPageObject::_getPresentationTitle($src['id']);
00555                                                 $lm_id = ilLMObject::_lookupContObjID($src['id']);
00556                                                 $lm_title = ilObject::_lookupTitle($lm_id);
00557                                                 $this->tpl->setCurrentBlock('backlink_item');
00558                                                 $ref_ids = ilObject::_getAllReferences($lm_id);
00559                                                 $access = false;
00560                                                 foreach($ref_ids as $rid)
00561                                                 {
00562                                                         if ($ilAccess->checkAccess("read", "", $rid))
00563                                                         {
00564                                                                 $access = true;
00565                                                         }
00566                                                 }
00567                                                 if ($access)
00568                                                 {
00569                                                         $this->tpl->setCurrentBlock("backlink_item");
00570                                                         $this->tpl->setVariable("BACKLINK_LINK",ILIAS_HTTP_PATH."/goto.php?target=".$type[1]."_".$src['id']);
00571                                                         $this->tpl->setVariable("BACKLINK_ITEM",$lm_title.": ".$title);
00572                                                         $this->tpl->parseCurrentBlock();
00573                                                         $backlist_shown = true;
00574                                                 }
00575                                         }
00576                                 }
00577                         }
00578                         if ($backlist_shown)
00579                         {
00580                                 $this->tpl->setCurrentBlock("backlink_list");
00581                                 $this->tpl->setVariable("BACKLINK_TITLE",$this->lng->txt('glo_term_used_in'));
00582                                 $this->tpl->parseCurrentBlock();
00583                         }
00584                 }
00585                 
00586                 $this->tpl->setCurrentBlock("perma_link");
00587                 $this->tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
00588                         "/goto.php?target=".
00589                         "git".
00590                         "_".$_GET["term_id"]."_".$_GET["ref_id"]."&client_id=".CLIENT_ID);
00591                 $this->tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
00592                 $this->tpl->setVariable("PERMA_TARGET", "_top");
00593                 $this->tpl->parseCurrentBlock();
00594 
00595                 
00596                 if ($this->offlineMode())
00597                 {
00598 //echo "<br>glo_pres_return";
00599                         return $this->tpl->get();
00600                 }
00601         }
00602         
00603 
00607         function fullscreen()
00608         {
00609                 $html = $this->media("fullscreen");
00610                 return $html;
00611         }
00612 
00616         function media($a_mode = "media")
00617         {
00618                 $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
00619                 include_once("classes/class.ilObjStyleSheet.php");
00620                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00621                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00622                         ilObjStyleSheet::getContentStylePath(0));
00623 
00624                 //$int_links = $page_object->getInternalLinks();
00625                 $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
00626 
00627                 // later
00628                 //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
00629 
00630                 $link_xlm = "";
00631 
00632                 require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
00633                 $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
00634 
00635                 $xml = "<dummy>";
00636                 // todo: we get always the first alias now (problem if mob is used multiple
00637                 // times in page)
00638                 $xml.= $media_obj->getXML(IL_MODE_ALIAS);
00639                 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
00640                 $xml.= $link_xml;
00641                 $xml.="</dummy>";
00642 
00643                 $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
00644                 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
00645                 $xh = xslt_create();
00646 
00647                 if (!$this->offlineMode())
00648                 {
00649                         $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output");
00650                         $wb_path = ilUtil::getWebspaceDir("output");
00651                 }
00652                 else
00653                 {
00654                         $enlarge_path = "images/enlarge.gif";
00655                         $wb_path = ".";
00656                 }
00657 
00658                 $mode = $a_mode;
00659 
00660                 $this->ctrl->setParameter($this, "obj_type", "MediaObject");
00661                 $fullscreen_link =
00662                         $this->getLink($_GET["ref_id"], "fullscreen");
00663                 $this->ctrl->clearParameters($this);
00664 
00665                 $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
00666                         'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
00667                         'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
00668                 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
00669                 echo xslt_error($xh);
00670                 xslt_free($xh);
00671 
00672                 // unmask user html
00673                 $this->tpl->setVariable("MEDIA_CONTENT", $output);
00674 
00675                 $this->tpl->parseCurrentBlock();
00676                 if ($this->offlineMode())
00677                 {
00678                         $html = $this->tpl->get();
00679                         return $html;
00680                 }
00681 
00682         }
00683 
00687         function showDownloadList()
00688         {
00689                 global $ilBench;
00690 
00691                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glo_download_list.html", "Modules/Glossary");
00692 
00693                 $this->setTabs();
00694                 
00695                 // set title header
00696                 $this->tpl->setTitle($this->glossary->getTitle());
00697                 //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
00698                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.gif"));
00699 
00700                 // create table
00701                 require_once("./Services/Table/classes/class.ilTableGUI.php");
00702                 $tbl = new ilTableGUI();
00703 
00704                 // load files templates
00705                 $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
00706 
00707                 // load template for table content data
00708                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/Glossary");
00709 
00710                 $export_files = array();
00711                 $types = array("xml", "html");
00712                 foreach($types as $type)
00713                 {
00714                         if ($this->glossary->getPublicExportFile($type) != "")
00715                         {
00716                                 $dir = $this->glossary->getExportDirectory($type);
00717                                 if (is_file($this->glossary->getExportDirectory($type)."/".
00718                                         $this->glossary->getPublicExportFile($type)))
00719                                 {
00720                                         $size = filesize($this->glossary->getExportDirectory($type)."/".
00721                                                 $this->glossary->getPublicExportFile($type));
00722                                         $export_files[] = array("type" => $type,
00723                                                 "file" => $this->glossary->getPublicExportFile($type),
00724                                                 "size" => $size);
00725                                 }
00726                         }
00727                 }
00728                 
00729                 $num = 0;
00730                 
00731                 $tbl->setTitle($this->lng->txt("download"));
00732 
00733                 $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
00734                         $this->lng->txt("cont_file"),
00735                         $this->lng->txt("size"), $this->lng->txt("date"),
00736                         ""));
00737 
00738                 $cols = array("format", "file", "size", "date", "download");
00739                 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
00740                         "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
00741                 $tbl->setHeaderVars($cols, $header_params);
00742                 $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
00743                 $tbl->disable("sort");
00744 
00745                 // control
00746                 $tbl->setOrderColumn($_GET["sort_by"]);
00747                 $tbl->setOrderDirection($_GET["sort_order"]);
00748                 $tbl->setLimit($_GET["limit"]);
00749                 $tbl->setOffset($_GET["offset"]);
00750                 $tbl->setMaxCount($this->maxcount);             // ???
00751 
00752                 $this->tpl->setVariable("COLUMN_COUNTS", 5);
00753 
00754                 // footer
00755                 //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00756                 $tbl->disable("footer");
00757 
00758                 $tbl->setMaxCount(count($export_files));
00759                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
00760 
00761                 $tbl->render();
00762                 if(count($export_files) > 0)
00763                 {
00764                         $i=0;
00765                         foreach($export_files as $exp_file)
00766                         {
00767                                 $this->tpl->setCurrentBlock("tbl_content");
00768                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
00769 
00770                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00771                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00772 
00773                                 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
00774                                 $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
00775                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
00776 
00777                                 $file_arr = explode("__", $exp_file["file"]);
00778                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
00779 
00780                                 $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
00781                                 $this->ctrl->setParameter($this, "type", $exp_file["type"]);
00782                                 $this->tpl->setVariable("LINK_DOWNLOAD",
00783                                         $this->ctrl->getLinkTarget($this, "downloadExportFile"));
00784                                         
00785                                 $this->tpl->parseCurrentBlock();
00786                         }
00787                 } //if is_array
00788                 else
00789                 {
00790                         $this->tpl->setCurrentBlock("notfound");
00791                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00792                         $this->tpl->setVariable("NUM_COLS", 5);
00793                         $this->tpl->parseCurrentBlock();
00794                 }
00795 
00796                 //$this->tpl->show();
00797         }
00798 
00802         function downloadExportFile()
00803         {
00804                 $file = $this->glossary->getPublicExportFile($_GET["type"]);
00805                 if ($this->glossary->getPublicExportFile($_GET["type"]) != "")
00806                 {
00807                         $dir = $this->glossary->getExportDirectory($_GET["type"]);
00808                         if (is_file($dir."/".$file))
00809                         {
00810                                 ilUtil::deliverFile($dir."/".$file, $file);
00811                                 exit;
00812                         }
00813                 }
00814                 $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
00815         }
00816 
00824         function setLocator($a_tree = "", $a_id = "")
00825         {
00826                 global $ilias_locator;
00827 
00828                 //$this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00829                 require_once ("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
00830                 $gloss_loc =& new ilGlossaryLocatorGUI();
00831                 $gloss_loc->setMode("presentation");
00832                 if (!empty($_GET["term_id"]))
00833                 {
00834                         $term =& new ilGlossaryTerm($_GET["term_id"]);
00835                         $gloss_loc->setTerm($term);
00836                 }
00837                 $gloss_loc->setGlossary($this->glossary);
00838                 //$gloss_loc->setDefinition($this->definition);
00839                 $gloss_loc->display();
00840         }
00841 
00845         function downloadFile()
00846         {
00847                 $file = explode("_", $_GET["file_id"]);
00848                 include_once("./Modules/File/classes/class.ilObjFile.php");
00849                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
00850                 $fileObj->sendFile();
00851                 exit;
00852         }
00853 
00857         function setTabs()
00858         {
00859                 global $ilTabs;
00860                 // catch feedback message
00861                 #include_once("classes/class.ilTabsGUI.php");
00862                 #$tabs_gui =& new ilTabsGUI();
00863                 $this->getTabs($ilTabs);
00864 
00865                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00866 
00867         }
00868 
00872         function getLinkXML($a_int_links)
00873         {
00874 
00875                 if ($a_layoutframes == "")
00876                 {
00877                         $a_layoutframes = array();
00878                 }
00879                 $link_info = "<IntLinkInfos>";
00880                 foreach ($a_int_links as $int_link)
00881                 {
00882 //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
00883                         $target = $int_link["Target"];
00884                         if (substr($target, 0, 4) == "il__")
00885                         {
00886                                 $target_arr = explode("_", $target);
00887                                 $target_id = $target_arr[count($target_arr) - 1];
00888                                 $type = $int_link["Type"];
00889                                 $targetframe = ($int_link["TargetFrame"] != "")
00890                                         ? $int_link["TargetFrame"]
00891                                         : "None";
00892                                         
00893                                 if ($targetframe == "New")
00894                                 {
00895                                         $ltarget = "_blank";
00896                                 }
00897                                 else
00898                                 {
00899                                         $ltarget = "";
00900                                 }
00901 
00902                                 switch($type)
00903                                 {
00904                                         case "PageObject":
00905                                         case "StructureObject":
00906                                                 $lm_id = ilLMObject::_lookupContObjID($target_id);
00907                                                 $cont_obj =& $this->content_object;
00908                                                 if ($type == "PageObject")
00909                                                 {
00910                                                         $href = "./goto.php?target=pg_".$target_id;
00911                                                 }
00912                                                 else
00913                                                 {
00914                                                         $href = "./goto.php?target=st_".$target_id;
00915                                                 }
00916                                                 //$ltarget = "ilContObj".$lm_id;
00917                                                 break;
00918 
00919                                         case "GlossaryItem":
00920                                                 if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId())
00921                                                 {
00922                                                         if ($this->offlineMode())
00923                                                         {
00924                                                                 $href = "term_".$target_id.".html";
00925                                                         }
00926                                                         else
00927                                                         {
00928                                                                 $this->ctrl->setParameter($this, "term_id", $target_id);
00929                                                                 $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
00930                                                                 $href = str_replace("&", "&amp;", $href);
00931                                                         }
00932                                                 }
00933                                                 else
00934                                                 {
00935                                                         $href = "./goto.php?target=git_".$target_id;
00936                                                 }
00937                                                 break;
00938 
00939                                         case "MediaObject":
00940                                                 if ($this->offlineMode())
00941                                                 {
00942                                                         $href = "media_".$target_id.".html";
00943                                                 }
00944                                                 else
00945                                                 {
00946                                                         $this->ctrl->setParameter($this, "obj_type", $type);
00947                                                         $this->ctrl->setParameter($this, "mob_id", $target_id);
00948                                                         $href = $this->ctrl->getLinkTarget($this, "media");
00949                                                         $href = str_replace("&", "&amp;", $href);
00950                                                 }
00951                                                 break;
00952 
00953                                         case "RepositoryItem":
00954                                                 $obj_type = ilObject::_lookupType($target_id, true);
00955                                                 $obj_id = ilObject::_lookupObjId($target_id);
00956                                                 $href = "./goto.php?target=".$obj_type."_".$target_id;
00957                                                 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
00958                                                 $ltarget = $t_frame;
00959                                                 break;
00960 
00961                                 }
00962                                 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00963                                         "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00964                                 
00965                                 $this->ctrl->clearParameters($this);
00966                         }
00967                 }
00968                 $link_info.= "</IntLinkInfos>";
00969 
00970                 return $link_info;
00971         }
00972 
00973 
00977         function getLink($a_ref_id, $a_cmd = "", $a_term_id = "", $a_def_id = "",
00978                 $a_frame = "", $a_type = "")
00979         {
00980                 if ($a_cmd == "")
00981                 {
00982                         $a_cmd = "layout";
00983                 }
00984                 //$script = "glossary_presentation.php";
00985 
00986                 // handle online links
00987                 if (!$this->offlineMode())
00988                 {
00989                         //$link = $script."?ref_id=".$a_ref_id;
00990                         switch ($a_cmd)
00991                         {
00992                                 case "fullscreen":
00993                                         $this->ctrl->setParameter($this, "def_id", $a_def_id);
00994                                         $link = $this->ctrl->getLinkTarget($this, "fullscreen");
00995                                         $link = str_replace("&", "&amp;", $link);
00996                                         break;
00997                                 
00998                                 default:
00999                                         $link.= "&amp;cmd=".$a_cmd;
01000                                         if ($a_frame != "")
01001                                         {
01002                                                 $this->ctrl->setParameter($this, "frame", $a_frame);
01003                                         }
01004                                         if ($a_obj_id != "")
01005                                         {
01006                                                 switch ($a_type)
01007                                                 {
01008                                                         case "MediaObject":
01009                                                                 $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
01010                                                                 break;
01011                                                                 
01012                                                         default:
01013                                                                 $this->ctrl->setParameter($this, "def_id", $a_def_id);
01014                                                                 break;
01015                                                 }
01016                                         }
01017                                         if ($a_type != "")
01018                                         {
01019                                                 $this->ctrl->setParameter($this, "obj_type", $a_type);
01020                                         }
01021                                         $link = $this->ctrl->getLinkTarget($this, $a_cmd);
01022                                         $link = str_replace("&", "&amp;", $link);
01023                                         break;
01024                         }
01025                 }
01026                 else    // handle offline links
01027                 {
01028                         switch ($a_cmd)
01029                         {
01030                                 case "downloadFile":
01031                                         break;
01032                                         
01033                                 case "fullscreen":
01034                                         $link = "fullscreen.html";              // id is handled by xslt
01035                                         break;
01036                                         
01037                                 case "layout":
01038                                         break;
01039                                         
01040                                 case "glossary":
01041                                         $link = "term_".$a_obj_id.".html";
01042                                         break;
01043                                 
01044                                 case "media":
01045                                         $link = "media_".$a_obj_id.".html";
01046                                         break;
01047                                         
01048                                 default:
01049                                         break;
01050                         }
01051                 }
01052                 $this->ctrl->clearParameters($this);
01053                 return $link;
01054         }
01055 
01056 
01060         function getTabs(&$tabs_gui)
01061         {
01062                 global $ilAccess;
01063                 
01064                 $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
01065                 
01066                 if (!$this->offlineMode())
01067                 {
01068                         if ($this->ctrl->getCmd() != "listDefinitions")
01069                         {
01070                                 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
01071                                 {
01072                                         $tabs_gui->addTarget("cont_terms",
01073                                                 $this->ctrl->getLinkTarget($this, "listTerms"),
01074                                                 array("listTerms", "searchTerms", "clearTerms", ""),
01075                                                 "");
01076                                 }
01077         
01078                                 $force_active = false;
01079                                 if ($this->ctrl->getCmd() == "showSummary" ||
01080                                         strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui")
01081                                 {
01082                                         $force_active = true;
01083                                 }
01084                                 $tabs_gui->addTarget("information_abbr",
01085                                         $this->ctrl->getLinkTarget($this, "infoScreen"), array("infoScreen"),
01086                                         "ilInfoScreenGUI", "", $force_active);
01087         
01088                                 // glossary menu
01089                                 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
01090                                 {
01091                                         if ($this->glossary->isActiveGlossaryMenu())
01092                                         {
01093                                                 // download links
01094                                                 if ($this->glossary->isActiveDownloads())
01095                                                 {
01096                                                         $tabs_gui->addTarget("download",
01097                                                                 $this->ctrl->getLinkTarget($this, "showDownloadList"), "showDownloadList",
01098                                                                 "");
01099                                                 }
01100                                         }
01101                                 }
01102                         }
01103                         else
01104                         {
01105                                 $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
01106                                 if (!empty ($_REQUEST["term"]))
01107                                 {
01108                                         $this->ctrl->setParameter($this, "term", $_REQUEST["term"]);
01109                                         $this->ctrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
01110                                         $back = $this->ctrl->getLinkTarget($this, "searchTerms");
01111                                 }
01112                                 else
01113                                 {
01114                                         $back = $this->ctrl->getLinkTarget($this, "listTerms");
01115                                 }
01116                                 $tabs_gui->setBackTarget($this->lng->txt("obj_glo"),
01117                                         $back, "", "");
01118                         }
01119                         
01120                 }
01121                 else
01122                 {
01123                         $tabs_gui->addTarget("cont_back",
01124                                 "index.html#term_".$_GET["term_id"], "",
01125                                 "");
01126                 }
01127         }
01128         
01129         function download_paragraph () {
01130                 include_once("./Services/COPage/classes/class.ilPageObject.php");
01131                 $pg_obj =& new ilPageObject("gdf", $_GET["pg_id"]);
01132                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
01133         }
01134 
01135 
01141         function infoScreen()
01142         {
01143                 $this->ctrl->setCmd("showSummary");
01144                 $this->ctrl->setCmdClass("ilinfoscreengui");
01145                 $this->outputInfoScreen();
01146         }
01147 
01151         /*
01152         function showInfoScreen()
01153         {
01154                 $this->outputInfoScreen(true);
01155         }*/
01156 
01160         function outputInfoScreen()
01161         {
01162                 global $ilBench, $ilAccess;
01163 
01164                 $this->setTabs();
01165                 $this->lng->loadLanguageModule("meta");
01166 
01167                 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
01168 
01169                 $info = new ilInfoScreenGUI($this->glossary_gui);
01170                 $info->enablePrivateNotes();
01171                 //$info->enableLearningProgress();
01172 
01173                 $info->enableNews();
01174                 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
01175                 {
01176                         $info->enableNewsEditing();
01177                         $news_set = new ilSetting("news");
01178                         $enable_internal_rss = $news_set->get("enable_rss_for_internal");
01179                         if ($enable_internal_rss)
01180                         {
01181                                 $info->setBlockProperty("news", "settings", true);
01182                         }
01183                 }
01184 
01185                 // add read / back button
01186                 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
01187                 {
01188                         /*
01189                         if ($_GET["obj_id"] > 0)
01190                         {
01191                                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
01192                                 $info->addButton($this->lng->txt("back"),
01193                                         $this->ctrl->getLinkTarget($this, "layout"));
01194                         }
01195                         else
01196                         {
01197                                 $info->addButton($this->lng->txt("view"),
01198                                         $this->ctrl->getLinkTarget($this, "layout"));
01199                         }*/
01200                 }
01201                 
01202                 // show standard meta data section
01203                 $info->addMetaDataSections($this->glossary->getId(),0, $this->glossary->getType());
01204 
01205                 if ($this->offlineMode())
01206                 {
01207                         $this->tpl->setContent($info->getHTML());
01208                         return $this->tpl->get();
01209                 }
01210                 else
01211                 {
01212                         // forward the command
01213                         $this->ctrl->forwardCommand($info);
01214                 }
01215         }
01216 
01217 }
01218 
01219 ?>

Generated on Fri Dec 13 2013 17:56:51 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1