• 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                 else
00191                 {
00192                         // create and insert object in objecttree
00193                         include_once("content/classes/class.ilObjGlossary.php");
00194                         $newObj = new ilObjGlossary();
00195                         $newObj->setType($this->type);
00196                         $newObj->setTitle($_POST["Fobject"]["title"]);
00197                         $newObj->setDescription($_POST["Fobject"]["desc"]);
00198                         $newObj->create();
00199                         $newObj->createReference();
00200                         $newObj->putInTree($_GET["ref_id"]);
00201                         $newObj->setPermissions($_GET["ref_id"]);
00202                         $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00203 
00204                         //$roles = $newObj->initDefaultRoles();
00205 
00206                         // assign author role to creator of forum object
00207                         //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
00208                         //ilObjUser::updateActiveRoles($newObj->getOwner());
00209 
00210                         unset($newObj);
00211 
00212                         // always send a message
00213                         sendInfo($this->lng->txt("glo_added"),true);
00214                         ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00215                 }
00216         }
00217 
00224         function importFileObject()
00225         {
00226                 global $HTTP_POST_FILES, $rbacsystem;
00227 
00228                 // check if file was uploaded
00229                 $source = $HTTP_POST_FILES["xmldoc"]["tmp_name"];
00230                 if (($source == 'none') || (!$source))
00231                 {
00232                         $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00233                 }
00234                 // check create permission
00235                 /*
00236                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
00237                 {
00238                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00239                 }*/
00240 
00241                 // check correct file type
00242                 if ($HTTP_POST_FILES["xmldoc"]["type"] != "application/zip" && $HTTP_POST_FILES["xmldoc"]["type"] != "application/x-zip-compressed")
00243                 {
00244                         $this->ilias->raiseError("Wrong file type!",$this->ilias->error_obj->MESSAGE);
00245                 }
00246 
00247                 // create and insert object in objecttree
00248                 include_once("content/classes/class.ilObjGlossary.php");
00249                 $newObj = new ilObjGlossary();
00250                 $newObj->setType($_GET["new_type"]);
00251                 $newObj->setTitle("dummy");
00252                 //$newObj->setDescription("dummy");
00253                 $newObj->create(true);
00254                 $newObj->createReference();
00255                 $newObj->putInTree($_GET["ref_id"]);
00256                 $newObj->setPermissions($_GET["ref_id"]);
00257                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00258 
00259                 // create import directory
00260                 $newObj->createImportDirectory();
00261 
00262                 // copy uploaded file to import directory
00263                 $file = pathinfo($_FILES["xmldoc"]["name"]);
00264                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
00265                 
00266                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
00267                         $_FILES["xmldoc"]["name"], $full_path);
00268                 
00269                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
00270 
00271                 // unzip file
00272                 ilUtil::unzip($full_path);
00273 
00274                 // determine filename of xml file
00275                 $subdir = basename($file["basename"],".".$file["extension"]);
00276                 $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
00277 //echo "xmlfile:".$xml_file;
00278 
00279                 include_once ("content/classes/class.ilContObjParser.php");
00280                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
00281                 $contParser->startParsing();
00282 
00283                 /* update title and description in object data */
00284                 // not allowed here: move to glossary class!
00285                 if (is_object($newObj->meta_data))
00286                 {
00287                         //$newObj->meta_data->read();
00288                         //$newObj->setTitle($newObj->meta_data->getTitle());
00289                         //$newObj->setDescription($newObj->meta_data->getDescription());
00290                         ilObject::_writeTitle($newObj->getID(), $newObj->getTitle());
00291                         ilObject::_writeDescription($newObj->getID(), $newObj->getDescription());
00292                         //$q = "UPDATE object_data SET title = '" . $newObj->getTitle() . "', description = '" . $newObj->getDescription() . "' WHERE obj_id = '" . $newObj->getID() . "'";
00293                         //$this->ilias->db->query($q);
00294                 }
00295 
00296                 sendInfo($this->lng->txt("glo_added"),true);
00297                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00298         }
00299 
00300 
00305         function chooseMetaSectionObject($a_target = "")
00306         {
00307                 if ($a_target == "")
00308                 {
00309                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00310                 }
00311 
00312                 include_once "classes/class.ilMetaDataGUI.php";
00313                 $meta_gui =& new ilMetaDataGUI();
00314                 $meta_gui->setObject($this->object);
00315                 $meta_gui->edit("ADM_CONTENT", "adm_content",
00316                         $a_target, $_REQUEST["meta_section"]);
00317         }
00318 
00323         function chooseMetaSection()
00324         {
00325                 //$this->prepareOutput();
00326                 $this->chooseMetaSectionObject($this->ctrl->getLinkTarget($this));
00327         }
00328 
00333         function addMetaObject($a_target = "")
00334         {
00335                 if ($a_target == "")
00336                 {
00337                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00338                 }
00339 
00340                 include_once "classes/class.ilMetaDataGUI.php";
00341                 $meta_gui =& new ilMetaDataGUI();
00342                 $meta_gui->setObject($this->object);
00343                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00344                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00345                 if ($meta_index == "")
00346                         $meta_index = 0;
00347                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00348                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00349                 if ($meta_name != "")
00350                 {
00351                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00352                 }
00353                 else
00354                 {
00355                         sendInfo($this->lng->txt("meta_choose_element"), true);
00356                 }
00357                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $meta_section);
00358         }
00359 
00364         function addMeta()
00365         {
00366                 //$this->prepareOutput();
00367                 $this->addMetaObject($this->ctrl->getLinkTarget($this));
00368         }
00369 
00370 
00375         function deleteMetaObject($a_target = "")
00376         {
00377                 if ($a_target == "")
00378                 {
00379                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00380                 }
00381 
00382                 include_once "classes/class.ilMetaDataGUI.php";
00383                 $meta_gui =& new ilMetaDataGUI();
00384                 $meta_gui->setObject($this->object);
00385                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00386                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
00387                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00388         }
00389 
00394         function deleteMeta()
00395         {
00396                 //$this->prepareOutput();
00397                 $this->deleteMetaObject($this->ctrl->getLinkTarget($this));
00398         }
00399 
00404         function editMetaObject($a_target = "")
00405         {
00406                 if ($a_target == "")
00407                 {
00408                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00409                 }
00410                 include_once "classes/class.ilMetaDataGUI.php";
00411                 $meta_gui =& new ilMetaDataGUI();
00412                 $meta_gui->setObject($this->object);
00413                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00414         }
00415 
00420         function editMeta()
00421         {
00422                 //$this->prepareOutput();
00423                 $this->editMetaObject($this->ctrl->getLinkTarget($this));
00424         }
00425 
00430         function saveMetaObject($a_target = "")
00431         {
00432                 if ($a_target == "")
00433                 {
00434                         $a_target = "adm_object.php?cmd=editMeta&ref_id=".$this->object->getRefId();
00435                 }
00436 
00437                 include_once "classes/class.ilMetaDataGUI.php";
00438                 $meta_gui =& new ilMetaDataGUI();
00439                 $meta_gui->setObject($this->object);
00440                 $meta_gui->save($_POST["meta_section"]);
00441                 ilUtil::redirect(ilUtil::appendUrlParameterString($a_target,
00442                         "meta_section=" . $_POST["meta_section"]));
00443         }
00444 
00449         function saveMeta()
00450         {
00451                 $this->saveMetaObject($this->ctrl->getLinkTarget($this, "editMeta"));
00452         }
00453 
00454 
00455         function viewObject()
00456         {
00457                 global $rbacsystem;
00458 
00459                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00460                 {
00461                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00462                 }
00463 
00464                 // edit button
00465                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00466 
00467                 if (!defined("ILIAS_MODULE"))
00468                 {
00469                         $this->tpl->setCurrentBlock("btn_cell");
00470                         $this->tpl->setVariable("BTN_LINK","content/glossary_edit.php?cmd=listTerms&ref_id=".$this->object->getRefID());
00471                         $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00472                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00473                         $this->tpl->parseCurrentBlock();
00474                 }
00475 
00476                 $this->tpl->setCurrentBlock("btn_cell");
00477                 $this->tpl->setVariable("BTN_LINK","content/glossary_presentation.php?cmd=listTerms&ref_id=".$this->object->getRefID());
00478                 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00479                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00480                 $this->tpl->parseCurrentBlock();
00481 
00482                 //parent::viewObject();
00483         }
00484 
00490         function properties()
00491         {
00492                 global $rbacsystem, $tree, $tpl;
00493 
00494                 // glossary properties
00495                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glossary_properties.html", true);
00496                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00497                 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_glo_properties"));
00498 
00499                 // online
00500                 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00501                 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00502                 $this->tpl->setVariable("VAL_ONLINE", "y");
00503                 if ($this->object->getOnline())
00504                 {
00505                         $this->tpl->setVariable("CHK_ONLINE", "checked");
00506                 }
00507 
00508                 $this->tpl->setCurrentBlock("commands");
00509                 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00510                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00511                 $this->tpl->parseCurrentBlock();
00512 
00513         }
00514 
00518         function saveProperties()
00519         {
00520                 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00521                 $this->object->update();
00522                 sendInfo($this->lng->txt("msg_obj_modified"), true);
00523                 $this->ctrl->redirect($this, "properties");
00524         }
00525 
00526 
00527 
00531         function listTerms()
00532         {
00533                 global $ilUser;
00534 
00535                 //$this->getTemplate();
00536                 //$this->setTabs();
00537                 //$this->setLocator();
00538                 $this->lng->loadLanguageModule("meta");
00539                 include_once "./classes/class.ilTableGUI.php";
00540 
00541 
00542                 // view button
00543                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00544 
00545                 $this->tpl->setCurrentBlock("btn_cell");
00546                 $this->tpl->setVariable("BTN_LINK", "glossary_presentation.php?cmd=listTerms&ref_id=".$this->object->getRefID());
00547                 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00548                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00549                 $this->tpl->parseCurrentBlock();
00550 
00551                 // export button
00552                 $this->tpl->setCurrentBlock("btn_cell");
00553                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
00554                 //$this->tpl->setVariable("BTN_TARGET"," target=\"_top\" ");
00555                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("export"));
00556                 $this->tpl->parseCurrentBlock();
00557 
00558                 // glossary term list template
00559                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_list.html", true);
00560                 $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
00561                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00562                 $this->tpl->setVariable("TXT_ADD2", $this->lng->txt("add"));
00563                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00564                 $lang = ilMetaData::getLanguages();
00565 
00566                 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00567                 {
00568                         $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00569                 }
00570                 else
00571                 {
00572                         $s_lang = $ilUser->getLanguage();
00573                 }
00574 
00575                 $select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
00576                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00577 
00578 
00579                 // load template for table
00580                 $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
00581 
00582                 // load template for table content data
00583                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_row.html", true);
00584 
00585                 $num = 0;
00586 
00587                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00588 
00589                 // create table
00590                 $tbl = new ilTableGUI();
00591 
00592                 // title & header columns
00593                 $tbl->setTitle($this->lng->txt("cont_terms"));
00594                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00595 
00596                 $tbl->setHeaderNames(array("", $this->lng->txt("cont_term"),
00597                          $this->lng->txt("language"), $this->lng->txt("cont_definitions")));
00598 
00599                 $cols = array("", "term", "language", "definitions", "id");
00600                 $header_params = array("ref_id" => $this->ref_id, "cmd" => "listTerms");
00601                 $tbl->setHeaderVars($cols, $header_params);
00602                 $tbl->setColumnWidth(array("1%","24%","15%","60%"));
00603 
00604                 // control
00605                 $tbl->setOrderColumn($_GET["sort_by"]);
00606                 $tbl->setOrderDirection($_GET["sort_order"]);
00607                 $tbl->setLimit($_GET["limit"]);
00608                 $tbl->setOffset($_GET["offset"]);
00609                 $tbl->setMaxCount($this->maxcount);
00610 
00611                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
00612                 $this->setActions(array("confirmTermDeletion" => "delete", "addDefinition" => "cont_add_definition"));
00613                 //$this->setSubObjects(array("term" => array()));
00614                 $this->showActions(true);
00615 
00616                 // footer
00617                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00618                 //$tbl->disable("footer");
00619 
00620                 $term_list = $this->object->getTermList();
00621                 $tbl->setMaxCount(count($term_list));
00622 
00623                 // sorting array
00624                 //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
00625                 $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
00626 
00627                 // render table
00628                 $tbl->render();
00629 
00630                 if (count($term_list) > 0)
00631                 {
00632                         $i=1;
00633                         foreach($term_list as $key => $term)
00634                         {
00635                                 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00636                                 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
00637                                 for($j=0; $j<count($defs); $j++)
00638                                 {
00639                                         $def = $defs[$j];
00640 
00641                                         // up
00642                                         if ($j > 0)
00643                                         {
00644                                                 $this->tpl->setCurrentBlock("move_up");
00645                                                 $this->tpl->setVariable("TXT_UP", $this->lng->txt("up"));
00646                                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00647                                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00648                                                 $this->tpl->setVariable("LINK_UP",
00649                                                         $this->ctrl->getLinkTarget($this, "moveDefinitionUp"));
00650                                                 $this->tpl->parseCurrentBlock();
00651                                         }
00652 
00653                                         // down
00654                                         if ($j+1 < count($defs))
00655                                         {
00656                                                 $this->tpl->setCurrentBlock("move_down");
00657                                                 $this->tpl->setVariable("TXT_DOWN", $this->lng->txt("down"));
00658                                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00659                                                 $this->ctrl->setParameter($this, "def", $def["id"]);
00660                                                 $this->tpl->setVariable("LINK_DOWN",
00661                                                         $this->ctrl->getLinkTarget($this, "moveDefinitionDown"));
00662                                                 $this->tpl->parseCurrentBlock();
00663                                         }
00664 
00665                                         // delete
00666                                         $this->tpl->setCurrentBlock("delete");
00667                                         $this->ctrl->setParameter($this, "term_id", $term["id"]);
00668                                         $this->ctrl->setParameter($this, "def", $def["id"]);
00669                                         $this->tpl->setVariable("LINK_DELETE",
00670                                                 $this->ctrl->getLinkTarget($this, "confirmDefinitionDeletion"));
00671                                         $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
00672                                         $this->tpl->parseCurrentBlock();
00673 
00674                                         // edit
00675                                         $this->tpl->setCurrentBlock("edit");
00676                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
00677                                         $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
00678                                         $this->tpl->setVariable("LINK_EDIT",
00679                                                 $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
00680                                                 "iltermdefinitioneditorgui",
00681                                                 "ilpageobjectgui"), "view"));
00682                                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00683                                         $this->tpl->parseCurrentBlock();
00684 
00685                                         // text
00686                                         $this->tpl->setCurrentBlock("definition");
00687                                         $short_str = strip_tags(ilPCParagraph::xml2output($def["short_text"]));
00688                                         $short_str = str_replace("<", "&lt;", $short_str);
00689                                         $short_str = str_replace(">", "&gt;", $short_str);
00690                                         $this->tpl->setVariable("DEF_SHORT", $short_str);
00691                                         $this->tpl->parseCurrentBlock();
00692 
00693                                         $this->tpl->setCurrentBlock("definition_row");
00694                                         $this->tpl->parseCurrentBlock();
00695                                 }
00696 
00697                                 $this->tpl->setCurrentBlock("check_col");
00698                                 $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
00699                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00700                                 $this->tpl->parseCurrentBlock();
00701 
00702                                 // edit term link
00703                                 $this->tpl->setCurrentBlock("edit_term");
00704                                 $this->tpl->setVariable("TEXT_TERM", $term["term"]);
00705                                 $this->ctrl->setParameter($this, "term_id", $term["id"]);
00706                                 $this->tpl->setVariable("LINK_EDIT_TERM",
00707                                         $this->ctrl->getLinkTarget($this, "editTerm"));
00708                                 $this->tpl->setVariable("TXT_EDIT_TERM", $this->lng->txt("edit"));
00709                                 $this->tpl->parseCurrentBlock();
00710 
00711                                 $this->tpl->setCurrentBlock("tbl_content");
00712 
00713                                 // output term and language
00714                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00715                                 $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
00716                                 $this->tpl->setCurrentBlock("tbl_content");
00717                                 $this->tpl->parseCurrentBlock();
00718                         }
00719                 } //if is_array
00720                 else
00721                 {
00722                         $this->tpl->setCurrentBlock("notfound");
00723                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00724                         $this->tpl->setVariable("NUM_COLS", $num);
00725                         $this->tpl->parseCurrentBlock();
00726                 }
00727         }
00728 
00732         function addTerm()
00733         {
00734                 // add term
00735                 include_once ("content/classes/class.ilGlossaryTerm.php");
00736                 $term =& new ilGlossaryTerm();
00737                 $term->setGlossary($this->object);
00738                 $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
00739                 $term->setLanguage($_POST["term_language"]);
00740                 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
00741                 $term->create();
00742 
00743                 // add first definition
00744                 $def =& new ilGlossaryDefinition();
00745                 $def->setTermId($term->getId());
00746                 $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
00747                 $def->create();
00748 
00749                 $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
00750                 $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
00751                 $this->ctrl->redirectByClass(array("ilglossarytermgui",
00752                         "iltermdefinitioneditorgui", "ilpageobjectgui"), "view");
00753         }
00754 
00758         function moveDefinitionUp()
00759         {
00760                 include_once("content/classes/class.ilGlossaryDefinition.php");
00761 
00762                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00763                 $definition->moveUp();
00764 
00765                 $this->ctrl->redirect($this, "listTerms");
00766         }
00767 
00771         function moveDefinitionDown()
00772         {
00773                 include_once("content/classes/class.ilGlossaryDefinition.php");
00774 
00775                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00776                 $definition->moveDown();
00777 
00778                 $this->ctrl->redirect($this, "listTerms");
00779         }
00780 
00784         function confirmDefinitionDeletion()
00785         {
00786                 //$this->getTemplate();
00787                 //$this->displayLocator();
00788                 //$this->setTabs();
00789 
00790                 $term = new ilGlossaryTerm($_GET["term_id"]);
00791 
00792                 // content style
00793                 $this->tpl->setCurrentBlock("ContentStyle");
00794                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00795                         ilObjStyleSheet::getContentStylePath(0));
00796                 $this->tpl->parseCurrentBlock();
00797 
00798                 // syntax style
00799                 $this->tpl->setCurrentBlock("SyntaxStyle");
00800                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00801                         ilObjStyleSheet::getSyntaxStylePath());
00802                 $this->tpl->parseCurrentBlock();
00803 
00804 
00805                 //$this->tpl->setVariable("HEADER",
00806                 //      $this->lng->txt("cont_term").": ".$term->getTerm());
00807 
00808                 $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
00809                 sendInfo($this->lng->txt("info_delete_sure"));
00810 
00811                 $this->tpl->setVariable("TXT_TERM", $term->getTerm());
00812 
00813                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00814                 $page =& new ilPageObject("gdf", $definition->getId());
00815                 $page_gui =& new ilPageObjectGUI($page);
00816                 $page_gui->setTemplateOutput(false);
00817                 $page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00818                 $output = $page_gui->preview();
00819 
00820                 $this->tpl->setCurrentBlock("definition");
00821                 $this->tpl->setVariable("PAGE_CONTENT", $output);
00822                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00823                 $this->tpl->setVariable("LINK_CANCEL",
00824                         $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
00825                 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
00826                 $this->ctrl->setParameter($this, "def", $definition->getId());
00827                 $this->tpl->setVariable("LINK_CONFIRM",
00828                         $this->ctrl->getLinkTarget($this, "deleteDefinition"));
00829                 $this->tpl->parseCurrentBlock();
00830         }
00831 
00832         function cancelDefinitionDeletion()
00833         {
00834                 $this->ctrl->redirect($this, "listTerms");
00835         }
00836 
00837 
00838         function deleteDefinition()
00839         {
00840                 $definition =& new ilGlossaryDefinition($_GET["def"]);
00841                 $definition->delete();
00842                 $this->ctrl->redirect($this, "listTerms");
00843         }
00844 
00848         function editTerm()
00849         {
00850                 $term = new ilGlossaryTerm($_GET["term_id"]);
00851                 //$this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$term->getTerm());
00852 
00853                 // load template for table
00854                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
00855                 $this->ctrl->setParameter($this, "term_id", $_GET["term_id"]);
00856                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00857                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
00858                 $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
00859                 $this->tpl->setVariable("INPUT_TERM", "term");
00860                 $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($term->getTerm()));
00861                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00862                 $lang = ilMetaData::getLanguages();
00863                 $select_language = ilUtil::formSelect ($term->getLanguage(),"term_language",$lang,false,true);
00864                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00865                 $this->tpl->setVariable("BTN_NAME", "updateTerm");
00866                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00867         }
00868 
00869 
00873         function updateTerm()
00874         {
00875                 $term = new ilGlossaryTerm($_GET["term_id"]);
00876 
00877                 $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
00878                 $term->setLanguage($_POST["term_language"]);
00879                 $term->update();
00880                 sendinfo($this->lng->txt("msg_obj_modified"),true);
00881                 $this->ctrl->redirect($this, "listTerms");
00882         }
00883 
00884 
00885         /*
00886         * list all export files
00887         */
00888         function exportList()
00889         {
00890                 global $tree;
00891 
00892                 $this->setTabs();
00893 
00894                 //add template for view button
00895                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00896 
00897                 // create export file button
00898                 $this->tpl->setCurrentBlock("btn_cell");
00899                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
00900                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file"));
00901                 $this->tpl->parseCurrentBlock();
00902 
00903                 // view last export log button
00904                 if (is_file($this->object->getExportDirectory()."/export.log"))
00905                 {
00906                         $this->tpl->setCurrentBlock("btn_cell");
00907                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
00908                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
00909                         $this->tpl->parseCurrentBlock();
00910                 }
00911 
00912 
00913                 $export_dir = $this->object->getExportDirectory();
00914 
00915                 $export_files = $this->object->getExportFiles($export_dir);
00916 
00917                 // create table
00918                 require_once("classes/class.ilTableGUI.php");
00919                 $tbl = new ilTableGUI();
00920 
00921                 // load files templates
00922                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00923 
00924                 // load template for table content data
00925                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.glo_export_file_row.html", true);
00926 
00927                 $num = 0;
00928 
00929                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00930 
00931                 $tbl->setTitle($this->lng->txt("cont_export_files"));
00932 
00933                 $tbl->setHeaderNames(array("", $this->lng->txt("cont_file"),
00934                         $this->lng->txt("cont_size"), $this->lng->txt("date") ));
00935 
00936                 $cols = array("", "file", "size", "date");
00937                 $header_params = array("ref_id" => $_GET["ref_id"],
00938                         "cmd" => "exportList", "cmdClass" => get_class($this));
00939                 $tbl->setHeaderVars($cols, $header_params);
00940                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
00941 
00942                 // control
00943                 $tbl->setOrderColumn($_GET["sort_by"]);
00944                 $tbl->setOrderDirection($_GET["sort_order"]);
00945                 $tbl->setLimit($_GET["limit"]);
00946                 $tbl->setOffset($_GET["offset"]);
00947                 $tbl->setMaxCount($this->maxcount);             // ???
00948 
00949 
00950                 $this->tpl->setVariable("COLUMN_COUNTS", 4);
00951 
00952                 // delete button
00953                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00954                 $this->tpl->setCurrentBlock("tbl_action_btn");
00955                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
00956                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00957                 $this->tpl->parseCurrentBlock();
00958 
00959                 $this->tpl->setCurrentBlock("tbl_action_btn");
00960                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
00961                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
00962                 $this->tpl->parseCurrentBlock();
00963 
00964                 // footer
00965                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00966                 //$tbl->disable("footer");
00967 
00968                 $tbl->setMaxCount(count($export_files));
00969                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
00970 
00971                 $tbl->render();
00972                 if(count($export_files) > 0)
00973                 {
00974                         $i=0;
00975                         foreach($export_files as $exp_file)
00976                         {
00977                                 $this->tpl->setCurrentBlock("tbl_content");
00978                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
00979 
00980                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00981                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00982 
00983                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
00984                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
00985 
00986                                 $file_arr = explode("__", $exp_file);
00987                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
00988 
00989                                 $this->tpl->parseCurrentBlock();
00990                         }
00991                 } //if is_array
00992                 else
00993                 {
00994                         $this->tpl->setCurrentBlock("notfound");
00995                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00996                         $this->tpl->setVariable("NUM_COLS", 3);
00997                         $this->tpl->parseCurrentBlock();
00998                 }
00999 
01000                 $this->tpl->parseCurrentBlock();
01001         }
01002 
01003 
01007         function export()
01008         {
01009                 require_once("content/classes/class.ilGlossaryExport.php");
01010                 $glo_exp = new ilGlossaryExport($this->object);
01011                 $glo_exp->buildExportFile();
01012                 $this->exportList();
01013         }
01014 
01018         function downloadExportFile()
01019         {
01020                 if(!isset($_POST["file"]))
01021                 {
01022                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01023                 }
01024 
01025                 if (count($_POST["file"]) > 1)
01026                 {
01027                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01028                 }
01029 
01030 
01031                 $export_dir = $this->object->getExportDirectory();
01032                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01033                         $_POST["file"][0]);
01034         }
01035 
01036         /*
01037         * list all export files
01038         */
01039         function viewExportLog()
01040         {
01041                 global $tree;
01042 
01043                 $this->setTabs();
01044 
01045                 //add template for view button
01046                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01047 
01048                 // create export file button
01049                 $this->tpl->setCurrentBlock("btn_cell");
01050                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
01051                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
01052                 $this->tpl->parseCurrentBlock();
01053 
01054                 // load files templates
01055                 $this->tpl->setVariable("ADM_CONTENT",
01056                         nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
01057 
01058                 $this->tpl->parseCurrentBlock();
01059         }
01060 
01064         function confirmDeleteExportFile()
01065         {
01066                 if(!isset($_POST["file"]))
01067                 {
01068                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01069                 }
01070 
01071                 $this->setTabs();
01072 
01073                 // SAVE POST VALUES
01074                 $_SESSION["ilExportFiles"] = $_POST["file"];
01075 
01076                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01077 
01078                 sendInfo($this->lng->txt("info_delete_sure"));
01079 
01080                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01081 
01082                 // BEGIN TABLE HEADER
01083                 $this->tpl->setCurrentBlock("table_header");
01084                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01085                 $this->tpl->parseCurrentBlock();
01086 
01087                 // BEGIN TABLE DATA
01088                 $counter = 0;
01089                 foreach($_POST["file"] as $file)
01090                 {
01091                                 $this->tpl->setCurrentBlock("table_row");
01092                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01093                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01094                                 $this->tpl->parseCurrentBlock();
01095                 }
01096 
01097                 // cancel/confirm button
01098                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01099                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
01100                         "deleteExportFile"  => $this->lng->txt("confirm"));
01101                 foreach ($buttons as $name => $value)
01102                 {
01103                         $this->tpl->setCurrentBlock("operation_btn");
01104                         $this->tpl->setVariable("BTN_NAME",$name);
01105                         $this->tpl->setVariable("BTN_VALUE",$value);
01106                         $this->tpl->parseCurrentBlock();
01107                 }
01108         }
01109 
01113         function cancelDeleteExportFile()
01114         {
01115                 session_unregister("ilExportFiles");
01116                 $this->ctrl->redirect($this, "exportList");
01117         }
01118 
01122         function deleteExportFile()
01123         {
01124                 $export_dir = $this->object->getExportDirectory();
01125                 foreach($_SESSION["ilExportFiles"] as $file)
01126                 {
01127                         $exp_file = $export_dir."/".$file;
01128                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01129                         if (@is_file($exp_file))
01130                         {
01131                                 unlink($exp_file);
01132                         }
01133                         if (@is_dir($exp_dir))
01134                         {
01135                                 ilUtil::delDir($exp_dir);
01136                         }
01137                 }
01138                 $this->ctrl->redirect($this, "exportList");
01139         }
01140 
01144         function confirmTermDeletion()
01145         {
01146                 //$this->prepareOutput();
01147                 if (!isset($_POST["id"]))
01148                 {
01149                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01150                 }
01151 
01152                 // save values to
01153                 $_SESSION["term_delete"] = $_POST["id"];
01154 
01155                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_confirm.html");
01156 
01157                 sendInfo($this->lng->txt("info_delete_sure"));
01158                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01159 
01160                 // output table header
01161                 $cols = array("cont_term");
01162                 foreach ($cols as $key)
01163                 {
01164                         $this->tpl->setCurrentBlock("table_header");
01165                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01166                         $this->tpl->parseCurrentBlock();
01167                 }
01168 
01169                 foreach($_POST["id"] as $id)
01170                 {
01171                         $term = new ilGlossaryTerm($id);
01172 
01173                         // output title
01174                         $this->tpl->setCurrentBlock("table_cell");
01175                         $this->tpl->setVariable("TEXT_CONTENT", $term->getTerm());
01176                         $this->tpl->parseCurrentBlock();
01177 
01178                         // output table row
01179                         $this->tpl->setCurrentBlock("table_row");
01180                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01181                         $this->tpl->parseCurrentBlock();
01182                 }
01183 
01184                 // cancel and confirm button
01185                 $buttons = array( "cancelTermDeletion"  => $this->lng->txt("cancel"),
01186                         "deleteTerms"  => $this->lng->txt("confirm"));
01187                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01188                 foreach($buttons as $name => $value)
01189                 {
01190                         $this->tpl->setCurrentBlock("operation_btn");
01191                         $this->tpl->setVariable("BTN_NAME",$name);
01192                         $this->tpl->setVariable("BTN_VALUE",$value);
01193                         $this->tpl->parseCurrentBlock();
01194                 }
01195 
01196         }
01197 
01203         function cancelTermDeletion()
01204         {
01205                 session_unregister("term_delete");
01206                 sendInfo($this->lng->txt("msg_cancel"),true);
01207                 $this->ctrl->redirect($this, "listTerms");
01208         }
01209 
01213         function deleteTerms()
01214         {
01215                 foreach($_SESSION["term_delete"] as $id)
01216                 {
01217                         $term = new ilGlossaryTerm($id);
01218                         $term->delete();
01219                 }
01220                 session_unregister("term_delete");
01221                 $this->ctrl->redirect($this, "listTerms");
01222         }
01223 
01231         function setLocator($a_tree = "", $a_id = "")
01232         {
01233                 global $ilias_locator;
01234 
01235                 if(!defined("ILIAS_MODULE"))
01236                 {
01237                         parent::setLocator($a_tree, $a_id);
01238                 }
01239                 else
01240                 {
01241                         if(is_object($this->object))
01242                         {
01243                                 require_once("content/classes/class.ilGlossaryLocatorGUI.php");
01244                                 $gloss_loc =& new ilGlossaryLocatorGUI();
01245                                 if (is_object($this->term))
01246                                 {
01247                                         $gloss_loc->setTerm($this->term);
01248                                 }
01249                                 $gloss_loc->setGlossary($this->object);
01250                                 //$gloss_loc->setDefinition($this->definition);
01251                                 $gloss_loc->display();
01252                                 return;
01253 
01254 
01255 
01256                                 // ### AA 03.11.10 added new locator GUI class ###
01257                                 $i = 1;
01258 
01259                                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
01260 
01261                                 if (!empty($_GET["term_id"]))
01262                                 {
01263                                         $this->tpl->touchBlock("locator_separator");
01264                                 }
01265 
01266                                 $this->tpl->setCurrentBlock("locator_item");
01267                                 $this->tpl->setVariable("ITEM", $this->object->getTitle());
01268                                 // TODO: SCRIPT NAME HAS TO BE VARIABLE!!!
01269                                 $this->tpl->setVariable("LINK_ITEM", "glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
01270                                 $this->tpl->parseCurrentBlock();
01271 
01272                                 // ### AA 03.11.10 added new locator GUI class ###
01273                                 // navigate locator
01274                                 $ilias_locator->navigate($i++,$this->object->getTitle(),"glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms","bottom");
01275 
01276                                 if (!empty($_GET["term_id"]))
01277                                 {
01278                                         $term =& new ilGlossaryTerm($_GET["term_id"]);
01279                                         $this->tpl->setCurrentBlock("locator_item");
01280                                         $this->tpl->setVariable("ITEM", $term->getTerm());
01281                                         $this->tpl->setVariable("LINK_ITEM", "glossary_edit.php?ref_id=".$_GET["ref_id"].
01282                                                 "&cmd=listDefinitions&term_id=".$term->getId());
01283                                         $this->tpl->parseCurrentBlock();
01284 
01285                                         // ### AA 03.11.10 added new locator GUI class ###
01286                                         // navigate locator
01287                                         $ilias_locator->navigate($i++,$term->getTerm(),"glossary_edit.php?ref_id=".$_GET["ref_id"].
01288                                                 "&cmd=listDefinitions&term_id=".$term->getId(),"bottom");
01289                                 }
01290 
01291                                 //$this->tpl->touchBlock("locator_separator");
01292 
01293                                 $this->tpl->setCurrentBlock("locator");
01294                                 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
01295                                 $this->tpl->parseCurrentBlock();
01296                         }
01297                 }
01298 
01299         }
01300 
01304         function perm()
01305         {
01306                 //$this->prepareOutput();
01307                 $this->setFormAction("addRole", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=addRole");
01308                 $this->setFormAction("permSave", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=permSave");
01309                 $this->permObject();
01310         }
01311 
01315         function permSave()
01316         {
01317                 $this->setReturnLocation("permSave", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=perm");
01318                 $this->permSaveObject();
01319         }
01320 
01324         function addRole()
01325         {
01326                 $this->setReturnLocation("addRole", "glossary_edit.php?ref_id=".$this->object->getRefId()."&cmd=perm");
01327                 $this->addRoleObject();
01328         }
01329 
01333         function owner()
01334         {
01335                 //$this->prepareOutput();
01336                 $this->ownerObject();
01337         }
01338 
01342         function view()
01343         {
01344                 //$this->prepareOutput();
01345                 $this->viewObject();
01346         }
01347 
01351         function create()
01352         {
01353                 switch($_POST["new_type"])
01354                 {
01355                         case "term":
01356                                 $term_gui =& new ilGlossaryTermGUI();
01357                                 $term_gui->create();
01358                                 break;
01359                 }
01360         }
01361 
01362         function saveTerm()
01363         {
01364                 $term_gui =& new ilGlossaryTermGUI();
01365                 $term_gui->setGlossary($this->object);
01366                 $term_gui->save();
01367 
01368                 sendinfo($this->lng->txt("cont_added_term"),true);
01369 
01370                 ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
01371         }
01372 
01373 
01377         function addDefinition()
01378         {
01379                 if (count($_POST["id"]) < 1)
01380                 {
01381                         $this->ilias->raiseError($this->lng->txt("cont_select_term"),$this->ilias->error_obj->MESSAGE);
01382                 }
01383 
01384                 if (count($_POST["id"]) > 1)
01385                 {
01386                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_term"),$this->ilias->error_obj->MESSAGE);
01387                 }
01388 
01389                 // add term
01390                 include_once ("content/classes/class.ilGlossaryTerm.php");
01391                 $term =& new ilGlossaryTerm($_POST["id"][0]);
01392 
01393                 // add first definition
01394                 $def =& new ilGlossaryDefinition();
01395                 $def->setTermId($term->getId());
01396                 $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
01397                 $def->create();
01398 
01399                 $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
01400                 $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
01401                 $this->ctrl->redirectByClass(array("ilglossarytermgui",
01402                         "iltermdefinitioneditorgui", "ilpageobjectgui"), "view");
01403                 
01404         }
01405 
01406         function getTemplate()
01407         {
01408                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01409                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01410 
01411                 $title = $this->object->getTitle();
01412 
01413                 // catch feedback message
01414                 sendInfo();
01415 
01416                 $this->tpl->setVariable("HEADER", $this->lng->txt("glo").": ".$title);
01417 
01418                 //$this->setAdminTabs($_POST["new_type"]);
01419                 //$this->setLocator();
01420 
01421         }
01422 
01426         function setTabs()
01427         {
01428 
01429                 // catch feedback message
01430                 include_once("classes/class.ilTabsGUI.php");
01431                 $tabs_gui =& new ilTabsGUI();
01432                 $this->getTabs($tabs_gui);
01433 
01434                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01435 
01436         }
01437 
01441         function getTabs(&$tabs_gui)
01442         {
01443 
01444                 // list definitions
01445                 $tabs_gui->addTarget("cont_terms",
01446                         $this->ctrl->getLinkTarget($this, "listTerms"), "listTerms",
01447                         get_class($this));
01448 
01449                 // properties
01450                 $tabs_gui->addTarget("properties",
01451                         $this->ctrl->getLinkTarget($this, "properties"), "properties",
01452                         get_class($this));
01453 
01454                 // meta data
01455                 $tabs_gui->addTarget("meta_data",
01456                         $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
01457                         get_class($this));
01458 
01459                 // permissions
01460                 $tabs_gui->addTarget("permission_settings",
01461                         $this->ctrl->getLinkTarget($this, "perm"), "perm",
01462                         get_class($this));
01463 
01464                 // owner
01465                 $tabs_gui->addTarget("owner",
01466                         $this->ctrl->getLinkTarget($this, "owner"), "owner",
01467                         get_class($this));
01468 
01469         }
01470 
01471 }
01472 
01473 ?>

Generated on Fri Dec 13 2013 08:00:16 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1