/**
  * Shorten short text
  *
  * @param
  * @return
  */
 function shortenShortText($text)
 {
     $a_length = 196;
     if ($this->getTermId() > 0) {
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
         $glo_id = ilGlossaryTerm::_lookGlossaryId($this->getTermId());
         $snippet_length = ilObjGlossary::lookupSnippetLength($glo_id);
         if ($snippet_length > 0) {
             $a_length = $snippet_length;
         }
     }
     $text = str_replace("<br/>", "<br>", $text);
     $text = strip_tags($text, "<br>");
     if (is_int(strpos(substr($text, $a_length - 16 - 5, 10), "[tex]"))) {
         $offset = 5;
     }
     $short = ilUtil::shortenText($text, $a_length - 16 + $offset, true);
     // make short text longer, if tex end tag is missing
     $ltexs = strrpos($short, "[tex]");
     $ltexe = strrpos($short, "[/tex]");
     if ($ltexs > $ltexe) {
         $ltexe = strpos($text, "[/tex]", $ltexs);
         if ($ltexe > 0) {
             $short = ilUtil::shortenText($text, $ltexe + 6, true);
         }
     }
     $short = ilUtil::shortenText($text, $a_length, true);
     return $short;
 }
Esempio n. 2
0
 public function outGlossarySelector()
 {
     require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
     require_once 'Modules/Glossary/classes/class.ilObjGlossary.php';
     $this->ctrl->setParameter($this, 'q_id', $this->object->getId());
     $glossary = new ilObjGlossary($_GET['source_id'], true);
     $terms = $glossary->getTermList();
     $rows = array();
     foreach ($terms as $term) {
         $this->ctrl->setParameter($this, 'git', $term['id']);
         $rows[] = array('title' => $term['term'], 'description' => '', 'text_add' => $this->lng->txt('add'), 'href_add' => $this->ctrl->getLinkTarget($this, 'addGIT'));
     }
     $table = new ilQuestionInternalLinkSelectionTableGUI($this, 'cancelExplorer', __METHOD__);
     $table->setTitle($this->lng->txt('glossary_term'));
     $table->setData($rows);
     $this->tpl->setContent($table->getHTML());
 }
 function isClickable($a_type, $a_ref_id, $a_obj_id = 0)
 {
     global $rbacsystem, $ilDB, $ilUser, $ilAccess;
     if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id)) {
         return false;
     }
     switch ($a_type) {
         case "crs":
             return $ilAccess->checkAccess("read", "", $a_ref_id);
             // visible groups can allways be clicked; group processing decides
             // what happens next
         // visible groups can allways be clicked; group processing decides
         // what happens next
         case "grp":
             return true;
         case 'tst':
             if (!$rbacsystem->checkAccess("read", $a_ref_id)) {
                 return false;
             }
             $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $a_obj_id);
             $res = $ilDB->query($query);
             while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
                 return (bool) $row->complete;
             }
             return false;
         case 'svy':
             if (!$rbacsystem->checkAccess("read", $a_ref_id)) {
                 return false;
             }
             $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $a_obj_id);
             $res = $ilDB->query($query);
             while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
                 return (bool) $row->complete;
             }
             return false;
             // media pools can only be edited
         // media pools can only be edited
         case "mep":
             if ($rbacsystem->checkAccess("read", $a_ref_id)) {
                 return true;
             } else {
                 return false;
             }
             break;
         case 'crsr':
         case 'catr':
             include_once './Services/ContainerReference/classes/class.ilContainerReferenceAccess.php';
             return ilContainerReferenceAccess::_isAccessible($a_ref_id);
             // all other types are only clickable, if read permission is given
         // all other types are only clickable, if read permission is given
         default:
             if ($rbacsystem->checkAccess("read", $a_ref_id)) {
                 // check if lm is online
                 if ($a_type == "lm") {
                     include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
                     $lm_obj =& new ilObjLearningModule($a_ref_id);
                     if (!$lm_obj->getOnline() && !$rbacsystem->checkAccess('write', $a_ref_id)) {
                         return false;
                     }
                 }
                 // check if fblm is online
                 if ($a_type == "htlm") {
                     include_once "./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php";
                     $lm_obj =& new ilObjFileBasedLM($a_ref_id);
                     if (!$lm_obj->getOnline() && !$rbacsystem->checkAccess('write', $a_ref_id)) {
                         return false;
                     }
                 }
                 // check if fblm is online
                 if ($a_type == "sahs") {
                     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
                     $lm_obj =& new ilObjSAHSLearningModule($a_ref_id);
                     if (!$lm_obj->getOnline() && !$rbacsystem->checkAccess('write', $a_ref_id)) {
                         return false;
                     }
                 }
                 // check if glossary is online
                 if ($a_type == "glo") {
                     $obj_id = ilObject::_lookupObjectId($a_ref_id);
                     include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
                     if (!ilObjGlossary::_lookupOnline($obj_id) && !$rbacsystem->checkAccess('write', $a_ref_id)) {
                         return false;
                     }
                 }
                 return true;
             } else {
                 return false;
             }
             break;
     }
 }
 /**
  * Save glossary form
  */
 public function saveGlossary()
 {
     global $tpl, $lng, $ilCtrl, $rbacsystem, $tree;
     $parent_ref_id = $tree->getParentId((int) $_GET["ref_id"]);
     if (!$rbacsystem->checkAccess("create", $parent_ref_id, "glo")) {
         ilUtil::sendFailure($lng->txt("no_permission"), true);
         $ilCtrl->redirect($this, "properties");
     }
     $this->initGlossaryCreationForm();
     if ($this->form->checkInput()) {
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         $newObj = new ilObjGlossary();
         $newObj->setType("glo");
         $newObj->setTitle($_POST["title"]);
         $newObj->setDescription($_POST["description"]);
         $newObj->setVirtualMode("none");
         $newObj->create();
         $newObj->createReference();
         $newObj->putInTree($parent_ref_id);
         $newObj->setPermissions($parent_ref_id);
         $newObj->notify("new", $parent_ref_id, $_GET["parent_non_rbac_id"], $parent_ref_id, $newObj->getRefId());
         // perform save
         $this->object->setAssignedGlossary($newObj->getId());
         $this->object->update();
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->redirect($this, "properties");
     }
     $this->form->setValuesByPost();
     $tpl->setContent($this->form->getHtml());
 }
 function exportPDF($a_inst, $a_target_dir, &$expLog)
 {
     global $ilBench;
     $a_xml_writer = new ilXmlWriter();
     $a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004SCO"));
     $this->exportXMLMetaData($a_xml_writer);
     $tree = new ilTree($this->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $sco) {
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
         $sco_folder = $a_target_dir . "/" . $sco['obj_id'];
         ilUtil::makeDir($sco_folder);
         $node = new ilSCORM2004Sco($this, $sco['obj_id']);
         $node->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
     }
     if ($this->getAssignedGlossary() != 0) {
         ilUtil::makeDir($a_target_dir . "/glossary");
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         include_once "./Modules/Glossary/classes/class.ilGlossaryExport.php";
         $glos = new ilObjGlossary($this->getAssignedGlossary(), false);
         $glos_export = new ilGlossaryExport($glos, "xml");
         $glos->exportXML($a_xml_writer, $glos_export->getInstId(), $a_target_dir . "/glossary", $expLog);
     }
     copy('./templates/default/images/icon_attachment_s.png', $a_target_dir . "/icon_attachment_s.png");
     $a_xml_writer->xmlEndTag("ContentObject");
     include_once 'Services/Transformation/classes/class.ilXML2FO.php';
     $xml2FO = new ilXML2FO();
     $xml2FO->setXSLTLocation('./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
     $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
     $xml2FO->setXSLTParams(array('target_dir' => $a_target_dir));
     $xml2FO->transform();
     $fo_string = $xml2FO->getFOString();
     $fo_xml = simplexml_load_string($fo_string);
     $fo_ext = $fo_xml->xpath("//fo:declarations");
     $fo_ext = $fo_ext[0];
     $results = array();
     include_once "./Services/Utilities/classes/class.ilFileUtils.php";
     ilFileUtils::recursive_dirscan($a_target_dir . "/objects", $results);
     if (is_array($results["file"])) {
         foreach ($results["file"] as $key => $value) {
             $e = $fo_ext->addChild("fox:embedded-file", "", "http://xml.apache.org/fop/extensions");
             $e->addAttribute("src", $results[path][$key] . $value);
             $e->addAttribute("name", $value);
             $e->addAttribute("desc", "");
         }
     }
     $fo_string = $fo_xml->asXML();
     $a_xml_writer->_XmlWriter;
     return $fo_string;
 }
Esempio n. 6
0
 /**
  * Get all glossary ids
  *
  * @param
  * @return
  */
 function getAllGlossaryIds($a_include_offline_childs = false)
 {
     global $tree;
     if ($this->isVirtual()) {
         $glo_ids = array();
         $virtual_mode = $this->getRefId() ? $this->getVirtualMode() : '';
         switch ($virtual_mode) {
             case "level":
                 $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()), "glo");
                 $glo_ids[] = $this->getId();
                 foreach ($glo_arr as $glo) {
                     $glo_ids[] = $glo['obj_id'];
                 }
                 if (!$a_include_offline_childs) {
                     $glo_ids = ilObjGlossary::removeOfflineGlossaries($glo_ids);
                 }
                 // always show entries of current glossary (if no permission is given, user will not come to the presentation screen)
                 // see bug #14477
                 if (!in_array($this->getId(), $glo_ids)) {
                     $glo_ids[] = $this->getId();
                 }
                 break;
             case "subtree":
                 $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
                 foreach ($subtree_nodes as $node) {
                     if ($node['type'] == 'glo') {
                         $glo_ids[] = $node['obj_id'];
                     }
                 }
                 if (!$a_include_offline_childs) {
                     $glo_ids = ilObjGlossary::removeOfflineGlossaries($glo_ids);
                 }
                 // always show entries of current glossary (if no permission is given, user will not come to the presentation screen)
                 // see bug #14477
                 if (!in_array($this->getId(), $glo_ids)) {
                     $glo_ids[] = $this->getId();
                 }
                 break;
                 // fallback to none virtual mode in case of error
             // fallback to none virtual mode in case of error
             default:
                 $glo_ids[] = $this->getId();
                 break;
         }
     } else {
         $glo_ids = $this->getId();
     }
     return $glo_ids;
 }
