/**
  * Get head dependencies
  *
  * @param		string		entity
  * @param		string		target release
  * @param		array		ids
  * @return		array		array of array with keys "component", entity", "ids"
  */
 function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
 {
     if ($a_entity == "pg") {
         // get all media objects and files of the page
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $mob_ids = array();
         $file_ids = array();
         foreach ($a_ids as $pg_id) {
             $pg_id = explode(":", $pg_id);
             // get media objects
             $mids = ilObjMediaObject::_getMobsOfObject($pg_id[0] . ":pg", $pg_id[1]);
             foreach ($mids as $mid) {
                 if (ilObject::_lookupType($mid) == "mob") {
                     $mob_ids[] = $mid;
                 }
             }
             // get files
             $files = ilObjFile::_getFilesOfObject($pg_id[0] . ":pg", $pg_id[1]);
             foreach ($files as $file) {
                 if (ilObject::_lookupType($file) == "file") {
                     $file_ids[] = $file;
                 }
             }
         }
         return array(array("component" => "Services/MediaObjects", "entity" => "mob", "ids" => $mob_ids), array("component" => "Modules/File", "entity" => "file", "ids" => $file_ids));
     }
     return array();
 }
 /**
  * Creates an XML material tag from a plain text or xhtml text
  *
  * @param object $a_xml_writer Reference to the ILIAS XML writer
  * @param string $a_material plain text or html text containing the material
  * @return string XML material tag
  * @access public
  */
 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $a_xml_writer->xmlStartTag("material", $attribs);
     $attrs = array("type" => "text/plain");
     if ($this->isHTML($a_material)) {
         $attrs["type"] = "text/xhtml";
     }
     $mattext = ilRTE::_replaceMediaObjectImageSrc($a_material, 0);
     $a_xml_writer->xmlElement("mattext", $attrs, $mattext);
     if ($add_mobs) {
         $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
         foreach ($mobs as $mob) {
             $mob_id = "il_" . IL_INST_ID . "_mob_" . $mob;
             if (strpos($mattext, $mob_id) !== FALSE) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $imgattrs = array("label" => $mob_id, "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle());
                 $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
             }
         }
     }
     if ($close_material_tag) {
         $a_xml_writer->xmlEndTag("material");
     }
 }
Beispiel #3
0
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion()) . '<br/>' . $this->getClozeText();
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array("onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false), "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true));
     $gaps = array();
     foreach ($this->getGaps() as $key => $gap) {
         $items = array();
         foreach ($gap->getItems() as $item) {
             $jitem = array();
             $jitem['points'] = $item->getPoints();
             $jitem['value'] = $item->getAnswertext();
             $jitem['order'] = $item->getOrder();
             if ($gap->getType() == CLOZE_NUMERIC) {
                 $jitem['lowerbound'] = $item->getLowerBound();
                 $jitem['upperbound'] = $item->getUpperBound();
             } else {
                 $jitem['value'] = trim($jitem['value']);
             }
             array_push($items, $jitem);
         }
         if ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_NUMERIC) {
             $jgap['size'] = $gap->getGapSize();
         }
         $jgap['shuffle'] = $gap->getShuffle();
         $jgap['type'] = $gap->getType();
         $jgap['item'] = $items;
         array_push($gaps, $jgap);
     }
     $result['gaps'] = $gaps;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['text'] = (string) ilRTE::_replaceMediaObjectImageSrc($this->getErrorText(), 0);
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array('onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)), 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)));
     $answers = array();
     foreach ($this->getErrorData() as $idx => $answer_obj) {
         array_push($answers, array("answertext_wrong" => (string) $answer_obj->text_wrong, "answertext_correct" => (string) $answer_obj->text_correct, "points" => (double) $answer_obj->points, "order" => (int) $idx + 1));
     }
     $result['correct_answers'] = $answers;
     $answers = array();
     $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
     foreach ($textarray as $textidx => $text) {
         $items = preg_split("/\\s+/", trim($text));
         foreach ($items as $idx => $item) {
             if (substr($item, 0, 1) == "#") {
                 $item = substr($item, 1);
                 // #14115 - add position to correct answer
                 foreach ($result["correct_answers"] as $aidx => $answer) {
                     if ($answer["answertext_wrong"] == $item && !$answer["pos"]) {
                         $result["correct_answers"][$aidx]["pos"] = $this->getId() . "_" . $textidx . "_" . ($idx + 1);
                         break;
                     }
                 }
             }
             array_push($answers, array("answertext" => (string) ilUtil::prepareFormOutput($item), "order" => $this->getId() . "_" . $textidx . "_" . ($idx + 1)));
         }
         if ($textidx != sizeof($textarray) - 1) {
             array_push($answers, array("answertext" => "###", "order" => $this->getId() . "_" . $textidx . "_" . ($idx + 2)));
         }
     }
     $result['answers'] = $answers;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
Beispiel #5
0
 function exportXHTMLMediaObjects($a_export_dir)
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->test_obj->getId());
     foreach ($mobs as $mob) {
         if (ilObjMediaObject::_exists($mob)) {
             $mob_obj =& new ilObjMediaObject($mob);
             $mob_obj->exportFiles($a_export_dir);
             unset($mob_obj);
         }
     }
     foreach ($this->test_obj->questions as $question_id) {
         $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
         foreach ($mobs as $mob) {
             if (ilObjMediaObject::_exists($mob)) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $mob_obj->exportFiles($a_export_dir);
                 unset($mob_obj);
             }
         }
     }
 }
