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

content/classes/class.ilGlossaryTermGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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("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                                 //$this->ctrl->setReturn($this, "listDefinitions");
00078                                 $def_edit =& new ilTermDefinitionEditorGUI();
00079                                 //$ret =& $def_edit->executeCommand();
00080                                 $ret =& $this->ctrl->forwardCommand($def_edit);
00081                                 break;
00082 
00083                         default:
00084                                 $ret =& $this->$cmd();
00085                                 break;
00086                 }
00087         }
00088 
00089 
00090         function setGlossary(&$a_glossary)
00091         {
00092                 $this->glossary =& $a_glossary;
00093         }
00094 
00095         function setLinkXML($a_link_xml)
00096         {
00097                 $this->link_xml = $a_link_xml;
00098         }
00099 
00100         function getLinkXML()
00101         {
00102                 return $this->link_xml;
00103         }
00104 
00108         function create()
00109         {
00110                 global $ilUser;
00111 
00112                 $this->getTemplate();
00113                 $this->displayLocator();
00114                 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_new_term"));
00115                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00116                 $this->setTabs();
00117 
00118                 // load template for table
00119                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_new.html", true);
00120                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00121                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_new_term"));
00122                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00123                 $this->tpl->setVariable("INPUT_TERM", "term");
00124                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00125                 $lang = ilMetaData::getLanguages();
00126 
00127                 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00128                 {
00129                         $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00130                 }
00131                 else
00132                 {
00133                         $s_lang = $ilUser->getLanguage();
00134                 }
00135 
00136                 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00137                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00138                 $this->tpl->setVariable("BTN_NAME", "saveTerm");
00139                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00140         }
00141 
00145         function saveTerm()
00146         {
00147                 $term =& new ilGlossaryTerm();
00148                 $term->setGlossary($this->glossary);
00149                 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00150                 $term->setLanguage($_POST["term_language"]);
00151                 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00152                 $term->create();
00153 
00154                 sendinfo($this->lng->txt("cont_added_term"),true);
00155                 $this->ctrl->returnToParent($this);
00156         }
00157 
00158 
00162         function editTerm()
00163         {
00164                 //$this->displayLocator();
00165                 $this->getTemplate();
00166                 $this->displayLocator();
00167                 $this->setTabs();
00168                 //$this->displayLocator();
00169                 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00170                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00171 
00172                 // load template for table
00173                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00174                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00175                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00176                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00177                 $this->tpl->setVariable("INPUT_TERM", "term");
00178                 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($this->term->getTerm()));
00179                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00180                 $lang = ilMetaData::getLanguages();
00181                 $select_language = ilUtil::formSelect ($this->term->getLanguage(),"term_language",$lang,false,true);
00182                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00183                 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00184                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00185         }
00186 
00187 
00191         function updateTerm()
00192         {
00193                 $this->term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00194                 $this->term->setLanguage($_POST["term_language"]);
00195                 $this->term->update();
00196                 sendinfo($this->lng->txt("msg_obj_modified"),true);
00197                 $this->ctrl->redirect($this, "editTerm");
00198         }
00199 
00205         function output($a_offline = false, $dir = "")
00206         {
00207                 require_once("content/classes/class.ilGlossaryDefinition.php");
00208                 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00209 
00210                 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00211 
00212                 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00213 
00214                 for($j=0; $j<count($defs); $j++)
00215                 {
00216                         $def = $defs[$j];
00217                         $page =& new ilPageObject("gdf", $def["id"]);
00218                         $page_gui =& new ilPageObjectGUI($page);
00219                         $page_gui->setSourcecodeDownloadScript($dir."glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00220                         if (!$a_offline)
00221                         {
00222                                 $page_gui->setFullscreenLink($dir."glossary_presentation.php?cmd=fullscreen&amp;ref_id=".$_GET["ref_id"]);
00223                         }
00224                         else
00225                         {
00226                                 $page_gui->setFullscreenLink("fullscreen.html");        // id is set by xslt
00227                         }
00228                         $page_gui->setFileDownloadLink($dir."glossary_presentation.php?cmd=downloadFile".
00229                                 "&amp;ref_id=".$_GET["ref_id"]);
00230 
00231                         if (!$a_offline)
00232                         {
00233                                 $page_gui->setOutputMode("presentation");
00234                         }
00235                         else
00236                         {
00237                                 $page_gui->setOutputMode("offline");
00238                         }
00239 
00240                         //$page_gui->setOutputMode("edit");
00241                         //$page_gui->setPresentationTitle($this->term->getTerm());
00242                         $page_gui->setLinkXML($this->getLinkXML());
00243                         $page_gui->setTemplateOutput(false);
00244                         $output = $page_gui->presentation($page_gui->getOutputMode());
00245 
00246                         if (count($defs) > 1)
00247                         {
00248                                 $this->tpl->setCurrentBlock("definition_header");
00249                                                 $this->tpl->setVariable("TXT_DEFINITION",
00250                                 $this->lng->txt("cont_definition")." ".($j+1));
00251                                 $this->tpl->parseCurrentBlock();
00252                         }
00253 
00254                         $this->tpl->setCurrentBlock("definition");
00255                         $this->tpl->setVariable("PAGE_CONTENT", $output);
00256                 }
00257         }
00258 
00262         function getInternalLinks()
00263         {
00264                 require_once("content/classes/class.ilGlossaryDefinition.php");
00265                 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00266 
00267                 $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
00268 
00269                 $term_links = array();
00270                 for($j=0; $j<count($defs); $j++)
00271                 {
00272                         $def = $defs[$j];
00273                         $page =& new ilPageObject("gdf", $def["id"]);
00274                         $page->buildDom();
00275                         $page_links = $page->getInternalLinks();
00276                         foreach($page_links as $key => $page_link)
00277                         {
00278                                 $term_links[$key] = $page_link;
00279                         }
00280                 }
00281 
00282                 return $term_links;
00283         }
00284 
00288         function listDefinitions()
00289         {
00290                 $this->getTemplate();
00291                 $this->displayLocator();
00292                 $this->setTabs();
00293 
00294                 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
00295 
00296                 // content style
00297                 $this->tpl->setCurrentBlock("ContentStyle");
00298                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00299                         ilObjStyleSheet::getContentStylePath(0));
00300                 $this->tpl->parseCurrentBlock();
00301 
00302                 // syntax style
00303                 $this->tpl->setCurrentBlock("SyntaxStyle");
00304                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00305                         ilObjStyleSheet::getSyntaxStylePath());
00306                 $this->tpl->parseCurrentBlock();
00307 
00308                 // load template for table
00309                 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", true);
00310                 //$this->tpl->addBlockfile("CONTENT", "def_list", "tpl.glossary_definition_list.html", true);
00311                 //sendInfo();
00312                 $this->tpl->addBlockfile("STATUSLINE", "statusline", "tpl.statusline.html");
00313                 $this->tpl->setVariable("HEADER",
00314                         $this->lng->txt("cont_term").": ".$this->term->getTerm());
00315                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00316 
00317                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00318 
00319                 $this->tpl->setCurrentBlock("add_def");
00320                 $this->tpl->setVariable("TXT_ADD_DEFINITION",
00321                         $this->lng->txt("cont_add_definition"));
00322                 $this->tpl->setVariable("BTN_ADD", "addDefinition");
00323                 $this->tpl->parseCurrentBlock();
00324                 $this->tpl->setCurrentBlock("def_list");
00325 
00326                 $defs = ilGlossaryDefinition::getDefinitionList($_GET["term_id"]);
00327 
00328                 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00329 
00330                 for($j=0; $j<count($defs); $j++)
00331                 {
00332                         $def = $defs[$j];
00333                         $page =& new ilPageObject("gdf", $def["id"]);
00334                         $page_gui =& new ilPageObjectGUI($page);
00335                         $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00336                         //$page_gui->setOutputMode("edit");
00337                         //$page_gui->setPresentationTitle($this->term->getTerm());
00338                         $page_gui->setTemplateOutput(false);
00339                         $output = $page_gui->preview();
00340 
00341                         if (count($defs) > 1)
00342                         {
00343                                 $this->tpl->setCurrentBlock("definition_header");
00344                                                 $this->tpl->setVariable("TXT_DEFINITION",
00345                                 $this->lng->txt("cont_definition")." ".($j+1));
00346                                 $this->tpl->parseCurrentBlock();
00347                         }
00348 
00349                         if ($j > 0)
00350                         {
00351                                 $this->tpl->setCurrentBlock("up");
00352                                 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00353                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00354                                 $this->tpl->setVariable("LINK_UP",
00355                                         $this->ctrl->getLinkTarget($this, "moveUp"));
00356                                 $this->tpl->parseCurrentBlock();
00357                         }
00358 
00359                         if ($j+1 < count($defs))
00360                         {
00361                                 $this->tpl->setCurrentBlock("down");
00362                                 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00363                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00364                                 $this->tpl->setVariable("LINK_DOWN",
00365                                         $this->ctrl->getLinkTarget($this, "moveDown"));
00366                                 $this->tpl->parseCurrentBlock();
00367                         }
00368                         $this->tpl->setCurrentBlock("submit_btns");
00369                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00370                         $this->ctrl->setParameter($this, "def", $def["id"]);
00371                         $this->ctrl->setParameterByClass("ilTermDefinitionEditorGUI", "def", $def["id"]);
00372                         $this->tpl->setVariable("LINK_EDIT",
00373                                 $this->ctrl->getLinkTargetByClass(array("ilTermDefinitionEditorGUI", "ilPageObjectGUI"), "view"));
00374                         $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00375                         $this->tpl->setVariable("LINK_DELETE",
00376                                 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00377                         $this->tpl->parseCurrentBlock();
00378 
00379                         $this->tpl->setCurrentBlock("definition");
00380                         $this->tpl->setVariable("PAGE_CONTENT", $output);
00381                         $this->tpl->parseCurrentBlock();
00382                 }
00383                 //$this->tpl->setCurrentBlock("def_list");
00384                 //$this->tpl->parseCurrentBlock();
00385 
00386         }
00387 
00388 
00392         function confirmDefinitionDeletion()
00393         {
00394                 $this->getTemplate();
00395                 $this->displayLocator();
00396                 $this->setTabs();
00397 
00398                 // content style
00399                 $this->tpl->setCurrentBlock("ContentStyle");
00400                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00401                         ilObjStyleSheet::getContentStylePath(0));
00402                 $this->tpl->parseCurrentBlock();
00403 
00404                 // syntax style
00405                 $this->tpl->setCurrentBlock("SyntaxStyle");
00406                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00407                         ilObjStyleSheet::getSyntaxStylePath());
00408                 $this->tpl->parseCurrentBlock();
00409 
00410                 $this->tpl->setVariable("HEADER",
00411                         $this->lng->txt("cont_term").": ".$this->term->getTerm());
00412                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00413 
00414                 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00415                 sendInfo($this->lng->txt("info_delete_sure"));
00416 
00417                 $this->tpl->setVariable("TXT_TERM", $this->term->getTerm());
00418 
00419                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00420                 $page =& new ilPageObject("gdf", $definition->getId());
00421                 $page_gui =& new ilPageObjectGUI($page);
00422                 $page_gui->setTemplateOutput(false);
00423                 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00424                 $output = $page_gui->preview();
00425 
00426                 $this->tpl->setCurrentBlock("definition");
00427                 $this->tpl->setVariable("PAGE_CONTENT", $output);
00428                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00429                 $this->tpl->setVariable("LINK_CANCEL",
00430                         $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00431                 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00432                 $this->ctrl->setParameter($this, "def", $definition->getId());
00433                 $this->tpl->setVariable("LINK_CONFIRM",
00434                         $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00435                 $this->tpl->parseCurrentBlock();
00436         }
00437 
00438         function cancelDefinitionDeletion()
00439         {
00440                 $this->ctrl->redirect($this, "listDefinitions");
00441         }
00442 
00443 
00444         function deleteDefinition()
00445         {
00446                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00447                 $definition->delete();
00448                 $this->ctrl->redirect($this, "listDefinitions");
00449         }
00450 
00451 
00455         function moveUp()
00456         {
00457                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00458                 $definition->moveUp();
00459                 $this->ctrl->redirect($this, "listDefinitions");
00460         }
00461 
00462 
00466         function moveDown()
00467         {
00468                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00469                 $definition->moveDown();
00470                 $this->ctrl->redirect($this, "listDefinitions");
00471         }
00472 
00473 
00477         function addDefinition()
00478         {
00479 
00480                 $this->getTemplate();
00481                 $this->displayLocator();
00482                 $this->setTabs();
00483                 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$this->term->getTerm());
00484                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
00485 
00486                 $term_id = $_GET["term_id"];
00487 
00488                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_edit.html");
00489                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00490                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("gdf_new"));
00491                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00492                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("gdf_add"));
00493                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00494                 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00495                 $this->tpl->setVariable("CMD_SUBMIT", "saveDefinition");
00496                 //$this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00497                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00498                 $this->tpl->parseCurrentBlock();
00499 
00500         }
00501 
00505         function cancel()
00506         {
00507                 sendInfo($this->lng->txt("msg_cancel"),true);
00508                 $this->ctrl->redirect($this, "listDefinitions");
00509         }
00510 
00514         function saveDefinition()
00515         {
00516                 //$meta_gui =& new ilMetaDataGUI();
00517                 //$meta_data =& $meta_gui->create();
00518                 $def =& new ilGlossaryDefinition();
00519                 $def->setTermId($_GET["term_id"]);
00520                 $def->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));#"content object ".$newObj->getId());          // set by meta_gui->save
00521                 $def->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));  // set by meta_gui->save
00522                 $def->create();
00523 
00524                 $this->ctrl->redirect($this, "listDefinitions");
00525         }
00526 
00527 
00531         function getTemplate()
00532         {
00533                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00534                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00535                 sendInfo();
00536         }
00537 
00541         function setTabs()
00542         {
00543                 global $ilTabs;
00544 
00545                 // catch feedback message
00546                 #include_once("classes/class.ilTabsGUI.php");
00547                 #$tabs_gui =& new ilTabsGUI();
00548                 $this->getTabs($ilTabs);
00549 
00550                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00551 
00552         }
00553 
00557         function displayLocator()
00558         {
00559                 require_once ("content/classes/class.ilGlossaryLocatorGUI.php");
00560                 $gloss_loc =& new ilGlossaryLocatorGUI();
00561                 $gloss_loc->setTerm($this->term);
00562                 $gloss_loc->setGlossary($this->glossary);
00563                 //$gloss_loc->setDefinition($this->definition);
00564                 $gloss_loc->display();
00565         }
00566 
00567 
00571         function getTabs(&$tabs_gui)
00572         {
00573 //echo ":".$_GET["term_id"].":";
00574                 if ($_GET["term_id"] != "")
00575                 {
00576                         $tabs_gui->addTarget("properties",
00577                                 $this->ctrl->getLinkTarget($this, "editTerm"), array("editTerm"),
00578                                 get_class($this));
00579                                 
00580                         $tabs_gui->addTarget("cont_definitions",
00581                                 $this->ctrl->getLinkTarget($this, "listDefinitions"),
00582                                 "listDefinitions",
00583                                 get_class($this));              
00584                 }
00585 
00586                 // back to glossary
00587                 $tabs_gui->setBackTarget($this->lng->txt("glossary"),
00588                         $this->ctrl->getLinkTargetByClass("ilobjglossarygui", "listTerms"));
00589         }
00590 
00591 }
00592 
00593 ?>

Generated on Fri Dec 13 2013 11:57:56 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1