Esempio n. 7
0
 /**
  * display status information or report errors messages
  * in case of error
  *
  * @access	public
  */
 function importFileObject()
 {
     $new_type = $_REQUEST["new_type"];
     // create permission is already checked in createObject. This check here is done to prevent hacking attempts
     if (!$this->checkPermissionBool("create", "", $new_type)) {
         $ilErr->raiseError($this->lng->txt("no_create_permission"));
     }
     $this->lng->loadLanguageModule($new_type);
     $this->ctrl->setParameter($this, "new_type", $new_type);
     $form = $this->initImportForm($new_type);
     if ($form->checkInput()) {
         $this->ctrl->setParameter($this, "new_type", "");
         $upload = $_FILES["importfile"];
         // create and insert object in objecttree
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         $newObj = new ilObjGlossary();
         $newObj->setType($new_type);
         $newObj->setTitle($upload["name"]);
         $newObj->create(true);
         $this->putObjectInTree($newObj);
         // create import directory
         $newObj->createImportDirectory();
         // copy uploaded file to import directory
         $file = pathinfo($upload["name"]);
         $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
         ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path);
         // unzip file
         ilUtil::unzip($full_path);
         // determine filename of xml file
         $subdir = basename($file["basename"], "." . $file["extension"]);
         $xml_file = $newObj->getImportDirectory() . "/" . $subdir . "/" . $subdir . ".xml";
         // check whether this is a new export file.
         // this is the case if manifest.xml exits
         //echo "1-".$newObj->getImportDirectory()."/".$subdir."/manifest.xml"."-";
         if (is_file($newObj->getImportDirectory() . "/" . $subdir . "/manifest.xml")) {
             include_once "./Services/Export/classes/class.ilImport.php";
             $imp = new ilImport((int) $_GET["ref_id"]);
             $map = $imp->getMapping();
             $map->addMapping("Modules/Glossary", "glo", "new_id", $newObj->getId());
             $imp->importObject($newObj, $full_path, $upload["name"], "glo", "Modules/Glossary", true);
             ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
             ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
         }
         // check whether subdirectory exists within zip file
         if (!is_dir($newObj->getImportDirectory() . "/" . $subdir)) {
             $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir), $this->ilias->error_obj->MESSAGE);
         }
         // check whether xml file exists within zip file
         if (!is_file($xml_file)) {
             $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml"), $this->ilias->error_obj->MESSAGE);
         }
         include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
         $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
         $contParser->startParsing();
         ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
         // delete import directory
         ilUtil::delDir($newObj->getImportDirectory());
         ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
         ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
     }
     // display form to correct errors
     $form->setValuesByPost();
     $tpl->setContent($form->getHtml());
 }
 /**
  * Get all glossary ids
  *
  * @param
  * @return
  */
 function getAllGlossaryIds($a_include_offline_childs = false)
 {
     global $tree;
     if ($this->isVirtual()) {
         $glo_ids = array();
         $virtual_mode = $this->getRefId() ? $this->getVirtualMode() : '';
         switch ($virtual_mode) {
             case "level":
                 $glo_arr = $tree->getChildsByType($tree->getParentId($this->getRefId()), "glo");
                 $glo_ids[] = $this->getId();
                 foreach ($glo_arr as $glo) {
                     $glo_ids[] = $glo['obj_id'];
                 }
                 if (!$a_include_offline_childs) {
                     $glo_ids = ilObjGlossary::removeOfflineGlossaries($glo_ids);
                 }
                 break;
             case "subtree":
                 $subtree_nodes = $tree->getSubTree($tree->getNodeData($tree->getParentId($this->getRefId())));
                 foreach ($subtree_nodes as $node) {
                     if ($node['type'] == 'glo') {
                         $glo_ids[] = $node['obj_id'];
                     }
                 }
                 if (!$a_include_offline_childs) {
                     $glo_ids = ilObjGlossary::removeOfflineGlossaries($glo_ids);
                 }
                 break;
                 // fallback to none virtual mode in case of error
             // fallback to none virtual mode in case of error
             default:
                 $glo_ids[] = $this->getId();
                 break;
         }
     } else {
         $glo_ids = $this->getId();
     }
     return $glo_ids;
 }
 function importGlossary($slm, $packageFolder)
 {
     global $ilias;
     // create and insert object in objecttree
     include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
     $newObj = new ilObjGlossary();
     $newObj->setType('glo');
     $newObj->setTitle('');
     $newObj->create(true);
     $newObj->createReference();
     $newObj->putInTree($_GET["ref_id"]);
     $newObj->setPermissions($_GET["ref_id"]);
     $newObj->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"], $_GET["ref_id"], $newObj->getRefId());
     $xml_file = $packageFolder . "/glossary.xml";
     // check whether xml file exists within zip file
     if (!is_file($xml_file)) {
         return;
     }
     include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
     $contParser = new ilContObjParser($newObj, $xml_file, $packageFolder);
     $contParser->startParsing();
     $newObj->update();
     //ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
     $slm->setAssignedGlossary($newObj->getId());
     $slm->update();
 }