• Main Page
  • Related Pages
  • 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-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("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;
00057 
00058                 $this->ctrl =& $ilCtrl;
00059                 $this->ctrl->saveParameter($this, array("ref_id", "offset"));
00060 
00061                 $this->type = "glo";
00062                 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
00063                 if (defined("ILIAS_MODULE"))
00064                 {
00065                         $this->setTabTargetScript("glossary_edit.php");
00066                 }
00067                 if ($a_prepare_output)
00068                 {
00069                         $this->prepareOutput();
00070                 }
00071         }
00072 
00076         function &executeCommand()
00077         {
00078                 $cmd = $this->ctrl->getCmd();
00079                 $next_class = $this->ctrl->getNextClass($this);
00080 
00081                 switch ($next_class)
00082                 {
00083                         case "ilglossarytermgui":
00084                                 $this->ctrl->setReturn($this, "listTerms");
00085                                 $term_gui =& new ilGlossaryTermGUI($_GET["term_id"]);
00086                                 $term_gui->setGlossary($this->object);
00087                                 //$ret =& $term_gui->executeCommand();
00088                                 $ret =& $this->ctrl->forwardCommand($term_gui);
00089                                 break;
00090 
00091                         default:
00092                                 $cmd = $this->ctrl->getCmd("ListTerms");
00093 
00094                                 if (($cmd == "create") && ($_POST["new_type"] == "term"))
00095                                 {
00096                                         $this->ctrl->setCmd("create");
00097                                         $this->ctrl->setCmdClass("ilGlossaryTermGUI");
00098                                         $ret =& $this->executeCommand();
00099                                         return;
00100                                 }
00101                                 else
00102                                 {
00103                                         $this->getTemplate();
00104                                         $this->setTabs();
00105                                         $this->setLocator();
00106                                         $ret =& $this->$cmd();
00107                                 }
00108                                 break;
00109                 }
00110 
00111                 $this->tpl->show();
00112         }
00113 
00114         function assignObject()
00115         {
00116                 include_once("content/classes/class.ilObjGlossary.php");
00117 
00118                 $this->object =& new ilObjGlossary($this->id, true);
00119         }
00120 
00121 
00125         function createObject()
00126         {
00127                 global $rbacsystem;
00128 
00129                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00130 
00131                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00132                 {
00133                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00134                 }
00135                 else
00136                 {
00137                         // fill in saved values in case of error
00138                         $data = array();
00139                         $data["fields"] = array();
00140                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00141                         $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00142 
00143                         $this->getTemplateFile("create", $new_type);
00144 
00145                         foreach ($data["fields"] as $key => $val)
00146                         {
00147                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00148                                 $this->tpl->setVariable(strtoupper($key), $val);
00149 
00150                                 if ($this->prepare_output)
00151                                 {
00152                                         $this->tpl->parseCurrentBlock();
00153                                 }
00154                         }
00155 
00156                         $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00157                                                                                                                                            $_GET["ref_id"]."&new_type=".$new_type));
00158                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00159                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00160                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00161                         $this->tpl->setVariable("CMD_SUBMIT", "save");
00162                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00163                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00164 
00165                         $this->tpl->setVariable("TXT_IMPORT_GLO", $this->lng->txt("import_glossary"));
00166                         $this->tpl->setVariable("TXT_GLO_FILE", $this->lng->txt("glo_upload_file"));
00167                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
00168                 }
00169         }
00170 
00171         function importObject()
00172         {
00173                 $this->createObject();
00174         }
00175 
00179         function saveObject()
00180         {
00181                 global $rbacadmin, $rbacsystem;
00182 
00183                 // always call parent method first to create an object_data entry & a reference
00184                 //$newObj = parent::saveObject();
00185                 // TODO: fix MetaDataGUI implementation to make it compatible to use parent call
00186                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
00187                 {
00188                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
00189                 }
00190                 
00191                 // check required fields
00192                 if (empty($_POST["Fobject"]["title"]))
00193                 {
00194                         $this->ilErr->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilErr->MESSAGE);
00195                 }
00196 
00197                 // create and insert object in objecttree
00198                 include_once("content/classes/class.ilObjGlossary.php");
00199                 $newObj = new ilObjGlossary();
00200                 $newObj->setType($this->type);
00201                 $newObj->setTitle($_POST["Fobject"]["title"]);
00202                 $newObj->setDescription($_POST["Fobject"]["desc"]);
00203                 $newObj->create();
00204                 $newObj->createReference();
00205                 $newObj->putInTree($_GET["ref_id"]);
00206                 $newObj->setPermissions($_GET["ref_id"]);
00207                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00208 
00209                 //$roles = $newObj->initDefaultRoles();
00210 
00211                 // assign author role to creator of forum object
00212                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
00213                 //ilObjUser::updateActiveRoles($newObj->getOwner());
00214 
00215                 unset($newObj);
00216 
00217                 // always send a message
00218                 sendInfo($this->lng->txt("glo_added"),true);
00219                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00220         }
00221 
00228         function importFileObject()
00229         {
00230                 global $_FILES, $rbacsystem;
00231 
00232                 // check if file was uploaded
00233                 $source = $_FILES["xmldoc"]["tmp_name"];
00234                 if (($source == 'none') || (!$source))
00235                 {
00236                         $this->ilias->raiseError($this->lng->txt("msg_no_file"),$this->ilias->error_obj->MESSAGE);
00237                 }
00238                 // check create permission
00239                 /*
00240                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
00241                 {
00242                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00243                 }*/
00244 
00245                 // check correct file type
00246                 if ($_FILES["xmldoc"]["type"] != "application/zip" && $_FILES["xmldoc"]["type"] != "application/x-zip-compressed"
00247                         && $_FILES["xmldoc"]["type"] != "application/x-zip")
00248                 {
00249                         $this->ilias->raiseError($this->lng->txt("msg_invalid_filetype"),$this->ilias->error_obj->MESSAGE);
00250                 }
00251 
00252                 // create and insert object in objecttree
00253                 include_once("content/classes/class.ilObjGlossary.php");
00254                 $newObj = new ilObjGlossary();
00255                 $newObj->setType($_GET["new_type"]);
00256                 $newObj->setTitle("dummy");
00257                 //$newObj->setDescription("dummy");
00258                 $newObj->create(true);
00259                 $newObj->createReference();
00260                 $newObj->putInTree($_GET["ref_id"]);
00261                 $newObj->setPermissions($_GET["ref_id"]);
00262                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00263 
00264                 // create import directory
00265                 $newObj->createImportDirectory();
00266 
00267                 // copy uploaded file to import directory
00268                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00269                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00270                 
00271                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
00272                         $_FILES["xmldoc"]["name"], $full_path);
00273                 
00274                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00275 
00276                 // unzip file
00277                 ilUtil::unzip($full_path);
00278 
00279                 // determine filename of xml file
00280                 $subdir = basename($file["basename"],".".$file["extension"]);
00281                 $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
00282 //echo "xmlfile:".$xml_file;
00283 
00284                 include_once ("content/classes/class.ilContObjParser.php");
00285                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
00286                 $contParser->startParsing();
00287 
00288                 /* update title and description in object data */
00289                 // not allowed here: move to glossary class!
00290                 if (is_object($newObj->meta_data))
00291                 {
00292                         //$newObj->meta_data->read();
00293                         //$newObj->setTitle($newObj->meta_data->getTitle());
00294                         //$newObj->setDescription($newObj->meta_data->getDescription());
00295                         ilObject::_writeTitle($newObj->getID(), $newObj->getTitle());
00296                         ilObject::_writeDescription($newObj->getID(), $newObj->getDescription());
00297                         //$q = "UPDATE object_data SET title = '" . $newObj->getTitle() . "', description = '" . $newObj->getDescription() . "' WHERE obj_id = '" . $newObj->getID() . "'";
00298                         //$this->ilias->db->query($q);
00299                 }
00300 
00301                 sendInfo($this->lng->txt("glo_added"),true);
00302                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00303         }
00304 
00305 
00310         function chooseMetaSectionObject($a_target = "")
00311         {
00312                 if ($a_target == "")
00313                 {
00314                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00315                 }
00316 
00317                 include_once "classes/class.ilMetaDataGUI.php";
00318                 $meta_gui =& new ilMetaDataGUI();
00319                 $meta_gui->setObject($this->object);
00320                 $meta_gui->edit("ADM_CONTENT", "adm_content",
00321                         $a_target, $_REQUEST["meta_section"]);
00322         }
00323 
00328         function chooseMetaSection()
00329         {
00330                 //$this->prepareOutput();
00331                 $this->chooseMetaSectionObject($this->ctrl->getLinkTarget($this));
00332         }
00333 
00338         function addMetaObject($a_target = "")
00339         {
00340                 if ($a_target == "")
00341                 {
00342                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00343                 }
00344 
00345                 include_once "classes/class.ilMetaDataGUI.php";
00346                 $meta_gui =& new ilMetaDataGUI();
00347                 $meta_gui->setObject($this->object);
00348                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00349                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00350                 if ($meta_index == "")
00351                         $meta_index = 0;
00352                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00353                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00354                 if ($meta_name != "")
00355                 {
00356                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00357                 }
00358                 else
00359                 {
00360                         sendInfo($this->lng->txt("meta_choose_element"), true);
00361                 }
00362                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $meta_section);
00363         }
00364 
00369         function addMeta()
00370         {
00371                 //$this->prepareOutput();
00372                 $this->addMetaObject($this->ctrl->getLinkTarget($this));
00373         }
00374 
00375 
00380         function deleteMetaObject($a_target = "")
00381         {
00382                 if ($a_target == "")
00383                 {
00384                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00385                 }
00386 
00387                 include_once "classes/class.ilMetaDataGUI.php";
00388                 $meta_gui =& new ilMetaDataGUI();
00389                 $meta_gui->setObject($this->object);
00390                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00391                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
00392                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00393         }
00394 
00399         function deleteMeta()
00400         {
00401                 //$this->prepareOutput();
00402                 $this->deleteMetaObject($this->ctrl->getLinkTarget($this));
00403         }
00404 
00409         function editMetaObject($a_target = "")
00410         {
00411                 if ($a_target == "")
00412                 {
00413                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00414                 }
00415                 include_once "classes/class.ilMetaDataGUI.php";
00416                 $meta_gui =& new ilMetaDataGUI();
00417                 $meta_gui->setObject($this->object);
00418                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00419         }
00420 
00425         function editMeta()
00426         {
00427                 //$this->prepareOutput();
00428                 $this->editMetaObject($this->ctrl->getLinkTarget($this));
00429         }
00430 
00435         function saveMetaObject($a_target = "")
00436         {
00437                 if ($a_target == "")
00438                 {
00439                         $a_target = "adm_object.php?cmd=editMeta&ref_id=".$this->object->getRefId();
00440                 }
00441 
00442                 include_once "classes/class.ilMetaDataGUI.php";
00443                 $meta_gui =& new ilMetaDataGUI();
00444                 $meta_gui->setObject($this->object);
00445                 $meta_gui->save($_POST["meta_section"]);
00446                 ilUtil::redirect(ilUtil::appendUrlParameterString($a_target,
00447                         "meta_section=" . $_POST["meta_section"]));
00448         }
00449 
00454         function saveMeta()
00455         {
00456                 $this->saveMetaObject($this->ctrl->getLinkTarget($this, "editMeta"));
00457         }
00458 
00459 
00460         function viewObject()
00461         {
00462                 global $rbacsystem;
00463 
00464                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00465                 {
00466                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00467                 }
00468 
00469                 // edit button
00470                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00471 
00472                 if (!defined("ILIAS_MODULE"))
00473                 {
00474                         $this->tpl->setCurrentBlock("btn_cell");
00475                         $this->tpl->setVariable("BTN_LINK","content/glossary_edit.php?cmd=listTerms&ref_id=".$this->object->getRefID());
00476                         $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00477                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00478                         $this->tpl->parseCurrentBlock();
00479                 }
00480 
00481                 $this->tpl->setCurrentBlock("btn_cell");
00482                 $this->tpl->setVariable("BTN_LINK","content/glossary_presentation.php?cmd=listTerms&ref_id=".$this->object->getRefID());
00483                 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00484                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00485                 $this->tpl->parseCurrentBlock();
00486 
00487                 //parent::viewObject();
00488         }
00489 
00495         function properties()
00496         {
00497                 global $rbacsystem, $tree, $tpl;
00498 
00499                 // glossary properties
00500                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glossary_properties.html", true);
00501                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00502                 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_glo_properties"));
00503 
00504                 // online
00505                 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00506                 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00507                 $this->tpl->setVariable("VAL_ONLINE", "y");
00508                 if ($this->object->getOnline())
00509                 {
00510                         $this->tpl->setVariable("CHK_ONLINE", "checked");
00511                 }
00512 
00513                 $this->tpl->setCurrentBlock("commands");
00514                 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00515                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00516                 $this->tpl->parseCurrentBlock();
00517 
00518         }
00519 
00523         function saveProperties()
00524         {
00525                 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00526                 $this->object->update();
00527                 sendInfo($this->lng->txt("msg_obj_modified"), true);
00528                 $this->ctrl->redirect($this, "properties");
00529         }
00530 
00531 
00532 
00536         function listTerms()
00537         {
00538                 global $ilUser;
00539 
00540                 //$this->getTemplate();
00541                 //$this->setTabs();
00542                 //$this->setLocator();
00543                 $this->lng->loadLanguageModule("meta");
00544                 include_once "./classes/class.ilTableGUI.php";
00545 
00546 
00547                 // view button
00548                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00549 
00550                 $this->tpl->setCurrentBlock("btn_cell");
00551                 $this->tpl->setVariable("BTN_LINK", "glossary_presentation.php?cmd=listTerms&ref_id=".$this->object->getRefID());
00552                 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00553                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00554                 $this->tpl->parseCurrentBlock();
00555 
00556                 // export button
00557                 $this->tpl->setCurrentBlock("btn_cell");
00558                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
00559                 //$this->tpl->setVariable("BTN_TARGET"," target=\"_top\" ");
00560                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("export"));
00561                 $this->tpl->parseCurrentBlock();
00562 
00563                 // glossary term list template
00564                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_list.html", true);
00565                 $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
00566                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00567                 $this->tpl->setVariable("TXT_ADD2", $this->lng->txt("add"));
00568                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00569                 $lang = ilMetaData::getLanguages();
00570 
00571                 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00572                 {
00573                         $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00574                 }
00575                 else
00576                 {
00577                         $s_lang = $ilUser->getLanguage();
00578                 }
00579 
00580                 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00581                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00582 
00583 
00584                 // load template for table
00585                 $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
00586 
00587                 // load template for table content data
00588                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_row.html", true);
00589 
00590                 $num = 0;
00591 
00592                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00593 
00594                 // create table
00595                 $tbl = new ilTableGUI();
00596 
00597                 // title & header columns
00598                 $tbl->setTitle($this->lng->txt("cont_terms"));
00599                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00600 
00601                 $tbl->setHeaderNames(array("", $this->lng->txt("cont_term"),
00602                          $this->lng->txt("language"), $this->lng->txt("cont_definitions")));
00603 
00604                 $cols = array("", "term", "language", "definitions", "id");
00605                 $header_params = array("ref_id" => $this->ref_id, "cmd" => "listTerms");
00606                 $tbl->setHeaderVars($cols, $header_params);
00607                 $tbl->setColumnWidth(array("1%","24%","15%","60%"));
00608 
00609                 // control
00610                 $tbl->setOrderColumn($_GET["sort_by"]);
00611                 $tbl->setOrderDirection($_GET["sort_order"]);
00612                 $tbl->setLimit($_GET["limit"]);
00613                 $tbl->setOffset($_GET["offset"]);
00614                 $tbl->setMaxCount($this->maxcount);
00615 
00616                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
00617                 $this->setActions(array("confirmTermDeletion" => "delete", "addDefinition" => "cont_add_definition"));
00618                 //$this->setSubObjects(array("term" => array()));
00619                 $this->showActions(true);
00620 
00621                 // footer
00622                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00623                 //$tbl->disable("footer");
00624 
00625                 $term_list = $this->object->getTermList();
00626                 $tbl->setMaxCount(count($term_list));
00627 
00628                 // sorting array
00629                 //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
00630                 $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
00631 
00632                 // render table
00633                 $tbl->render();
00634 
00635                 if (count($term_list) > 0)
00636                 {
00637                         $i=1;
00638                         foreach($term_list as $key => $term)
00639                         {
00640                                 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00641                                 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
00642                                 for($j=0; $j<count($defs); $j++)
00643                                 {
00644                                         $def = $defs[$j];
00645 
00646                                         // up
00647                                         if ($j > 0)
00648                                         {
00649                                                 $this->tpl->setCurrentBlock("move_up");
00650                                                 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00651                                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00652                                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00653                                                 $this->tpl->setVariable("LINK_UP",
00654                                                         $this->ctrl->getLinkTarget($this, "moveDefinitionUp"));
00655                                                 $this->tpl->parseCurrentBlock();
00656                                         }
00657 
00658                                         // down
00659                                         if ($j+1 < count($defs))
00660                                         {
00661                                                 $this->tpl->setCurrentBlock("move_down");
00662                                                 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00663                                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00664                                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00665                                                 $this->tpl->setVariable("LINK_DOWN",
00666                                                         $this->ctrl->getLinkTarget($this, "moveDefinitionDown"));
00667                                                 $this->tpl->parseCurrentBlock();
00668                                         }
00669 
00670                                         // delete
00671                                         $this->tpl->setCurrentBlock("delete");
00672                                         $this->ctrl->setParameter($this, "term_id", $term["id"]);
00673                                         $this->ctrl->setParameter($this, "def", $def["id"]);
00674                                         $this->tpl->setVariable("LINK_DELETE",
00675                                                 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00676                                         $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00677                                         $this->tpl->parseCurrentBlock();
00678 
00679                                         // edit
00680                                         $this->tpl->setCurrentBlock("edit");
00681                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
00682                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
00683                                         $this->tpl->setVariable("LINK_EDIT",
00684                                                 $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
00685                                                 "iltermdefinitioneditorgui",
00686                                                 "ilpageobjectgui"), "view"));
00687                                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00688                                         $this->tpl->parseCurrentBlock();
00689 
00690                                         // text
00691                                         $this->tpl->setCurrentBlock("definition");
00692                                         $short_str = ilPCParagraph::xml2output($def["short_text"]);
00693                                         //$short_str = str_replace("<", "&lt;", $short_str);
00694                                         //$short_str = str_replace(">", "&gt;", $short_str);
00695                                         $this->tpl->setVariable("DEF_SHORT", $short_str);
00696                                         $this->tpl->parseCurrentBlock();
00697 
00698                                         $this->tpl->setCurrentBlock("definition_row");
00699                                         $this->tpl->parseCurrentBlock();
00700                                 }
00701 
00702                                 $this->tpl->setCurrentBlock("check_col");
00703                                 $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
00704                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00705                                 $this->tpl->parseCurrentBlock();
00706 
00707                                 // edit term link
00708                                 $this->tpl->setCurrentBlock("edit_term");
00709                                 $this->tpl->setVariable("TEXT_TERM", $term["term"]);
00710                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00711                                 $this->tpl->setVariable("LINK_EDIT_TERM",
00712                                         $this->ctrl->getLinkTarget($this, "editTerm"));
00713                                 $this->tpl->setVariable("TXT_EDIT_TERM", $this->lng->txt("edit"));
00714                                 $this->tpl->parseCurrentBlock();
00715 
00716                                 $this->tpl->setCurrentBlock("tbl_content");
00717 
00718                                 // output term and language
00719                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00720                                 $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
00721                                 $this->tpl->setCurrentBlock("tbl_content");
00722                                 $this->tpl->parseCurrentBlock();
00723                         }
00724                 } //if is_array
00725                 else
00726                 {
00727                         $this->tpl->setCurrentBlock("notfound");
00728                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00729                         $this->tpl->setVariable("NUM_COLS", $num);
00730                         $this->tpl->parseCurrentBlock();
00731                 }
00732         }
00733 
00737         function addTerm()
00738         {
00739                 // add term
00740                 include_once ("content/classes/class.ilGlossaryTerm.php");
00741                 $term =& new ilGlossaryTerm();
00742                 $term->setGlossary($this->object);
00743                 $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
00744                 $term->setLanguage($_POST["term_language"]);
00745                 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00746                 $term->create();
00747 
00748                 // add first definition
00749                 $def =& new ilGlossaryDefinition();
00750                 $def->setTermId($term->getId());
00751                 $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
00752                 $def->create();
00753 
00754                 $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
00755                 $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
00756                 $this->ctrl->redirectByClass(array("ilglossarytermgui",
00757                         "iltermdefinitioneditorgui", "ilpageobjectgui"), "view");
00758         }
00759 
00763         function moveDefinitionUp()
00764         {
00765                 include_once("content/classes/class.ilGlossaryDefinition.php");
00766 
00767                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00768                 $definition->moveUp();
00769 
00770                 $this->ctrl->redirect($this, "listTerms");
00771         }
00772 
00776         function moveDefinitionDown()
00777         {
00778                 include_once("content/classes/class.ilGlossaryDefinition.php");
00779 
00780                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00781                 $definition->moveDown();
00782 
00783                 $this->ctrl->redirect($this, "listTerms");
00784         }
00785 
00789         function confirmDefinitionDeletion()
00790         {
00791                 //$this->getTemplate();
00792                 //$this->displayLocator();
00793                 //$this->setTabs();
00794 
00795                 $term = new ilGlossaryTerm($_GET["term_id"]);
00796 
00797                 // content style
00798                 $this->tpl->setCurrentBlock("ContentStyle");
00799                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00800                         ilObjStyleSheet::getContentStylePath(0));
00801                 $this->tpl->parseCurrentBlock();
00802 
00803                 // syntax style
00804                 $this->tpl->setCurrentBlock("SyntaxStyle");
00805                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00806                         ilObjStyleSheet::getSyntaxStylePath());
00807                 $this->tpl->parseCurrentBlock();
00808 
00809 
00810                 //$this->tpl->setVariable("HEADER",
00811                 //      $this->lng->txt("cont_term").": ".$term->getTerm());
00812 
00813                 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00814                 sendInfo($this->lng->txt("info_delete_sure"));
00815 
00816                 $this->tpl->setVariable("TXT_TERM", $term->getTerm());
00817 
00818                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00819                 $page =& new ilPageObject("gdf", $definition->getId());
00820                 $page_gui =& new ilPageObjectGUI($page);
00821                 $page_gui->setTemplateOutput(false);
00822                 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00823                 $output = $page_gui->preview();
00824 
00825                 $this->tpl->setCurrentBlock("definition");
00826                 $this->tpl->setVariable("PAGE_CONTENT", $output);
00827                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00828                 $this->tpl->setVariable("LINK_CANCEL",
00829                         $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00830                 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00831                 $this->ctrl->setParameter($this, "def", $definition->getId());
00832                 $this->tpl->setVariable("LINK_CONFIRM",
00833                         $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00834                 $this->tpl->parseCurrentBlock();
00835         }
00836 
00837         function cancelDefinitionDeletion()
00838         {
00839                 $this->ctrl->redirect($this, "listTerms");
00840         }
00841 
00842 
00843         function deleteDefinition()
00844         {
00845                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00846                 $definition->delete();
00847                 $this->ctrl->redirect($this, "listTerms");
00848         }
00849 
00853         function editTerm()
00854         {
00855                 $term = new ilGlossaryTerm($_GET["term_id"]);
00856                 //$this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$term->getTerm());
00857 
00858                 // load template for table
00859                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00860                 $this->ctrl->setParameter($this, "term_id", $_GET["term_id"]);
00861                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00862                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00863                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00864                 $this->tpl->setVariable("INPUT_TERM", "term");
00865                 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($term->getTerm()));
00866                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00867                 $lang = ilMetaData::getLanguages();
00868                 $select_language = ilUtil::formSelect ($term->getLanguage(),"term_language",$lang,false,true);
00869                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00870                 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00871                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00872         }
00873 
00874 
00878         function updateTerm()
00879         {
00880                 $term = new ilGlossaryTerm($_GET["term_id"]);
00881 
00882                 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00883                 $term->setLanguage($_POST["term_language"]);
00884                 $term->update();
00885                 sendinfo($this->lng->txt("msg_obj_modified"),true);
00886                 $this->ctrl->redirect($this, "listTerms");
00887         }
00888 
00889 
00890         /*
00891         * list all export files
00892         */
00893         function exportList()
00894         {
00895                 global $tree;
00896 
00897                 $this->setTabs();
00898 
00899                 //add template for view button
00900                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00901 
00902                 // create export file button
00903                 $this->tpl->setCurrentBlock("btn_cell");
00904                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
00905                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file"));
00906                 $this->tpl->parseCurrentBlock();
00907 
00908                 // view last export log button
00909                 if (is_file($this->object->getExportDirectory()."/export.log"))
00910                 {
00911                         $this->tpl->setCurrentBlock("btn_cell");
00912                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
00913                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
00914                         $this->tpl->parseCurrentBlock();
00915                 }
00916 
00917 
00918                 $export_dir = $this->object->getExportDirectory();
00919 
00920                 $export_files = $this->object->getExportFiles($export_dir);
00921 
00922                 // create table
00923                 require_once("classes/class.ilTableGUI.php");
00924                 $tbl = new ilTableGUI();
00925 
00926                 // load files templates
00927                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00928 
00929                 // load template for table content data
00930                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.glo_export_file_row.html", true);
00931 
00932                 $num = 0;
00933 
00934                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00935 
00936                 $tbl->setTitle($this->lng->txt("cont_export_files"));
00937 
00938                 $tbl->setHeaderNames(array("", $this->lng->txt("cont_file"),
00939                         $this->lng->txt("cont_size"), $this->lng->txt("date") ));
00940 
00941                 $cols = array("", "file", "size", "date");
00942                 $header_params = array("ref_id" => $_GET["ref_id"],
00943                         "cmd" => "exportList", "cmdClass" => get_class($this));
00944                 $tbl->setHeaderVars($cols, $header_params);
00945                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
00946 
00947                 // control
00948                 $tbl->setOrderColumn($_GET["sort_by"]);
00949                 $tbl->setOrderDirection($_GET["sort_order"]);
00950                 $tbl->setLimit($_GET["limit"]);
00951                 $tbl->setOffset($_GET["offset"]);
00952                 $tbl->setMaxCount($this->maxcount);             // ???
00953 
00954 
00955                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
00956 
00957                 // delete button
00958                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00959                 $this->tpl->setCurrentBlock("tbl_action_btn");
00960                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
00961                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00962                 $this->tpl->parseCurrentBlock();
00963 
00964                 $this->tpl->setCurrentBlock("tbl_action_btn");
00965                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
00966                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
00967                 $this->tpl->parseCurrentBlock();
00968 
00969                 // footer
00970                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00971                 //$tbl->disable("footer");
00972 
00973                 $tbl->setMaxCount(count($export_files));
00974                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
00975 
00976                 $tbl->render();
00977                 if(count($export_files) > 0)
00978                 {
00979                         $i=0;
00980                         foreach($export_files as $exp_file)
00981                         {
00982                                 $this->tpl->setCurrentBlock("tbl_content");
00983                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
00984 
00985                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00986                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00987 
00988                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
00989                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
00990 
00991                                 $file_arr = explode("__", $exp_file);
00992                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
00993 
00994                                 $this->tpl->parseCurrentBlock();
00995                         }
00996                 } //if is_array
00997                 else
00998                 {
00999                         $this->tpl->setCurrentBlock("notfound");
01000                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01001                         $this->tpl->setVariable("NUM_COLS", 3);
01002                         $this->tpl->parseCurrentBlock();
01003                 }
01004 
01005                 $this->tpl->parseCurrentBlock();
01006         }
01007 
01008 
01012         function export()
01013         {
01014                 require_once("content/classes/class.ilGlossaryExport.php");
01015                 $glo_exp = new ilGlossaryExport($this->object);
01016                 $glo_exp->buildExportFile();
01017                 $this->exportList();
01018         }
01019 
01023         function downloadExportFile()
01024         {
01025                 if(!isset($_POST["file"]))
01026                 {
01027                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01028                 }
01029 
01030                 if (count($_POST["file"]) > 1)
01031                 {
01032                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01033                 }
01034 
01035 
01036                 $export_dir = $this->object->getExportDirectory();
01037                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01038                         $_POST["file"][0]);
01039         }
01040 
01041         /*
01042         * list all export files
01043         */
01044         function viewExportLog()
01045         {
01046                 global $tree;
01047 
01048                 $this->setTabs();
01049 
01050                 //add template for view button
01051                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01052 
01053                 // create export file button
01054                 $this->tpl->setCurrentBlock("btn_cell");
01055                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
01056                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
01057                 $this->tpl->parseCurrentBlock();
01058 
01059                 // load files templates
01060                 $this->tpl->setVariable("ADM_CONTENT",
01061                         nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
01062 
01063                 $this->tpl->parseCurrentBlock();
01064         }
01065 
01069         function confirmDeleteExportFile()
01070         {
01071                 if(!isset($_POST["file"]))
01072                 {
01073                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01074                 }
01075 
01076                 $this->setTabs();
01077 
01078                 // SAVE POST VALUES
01079                 $_SESSION["ilExportFiles"] = $_POST["file"];
01080 
01081                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01082 
01083                 sendInfo($this->lng->txt("info_delete_sure"));
01084 
01085                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01086 
01087                 // BEGIN TABLE HEADER
01088                 $this->tpl->setCurrentBlock("table_header");
01089                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01090                 $this->tpl->parseCurrentBlock();
01091 
01092                 // BEGIN TABLE DATA
01093                 $counter = 0;
01094                 foreach($_POST["file"] as $file)
01095                 {
01096                                 $this->tpl->setCurrentBlock("table_row");
01097                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01098                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01099                                 $this->tpl->parseCurrentBlock();
01100                 }
01101 
01102                 // cancel/confirm button
01103                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01104                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
01105                         "deleteExportFile"  => $this->lng->txt("confirm"));
01106                 foreach ($buttons as $name => $value)
01107                 {
01108                         $this->tpl->setCurrentBlock("operation_btn");
01109                         $this->tpl->setVariable("BTN_NAME",$name);
01110                         $this->tpl->setVariable("BTN_VALUE",$value);
01111                         $this->tpl->parseCurrentBlock();
01112                 }
01113         }
01114 
01118         function cancelDeleteExportFile()
01119         {
01120                 session_unregister("ilExportFiles");
01121                 $this->ctrl->redirect($this, "exportList");
01122         }
01123 
01127         function deleteExportFile()
01128         {
01129                 $export_dir = $this->object->getExportDirectory();
01130                 foreach($_SESSION["ilExportFiles"] as $file)
01131                 {
01132                         $exp_file = $export_dir."/".$file;
01133                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01134                         if (@is_file($exp_file))
01135                         {
01136                                 unlink($exp_file);
01137                         }
01138                         if (@is_dir($exp_dir))
01139                         {
01140                                 ilUtil::delDir($exp_dir);
01141                         }
01142                 }
01143                 $this->ctrl->redirect($this, "exportList");
01144         }
01145 
01149         function confirmTermDeletion()
01150         {
01151                 //$this->prepareOutput();
01152                 if (!isset($_POST["id"]))
01153                 {
01154                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01155                 }
01156 
01157                 // save values to
01158                 $_SESSION["term_delete"] = $_POST["id"];
01159 
01160                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_confirm.html");
01161 
01162                 sendInfo($this->lng->txt("info_delete_sure"));
01163                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01164 
01165                 // output table header
01166                 $cols = array("cont_term");
01167                 foreach ($cols as $key)
01168                 {
01169                         $this->tpl->setCurrentBlock("table_header");
01170                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01171                         $this->tpl->parseCurrentBlock();
01172                 }
01173 
01174                 foreach($_POST["id"] as $id)
01175                 {
01176                         $term = new ilGlossaryTerm($id);
01177 
01178                         // output title
01179                         $this->tpl->setCurrentBlock("table_cell");
01180                         $this->tpl->setVariable("TEXT_CONTENT", $term->getTerm());
01181                         $this->tpl->parseCurrentBlock();
01182 
01183                         // output table row
01184                         $this->tpl->setCurrentBlock("table_row");
01185                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01186                         $this->tpl->parseCurrentBlock();
01187                 }
01188 
01189                 // cancel and confirm button
01190                 $buttons = array( "cancelTermDeletion"  => $this->lng->txt("cancel"),
01191                         "deleteTerms"  => $this->lng->txt("confirm"));
01192                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01193                 foreach($buttons as $name => $value)
01194                 {
01195                         $this->tpl->setCurrentBlock("operation_btn");
01196                         $this->tpl->setVariable("BTN_NAME",$name);
01197                         $this->tpl->setVariable("BTN_VALUE",$value);
01198                         $this->tpl->parseCurrentBlock();
01199                 }
01200 
01201         }
01202 
01208         function cancelTermDeletion()
01209         {
01210                 session_unregister("term_delete");
01211                 sendInfo($this->lng->txt("msg_cancel"),true);
01212                 $this->ctrl->redirect($this, "listTerms");
01213         }
01214 
01218         function deleteTerms()
01219         {
01220                 foreach($_SESSION["term_delete"] as $id)
01221                 {
01222                         $term = new ilGlossaryTerm($id);
01223                         $term->delete();
01224                 }
01225                 session_unregister("term_delete");
01226                 $this->ctrl->redirect($this, "listTerms");
01227         }
01228 
01236         function setLocator($a_tree = "", $a_id = "")
01237         {
01238                 global $ilias_locator;
01239 
01240                 if(!defined("ILIAS_MODULE"))
01241                 {
01242                         parent::setLocator($a_tree, $a_id);
01243                 }
01244                 else
01245                 {
01246                         if(is_object($this->object))
01247                         {
01248                                 require_once("content/classes/class.ilGlossaryLocatorGUI.php");
01249                                 $gloss_loc =& new ilGlossaryLocatorGUI();
01250                                 if (is_object($this->term))
01251                                 {
01252                                         $gloss_loc->setTerm($this->term);
01253                                 }
01254                                 $gloss_loc->setGlossary($this->object);
01255                                 //$gloss_loc->setDefinition($this->definition);
01256                                 $gloss_loc->display();
01257                                 return;
01258 
01259 
01260 
01261                                 // ### AA 03.11.10 added new locator GUI class ###
01262                                 $i = 1;
01263 
01264                                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
01265 
01266                                 if (!empty($_GET["term_id"]))
01267                                 {
01268                                         $this->tpl->touchBlock("locator_separator");
01269                                 }
01270 
01271                                 $this->tpl->setCurrentBlock("locator_item");
01272                                 $this->tpl->setVariable("ITEM", $this->object->getTitle());
01273                                 // TODO: SCRIPT NAME HAS TO BE VARIABLE!!!
01274                                 $this->tpl->setVariable("LINK_ITEM", "glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
01275                                 $this->tpl->parseCurrentBlock();
01276 
01277                                 // ### AA 03.11.10 added new locator GUI class ###
01278                                 // navigate locator
01279                                 $ilias_locator->navigate($i++,$this->object->getTitle(),"glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms","bottom");
01280 
01281                                 if (!empty($_GET["term_id"]))
01282                                 {
01283                                         $term =& new ilGlossaryTerm($_GET["term_id"]);
01284                                         $this->tpl->setCurrentBlock("locator_item");
01285                                         $this->tpl->setVariable("ITEM", $term->getTerm());
01286                                         $this->tpl->setVariable("LINK_ITEM", "glossary_edit.php?ref_id=".$_GET["ref_id"].
01287                                                 "&cmd=listDefinitions&term_id=".$term->getId());
01288                                         $this->tpl->parseCurrentBlock();
01289 
01290                                         // ### AA 03.11.10 added new locator GUI class ###
01291                                         // navigate locator
01292                                         $ilias_locator->navigate($i++,$term->getTerm(),"glossary_edit.php?ref_id=".$_GET["ref_id"].
01293                                                 "&cmd=listDefinitions&term_id=".$term->getId(),"bottom");
01294                                 }
01295 
01296                                 //$this->tpl->touchBlock("locator_separator");
01297 
01298                                 $this->tpl->setCurrentBlock("locator");
01299                                 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
01300                                 $this->tpl->parseCurrentBlock();
01301                         }
01302                 }
01303 
01304         }
01305 
01309         function perm()
01310         {
01311                 //$this->prepareOutput();
01312                 $this->setFormAction("addRole", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=addRole");
01313                 $this->setFormAction("permSave", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=permSave");
01314                 $this->permObject();
01315         }
01316 
01320         function permSave()
01321         {
01322                 $this->setReturnLocation("permSave", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=perm");
01323                 $this->permSaveObject();
01324         }
01325 
01329         function addRole()
01330         {
01331                 $this->setReturnLocation("addRole", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=perm");
01332                 $this->addRoleObject();
01333         }
01334 
01338         function owner()
01339         {
01340                 //$this->prepareOutput();
01341                 $this->ownerObject();
01342         }
01343 
01347         function view()
01348         {
01349                 //$this->prepareOutput();
01350                 $this->viewObject();
01351         }
01352 
01356         function create()
01357         {
01358                 switch($_POST["new_type"])
01359                 {
01360                         case "term":
01361                                 $term_gui =& new ilGlossaryTermGUI();
01362                                 $term_gui->create();
01363                                 break;
01364                 }
01365         }
01366 
01367         function saveTerm()
01368         {
01369                 $term_gui =& new ilGlossaryTermGUI();
01370                 $term_gui->setGlossary($this->object);
01371                 $term_gui->save();
01372 
01373                 sendinfo($this->lng->txt("cont_added_term"),true);
01374 
01375                 ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
01376         }
01377 
01378 
01382         function addDefinition()
01383         {
01384                 if (count($_POST["id"]) < 1)
01385                 {
01386                         $this->ilias->raiseError($this->lng->txt("cont_select_term"),$this->ilias->error_obj->MESSAGE);
01387                 }
01388 
01389                 if (count($_POST["id"]) > 1)
01390                 {
01391                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_term"),$this->ilias->error_obj->MESSAGE);
01392                 }
01393 
01394                 // add term
01395                 include_once ("content/classes/class.ilGlossaryTerm.php");
01396                 $term =& new ilGlossaryTerm($_POST["id"][0]);
01397 
01398                 // add first definition
01399                 $def =& new ilGlossaryDefinition();
01400                 $def->setTermId($term->getId());
01401                 $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
01402                 $def->create();
01403 
01404                 $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
01405                 $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
01406                 $this->ctrl->redirectByClass(array("ilglossarytermgui",
01407                         "iltermdefinitioneditorgui", "ilpageobjectgui"), "view");
01408                 
01409         }
01410 
01411         function getTemplate()
01412         {
01413                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01414                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01415 
01416                 $title = $this->object->getTitle();
01417 
01418                 // catch feedback message
01419                 sendInfo();
01420 
01421                 $this->tpl->setVariable("HEADER", $this->lng->txt("glo").": ".$title);
01422 
01423                 //$this->setAdminTabs($_POST["new_type"]);
01424                 //$this->setLocator();
01425 
01426         }
01427 
01431         function setTabs()
01432         {
01433 
01434                 // catch feedback message
01435                 include_once("classes/class.ilTabsGUI.php");
01436                 $tabs_gui =& new ilTabsGUI();
01437                 $this->getTabs($tabs_gui);
01438 
01439                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01440 
01441         }
01442 
01446         function getTabs(&$tabs_gui)
01447         {
01448 
01449                 // list definitions
01450                 $tabs_gui->addTarget("cont_terms",
01451                         $this->ctrl->getLinkTarget($this, "listTerms"), "listTerms",
01452                         get_class($this));
01453 
01454                 // properties
01455                 $tabs_gui->addTarget("properties",
01456                         $this->ctrl->getLinkTarget($this, "properties"), "properties",
01457                         get_class($this));
01458 
01459                 // meta data
01460                 $tabs_gui->addTarget("meta_data",
01461                         $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
01462                         get_class($this));
01463 
01464                 // permissions
01465                 $tabs_gui->addTarget("permission_settings",
01466                         $this->ctrl->getLinkTarget($this, "perm"), "perm",
01467                         get_class($this));
01468 
01469                 // owner
01470                 $tabs_gui->addTarget("owner",
01471                         $this->ctrl->getLinkTarget($this, "owner"), "owner",
01472                         get_class($this));
01473 
01474         }
01475 
01476 }
01477 
01478 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1