Beispiel #6
0
 function getLastUpdateOfIncludedElements()
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $mobs = ilObjMediaObject::_getMobsOfObject($this->getParentType() . ":pg", $this->getId());
     $files = ilObjFile::_getFilesOfObject($this->getParentType() . ":pg", $this->getId());
     $objs = array_merge($mobs, $files);
     return ilObject::_getLastUpdateOfObjects($objs);
 }
 /**
  * Collect page elements (that need to be exported separately)
  *
  * @param string $a_pg_type page type
  * @param int $a_pg_id page id
  */
 function collectPageElements($a_type, $a_id)
 {
     // collect media objects
     $pg_mobs = ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
     foreach ($pg_mobs as $pg_mob) {
         $this->mobs[$pg_mob] = $pg_mob;
     }
     // collect all files
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $files = ilObjFile::_getFilesOfObject($a_type, $a_id);
     foreach ($files as $f) {
         $this->files[$f] = $f;
     }
     $skill_tree = $ws_tree = null;
     $pcs = ilPageContentUsage::getUsagesOfPage($a_id, $a_type);
     foreach ($pcs as $pc) {
         // skils
         if ($pc["type"] == "skmg") {
             $skill_id = $pc["id"];
             // get user id from portfolio page
             include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
             $page = new ilPortfolioPage(0, $a_id);
             $user_id = $page->create_user;
             // we only need 1 instance each
             if (!$skill_tree) {
                 include_once "Services/Skill/classes/class.ilSkillTree.php";
                 $skill_tree = new ilSkillTree();
                 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
                 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
                 $ws_tree = new ilWorkspaceTree($user_id);
             }
             // walk skill tree
             $b_skills = ilSkillTreeNode::getSkillTreeNodes($skill_id, true);
             foreach ($b_skills as $bs) {
                 $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
                 $level_data = $skill->getLevelData();
                 foreach ($level_data as $k => $v) {
                     // get assigned materials from personal skill
                     $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref"], $v["id"]);
                     if (sizeof($mat)) {
                         foreach ($mat as $item) {
                             $wsp_id = $item["wsp_id"];
                             $obj_id = $ws_tree->lookupObjectId($wsp_id);
                             // all possible material types for now
                             switch (ilObject::_lookupType($obj_id)) {
                                 case "file":
                                     $this->files[$obj_id] = $obj_id;
                                     break;
                                 case "tstv":
                                     include_once "Modules/Test/classes/class.ilObjTestVerification.php";
                                     $obj = new ilObjTestVerification($obj_id, false);
                                     $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                     break;
                                 case "excv":
                                     include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
                                     $obj = new ilObjExerciseVerification($obj_id, false);
                                     $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                     break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 function exportXHTMLMediaObjects($a_export_dir)
 {
     global $ilBench;
     $ilBench->start("SurveyExport", "exportXHTMLMediaObjects");
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
     foreach ($mobs as $mob) {
         $mob_obj =& new ilObjMediaObject($mob);
         $mob_obj->exportFiles($a_export_dir);
         unset($mob_obj);
     }
     // #14850
     foreach ($this->survey_obj->questions as $question_id) {
         $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
         foreach ($mobs as $mob) {
             $mob_obj =& new ilObjMediaObject($mob);
             $mob_obj->exportFiles($a_export_dir);
             unset($mob_obj);
         }
     }
     $ilBench->stop("SurveyExport", "exportXHTMLMediaObjects");
 }
Beispiel #9
0
 public function viewThreadObject()
 {
     /**
      * @var $tpl ilTemplate
      * @var $lng ilLanguage
      * @var $ilUser ilObjUser
      * @var $ilAccess ilAccessHandler
      * @var $rbacreview ilRbacReview
      * @var $ilNavigationHistory ilNavigationHistory
      * @var $ilCtrl ilCtrl
      * @var $ilToolbar ilToolbarGUI
      */
     global $tpl, $lng, $ilUser, $ilAccess, $rbacreview, $ilNavigationHistory, $ilCtrl, $frm, $ilToolbar, $ilLocator;
     $tpl->addCss('./Modules/Forum/css/forum_tree.css');
     if (!isset($_SESSION['viewmode'])) {
         $_SESSION['viewmode'] = $this->objProperties->getDefaultView();
     }
     // quick and dirty: check for treeview
     if (!isset($_SESSION['thread_control']['old'])) {
         $_SESSION['thread_control']['old'] = $_GET['thr_pk'];
         $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
     } else {
         if (isset($_SESSION['thread_control']['old']) && $_GET['thr_pk'] != $_SESSION['thread_control']['old']) {
             $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
         }
     }
     if (isset($_GET['viewmode']) && $_GET['viewmode'] != $_SESSION['viewmode']) {
         $_SESSION['viewmode'] = $_GET['viewmode'];
     }
     if (isset($_GET['action']) && $_SESSION['viewmode'] != ilForumProperties::VIEW_DATE || $_SESSION['viewmode'] == ilForumProperties::VIEW_TREE) {
         $_SESSION['viewmode'] = ilForumProperties::VIEW_TREE;
     } else {
         $_SESSION['viewmode'] = ilForumProperties::VIEW_DATE;
     }
     if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
     }
     // init objects
     $oForumObjects = $this->getForumObjects();
     /**
      * @var $forumObj ilObjForum
      */
     $forumObj = $oForumObjects['forumObj'];
     /**
      * @var $frm ilForum
      */
     $frm = $oForumObjects['frm'];
     /**
      * @var $file_obj ilFileDataForum
      */
     $file_obj = $oForumObjects['file_obj'];
     // download file
     if ($_GET['file']) {
         if (!($path = $file_obj->getFileDataByMD5Filename($_GET['file']))) {
             ilUtil::sendFailure($this->lng->txt('error_reading_file'));
         } else {
             ilUtil::deliverFile($path['path'], $path['clean_filename']);
         }
     }
     if (!$this->objCurrentTopic->getId()) {
         $ilCtrl->redirect($this, 'showThreads');
     }
     // Set context for login
     $append = '_' . $this->objCurrentTopic->getId() . ($this->objCurrentPost->getId() ? '_' . $this->objCurrentPost->getId() : '');
     $tpl->setLoginTargetPar('frm_' . $_GET['ref_id'] . $append);
     // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
     if ($_GET['action'] != 'showreply' && $_GET['action'] != 'showedit') {
         try {
             include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
             $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
             foreach ($mobs as $mob) {
                 if (ilObjMediaObject::_exists($mob)) {
                     ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
                     $mob_obj = new ilObjMediaObject($mob);
                     $mob_obj->delete();
                 }
             }
         } catch (Exception $e) {
         }
     }
     require_once './Modules/Forum/classes/class.ilObjForum.php';
     require_once './Modules/Forum/classes/class.ilFileDataForum.php';
     $lng->loadLanguageModule('forum');
     // add entry to navigation history
     if (!$this->getCreationMode() && $ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $ilCtrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
         $ilNavigationHistory->addItem($this->object->getRefId(), $ilCtrl->getLinkTarget($this, 'showThreads'), 'frm');
     }
     // save last access
     $forumObj->updateLastAccess($ilUser->getId(), (int) $this->objCurrentTopic->getId());
     $this->prepareThreadScreen($forumObj);
     $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_view.html', 'Modules/Forum');
     if (isset($_GET['anchor'])) {
         $tpl->setVariable('JUMP2ANCHOR_ID', (int) $_GET['anchor']);
     }
     if ($_SESSION['viewmode'] == 'date' || $_SESSION['viewmode'] == ilForumProperties::VIEW_DATE) {
         $orderField = 'frm_posts_tree.fpt_date';
         $this->objCurrentTopic->setOrderDirection(in_array($this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_TREE)) ? 'ASC' : 'DESC');
     } else {
         $orderField = 'frm_posts_tree.rgt';
         $this->objCurrentTopic->setOrderDirection('DESC');
     }
     // get forum- and thread-data
     $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
     if (is_array($topicData = $frm->getOneTopic())) {
         // Visit-Counter for topic
         $this->objCurrentTopic->updateVisits();
         $tpl->setTitle($lng->txt('forums_thread') . " \"" . $this->objCurrentTopic->getSubject() . "\"");
         // ********************************************************************************
         // build location-links
         $ilLocator->addRepositoryItems();
         $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this, ""), "_top");
         $tpl->setLocator();
         // set tabs
         // menu template (contains linkbar)
         /** @var $menutpl ilTemplate */
         $menutpl = new ilTemplate('tpl.forums_threads_menu.html', true, true, 'Modules/Forum');
         include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
         // mark all as read
         if ($ilUser->getId() != ANONYMOUS_USER_ID && $forumObj->getCountUnread($ilUser->getId(), (int) $this->objCurrentTopic->getId())) {
             $this->ctrl->setParameter($this, 'mark_read', '1');
             $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
             $ilToolbar->addButton($this->lng->txt('forums_mark_read'), $this->ctrl->getLinkTarget($this, 'viewThread'), '', ilAccessKey::MARK_ALL_READ);
             $this->ctrl->clearParameters($this);
         }
         // print thread
         $this->ctrl->setParameterByClass('ilforumexportgui', 'print_thread', $this->objCurrentTopic->getId());
         $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_top_fk', $this->objCurrentTopic->getForumId());
         $ilToolbar->addButton($this->lng->txt('forums_print_thread'), $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printThread'));
         $this->ctrl->clearParametersByClass('ilforumexportgui');
         $this->addHeaderAction();
         if ($_GET['mark_read']) {
             $forumObj->markThreadRead($ilUser->getId(), (int) $this->objCurrentTopic->getId());
             ilUtil::sendInfo($lng->txt('forums_thread_marked'), true);
         }
         // delete post and its sub-posts
         require_once './Modules/Forum/classes/class.ilForum.php';
         if ($_GET['action'] == 'ready_delete' && $_POST['confirm'] != '') {
             if (!$this->objCurrentTopic->isClosed() && ($this->is_moderator || $this->objCurrentPost->isOwner($ilUser->getId()) && !$this->objCurrentPost->hasReplies()) && $ilUser->getId() != ANONYMOUS_USER_ID) {
                 $frm = new ilForum();
                 $frm->setForumId($forumObj->getId());
                 $frm->setForumRefId($forumObj->getRefId());
                 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
                 // if complete thread was deleted ...
                 if ($dead_thr == $this->objCurrentTopic->getId()) {
                     $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($forumObj->getId()));
                     $topicData = $frm->getOneTopic();
                     ilUtil::sendInfo($lng->txt('forums_post_deleted'), true);
                     if ($topicData['top_num_threads'] > 0) {
                         $this->ctrl->redirect($this, 'showThreads');
                     } else {
                         $this->ctrl->redirect($this, 'createThread');
                     }
                 }
                 ilUtil::sendInfo($lng->txt('forums_post_deleted'));
             }
         }
         // form processing (censor)
         if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'ready_censor') {
             if (($_POST['confirm'] != '' || $_POST['no_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
                 $frm->postCensorship($this->handleFormInput($_POST['formData']['cens_message']), $this->objCurrentPost->getId(), 1);
             } else {
                 if (($_POST['cancel'] != '' || $_POST['yes_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
                     $frm->postCensorship($this->handleFormInput($_POST['formData']['cens_message']), $this->objCurrentPost->getId());
                 }
             }
         }
         // get complete tree of thread
         $first_node = $this->objCurrentTopic->getFirstPostNode();
         $this->objCurrentTopic->setOrderField($orderField);
         $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node);
         // no posts
         if (!($posNum = count($subtree_nodes))) {
             ilUtil::sendInfo($this->lng->txt('forums_no_posts_available'));
         }
         $pageHits = $frm->getPageHits();
         $z = 0;
         // navigation to browse
         if ($posNum > $pageHits) {
             $params = array('ref_id' => $_GET['ref_id'], 'thr_pk' => $this->objCurrentTopic->getId(), 'orderby' => $_GET['orderby']);
             if (!$_GET['offset']) {
                 $Start = 0;
             } else {
                 $Start = $_GET['offset'];
             }
             $linkbar = ilUtil::Linkbar($ilCtrl->getLinkTarget($this, 'viewThread'), $posNum, $pageHits, $Start, $params);
             if ($linkbar != '') {
                 $menutpl->setCurrentBlock('linkbar');
                 $menutpl->setVariable('LINKBAR', $linkbar);
                 $menutpl->parseCurrentBlock();
             }
         }
         $tpl->setVariable('THREAD_MENU', $menutpl->get());
         // assistance val for anchor-links
         $jump = 0;
         // generate post-dates
         foreach ($subtree_nodes as $node) {
             /**
              * @var $node ilForumPost 
              */
             $this->ctrl->clearParameters($this);
             if ($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId()) {
                 $jump++;
             }
             if ($posNum > $pageHits && $z >= $Start + $pageHits) {
                 // if anchor-link was not found ...
                 if ($this->objCurrentPost->getId() && $jump < 1) {
                     $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
                     $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
                     $this->ctrl->setParameter($this, 'offset', $Start + $pageHits);
                     $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                     $this->ctrl->redirect($this, 'viewThread', $this->objCurrentPost->getId());
                     exit;
                 } else {
                     break;
                 }
             }
             if ($posNum > $pageHits && $z >= $Start || $posNum <= $pageHits) {
                 if ($this->objCurrentPost->getId() == $node->getId()) {
                     # actions for "active" post
                     if ($this->is_moderator || $node->isActivated()) {
                         // reply/edit
                         if (!$this->objCurrentTopic->isClosed() && ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit')) {
                             if ($_GET['action'] == 'showedit' && (!$this->is_moderator && !$node->isOwner($ilUser->getId()) || $ilUser->getId() == ANONYMOUS_USER_ID || $node->isCensored())) {
                                 $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
                             } else {
                                 if ($_GET['action'] == 'showreply' && !$ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
                                     $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
                                 }
                             }
                             $tpl->setVariable('REPLY_ANKER', $this->objCurrentPost->getId());
                             $oEditReplyForm = $this->getReplyEditForm();
                             switch ($this->objProperties->getSubjectSetting()) {
                                 case 'add_re_to_subject':
                                     $subject = $this->getModifiedReOnSubject(true);
                                     break;
                                 case 'preset_subject':
                                     $subject = $this->objCurrentPost->getSubject();
                                     break;
                                 case 'empty_subject':
                                 default:
                                     $subject = NULL;
                                     break;
                             }
                             switch ($_GET['action']) {
                                 case 'showreply':
                                     if ($this->ctrl->getCmd() == 'savePost') {
                                         $oEditReplyForm->setValuesByPost();
                                     } else {
                                         if ($this->ctrl->getCmd() == 'quotePost') {
                                             require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
                                             $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getDisplayUserId(), $node->getUserAlias(), $node->getImportName());
                                             $oEditReplyForm->setValuesByPost();
                                             $oEditReplyForm->getItemByPostVar('message')->setValue(ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName()) . "\n" . $oEditReplyForm->getInput('message'), 1));
                                         } else {
                                             $oEditReplyForm->setValuesByArray(array('alias' => '', 'subject' => $subject, 'message' => '', 'notify' => 0, 'userfile' => '', 'del_file' => array()));
                                         }
                                     }
                                     $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
                                     $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
                                     $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum/');
                                     $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC', $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
                                     $this->ctrl->clearParameters($this);
                                     $this->tpl->setVariable('FORM_ADDITIONAL_JS', $jsTpl->get());
                                     break;
                                 case 'showedit':
                                     if ($this->ctrl->getCmd() == 'savePost') {
                                         $oEditReplyForm->setValuesByPost();
                                     } else {
                                         $oEditReplyForm->setValuesByArray(array('alias' => '', 'subject' => $this->objCurrentPost->getSubject(), 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 2), 1), 'notify' => $this->objCurrentPost->isNotificationEnabled() ? true : false, 'userfile' => '', 'del_file' => array()));
                                     }
                                     break;
                             }
                             $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'action', $_GET['action']);
                             $tpl->setVariable('FORM', $oEditReplyForm->getHTML());
                             $this->ctrl->clearParameters($this);
                         } else {
                             if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'delete') {
                                 if ($this->is_moderator || $node->isOwner($ilUser->getId()) && !$node->hasReplies() && $ilUser->getId() != ANONYMOUS_USER_ID) {
                                     // confirmation: delete
                                     $tpl->setVariable('FORM', $this->getDeleteFormHTML());
                                 }
                             } else {
                                 if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'censor') {
                                     if ($this->is_moderator) {
                                         // confirmation: censor / remove censorship
                                         $tpl->setVariable('FORM', $this->getCensorshipFormHTML());
                                     }
                                 } else {
                                     if (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation()) {
                                         if ($this->is_moderator) {
                                             // confirmation: activate
                                             $tpl->setVariable('FORM', $this->getActivationFormHTML());
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // if ($this->objCurrentPost->getId() == $node->getId())
                 if ($this->objCurrentPost->getId() != $node->getId() || $_GET['action'] != 'showreply' && $_GET['action'] != 'showedit' && $_GET['action'] != 'censor' && $_GET['action'] != 'delete' && !$this->displayConfirmPostActivation()) {
                     if ($this->is_moderator || $node->isActivated()) {
                         // button: reply
                         if (!$this->objCurrentTopic->isClosed() && $ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id']) && !$node->isCensored()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'showreply');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('reply'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: edit article
                         if (!$this->objCurrentTopic->isClosed() && ($node->isOwner($ilUser->getId()) || $this->is_moderator) && !$node->isCensored() && $ilUser->getId() != ANONYMOUS_USER_ID) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'showedit');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('edit'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: print
                         if (!$node->isCensored()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameterByClass('ilforumexportgui', 'print_post', $node->getId());
                             $this->ctrl->setParameterByClass('ilforumexportgui', 'top_pk', $node->getForumId());
                             $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_pk', $node->getThreadId());
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printPost'));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('print'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         # buttons for every post except the "active"
                         if (!$this->objCurrentTopic->isClosed() && ($this->is_moderator || $node->isOwner($ilUser->getId()) && !$node->hasReplies()) && $ilUser->getId() != ANONYMOUS_USER_ID) {
                             // button: delete
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'delete');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('delete'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         if (!$this->objCurrentTopic->isClosed() && $this->is_moderator) {
                             // button: censor
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'action', 'censor');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('censorship'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                             // button: activation/deactivation
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             if (!$node->isActivated()) {
                                 $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'askForPostActivation', $node->getId()));
                                 $tpl->setVariable('COMMANDS_TXT', $lng->txt('activate_post'));
                             }
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: mark read
                         if ($ilUser->getId() != ANONYMOUS_USER_ID && !$node->isPostRead()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('is_read'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         // button: mark unread
                         if ($ilUser->getId() != ANONYMOUS_USER_ID && $node->isPostRead()) {
                             $tpl->setCurrentBlock('commands');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                             $this->ctrl->setParameter($this, 'offset', $Start);
                             $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                             $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
                             $tpl->setVariable('COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this, 'markPostUnread', $node->getId()));
                             $tpl->setVariable('COMMANDS_TXT', $lng->txt('unread'));
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                     }
                 }
                 // if ($this->objCurrentPost->getId() != $node->getId())
                 // download post attachments
                 $tmp_file_obj = new ilFileDataForum($forumObj->getId(), $node->getId());
                 if (count($tmp_file_obj->getFilesOfPost())) {
                     if ($node->getId() != $this->objCurrentPost->getId() || $_GET['action'] != 'showedit') {
                         foreach ($tmp_file_obj->getFilesOfPost() as $file) {
                             $tpl->setCurrentBlock('attachment_download_row');
                             $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                             $this->ctrl->setParameter($this, 'file', $file['md5']);
                             $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
                             $tpl->setVariable('TXT_FILENAME', $file['name']);
                             $this->ctrl->clearParameters($this);
                             $tpl->parseCurrentBlock();
                         }
                         $tpl->setCurrentBlock('attachments');
                         $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $lng->txt('forums_attachments'));
                         include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
                         $tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $lng->txt('forums_download_attachment')));
                         $tpl->parseCurrentBlock();
                     }
                 }
                 $tpl->setCurrentBlock('posts_row');
                 // anker for every post
                 $tpl->setVariable('POST_ANKER', $node->getId());
                 //permanent link for every post
                 //	$tpl->setVariable('PERMA_LINK', ILIAS_HTTP_PATH."/goto.php?target="."frm"."_".$this->object->getRefId()."_".$node->getThreadId()."_".$node->getId()."&client_id=".CLIENT_ID);
                 $tpl->setVariable('TXT_PERMA_LINK', $lng->txt('perma_link'));
                 $tpl->setVariable('PERMA_TARGET', '_top');
                 if ($this->objProperties->getMarkModeratorPosts() == 1) {
                     if ($node->getIsAuthorModerator() === null && ($is_moderator = ilForum::_isModerator($_GET['ref_id'], $node->getPosAuthorId()))) {
                         $rowCol = 'ilModeratorPosting';
                     } elseif ($node->getIsAuthorModerator()) {
                         $rowCol = 'ilModeratorPosting';
                     } else {
                         $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
                     }
                 } else {
                     $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
                 }
                 if ($_GET['action'] != 'delete' && $_GET['action'] != 'censor' && !$this->displayConfirmPostActivation() || $this->objCurrentPost->getId() != $node->getId()) {
                     $tpl->setVariable('ROWCOL', ' ' . $rowCol);
                 } else {
                     // highlight censored posts
                     $rowCol = 'tblrowmarked';
                 }
                 // post is censored
                 if ($node->isCensored()) {
                     // display censorship advice
                     if ($_GET['action'] != 'censor') {
                         $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
                     }
                     // highlight censored posts
                     $rowCol = 'tblrowmarked';
                 }
                 // set row color
                 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
                 // if post is not activated display message for the owner
                 if (!$node->isActivated() && $node->isOwner($ilUser->getId())) {
                     $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
                 }
                 // Author
                 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                 $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
                 $this->ctrl->clearParameters($this);
                 $this->ctrl->setParameter($this, 'backurl', $backurl);
                 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                 $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
                 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
                 $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getDisplayUserId(), $node->getUserAlias(), $node->getImportName(), array('href' => $this->ctrl->getLinkTarget($this, 'showUser')));
                 $this->ctrl->clearParameters($this);
                 if ($authorinfo->hasSuffix()) {
                     $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
                     $tpl->setVariable('USR_NAME', $node->getUserAlias());
                 } else {
                     $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
                     if ($authorinfo->getAuthorName(true)) {
                         $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
                     }
                 }
                 $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
                 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $node->getPosAuthorId())) {
                     if ($authorinfo->getAuthor()->getGender() == 'f') {
                         $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
                     } else {
                         if ($authorinfo->getAuthor()->getGender() == 'm') {
                             $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
                         }
                     }
                 }
                 // get create- and update-dates
                 if ($node->getUpdateUserId() > 0) {
                     $spanClass = '';
                     // last update from moderator?
                     $posMod = $frm->getModeratorFromPost($node->getId());
                     if (is_array($posMod) && $posMod['top_mods'] > 0) {
                         $MODS = $rbacreview->assignedUsers($posMod['top_mods']);
                         if (is_array($MODS)) {
                             if (in_array($node->getUpdateUserId(), $MODS)) {
                                 $spanClass = 'moderator_small';
                             }
                         }
                     }
                     $node->setChangeDate($node->getChangeDate());
                     if ($spanClass == '') {
                         $spanClass = 'small';
                     }
                     $this->ctrl->setParameter($this, 'backurl', $backurl);
                     $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                     $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
                     require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
                     $authorinfo = new ilForumAuthorInformation($node->getPosAuthorId(), $node->getUpdateUserId(), '', '', array('href' => $this->ctrl->getLinkTarget($this, 'showUser')));
                     $this->ctrl->clearParameters($this);
                     $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($lng->txt('by')));
                     $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
                     if ($authorinfo->getAuthorName(true)) {
                         $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
                     }
                 }
                 // if ($node->getUpdateUserId() > 0)*/
                 // Author end
                 // prepare post
                 $node->setMessage($frm->prepareText($node->getMessage()));
                 if ($ilUser->getId() == ANONYMOUS_USER_ID || $node->isPostRead()) {
                     $tpl->setVariable('SUBJECT', $node->getSubject());
                 } else {
                     $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
                     $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
                     $this->ctrl->setParameter($this, 'offset', $Start);
                     $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
                     $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
                     $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
                     $tpl->setVariable('SUBJECT', "<a href=\"" . $mark_post_target . "\"><b>" . $node->getSubject() . "</b></a>");
                 }
                 $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
                 if (!$node->isCensored() || $this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor') {
                     // post from moderator?
                     $modAuthor = $frm->getModeratorFromPost($node->getId());
                     $spanClass = "";
                     if (is_array($modAuthor) && $modAuthor['top_mods'] > 0) {
                         unset($MODS);
                         $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']);
                         if (is_array($MODS)) {
                             if (in_array($node->getDisplayUserId(), $MODS)) {
                                 $spanClass = 'moderator';
                             }
                         }
                     }
                     // possible bugfix for mantis #8223
                     if ($node->getMessage() == strip_tags($node->getMessage())) {
                         // We can be sure, that there are not html tags
                         $node->setMessage(nl2br($node->getMessage()));
                     }
                     if ($spanClass != "") {
                         $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1) . "</span>");
                     } else {
                         $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1));
                     }
                 } else {
                     $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($node->getCensorshipComment()) . "</span>");
                 }
                 $tpl->parseCurrentBlock();
             }
             $z++;
         }
     } else {
         $tpl->setCurrentBlock('posts_no');
         $tpl->setVariable('TXT_MSG_NO_POSTS_AVAILABLE', $lng->txt('forums_posts_not_available'));
         $tpl->parseCurrentBlock();
     }
     $oThreadToolbar = clone $ilToolbar;
     $oThreadToolbar->addSeparator();
     $oThreadToolbar->addButton($this->lng->txt('top_of_page'), '#frm_page_top');
     $tpl->setVariable('THREAD_TOOLBAR', $oThreadToolbar->getHTML());
     $tpl->setVariable('TPLPATH', $tpl->vars['TPLPATH']);
     // permanent link
     include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
     $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId(), '_' . $this->objCurrentTopic->getId());
     $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
     // Render tree
     if ($_SESSION['viewmode'] == 'answers' || $_SESSION['viewmode'] == ilForumProperties::VIEW_TREE) {
         $tpl->setLeftNavContent($this->getForumExplorer());
     }
     return true;
 }
 /**
  * export glossary terms
  */
 function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir)
 {
     global $ilUser;
     include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
     $copage_export = new ilCOPageHTMLExport($a_target_dir);
     $copage_export->exportSupportScripts();
     // index.html file
     $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
     $style_name = $ilUser->prefs["style"] . ".css";
     $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name);
     $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
     $a_glo_gui->tpl->setTitle($this->getTitle());
     $content = $a_glo_gui->listTerms();
     $file = $a_target_dir . "/index.html";
     // open file
     if (!($fp = @fopen($file, "w+"))) {
         die("<b>Error</b>: Could not open \"" . $file . "\" for writing" . " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
     }
     chmod($file, 0770);
     fwrite($fp, $content);
     fclose($fp);
     $terms = $this->getTermList();
     $this->offline_mobs = array();
     $this->offline_files = array();
     foreach ($terms as $term) {
         $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true);
         $a_glo_gui->tpl = $copage_export->getPreparedMainTemplate();
         //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
         // set style
         $style_name = $ilUser->prefs["style"] . ".css";
         $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name);
         $_GET["term_id"] = $term["id"];
         $_GET["frame"] = "_blank";
         $content =& $a_glo_gui->listDefinitions($_GET["ref_id"], $term["id"], false);
         $file = $a_target_dir . "/term_" . $term["id"] . ".html";
         // open file
         if (!($fp = @fopen($file, "w+"))) {
             die("<b>Error</b>: Could not open \"" . $file . "\" for writing" . " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
         }
         chmod($file, 0770);
         fwrite($fp, $content);
         fclose($fp);
         // store linked/embedded media objects of glosssary term
         include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
         $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
         foreach ($defs as $def) {
             $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
             foreach ($def_mobs as $def_mob) {
                 $this->offline_mobs[$def_mob] = $def_mob;
             }
             // get all files of page
             include_once "./Modules/File/classes/class.ilObjFile.php";
             $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]);
             $this->offline_files = array_merge($this->offline_files, $def_files);
         }
     }
 }
 /**
  * Returns a JSON representation of the question
  * TODO
  */
 public function toJSON()
 {
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['matching_mode'] = $this->getMatchingMode();
     $result['shuffle'] = true;
     $result['feedback'] = array("onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false), "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true));
     $terms = array();
     foreach ($this->getTerms() as $term) {
         $terms[] = array("text" => $term->text, "id" => (int) $term->identifier);
     }
     $result['terms'] = $terms;
     // alex 9.9.2010 as a fix for bug 6513 I added the question id
     // to the "def_id" in the array. The $pair->definition->identifier is not
     // unique, since it gets it value from the morder table field
     // this value is not changed, when a question is copied.
     // thus copying the same question on a page results in problems
     // when the second one (the copy) is answered.
     $definitions = array();
     foreach ($this->getDefinitions() as $def) {
         $definitions[] = array("text" => (string) $def->text, "id" => (int) $this->getId() . $def->identifier);
     }
     $result['definitions'] = $definitions;
     // #10353
     $matchings = array();
     foreach ($this->getMatchingPairs() as $pair) {
         $pid = $pair->definition->identifier;
         if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
             $pid .= '::' . $pair->term->identifier;
         }
         if (!isset($matchings[$pid]) || $matchings[$pid]["points"] < $pair->points) {
             $matchings[$pid] = array("term_id" => (int) $pair->term->identifier, "def_id" => (int) $this->getId() . $pair->definition->identifier, "points" => (int) $pair->points);
         }
     }
     $result['matchingPairs'] = array_values($matchings);
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     global $lng;
     $lng->loadLanguageModule('assessment');
     $result['reset_button_label'] = $lng->txt("reset_terms");
     return json_encode($result);
 }
    function start()
    {
        global $ilDB;
        ilUtil::makeDir($this->target_dir_absolute . "/objects");
        $query_frm = 'SELECT * FROM frm_settings fs ' . 'JOIN object_data od ON fs.obj_id = od.obj_id ' . 'JOIN frm_data ON top_frm_fk  = od.obj_id ' . 'WHERE fs.obj_id = ' . $ilDB->quote($this->forum_id, 'integer');
        $res = $ilDB->query($query_frm);
        while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
            break;
        }
        $this->xmlStartTag("Forum", null);
        $this->xmlElement("Id", null, (int) $row->top_pk);
        $this->xmlElement("ObjId", null, (int) $row->obj_id);
        $this->xmlElement("Title", null, $row->title);
        $this->xmlElement("Description", null, $row->description);
        $this->xmlElement("DefaultView", null, (int) $row->default_view);
        $this->xmlElement("Pseudonyms", null, (int) $row->anonymized);
        $this->xmlElement("Statistics", null, (int) $row->statistics_enabled);
        $this->xmlElement("PostingActivation", null, (int) $row->post_activation);
        $this->xmlElement("PresetSubject", null, (int) $row->preset_subject);
        $this->xmlElement("PresetRe", null, (int) $row->add_re_subject);
        $this->xmlElement("NotificationType", null, $row->notification_type);
        $this->xmlElement("ForceNotification", null, (int) $row->admin_force_noti);
        $this->xmlElement("ToggleNotification", null, (int) $row->user_toggle_noti);
        $this->xmlElement("LastPost", null, $row->top_last_post);
        $this->xmlElement("Moderator", null, (int) $row->top_mods);
        $this->xmlElement("CreateDate", null, $row->top_date);
        $this->xmlElement("UpdateDate", null, $row->top_update);
        $this->xmlElement("UpdateUserId", null, $row->update_user);
        $this->xmlElement("UserId", null, (int) $row->top_usr_id);
        $query_thr = "SELECT frm_threads.* " . " FROM frm_threads " . " INNER JOIN frm_data ON top_pk = thr_top_fk " . 'WHERE top_frm_fk = ' . $ilDB->quote($this->forum_id, 'integer');
        $res = $ilDB->query($query_thr);
        while ($row = $ilDB->fetchObject($res)) {
            $this->xmlStartTag("Thread");
            $this->xmlElement("Id", null, (int) $row->thr_pk);
            $this->xmlElement("Subject", null, $row->thr_subject);
            $this->xmlElement("UserId", null, (int) $row->thr_usr_id);
            $this->xmlElement("Alias", null, $row->thr_usr_alias);
            $this->xmlElement("LastPost", null, $row->thr_last_post);
            $this->xmlElement("CreateDate", null, $row->thr_date);
            $this->xmlElement("UpdateDate", null, $row->thr_date);
            $this->xmlElement("ImportName", null, $row->import_name);
            $this->xmlElement("Sticky", null, (int) $row->is_sticky);
            $this->xmlElement("Closed", null, (int) $row->is_closed);
            $query = 'SELECT frm_posts.*, frm_posts_tree.*
						FROM frm_posts
							INNER JOIN frm_data
								ON top_pk = pos_top_fk
							INNER JOIN frm_posts_tree
								ON pos_fk = pos_pk
						WHERE pos_thr_fk = ' . $ilDB->quote($row->thr_pk, 'integer') . ' ';
            $query .= " ORDER BY frm_posts_tree.lft ASC";
            $resPosts = $ilDB->query($query);
            $lastDepth = null;
            while ($rowPost = $ilDB->fetchObject($resPosts)) {
                /*
                				// Used for nested postings
                				if( $rowPost->depth < $lastDepth )
                				{
                					for( $i = $rowPost->depth; $i <= $lastDepth; $i++ )
                					{
                						$this->xmlEndTag("Post");
                					}
                				}*/
                $this->xmlStartTag("Post");
                $this->xmlElement("Id", null, (int) $rowPost->pos_pk);
                $this->xmlElement("UserId", null, (int) $rowPost->pos_usr_id);
                $this->xmlElement("Alias", null, $rowPost->pos_usr_alias);
                $this->xmlElement("Subject", null, $rowPost->pos_subject);
                $this->xmlElement("CreateDate", null, $rowPost->pos_date);
                $this->xmlElement("UpdateDate", null, $rowPost->pos_update);
                $this->xmlElement("UpdateUserId", null, (int) $rowPost->update_user);
                $this->xmlElement("Censorship", null, (int) $rowPost->pos_cens);
                $this->xmlElement("CensorshipMessage", null, $rowPost->pos_cens_com);
                $this->xmlElement("Notification", null, $rowPost->notify);
                $this->xmlElement("ImportName", null, $rowPost->import_name);
                $this->xmlElement("Status", null, (int) $rowPost->pos_status);
                $this->xmlElement("Message", null, ilRTE::_replaceMediaObjectImageSrc($rowPost->pos_message, 0));
                $media_exists = false;
                $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $rowPost->pos_pk);
                foreach ($mobs as $mob) {
                    $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
                    if (ilObjMediaObject::_exists($mob)) {
                        if (!$media_exists) {
                            $this->xmlStartTag("MessageMediaObjects");
                            $media_exists = true;
                        }
                        $mob_obj = new ilObjMediaObject($mob);
                        $imgattrs = array("label" => $moblabel, "uri" => $this->target_dir_relative . "/objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle());
                        $this->xmlElement("MediaObject", $imgattrs, NULL);
                        $mob_obj->exportFiles($this->target_dir_absolute);
                    }
                }
                if ($media_exists) {
                    $this->xmlEndTag("MessageMediaObjects");
                }
                $this->xmlElement("Lft", null, (int) $rowPost->lft);
                $this->xmlElement("Rgt", null, (int) $rowPost->rgt);
                $this->xmlElement("Depth", null, (int) $rowPost->depth);
                $this->xmlElement("ParentId", null, (int) $rowPost->parent_pos);
                $tmp_file_obj = new ilFileDataForum($this->forum_id, $rowPost->pos_pk);
                $set = array();
                if (count($tmp_file_obj->getFilesOfPost())) {
                    foreach ($tmp_file_obj->getFilesOfPost() as $file) {
                        $this->xmlStartTag("Attachment");
                        copy($file['path'], $this->target_dir_absolute . "/" . basename($file['path']));
                        $content = $this->target_dir_relative . "/" . basename($file['path']);
                        $this->xmlElement("Content", null, $content);
                        $this->xmlEndTag("Attachment");
                    }
                }
                //Used for nested postings
                //$lastDepth = $rowPost->depth;
                $this->xmlEndTag("Post");
            }
            /*
            			// Used for nested postings
            			if( $lastDepth )
            			{
            				for( $i = 1; $i <= $lastDepth ; $i++ )
            				{
            					$this->xmlEndTag("Post");
            				}
            
            				$lastDepth = null;
            			}*/
            $this->xmlEndTag("Thread");
        }
        $this->xmlEndTag("Forum");
        return true;
    }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) true;
     $result['points'] = (bool) $this->getPoints();
     $result['feedback'] = array("onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false), "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true));
     $arr = array();
     foreach ($this->getOrderingElements() as $order => $answer) {
         array_push($arr, array("answertext" => (string) $answer, "order" => (int) $order + 1));
     }
     $result['answers'] = $arr;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Returns a JSON representation of the question
  * TODO
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = true;
     $result['feedback'] = array("onenotcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(0), 0)), "allcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(1), 0)));
     $terms = array("" => array("id" => "-1", "term" => $this->lng->txt("please_select")));
     foreach ($this->getTerms() as $term) {
         $terms[(int) $term->identifier] = array("term" => $term->text, "id" => (int) $term->identifier);
     }
     // $terms = $this->pcArrayShuffle($terms);
     // alex 9.9.2010 as a fix for bug 6513 I added the question id
     // to the "def_id" in the array. The $pair->definition->identifier is not
     // unique, since it gets it value from the morder table field
     // this value is not changed, when a question is copied.
     // thus copying the same question on a page results in problems
     // when the second one (the copy) is answered.
     $pairs = array();
     foreach ($this->getDefinitions() as $def) {
         array_push($pairs, array("definition" => (string) $def->text, "def_id" => (int) $this->getId() . $def->identifier, "terms" => $terms));
     }
     $result['pairs'] = $pairs;
     // #10353
     $match = $points = array();
     foreach ($this->getMatchingPairs() as $pair) {
         $pid = $pair->definition->identifier;
         // we only need pairs with max. points for def-id
         if (!isset($match[$pid]) || $match[$pid]["points"] < $pair->points) {
             $match[$pid] = array("term_id" => (int) $pair->term->identifier, "def_id" => (int) $this->getId() . $pair->definition->identifier, "points" => (int) $pair->points);
         }
     }
     $result['match'] = array_values($match);
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
    /**
     * delete post and sub-posts
     * @param	integer	$post: ID	
     * @access	public
     * @return	integer	0 or thread-ID
     */
    public function deletePost($post)
    {
        global $ilDB;
        include_once "./Modules/Forum/classes/class.ilObjForum.php";
        // delete tree and get id's of all posts to delete
        $p_node = $this->getPostNode($post);
        $del_id = $this->deletePostTree($p_node);
        // Delete User read entries
        foreach ($del_id as $post_id) {
            ilObjForum::_deleteReadEntries($post_id);
        }
        // DELETE ATTACHMENTS ASSIGNED TO POST
        $this->__deletePostFiles($del_id);
        $dead_pos = count($del_id);
        $dead_thr = 0;
        // if deletePost is thread opener ...
        if ($p_node["parent"] == 0) {
            // delete thread access data
            include_once './Modules/Forum/classes/class.ilObjForum.php';
            ilObjForum::_deleteAccessEntries($p_node['tree']);
            // delete thread
            $dead_thr = $p_node["tree"];
            $statement = $ilDB->manipulateF('
				DELETE FROM frm_threads
				WHERE thr_pk = %s', array('integer'), array($p_node['tree']));
            // update num_threads
            $statement = $ilDB->manipulateF('
				UPDATE frm_data 
				SET top_num_threads = top_num_threads - 1 
				WHERE top_frm_fk = %s', array('integer'), array($this->id));
            // delete all related news
            $posset = $ilDB->queryf('
				SELECT * FROM frm_posts
				WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree']));
            while ($posrec = $ilDB->fetchAssoc($posset)) {
                include_once "./Services/News/classes/class.ilNewsItem.php";
                $news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $posrec["pos_pk"], "pos");
                if ($news_id > 0) {
                    $news_item = new ilNewsItem($news_id);
                    $news_item->delete();
                }
                try {
                    include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
                    $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
                    foreach ($mobs as $mob) {
                        if (ilObjMediaObject::_exists($mob)) {
                            ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
                            $mob_obj = new ilObjMediaObject($mob);
                            $mob_obj->delete();
                        }
                    }
                } catch (Exception $e) {
                }
            }
            // delete all posts of this thread
            $statement = $ilDB->manipulateF('
				DELETE FROM frm_posts
				WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree']));
        } else {
            // delete this post and its sub-posts
            for ($i = 0; $i < $dead_pos; $i++) {
                $statement = $ilDB->manipulateF('
					DELETE FROM frm_posts
					WHERE pos_pk = %s', array('integer'), array($del_id[$i]));
                // delete related news item
                include_once "./Services/News/classes/class.ilNewsItem.php";
                $news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $del_id[$i], "pos");
                if ($news_id > 0) {
                    $news_item = new ilNewsItem($news_id);
                    $news_item->delete();
                }
                try {
                    include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
                    $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
                    foreach ($mobs as $mob) {
                        if (ilObjMediaObject::_exists($mob)) {
                            ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
                            $mob_obj = new ilObjMediaObject($mob);
                            $mob_obj->delete();
                        }
                    }
                } catch (Exception $e) {
                }
            }
            // update num_posts in frm_threads
            $statement = $ilDB->manipulateF('
				UPDATE frm_threads
				SET thr_num_posts = thr_num_posts - %s
				WHERE thr_pk = %s', array('integer', 'integer'), array($dead_pos, $p_node['tree']));
            // get latest post of thread and update last_post
            $res1 = $ilDB->queryf('
				SELECT * FROM frm_posts 
				WHERE pos_thr_fk = %s
				ORDER BY pos_date DESC', array('integer'), array($p_node['tree']));
            if ($res1->numRows() == 0) {
                $lastPost_thr = "";
            } else {
                $z = 0;
                while ($selData = $ilDB->fetchAssoc($res1)) {
                    if ($z > 0) {
                        break;
                    }
                    $lastPost_thr = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"];
                    $z++;
                }
            }
            $statement = $ilDB->manipulateF('
				UPDATE frm_threads
				SET thr_last_post = %s
				WHERE thr_pk = %s', array('text', 'integer'), array($lastPost_thr, $p_node['tree']));
        }
        // update num_posts in frm_data
        $statement = $ilDB->manipulateF('
			UPDATE frm_data
			SET top_num_posts = top_num_posts - %s
			WHERE top_frm_fk = %s', array('integer', 'integer'), array($dead_pos, $this->id));
        // get latest post of forum and update last_post
        $res2 = $ilDB->queryf('
			SELECT * FROM frm_posts, frm_data 
			WHERE pos_top_fk = top_pk 
			AND top_frm_fk = %s
			ORDER BY pos_date DESC', array('integer'), array($this->id));
        if ($res2->numRows() == 0) {
            $lastPost_top = "";
        } else {
            $z = 0;
            while ($selData = $ilDB->fetchAssoc($res2)) {
                if ($z > 0) {
                    break;
                }
                $lastPost_top = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"];
                $z++;
            }
        }
        $statement = $ilDB->manipulateF('
			UPDATE frm_data
			SET top_last_post = %s
			WHERE top_frm_fk = %s', array('text', 'integer'), array($lastPost_top, $this->id));
        return $dead_thr;
    }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     $this->lng->loadLanguageModule('assessment');
     require_once './Services/RTE/classes/class.ilRTE.php';
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['instruction'] = $this->getInstructionTextTranslation($this->lng, $this->getOptionLabel());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->isShuffleAnswersEnabled();
     $result['feedback'] = array('onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)), 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)));
     $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
     $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
     $result['num_allowed_failures'] = $this->getNumAllowedFailures();
     $answers = array();
     $has_image = false;
     foreach ($this->getAnswers() as $key => $answer) {
         if (strlen((string) $answer->getImageFile())) {
             $has_image = true;
         }
         $answers[] = array('answertext' => (string) $this->formatSAQuestion($answer->getAnswertext()), 'correctness' => (bool) $answer->getCorrectness(), 'order' => (int) $answer->getPosition(), 'image' => (string) $answer->getImageFile(), 'feedback' => ilRTE::_replaceMediaObjectImageSrc($this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0));
     }
     $result['answers'] = $answers;
     if ($has_image) {
         $result['path'] = $this->getImagePathWeb();
         $result['thumb'] = $this->getThumbSize();
     }
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array("onenotcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(0), 0)), "allcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(1), 0)));
     $gaps = array();
     foreach ($this->getGaps() as $key => $gap) {
         $items = array();
         foreach ($gap->getItems() as $item) {
             $jitem = array();
             $jitem['points'] = $item->getPoints();
             $jitem['value'] = $item->getAnswertext();
             $jitem['order'] = $item->getOrder();
             if ($gap->getType() == CLOZE_NUMERIC) {
                 $jitem['lowerbound'] = $item->getLowerBound();
                 $jitem['upperbound'] = $item->getUpperBound();
             }
             array_push($items, $jitem);
         }
         $jgap['shuffle'] = $gap->getShuffle();
         $jgap['type'] = $gap->getType();
         $jgap['item'] = $items;
         array_push($gaps, $jgap);
     }
     $result['gaps'] = $gaps;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array("onenotcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(0), 0)), "allcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(1), 0)));
     $result['image'] = (string) $this->getImagePathWeb() . $this->getImageFilename();
     $answers = array();
     foreach ($this->getAnswers() as $key => $answer_obj) {
         array_push($answers, array("answertext" => (string) $answer_obj->getAnswertext(), "points" => (double) $answer_obj->getPoints(), "order" => (int) $answer_obj->getOrder(), "coords" => $answer_obj->getCoords(), "state" => $answer_obj->getState(), "area" => $answer_obj->getArea(), "feedback" => ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackSingleAnswer($key), 0)));
     }
     $result['answers'] = $answers;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
Beispiel #19
0
 /**
  * Creates a QTI material tag from a plain text or xhtml text
  *
  * @param object $a_xml_writer Reference to the ILIAS XML writer
  * @param string $a_material plain text or html text containing the material
  * @return string QTI material tag
  * @access public
  */
 function addQTIMaterial(&$a_xml_writer, $a_material)
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $a_xml_writer->xmlStartTag("material");
     $attrs = array("texttype" => "text/plain");
     if ($this->isHTML($a_material)) {
         $attrs["texttype"] = "text/xhtml";
     }
     $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
     $mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->getId());
     foreach ($mobs as $mob) {
         $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
         if (strpos($a_material, "mm_{$mob}") !== FALSE) {
             if (ilObjMediaObject::_exists($mob)) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $imgattrs = array("label" => $moblabel, "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle());
             }
             $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
         }
     }
     $a_xml_writer->xmlEndTag("material");
 }
 /**
  * Before page is being deleted
  *
  * @param object $a_page page object
  */
 static function beforePageDelete($a_page)
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mob_ids = ilObjMediaObject::_getMobsOfObject($a_page->getParentType() . ":pg", $a_page->getId(), 0, $a_page->getLanguage());
     ilObjMediaObject::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), false, $a_page->getLanguage());
     foreach ($mob_ids as $mob) {
         if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
             $mob_obj = new ilObjMediaObject($mob);
             $usages = $mob_obj->getUsages(false);
             if (count($usages) == 0) {
                 $mob_obj->delete();
             }
         }
     }
 }
