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

content/classes/class.ilObjGlossaryGUI.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("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 
00044 class ilObjGlossaryGUI extends ilObjectGUI
00045 {
00046         var $admin_tabs;
00047         var $mode;
00048         var $term;
00049 
00054         function ilObjGlossaryGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
00055         {
00056                 global $ilCtrl, $lng;
00057 
00058                 $this->ctrl =& $ilCtrl;
00059                 $this->ctrl->saveParameter($this, array("ref_id", "offset"));
00060                 $lng->loadLanguageModule("content");
00061 
00062                 $this->type = "glo";
00063                 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
00064                 //if ($a_prepare_output)
00065                 //{
00066                 //      $this->prepareOutput();
00067                 //}
00068         }
00069 
00073         function &executeCommand()
00074         {
00075                 global $lng, $ilAccess;
00076                 
00077                 $cmd = $this->ctrl->getCmd();
00078                 $next_class = $this->ctrl->getNextClass($this);
00079 
00080                 switch ($next_class)
00081                 {
00082                         case 'ilmdeditorgui':
00083                                 $this->getTemplate();
00084                                 $this->setTabs();
00085                                 $this->setLocator();
00086 
00087                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00088 
00089                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00090                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00091 
00092                                 $this->ctrl->forwardCommand($md_gui);
00093                                 break;
00094 
00095                         case "ilglossarytermgui":
00096                                 $this->ctrl->setReturn($this, "listTerms");
00097                                 $term_gui =& new ilGlossaryTermGUI($_GET["term_id"]);
00098                                 $term_gui->setGlossary($this->object);
00099                                 //$ret =& $term_gui->executeCommand();
00100                                 $ret =& $this->ctrl->forwardCommand($term_gui);
00101                                 break;
00102                                 
00103                         case 'ilpermissiongui':
00104                                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00105                                 {
00106                                         $this->prepareOutput();
00107                                 }
00108                                 else
00109                                 {
00110                                         $this->getTemplate();
00111                                         $this->setTabs();
00112                                         $this->setLocator();
00113                                 }
00114                                 include_once("./classes/class.ilPermissionGUI.php");
00115                                 $perm_gui =& new ilPermissionGUI($this);
00116                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00117                                 break;
00118 
00119                         default:
00120                                 $cmd = $this->ctrl->getCmd("frameset");
00121 
00122                                 if (($cmd == "create") && ($_POST["new_type"] == "term"))
00123                                 {
00124                                         $this->ctrl->setCmd("create");
00125                                         $this->ctrl->setCmdClass("ilGlossaryTermGUI");
00126                                         $ret =& $this->executeCommand();
00127                                         return;
00128                                 }
00129                                 else
00130                                 {
00131                                         if (!in_array($cmd, array("frameset", "quickList")))
00132                                         {
00133                                                 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00134                                                         $this->getCreationMode() == true)
00135                                                 {
00136                                                         $this->prepareOutput();
00137                                                         $cmd.= "Object";
00138                                                 }
00139                                                 else
00140                                                 {
00141                                                         $this->getTemplate();
00142                                                         $this->setTabs();
00143                                                         $this->setLocator();
00144                                                 }
00145                                         }
00146                                         $ret =& $this->$cmd();
00147                                 }
00148                                 break;
00149                 }
00150 
00151                 if (!in_array($cmd, array("frameset", "quickList")))
00152                 {
00153                         if (strtolower($_GET["baseClass"]) != "iladministrationgui")
00154                         {
00155                                 if (!$this->getCreationMode())
00156                                 {
00157                                         $this->tpl->show();
00158                                 }
00159                         }
00160                 }
00161                 else
00162                 {
00163                         $this->tpl->show(false);
00164                 }
00165         }
00166 
00167         function assignObject()
00168         {
00169                 include_once("content/classes/class.ilObjGlossary.php");
00170 
00171                 $this->object =& new ilObjGlossary($this->id, true);
00172         }
00173 
00174 
00178         function createObject()
00179         {
00180                 global $rbacsystem;
00181 
00182                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00183 
00184                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00185                 {
00186                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00187                 }
00188                 
00189                 $stati  = array(
00190                                                 "none"=>$this->lng->txt("glo_mode_normal"),
00191                                                 "level"=>$this->lng->txt("glo_mode_level"),
00192                                                 "subtree"=>$this->lng->txt("glo_mode_subtree")
00193                                                 );
00194 
00195                 $glo_type = $_SESSION["error_post_vars"]["glo_type"];
00196                 
00197                 $opts   = ilUtil::formSelect("none","glo_mode",$stati,false,true);
00198 
00199                 // fill in saved values in case of error
00200                 $data = array();
00201                 $data["fields"] = array();
00202                 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00203                 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00204 
00205                 $this->getTemplateFile("create", $new_type);
00206                 
00207                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_glo.gif'));
00208                 $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_glo"));
00209 
00210                 foreach ($data["fields"] as $key => $val)
00211                 {
00212                         $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00213                         $this->tpl->setVariable(strtoupper($key), $val);
00214 
00215                         if ($this->prepare_output)
00216                         {
00217                                 $this->tpl->parseCurrentBlock();
00218                         }
00219                 }
00220 
00221                 $this->ctrl->setParameter($this, "new_type", $new_type);
00222                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00223 
00224                 //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00225                 //                                                                                                                         $_GET["ref_id"]."&new_type=".$new_type));
00226                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00227                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00228                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00229                 $this->tpl->setVariable("CMD_SUBMIT", "save");
00230                 $this->tpl->setVariable("TARGET", ' target="'.
00231                         ilFrameTargetInfo::_getFrame("MainContent").'" ');
00232                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00233                 
00234                 $this->tpl->setVariable("SELECT_GLO_MODE", $opts);
00235                 $this->tpl->setVariable("TXT_GLO_MODE", $this->lng->txt("glo_mode"));
00236                 $this->tpl->setVariable("TXT_GLO_MODE_DESC", $this->lng->txt("glo_mode_desc"));
00237 
00238                 $this->tpl->setVariable("TXT_IMPORT_GLO", $this->lng->txt("import_glossary"));
00239                 $this->tpl->setVariable("TXT_GLO_FILE", $this->lng->txt("glo_upload_file"));
00240                 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
00241         }
00242 
00243         function importObject()
00244         {
00245                 $this->createObject();
00246         }
00247 
00251         function saveObject()
00252         {
00253                 global $rbacadmin, $rbacsystem;
00254 
00255                 // always call parent method first to create an object_data entry & a reference
00256                 //$newObj = parent::saveObject();
00257                 // TODO: fix MetaDataGUI implementation to make it compatible to use parent call
00258                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
00259                 {
00260                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
00261                 }
00262                 
00263                 // check required fields
00264                 if (empty($_POST["Fobject"]["title"]))
00265                 {
00266                         $this->ilErr->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilErr->MESSAGE);
00267                 }
00268                 
00269                 // create and insert object in objecttree
00270                 include_once("content/classes/class.ilObjGlossary.php");
00271                 $newObj = new ilObjGlossary();
00272                 $newObj->setType($this->type);
00273                 $newObj->setTitle($_POST["Fobject"]["title"]);
00274                 $newObj->setDescription($_POST["Fobject"]["desc"]);
00275                 $newObj->setVirtualMode($_POST["glo_mode"]);
00276                 $newObj->create();
00277                 $newObj->createReference();
00278                 $newObj->putInTree($_GET["ref_id"]);
00279                 $newObj->setPermissions($_GET["ref_id"]);
00280                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00281 
00282                 // always send a message
00283                 sendInfo($this->lng->txt("glo_added"),true);
00284                 ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
00285 
00286                 //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00287         }
00288 
00295         function importFileObject()
00296         {
00297                 global $_FILES, $rbacsystem;
00298 
00299                 // check if file was uploaded
00300                 $source = $_FILES["xmldoc"]["tmp_name"];
00301                 if (($source == 'none') || (!$source))
00302                 {
00303                         $this->ilias->raiseError($this->lng->txt("msg_no_file"),$this->ilias->error_obj->MESSAGE);
00304                 }
00305                 // check create permission
00306                 /*
00307                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
00308                 {
00309                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00310                 }*/
00311 
00312                 // check correct file type
00313                 // check correct file type
00314                 $info = pathinfo($_FILES["xmldoc"]["name"]);
00315                 if (strtolower($info["extension"]) != "zip")
00316                 {
00317                         $this->ilias->raiseError($this->lng->txt("cont_no_zip_file"),
00318                                 $this->ilias->error_obj->MESSAGE);
00319                 }
00320 
00321                 // create and insert object in objecttree
00322                 include_once("content/classes/class.ilObjGlossary.php");
00323                 $newObj = new ilObjGlossary();
00324                 $newObj->setType($_GET["new_type"]);
00325                 $newObj->setTitle($_FILES["xmldoc"]["name"]);
00326                 $newObj->create(true);
00327                 $newObj->createReference();
00328                 $newObj->putInTree($_GET["ref_id"]);
00329                 $newObj->setPermissions($_GET["ref_id"]);
00330                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00331 
00332                 // create import directory
00333                 $newObj->createImportDirectory();
00334 
00335                 // copy uploaded file to import directory
00336                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00337                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00338                 
00339                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
00340                         $_FILES["xmldoc"]["name"], $full_path);
00341                 
00342                 // unzip file
00343                 ilUtil::unzip($full_path);
00344 
00345                 // determine filename of xml file
00346                 $subdir = basename($file["basename"],".".$file["extension"]);
00347                 $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
00348 
00349                 // check whether subdirectory exists within zip file
00350                 if (!is_dir($newObj->getImportDirectory()."/".$subdir))
00351                 {
00352                         $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir),
00353                                 $this->ilias->error_obj->MESSAGE);
00354                 }
00355 
00356                 // check whether xml file exists within zip file
00357                 if (!is_file($xml_file))
00358                 {
00359                         $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"),
00360                                 $this->ilias->error_obj->MESSAGE);
00361                 }
00362 
00363                 include_once ("content/classes/class.ilContObjParser.php");
00364                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
00365                 $contParser->startParsing();
00366                 ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
00367 
00368                 // delete import directory
00369                 ilUtil::delDir($newObj->getImportDirectory());
00370 
00371                 sendInfo($this->lng->txt("glo_added"),true);
00372                 ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
00373                 //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00374         }
00375 
00376 
00377         function viewObject()
00378         {
00379                 global $rbacsystem;
00380                 
00381                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00382                 {
00383                         parent::viewObject();
00384                         return;
00385                 }
00386 
00387                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00388                 {
00389                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00390                 }
00391 
00392                 // edit button
00393                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00394 
00395                 $this->tpl->setCurrentBlock("btn_cell");
00396                 $this->tpl->setVariable("BTN_LINK",
00397                         "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID());
00398                 $this->tpl->setVariable("BTN_TARGET"," target=\"".
00399                         ilFrameTargetInfo::_getFrame("MainContent")."\" ");
00400                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00401                 $this->tpl->parseCurrentBlock();
00402 
00403                 //parent::viewObject();
00404         }
00405 
00411         function properties()
00412         {
00413                 global $rbacsystem, $tree, $tpl;
00414 
00415                 // glossary properties
00416                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glossary_properties.html", true);
00417                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00418                 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_glo_properties"));
00419 
00420                 // online
00421                 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00422                 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00423                 $this->tpl->setVariable("VAL_ONLINE", "y");
00424 
00425                 if ($this->object->getOnline())
00426                 {
00427                         $this->tpl->setVariable("CHK_ONLINE", "checked");
00428                 }
00429                 
00430                 // glossary mode
00431                 $stati  = array(
00432                                                 "none"=>$this->lng->txt("glo_mode_normal"),
00433                                                 "level"=>$this->lng->txt("glo_mode_level"),
00434                                                 "subtree"=>$this->lng->txt("glo_mode_subtree")
00435                                                 );
00436 
00437                 $opts   = ilUtil::formSelect($this->object->getVirtualMode(),"glo_mode",$stati,false,true);
00438                 
00439                 $this->tpl->setVariable("SELECT_GLO_MODE", $opts);
00440                 $this->tpl->setVariable("TXT_GLO_MODE", $this->lng->txt("glo_mode"));
00441                 $this->tpl->setVariable("TXT_GLO_MODE_DESC", $this->lng->txt("glo_mode_desc"));
00442 
00443                 // glossary menu
00444                 $this->tpl->setVariable("TXT_GLO_MENU", $this->lng->txt("cont_glo_menu"));
00445                 $this->tpl->setVariable("TXT_ACT_MENU", $this->lng->txt("cont_active"));
00446                 $this->tpl->setVariable("CBOX_GLO_MENU", "glo_act_menu");
00447                 $this->tpl->setVariable("VAL_GLO_MENU", "y");
00448 
00449                 if ($this->object->isActiveGlossaryMenu())
00450                 {
00451                         $this->tpl->setVariable("CHK_GLO_MENU", "checked");
00452                 }
00453                 
00454                 // downloads
00455                 $this->tpl->setVariable("TXT_DOWNLOADS", $this->lng->txt("cont_downloads"));
00456                 $this->tpl->setVariable("TXT_DOWNLOADS_DESC", $this->lng->txt("cont_downloads_desc"));
00457                 $this->tpl->setVariable("CBOX_DOWNLOADS", "glo_act_downloads");
00458                 $this->tpl->setVariable("VAL_DOWNLOADS", "y");
00459                 if ($this->object->isActiveDownloads())
00460                 {
00461                         $this->tpl->setVariable("CHK_DOWNLOADS", "checked");
00462                 }
00463 
00464 
00465                 $this->tpl->setCurrentBlock("commands");
00466                 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00467                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00468                 $this->tpl->parseCurrentBlock();
00469 
00470         }
00471 
00475         function saveProperties()
00476         {
00477                 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00478                 $this->object->setVirtualMode($_POST["glo_mode"]);
00479                 $this->object->setActiveGlossaryMenu(ilUtil::yn2tf($_POST["glo_act_menu"]));
00480                 $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["glo_act_downloads"]));
00481                 $this->object->update();
00482                 sendInfo($this->lng->txt("msg_obj_modified"), true);
00483                 $this->ctrl->redirect($this, "properties");
00484         }
00485 
00489         function frameset()
00490         {
00491                 include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
00492                 $fs_gui = new ilFramesetGUI();
00493                 $fs_gui->setFramesetTitle($this->object->getTitle());
00494                 $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "listTerms"));
00495                 $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this, "quickList"));
00496                 $fs_gui->setMainFrameName("content");
00497                 $fs_gui->setSideFrameName("tree");
00498                 $fs_gui->show();
00499                 exit;
00500         }
00501         
00505         function quickList()
00506         {
00507                 global $ilUser;
00508 
00509                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.glossary_short_list.html", "content");
00510                 
00511                 $this->tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
00512                 $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
00513                 
00514                 $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
00515                 $this->tpl->setVariable("CMD_REFR", "quickList");
00516                 $this->tpl->setVariable("TXT_REFR", $this->lng->txt("refresh"));
00517                 
00518                 include_once "./classes/class.ilTableGUI.php";
00519 
00520                 // glossary term list template
00521 
00522                 // load template for table
00523                 $this->tpl->addBlockfile("SHORT_LIST", "list", "tpl.table.html");
00524 
00525                 // load template for table content data
00526                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_short_tbl_row.html", true);
00527 
00528                 $num = 0;
00529 
00530                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00531 
00532                 // create table
00533                 $tbl = new ilTableGUI();
00534 
00535                 // title & header columns
00536                 $tbl->setTitle($this->lng->txt("cont_terms"));
00537                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00538 
00539                 $tbl->setHeaderNames(array($this->lng->txt("cont_term")));
00540 
00541                 $cols = array("term");
00542                 $header_params = $this->ctrl->getParameterArrayByClass("ilobjglossarygui", "listTerms");
00543                 $header_params["cmd"] = "quickList";
00544                 $tbl->setHeaderVars($cols, $header_params);
00545                 $tbl->setColumnWidth(array("100%"));
00546 
00547                 // control
00548                 $tbl->setOrderColumn($_GET["sort_by"]);
00549                 $tbl->setOrderDirection($_GET["sort_order"]);
00550                 $tbl->setLimit($_GET["limit"]);
00551                 $tbl->setOffset($_GET["offset"]);
00552                 $tbl->disable("header");
00553                 
00554                 $term_list = $this->object->getTermList();
00555                 $tbl->setMaxCount(count($term_list));
00556 
00557                 $this->tpl->setVariable("COLUMN_COUNT", 1);
00558 
00559                 // footer
00560                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00561                 
00562 
00563                 // sorting array
00564                 $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
00565 
00566                 // render table
00567                 $tbl->render();
00568 
00569                 if (count($term_list) > 0)
00570                 {
00571                         $i=1;
00572                         foreach($term_list as $key => $term)
00573                         {
00574                                 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
00575                                 
00576                                 $sep = ": ";
00577                                 for($j=0; $j<count($defs); $j++)
00578                                 {
00579                                         $def = $defs[$j];
00580 
00581                                         // edit
00582                                         $this->tpl->setCurrentBlock("definition");
00583                                         $this->tpl->setVariable("SEP", $sep);
00584                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
00585                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
00586                                         $this->tpl->setVariable("LINK_EDIT_DEF",
00587                                                 $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
00588                                                 "iltermdefinitioneditorgui",
00589                                                 "ilpageobjectgui"), "view"));
00590                                         $this->tpl->setVariable("TEXT_DEF", $this->lng->txt("glo_definition_abbr").($j+1));
00591                                         $this->tpl->parseCurrentBlock();
00592                                         $sep = ", ";
00593                                 }
00594 
00595                                 $this->tpl->setCurrentBlock("tbl_content");
00596                                 $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
00597 
00598                                 // edit term link
00599                                 $this->tpl->setVariable("TEXT_TERM", $term["term"]);
00600                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00601                                 $this->tpl->setVariable("LINK_EDIT_TERM",
00602                                         $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
00603                                         
00604                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00605                                 $this->tpl->parseCurrentBlock();
00606                         }
00607                 } //if is_array
00608                 else
00609                 {
00610                         $this->tpl->setCurrentBlock("notfound");
00611                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00612                         $this->tpl->setVariable("NUM_COLS", $num);
00613                         $this->tpl->parseCurrentBlock();
00614                 }
00615         }
00616         
00617 
00621         function listTerms()
00622         {
00623                 global $ilUser;
00624 
00625                 //$this->getTemplate();
00626                 //$this->setTabs();
00627                 //$this->setLocator();
00628                 $this->lng->loadLanguageModule("meta");
00629                 include_once "./classes/class.ilTableGUI.php";
00630 
00631 
00632                 // view button
00633                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00634 
00635                 $this->tpl->setCurrentBlock("btn_cell");
00636                 $this->tpl->setVariable("BTN_LINK",
00637                         "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID());
00638                 $this->tpl->setVariable("BTN_TARGET"," target=\"".
00639                         ilFrameTargetInfo::_getFrame("MainContent")."\" ");
00640                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00641                 $this->tpl->parseCurrentBlock();
00642 
00643                 // glossary term list template
00644                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_list.html", true);
00645                 $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
00646                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00647                 $this->tpl->setVariable("TXT_ADD2", $this->lng->txt("add"));
00648                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00649                 $lang = ilMetaData::getLanguages();
00650 
00651                 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00652                 {
00653                         $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00654                 }
00655                 else
00656                 {
00657                         $s_lang = $ilUser->getLanguage();
00658                 }
00659 
00660                 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00661                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00662 
00663 
00664                 // load template for table
00665                 $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
00666 
00667                 // load template for table content data
00668                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_row.html", true);
00669 
00670                 $num = 0;
00671 
00672                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00673 
00674                 // create table
00675                 $tbl = new ilTableGUI();
00676 
00677                 // title & header columns
00678                 $tbl->setTitle($this->lng->txt("cont_terms"));
00679                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00680 
00681                 $tbl->setHeaderNames(array("", $this->lng->txt("cont_term"),
00682                          $this->lng->txt("language"), $this->lng->txt("cont_definitions")));
00683 
00684                 $cols = array("", "term", "language", "definitions", "id");
00685                 // get all ilCtrl parameters to feed the table urls
00686                 $header_params = $this->ctrl->getParameterArrayByClass("ilobjglossarygui", "listTerms");
00687                 $tbl->setHeaderVars($cols, $header_params);
00688                 $tbl->setColumnWidth(array("1%","24%","15%","60%"));
00689 
00690                 // control
00691                 $tbl->setOrderColumn($_GET["sort_by"]);
00692                 $tbl->setOrderDirection($_GET["sort_order"]);
00693                 $tbl->setLimit($_GET["limit"]);
00694                 $tbl->setOffset($_GET["offset"]);
00695                 $tbl->disable("sort");
00696                 
00697                 $term_list = $this->object->getTermList();
00698                 $tbl->setMaxCount(count($term_list));
00699 
00700 //echo "maxcount:".count($term_list).":";
00701 //echo "+".$_GET["offset"]."+".$_GET["limit"]."+";
00702 
00703                 $this->setActions(array("confirmTermDeletion" => "delete", "addDefinition" => "cont_add_definition"));
00704                 //$this->setSubObjects(array("term" => array()));
00705 
00706                 // footer
00707                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00708 
00709                 // sorting array
00710                 //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
00711                 $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
00712 
00713                 // render table
00714                 $tbl->render();
00715 
00716                 if (count($term_list) > 0)
00717                 {
00718                         $this->tpl->setVariable("COLUMN_COUNTS", 4);
00719                         $this->showActions(true);
00720 
00721                         $i=1;
00722                         foreach($term_list as $key => $term)
00723                         {
00724                                 $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
00725                                 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
00726                                 for($j=0; $j<count($defs); $j++)
00727                                 {
00728                                         $def = $defs[$j];
00729 
00730                                         // up
00731                                         if ($j > 0)
00732                                         {
00733                                                 $this->tpl->setCurrentBlock("move_up");
00734                                                 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00735                                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00736                                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00737                                                 $this->tpl->setVariable("LINK_UP",
00738                                                         $this->ctrl->getLinkTarget($this, "moveDefinitionUp"));
00739                                                 $this->tpl->parseCurrentBlock();
00740                                         }
00741 
00742                                         // down
00743                                         if ($j+1 < count($defs))
00744                                         {
00745                                                 $this->tpl->setCurrentBlock("move_down");
00746                                                 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00747                                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00748                                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00749                                                 $this->tpl->setVariable("LINK_DOWN",
00750                                                         $this->ctrl->getLinkTarget($this, "moveDefinitionDown"));
00751                                                 $this->tpl->parseCurrentBlock();
00752                                         }
00753 
00754                                         // delete
00755                                         $this->tpl->setCurrentBlock("delete");
00756                                         $this->ctrl->setParameter($this, "term_id", $term["id"]);
00757                                         $this->ctrl->setParameter($this, "def", $def["id"]);
00758                                         $this->tpl->setVariable("LINK_DELETE",
00759                                                 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00760                                         $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00761                                         $this->tpl->parseCurrentBlock();
00762 
00763                                         // edit
00764                                         $this->tpl->setCurrentBlock("edit");
00765                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
00766                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
00767                                         $this->tpl->setVariable("LINK_EDIT",
00768                                                 $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
00769                                                 "iltermdefinitioneditorgui",
00770                                                 "ilpageobjectgui"), "view"));
00771                                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00772                                         $this->tpl->parseCurrentBlock();
00773 
00774                                         // text
00775                                         $this->tpl->setCurrentBlock("definition");
00776                                         $short_str = ilPCParagraph::xml2output($def["short_text"]);
00777                                         
00778                                         // replace tex
00779                                         // if a tex end tag is missing a tex end tag
00780                                         $ltexs = strrpos($short_str, "[tex]");
00781                                         $ltexe = strrpos($short_str, "[/tex]");
00782                                         if ($ltexs > $ltexe)
00783                                         {
00784                                                 $page =& new ilPageObject("gdf", $def["id"]);
00785                                                 $page->buildDom();
00786                                                 $short_str = $page->getFirstParagraphText();
00787                                                 $short_str = strip_tags($short_str, "<br>");
00788                                                 $ltexe = strpos($short_str, "[/tex]", $ltexs);
00789                                                 $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
00790                                         }
00791                                         $short_str = ilUtil::insertLatexImages($short_str);
00792                                         $this->tpl->setVariable("DEF_SHORT", $short_str);
00793                                         $this->tpl->parseCurrentBlock();
00794 
00795                                         $this->tpl->setCurrentBlock("definition_row");
00796                                         $this->tpl->parseCurrentBlock();
00797                                 }
00798 
00799                                 $this->tpl->setCurrentBlock("check_col");
00800                                 $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
00801                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00802                                 $this->tpl->parseCurrentBlock();
00803 
00804                                 // edit term link
00805                                 $this->tpl->setCurrentBlock("edit_term");
00806                                 $this->tpl->setVariable("TEXT_TERM", $term["term"]);
00807                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00808                                 $this->tpl->setVariable("LINK_EDIT_TERM",
00809                                         $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
00810                                 $this->tpl->setVariable("TXT_EDIT_TERM", $this->lng->txt("edit"));
00811                                 $this->tpl->parseCurrentBlock();
00812 
00813                                 $this->tpl->setCurrentBlock("tbl_content");
00814 
00815                                 // output term and language
00816                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00817                                 $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
00818                                 $this->tpl->setCurrentBlock("tbl_content");
00819                                 $this->tpl->parseCurrentBlock();
00820                         }
00821                 } //if is_array
00822                 else
00823                 {
00824                         $this->tpl->setCurrentBlock("notfound");
00825                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00826                         $this->tpl->setVariable("NUM_COLS", $num);
00827                         $this->tpl->parseCurrentBlock();
00828                 }
00829         }
00830 
00834         function addTerm()
00835         {
00836                 // add term
00837                 include_once ("content/classes/class.ilGlossaryTerm.php");
00838                 $term =& new ilGlossaryTerm();
00839                 $term->setGlossary($this->object);
00840                 $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
00841                 $term->setLanguage($_POST["term_language"]);
00842                 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00843                 $term->create();
00844 
00845                 // add first definition
00846                 $def =& new ilGlossaryDefinition();
00847                 $def->setTermId($term->getId());
00848                 $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
00849                 $def->create();
00850 
00851                 $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
00852                 $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
00853                 $this->ctrl->redirectByClass(array("ilglossarytermgui",
00854                         "iltermdefinitioneditorgui", "ilpageobjectgui"), "view");
00855         }
00856 
00860         function moveDefinitionUp()
00861         {
00862                 include_once("content/classes/class.ilGlossaryDefinition.php");
00863 
00864                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00865                 $definition->moveUp();
00866 
00867                 $this->ctrl->redirect($this, "listTerms");
00868         }
00869 
00873         function moveDefinitionDown()
00874         {
00875                 include_once("content/classes/class.ilGlossaryDefinition.php");
00876 
00877                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00878                 $definition->moveDown();
00879 
00880                 $this->ctrl->redirect($this, "listTerms");
00881         }
00882 
00886         function confirmDefinitionDeletion()
00887         {
00888                 //$this->getTemplate();
00889                 //$this->displayLocator();
00890                 //$this->setTabs();
00891 
00892                 $term = new ilGlossaryTerm($_GET["term_id"]);
00893 
00894                 // content style
00895                 $this->tpl->setCurrentBlock("ContentStyle");
00896                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00897                         ilObjStyleSheet::getContentStylePath(0));
00898                 $this->tpl->parseCurrentBlock();
00899 
00900                 // syntax style
00901                 $this->tpl->setCurrentBlock("SyntaxStyle");
00902                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00903                         ilObjStyleSheet::getSyntaxStylePath());
00904                 $this->tpl->parseCurrentBlock();
00905 
00906 
00907                 //$this->tpl->setVariable("HEADER",
00908                 //      $this->lng->txt("cont_term").": ".$term->getTerm());
00909 
00910                 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00911                 sendInfo($this->lng->txt("info_delete_sure"));
00912 
00913                 $this->tpl->setVariable("TXT_TERM", $term->getTerm());
00914 
00915                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00916                 $page =& new ilPageObject("gdf", $definition->getId());
00917                 $page_gui =& new ilPageObjectGUI($page);
00918                 $page_gui->setTemplateOutput(false);
00919                 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
00920                 $output = $page_gui->preview();
00921 
00922                 $this->tpl->setCurrentBlock("definition");
00923                 $this->tpl->setVariable("PAGE_CONTENT", $output);
00924                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00925                 $this->tpl->setVariable("LINK_CANCEL",
00926                         $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00927                 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00928                 $this->ctrl->setParameter($this, "def", $definition->getId());
00929                 $this->tpl->setVariable("LINK_CONFIRM",
00930                         $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00931                 $this->tpl->parseCurrentBlock();
00932         }
00933         
00939         function cancelObject($in_rep = false)
00940         {
00941                 sendInfo($this->lng->txt("msg_cancel"),true);
00942                 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00943                 //$this->ctrl->redirectByClass("ilrepositorygui", "frameset");
00944         }
00945 
00946         function cancelDefinitionDeletion()
00947         {
00948                 $this->ctrl->redirect($this, "listTerms");
00949         }
00950 
00951 
00952         function deleteDefinition()
00953         {
00954                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00955                 $definition->delete();
00956                 $this->ctrl->redirect($this, "listTerms");
00957         }
00958 
00962         function editTerm()
00963         {
00964                 /*
00965                 $term = new ilGlossaryTerm($_GET["term_id"]);
00966                 //$this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$term->getTerm());
00967 
00968                 // load template for table
00969                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00970                 $this->ctrl->setParameter($this, "term_id", $_GET["term_id"]);
00971                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00972                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00973                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00974                 $this->tpl->setVariable("INPUT_TERM", "term");
00975                 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($term->getTerm()));
00976                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00977                 $lang = ilMetaData::getLanguages();
00978                 $select_language = ilUtil::formSelect ($term->getLanguage(),"term_language",$lang,false,true);
00979                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00980                 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00981                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00982                 */
00983         }
00984 
00985 
00989         function updateTerm()
00990         {
00991                 $term = new ilGlossaryTerm($_GET["term_id"]);
00992 
00993                 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00994                 $term->setLanguage($_POST["term_language"]);
00995                 $term->update();
00996                 sendinfo($this->lng->txt("msg_obj_modified"),true);
00997                 $this->ctrl->redirect($this, "listTerms");
00998         }
00999 
01000 
01001         /*
01002         * list all export files
01003         */
01004         function exportList()
01005         {
01006                 global $tree;
01007 
01008                 //$this->setTabs();
01009 
01010                 //add template for view button
01011                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01012 
01013                 // create export file button (xml)
01014                 $this->tpl->setCurrentBlock("btn_cell");
01015                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
01016                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
01017                 $this->tpl->parseCurrentBlock();
01018 
01019                 // create export file button (html)
01020                 $this->tpl->setCurrentBlock("btn_cell");
01021                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportHTML"));
01022                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_html"));
01023                 $this->tpl->parseCurrentBlock();
01024 
01025                 // view last export log button
01026                 if (is_file($this->object->getExportDirectory()."/export.log"))
01027                 {
01028                         $this->tpl->setCurrentBlock("btn_cell");
01029                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
01030                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
01031                         $this->tpl->parseCurrentBlock();
01032                 }
01033 
01034 
01035                 $export_dir = $this->object->getExportDirectory();
01036 
01037                 $export_files = $this->object->getExportFiles();
01038                 
01039                 // create table
01040                 require_once("classes/class.ilTableGUI.php");
01041                 $tbl = new ilTableGUI();
01042 
01043                 // load files templates
01044                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01045 
01046                 // load template for table content data
01047                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.glo_export_file_row.html", true);
01048 
01049                 $num = 0;
01050 
01051                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01052 
01053                 $tbl->setTitle($this->lng->txt("cont_export_files"));
01054 
01055                 $tbl->setHeaderNames(array("", $this->lng->txt("type"),
01056                         $this->lng->txt("cont_file"),
01057                         $this->lng->txt("cont_size"), $this->lng->txt("date") ));
01058 
01059                 $cols = array("", "type", "file", "size", "date");
01060                 $header_params = array("ref_id" => $_GET["ref_id"],
01061                         "cmd" => "exportList", "cmdClass" => get_class($this));
01062                 $tbl->setHeaderVars($cols, $header_params);
01063                 $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
01064                 $tbl->disable("sort");
01065 
01066                 // control
01067                 $tbl->setOrderColumn($_GET["sort_by"]);
01068                 $tbl->setOrderDirection($_GET["sort_order"]);
01069                 $tbl->setLimit($_GET["limit"]);
01070                 $tbl->setOffset($_GET["offset"]);
01071                 $tbl->setMaxCount($this->maxcount);             // ???
01072 
01073                 $this->tpl->setVariable("COLUMN_COUNTS", 5);
01074 
01075                 // delete button
01076                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01077                 $this->tpl->setCurrentBlock("tbl_action_btn");
01078                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01079                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01080                 $this->tpl->parseCurrentBlock();
01081 
01082                 $this->tpl->setCurrentBlock("tbl_action_btn");
01083                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01084                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01085                 $this->tpl->parseCurrentBlock();
01086 
01087                 // public access
01088                 $this->tpl->setCurrentBlock("tbl_action_btn");
01089                 $this->tpl->setVariable("BTN_NAME", "publishExportFile");
01090                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_public_access"));
01091                 $this->tpl->parseCurrentBlock();
01092 
01093                 // footer
01094                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01095                 //$tbl->disable("footer");
01096 
01097                 $tbl->setMaxCount(count($export_files));
01098                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01099 
01100                 $tbl->render();
01101                 if(count($export_files) > 0)
01102                 {
01103                         $i=0;
01104                         foreach($export_files as $exp_file)
01105                         {
01106                                 $this->tpl->setCurrentBlock("tbl_content");
01107                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
01108 
01109                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01110                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01111 
01112                                 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
01113 
01114                                 $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
01115                                         ? " <b>(".$this->lng->txt("public").")<b>"
01116                                         : "";
01117                                 $this->tpl->setVariable("TXT_TYPE", $exp_file["type"].$public_str);
01118                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
01119 
01120                                 $file_arr = explode("__", $exp_file["file"]);
01121                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01122 
01123                                 $this->tpl->parseCurrentBlock();
01124                         }
01125                 } //if is_array
01126                 else
01127                 {
01128                         $this->tpl->setCurrentBlock("notfound");
01129                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01130                         $this->tpl->setVariable("NUM_COLS", 3);
01131                         $this->tpl->parseCurrentBlock();
01132                 }
01133 
01134                 $this->tpl->parseCurrentBlock();
01135         }
01136 
01137 
01141         function export()
01142         {
01143                 require_once("content/classes/class.ilGlossaryExport.php");
01144                 $glo_exp = new ilGlossaryExport($this->object);
01145                 $glo_exp->buildExportFile();
01146                 $this->ctrl->redirect($this, "exportList");
01147         }
01148         
01152         function exportHTML()
01153         {
01154                 require_once("content/classes/class.ilGlossaryExport.php");
01155                 $glo_exp = new ilGlossaryExport($this->object, "html");
01156                 $glo_exp->buildExportFile();
01157 //echo $this->tpl->get();
01158                 $this->ctrl->redirect($this, "exportList");
01159         }
01160 
01161 
01165         function downloadExportFile()
01166         {
01167                 if(!isset($_POST["file"]))
01168                 {
01169                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01170                 }
01171 
01172                 if (count($_POST["file"]) > 1)
01173                 {
01174                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01175                 }
01176 
01177                 $file = explode(":", $_POST["file"][0]);
01178                 $export_dir = $this->object->getExportDirectory($file[0]);
01179                 ilUtil::deliverFile($export_dir."/".$file[1],
01180                         $file[1]);
01181         }
01182 
01186         function publishExportFile()
01187         {
01188                 if(!isset($_POST["file"]))
01189                 {
01190                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01191                 }
01192                 if (count($_POST["file"]) > 1)
01193                 {
01194                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01195                 }
01196                 
01197                 $file = explode(":", $_POST["file"][0]);
01198                 $export_dir = $this->object->getExportDirectory($file[0]);
01199                 
01200                 if ($this->object->getPublicExportFile($file[0]) ==
01201                         $file[1])
01202                 {
01203                         $this->object->setPublicExportFile($file[0], "");
01204                 }
01205                 else
01206                 {
01207                         $this->object->setPublicExportFile($file[0], $file[1]);
01208                 }
01209                 $this->object->update();
01210                 $this->ctrl->redirect($this, "exportList");
01211         }
01212 
01213         /*
01214         * list all export files
01215         */
01216         function viewExportLog()
01217         {
01218                 global $tree;
01219 
01220                 $this->setTabs();
01221 
01222                 //add template for view button
01223                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01224 
01225                 // create export file button
01226                 $this->tpl->setCurrentBlock("btn_cell");
01227                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
01228                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
01229                 $this->tpl->parseCurrentBlock();
01230 
01231                 // load files templates
01232                 $this->tpl->setVariable("ADM_CONTENT",
01233                         nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
01234 
01235                 $this->tpl->parseCurrentBlock();
01236         }
01237 
01241         function confirmDeleteExportFile()
01242         {
01243                 if(!isset($_POST["file"]))
01244                 {
01245                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01246                 }
01247 
01248                 $this->setTabs();
01249 
01250                 // SAVE POST VALUES
01251                 $_SESSION["ilExportFiles"] = $_POST["file"];
01252 
01253                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01254 
01255                 sendInfo($this->lng->txt("info_delete_sure"));
01256 
01257                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01258 
01259                 // BEGIN TABLE HEADER
01260                 $this->tpl->setCurrentBlock("table_header");
01261                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01262                 $this->tpl->parseCurrentBlock();
01263 
01264                 // BEGIN TABLE DATA
01265                 $counter = 0;
01266                 foreach($_POST["file"] as $file)
01267                 {
01268                                 $file = explode(":", $file);
01269                                 $this->tpl->setCurrentBlock("table_row");
01270                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01271                                 $this->tpl->setVariable("TEXT_CONTENT", $file[1]." (".$file[0].")");
01272                                 $this->tpl->parseCurrentBlock();
01273                 }
01274 
01275                 // cancel/confirm button
01276                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01277                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
01278                         "deleteExportFile"  => $this->lng->txt("confirm"));
01279                 foreach ($buttons as $name => $value)
01280                 {
01281                         $this->tpl->setCurrentBlock("operation_btn");
01282                         $this->tpl->setVariable("BTN_NAME",$name);
01283                         $this->tpl->setVariable("BTN_VALUE",$value);
01284                         $this->tpl->parseCurrentBlock();
01285                 }
01286         }
01287 
01291         function cancelDeleteExportFile()
01292         {
01293                 session_unregister("ilExportFiles");
01294                 $this->ctrl->redirect($this, "exportList");
01295         }
01296 
01300         function deleteExportFile()
01301         {
01302                 foreach($_SESSION["ilExportFiles"] as $file)
01303                 {
01304                         $file = explode(":", $file);
01305                         $export_dir = $this->object->getExportDirectory($file[0]);
01306                         
01307                         $exp_file = $export_dir."/".$file[1];
01308                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01309                         if (@is_file($exp_file))
01310                         {
01311                                 unlink($exp_file);
01312                         }
01313                         if (@is_dir($exp_dir))
01314                         {
01315                                 ilUtil::delDir($exp_dir);
01316                         }
01317                 }
01318                 $this->ctrl->redirect($this, "exportList");
01319         }
01320 
01324         function confirmTermDeletion()
01325         {
01326                 //$this->prepareOutput();
01327                 if (!isset($_POST["id"]))
01328                 {
01329                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01330                 }
01331 
01332                 // save values to
01333                 $_SESSION["term_delete"] = $_POST["id"];
01334 
01335                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_confirm.html");
01336 
01337                 sendInfo($this->lng->txt("info_delete_sure"));
01338                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01339 
01340                 // output table header
01341                 $cols = array("cont_term");
01342                 foreach ($cols as $key)
01343                 {
01344                         $this->tpl->setCurrentBlock("table_header");
01345                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01346                         $this->tpl->parseCurrentBlock();
01347                 }
01348 
01349                 foreach($_POST["id"] as $id)
01350                 {
01351                         $term = new ilGlossaryTerm($id);
01352 
01353                         // output title
01354                         $this->tpl->setCurrentBlock("table_cell");
01355                         $this->tpl->setVariable("TEXT_CONTENT", $term->getTerm());
01356                         $this->tpl->parseCurrentBlock();
01357 
01358                         // output table row
01359                         $this->tpl->setCurrentBlock("table_row");
01360                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01361                         $this->tpl->parseCurrentBlock();
01362                 }
01363 
01364                 // cancel and confirm button
01365                 $buttons = array( "cancelTermDeletion"  => $this->lng->txt("cancel"),
01366                         "deleteTerms"  => $this->lng->txt("confirm"));
01367                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01368                 foreach($buttons as $name => $value)
01369                 {
01370                         $this->tpl->setCurrentBlock("operation_btn");
01371                         $this->tpl->setVariable("BTN_NAME",$name);
01372                         $this->tpl->setVariable("BTN_VALUE",$value);
01373                         $this->tpl->parseCurrentBlock();
01374                 }
01375 
01376         }
01377 
01383         function cancelTermDeletion()
01384         {
01385                 session_unregister("term_delete");
01386                 sendInfo($this->lng->txt("msg_cancel"),true);
01387                 $this->ctrl->redirect($this, "listTerms");
01388         }
01389 
01393         function deleteTerms()
01394         {
01395                 foreach($_SESSION["term_delete"] as $id)
01396                 {
01397                         $term = new ilGlossaryTerm($id);
01398                         $term->delete();
01399                 }
01400                 session_unregister("term_delete");
01401                 $this->ctrl->redirect($this, "listTerms");
01402         }
01403 
01411         function setLocator($a_tree = "", $a_id = "")
01412         {
01413                 global $ilias_locator;
01414 
01415                 if(strtolower($_GET["baseClass"]) != "ilglossaryeditorgui")
01416                 {
01417                         parent::setLocator($a_tree, $a_id);
01418                 }
01419                 else
01420                 {
01421                         if(is_object($this->object))
01422                         {
01423                                 require_once("content/classes/class.ilGlossaryLocatorGUI.php");
01424                                 $gloss_loc =& new ilGlossaryLocatorGUI();
01425                                 if (is_object($this->term))
01426                                 {
01427                                         $gloss_loc->setTerm($this->term);
01428                                 }
01429                                 $gloss_loc->setGlossary($this->object);
01430                                 //$gloss_loc->setDefinition($this->definition);
01431                                 $gloss_loc->display();
01432                         }
01433                 }
01434 
01435         }
01436 
01440         function perm()
01441         {
01442                 echo "Deprecated"; exit;
01443                 
01444                 //$this->prepareOutput();
01445                 //$this->setFormAction("addRole", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=addRole");
01446                 //$this->setFormAction("permSave", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=permSave");
01447                 //$this->permObject();
01448         }
01449 
01453         function permSave()
01454         {
01455                 echo "Deprecated"; exit;
01456                 
01457                 //$this->setReturnLocation("permSave", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=perm");
01458                 //$this->permSaveObject();
01459         }
01460         
01464         function info()
01465         {
01466                 echo "Deprecated"; exit;
01467                 
01468                 //$this->infoObject();
01469         }
01470 
01474         function addRole()
01475         {
01476                 echo "Deprecated"; exit;
01477                 
01478                 //$this->setReturnLocation("addRole", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=perm");
01479                 //$this->addRoleObject();
01480         }
01481 
01485         function owner()
01486         {
01487                 echo "Deprecated"; exit;
01488                 
01489                 //$this->prepareOutput();
01490                 //$this->ownerObject();
01491         }
01492 
01496         function view()
01497         {
01498                 //$this->prepareOutput();
01499                 $this->viewObject();
01500         }
01501 
01505         function create()
01506         {
01507                 switch($_POST["new_type"])
01508                 {
01509                         case "term":
01510                                 $term_gui =& new ilGlossaryTermGUI();
01511                                 $term_gui->create();
01512                                 break;
01513                 }
01514         }
01515 
01516         function saveTerm()
01517         {
01518                 $term_gui =& new ilGlossaryTermGUI();
01519                 $term_gui->setGlossary($this->object);
01520                 $term_gui->save();
01521 
01522                 sendinfo($this->lng->txt("cont_added_term"),true);
01523 
01524                 //ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
01525                 $ilCtrl->redirect($this, "listTerms");
01526         }
01527 
01528 
01532         function addDefinition()
01533         {
01534                 if (count($_POST["id"]) < 1)
01535                 {
01536                         $this->ilias->raiseError($this->lng->txt("cont_select_term"),$this->ilias->error_obj->MESSAGE);
01537                 }
01538 
01539                 if (count($_POST["id"]) > 1)
01540                 {
01541                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_term"),$this->ilias->error_obj->MESSAGE);
01542                 }
01543 
01544                 // add term
01545                 include_once ("content/classes/class.ilGlossaryTerm.php");
01546                 $term =& new ilGlossaryTerm($_POST["id"][0]);
01547 
01548                 // add first definition
01549                 $def =& new ilGlossaryDefinition();
01550                 $def->setTermId($term->getId());
01551                 $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
01552                 $def->create();
01553 
01554                 $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
01555                 $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
01556                 $this->ctrl->redirectByClass(array("ilglossarytermgui",
01557                         "iltermdefinitioneditorgui", "ilpageobjectgui"), "view");
01558                 
01559         }
01560 
01561         function getTemplate()
01562         {
01563                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01564                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01565 
01566                 $title = $this->object->getTitle();
01567 
01568                 // catch feedback message
01569                 sendInfo();
01570 
01571                 if ($_GET["term_id"] > 0)
01572                 {
01573                         //$this->tpl->setCurrentBlock("header_image");
01574                         //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
01575                         //$this->tpl->parseCurrentBlock();
01576                         $this->tpl->setVariable("HEADER", $this->lng->txt("term").": ".
01577                                 ilGlossaryTerm::_lookGlossaryTerm($_GET["term_id"]));
01578                 }
01579                 else
01580                 {
01581                         $this->tpl->setCurrentBlock("header_image");
01582                         $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
01583                         $this->tpl->parseCurrentBlock();
01584                         $this->tpl->setVariable("HEADER", $this->lng->txt("glo").": ".$title);
01585                 }
01586 
01587                 //$this->setAdminTabs($_POST["new_type"]);
01588                 //$this->setLocator();
01589 
01590         }
01591 
01595         function setTabs()
01596         {
01597 
01598                 // catch feedback message
01599                 #include_once("classes/class.ilTabsGUI.php");
01600                 #$tabs_gui =& new ilTabsGUI();
01601                 $this->getTabs($this->tabs_gui);
01602 
01603                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01604 
01605         }
01606 
01610         function getTabs(&$tabs_gui)
01611         {
01612                 global $rbacsystem;
01613 
01614                 // list terms
01615                 $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "listTerms")
01616                                 ? true
01617                                 : false;
01618                 $tabs_gui->addTarget("cont_terms",
01619                         $this->ctrl->getLinkTarget($this, "listTerms"), array("listTerms", ""),
01620                         get_class($this), "", $force_active);
01621 
01622                 // properties
01623                 $tabs_gui->addTarget("properties",
01624                         $this->ctrl->getLinkTarget($this, "properties"), "properties",
01625                         get_class($this));
01626 
01627                 // meta data
01628                 $tabs_gui->addTarget("meta_data",
01629                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01630                          "", "ilmdeditorgui");
01631 
01632                 // export
01633                 $tabs_gui->addTarget("export",
01634                          $this->ctrl->getLinkTarget($this, "exportList"),
01635                          array("exportList", "viewExportLog"), get_class($this));
01636 
01637                 // permissions
01638                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01639                 {
01640                         /*$tabs_gui->addTarget("permission_settings",
01641                                 $this->ctrl->getLinkTarget($this, "perm"),
01642                                 array("perm", "info"),
01643                                 get_class($this));
01644                                 */
01645                         $tabs_gui->addTarget("perm_settings",
01646                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01647 
01648                 }
01649         }
01650         
01656         function _goto($a_target)
01657         {
01658                 global $rbacsystem, $ilErr, $lng, $ilAccess;
01659 
01660                 if ($ilAccess->checkAccess("read", "", $a_target))
01661                 {
01662                         $_GET["ref_id"] = $a_target;
01663                         $_GET["baseClass"] = "ilGlossaryPresentationGUI";
01664                         include("ilias.php");
01665                         exit;
01666                 }
01667                 else if ($ilAccess->checkAccess("visible", "", $a_target))
01668                 {
01669                         $_GET["ref_id"] = $a_target;
01670                         $_GET["cmd"] = "infoScreen";
01671                         $_GET["baseClass"] = "ilGlossaryPresentationGUI";
01672                         include("ilias.php");
01673                         exit;
01674                 }
01675                 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
01676                 {
01677                         $_GET["cmd"] = "frameset";
01678                         $_GET["target"] = "";
01679                         $_GET["ref_id"] = ROOT_FOLDER_ID;
01680                         sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
01681                                 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
01682                         include("repository.php");
01683                         exit;
01684                 }
01685 
01686                 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
01687         }
01688 
01689 }
01690 
01691 ?>

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1