Beispiel #21
0
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['matching_method'] = (string) $this->getTextRating();
     $result['feedback'] = array("onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false), "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true));
     $answers = array();
     foreach ($this->getAnswers() as $key => $answer_obj) {
         array_push($answers, array("answertext" => (string) $answer_obj->getAnswertext(), "points" => (double) $answer_obj->getPoints(), "order" => (int) $answer_obj->getOrder()));
     }
     $result['correct_answers'] = $answers;
     $answers = array();
     for ($loop = 1; $loop <= (int) $this->getCorrectAnswers(); $loop++) {
         array_push($answers, array("answernr" => $loop));
     }
     $result['answers'] = $answers;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
Beispiel #22
0
 /**
  * synchronises appearances of media objects in $a_text with media
  * object usage table
  *
  * @param	string	$a_text			text, including media object tags
  * @param	string	$a_usage_type	type of context of usage, e.g. cat:html
  * @param	int		$a_usage_id		if of context of usage, e.g. category id
  */
 function _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
 {
     // get current stored mobs
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mobs = ilObjMediaObject::_getMobsOfObject($a_usage_type, $a_usage_id);
     while (eregi("data\\/" . CLIENT_ID . "\\/mobs\\/mm_([0-9]+)", $a_text, $found)) {
         $a_text = str_replace($found[0], "", $a_text);
         if (!in_array($found[1], $mobs)) {
             // save usage if missing
             ilObjMediaObject::_saveUsage($found[1], $a_usage_type, $a_usage_id);
         } else {
             // if already saved everything ok -> take mob out of mobs array
             unset($mobs[$found[1]]);
         }
     }
     // remaining usages are not in text anymore -> delete them
     // and media objects (note: delete method of ilObjMediaObject
     // checks whether object is used in another context; if yes,
     // the object is not deleted!)
     foreach ($mobs as $mob) {
         ilObjMediaObject::_removeUsage($mob, $a_usage_type, $a_usage_id);
         $mob_obj =& new ilObjMediaObject($mob);
         $mob_obj->delete();
     }
 }
 public function saveStatutoryRegulationsObject()
 {
     require_once 'Services/RTE/classes/class.ilRTE.php';
     if (isset($_POST['statutory_regulations']) && $_POST['statutory_regulations'] != NULL) {
         $this->genSetData->set('statutory_regulations', ilRTE::_replaceMediaObjectImageSrc($_POST['statutory_regulations'], 0), 'regulations');
         // copy temporary media objects (frm~)
         include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
         $mediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
         $myMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
         foreach ($mediaObjects as $mob) {
             foreach ($myMediaObjects as $myMob) {
                 if ($mob == $myMob) {
                     // change usage
                     ilObjMediaObject::_removeUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
                     break;
                 }
             }
             ilObjMediaObject::_saveUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
         }
     } else {
         $this->genSetData->set('statutory_regulations', NULL, 'regulations');
     }
     // remove usage of deleted media objects
     include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
     $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
     $curMediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
     foreach ($oldMediaObjects as $oldMob) {
         $found = false;
         foreach ($curMediaObjects as $curMob) {
             if ($oldMob == $curMob) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             if (ilObjMediaObject::_exists($oldMob)) {
                 ilObjMediaObject::_removeUsage($oldMob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
                 $mob_obj = new ilObjMediaObject($oldMob);
                 $mob_obj->delete();
             }
         }
     }
     $this->genSetData->set('show_sr_shoppingcart', isset($_POST['show_sr_shoppingcart']) ? 1 : 0, 'regulations');
     $this->genSetData->set('attach_sr_invoice', isset($_POST['attach_sr_invoice']) ? 1 : 0, 'regulations');
     $this->StatutoryRegulationsObject();
     ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
     return true;
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) true;
     $result['points'] = (bool) $this->getPoints();
     $result['feedback'] = array("onenotcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(0), 0)), "allcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(1), 0)));
     if ($this->getOrderingType() == OQ_PICTURES) {
         $result['path'] = $this->getImagePathWeb();
     }
     $counter = 1;
     $answers = array();
     foreach ($this->getAnswers() as $answer_obj) {
         $answers[$counter] = $answer_obj->getAnswertext();
         $counter++;
     }
     $answers = $this->pcArrayShuffle($answers);
     $arr = array();
     foreach ($answers as $order => $answer) {
         array_push($arr, array("answertext" => (string) $answer, "order" => (int) $order));
     }
     $result['answers'] = $arr;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array("onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false), "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true));
     $answers = array();
     $has_image = false;
     foreach ($this->getAnswers() as $key => $answer_obj) {
         if ((string) $answer_obj->getImage()) {
             $has_image = true;
         }
         array_push($answers, array("answertext" => (string) $answer_obj->getAnswertext(), "points" => (double) $answer_obj->getPoints(), "order" => (int) $answer_obj->getOrder(), "image" => (string) $answer_obj->getImage(), "feedback" => ilRTE::_replaceMediaObjectImageSrc($this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0)));
     }
     $result['answers'] = $answers;
     if ($has_image) {
         $result['path'] = $this->getImagePathWeb();
         $result['thumb'] = $this->getThumbSize();
     }
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * export all pages of learning module to html file
  */
 function exportHTMLPages(&$a_lm_gui, $a_target_dir)
 {
     global $tpl, $ilBench, $ilLocator;
     $pages = ilLMPageObject::getPageList($this->getId());
     $lm_tree =& $this->getLMTree();
     $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
     $this->first_page_id = $first_page["child"];
     // iterate all learning module pages
     $mobs = array();
     $int_links = array();
     $this->offline_files = array();
     include_once "./Services/COPage/classes/class.ilPageContentUsage.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     // get html export id mapping
     $lm_set = new ilSetting("lm");
     $exp_id_map = array();
     if ($lm_set->get("html_export_ids")) {
         foreach ($pages as $page) {
             $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]);
             if (trim($exp_id) != "") {
                 $exp_id_map[$page["obj_id"]] = trim($exp_id);
             }
         }
     }
     //exit;
     reset($pages);
     foreach ($pages as $page) {
         if (ilLMPage::_exists($this->getType(), $page["obj_id"])) {
             $ilLocator->clearItems();
             $ilBench->start("ExportHTML", "exportHTMLPage");
             $ilBench->start("ExportHTML", "exportPageHTML");
             $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"], "", $exp_id_map);
             $ilBench->stop("ExportHTML", "exportPageHTML");
             // get all snippets of page
             $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType() . ":pg");
             foreach ($pcs as $pc) {
                 if ($pc["type"] == "incl") {
                     $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]);
                     foreach ($incl_mobs as $incl_mob) {
                         $mobs[$incl_mob] = $incl_mob;
                     }
                 }
             }
             // get all media objects of page
             $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType() . ":pg", $page["obj_id"]);
             foreach ($pg_mobs as $pg_mob) {
                 $mobs[$pg_mob] = $pg_mob;
             }
             // get all internal links of page
             $pg_links = ilInternalLink::_getTargetsOfSource($this->getType() . ":pg", $page["obj_id"]);
             $int_links = array_merge($int_links, $pg_links);
             // get all files of page
             include_once "./Modules/File/classes/class.ilObjFile.php";
             $pg_files = ilObjFile::_getFilesOfObject($this->getType() . ":pg", $page["obj_id"]);
             $this->offline_files = array_merge($this->offline_files, $pg_files);
             $ilBench->stop("ExportHTML", "exportHTMLPage");
         }
     }
     $this->offline_mobs = $mobs;
     $this->offline_int_links = $int_links;
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['is_multiple'] = (bool) $this->getIsMultipleChoice();
     $result['feedback'] = array('onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)), 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)));
     $result['image'] = (string) $this->getImagePathWeb() . $this->getImageFilename();
     $answers = array();
     $order = 0;
     foreach ($this->getAnswers() as $key => $answer_obj) {
         array_push($answers, array("answertext" => (string) $answer_obj->getAnswertext(), "points" => (double) $answer_obj->getPoints(), "points_unchecked" => (double) $answer_obj->getPointsUnchecked(), "order" => (int) $order, "coords" => $answer_obj->getCoords(), "state" => $answer_obj->getState(), "area" => $answer_obj->getArea(), "feedback" => ilRTE::_replaceMediaObjectImageSrc($this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0)));
         $order++;
     }
     $result['answers'] = $answers;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 function getMobsOfObject($sid, $a_type, $a_id)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     return ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
 }