public function showResults()
 {
     global $lng, $ilUser, $rbacreview, $ilObjDataCache;
     $form = $this->initSearchForm();
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_search.html", "Services/Contact");
     $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
     $this->tpl->setTitle($this->lng->txt("mail"));
     $this->tpl->setVariable('SEARCHFORM', $form->getHtml());
     // #14109
     if (strlen($_SESSION['mail_search_search']) < 3) {
         if ($_GET["ref"] != "wsp") {
             $this->tpl->show();
         }
         return;
     }
     $abook = new ilAddressbook($ilUser->getId());
     $entries = $abook->searchUsers(addslashes(urldecode($_SESSION['mail_search_search'])));
     // remove all contacts who are not registered users for personal workspace
     if ($_GET["ref"] == "wsp") {
         foreach ($entries as $idx => $entry) {
             if (!$entry["login"]) {
                 unset($entries[$idx]);
             }
         }
     }
     if (count($entries)) {
         $tbl_addr = new ilTable2GUI($this);
         $tbl_addr->setTitle($lng->txt('mail_addressbook'));
         $tbl_addr->setRowTemplate('tpl.mail_search_addr_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         foreach ($entries as $entry) {
             if ($_GET["ref"] != "wsp") {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_addr[]', $entry['login'] ? $entry['login'] : $entry['email']) . ilUtil::formCheckbox(0, 'search_name_cc[]', $entry['login'] ? $entry['login'] : $entry['email']) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $entry['login'] ? $entry['login'] : $entry['email']);
             } else {
                 $user_id = ilObjUser::_loginExists($entry["login"]);
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_addr[]', $user_id);
             }
             $result[$counter]['login'] = $entry['login'];
             $result[$counter]['firstname'] = $entry['firstname'];
             $result[$counter]['lastname'] = $entry['lastname'];
             $id = ilObjUser::_lookupId($entry['login']);
             if (ilObjUser::_lookupPref($id, 'public_email') == 'y' || !$entry['login']) {
                 $has_mail_addr = true;
                 $result[$counter]['email'] = $entry['email'];
             }
             ++$counter;
         }
         if ($_GET["ref"] != "wsp") {
             $tbl_addr->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
         } else {
             $tbl_addr->addColumn("", "", "1%");
         }
         $tbl_addr->addColumn($this->lng->txt('login'), 'login', "15%");
         $tbl_addr->addColumn($this->lng->txt('firstname'), 'firstname', "15%");
         $tbl_addr->addColumn($this->lng->txt('lastname'), 'lastname', "15%");
         if ($has_mail_addr) {
             foreach ($result as $key => $val) {
                 if ($val['email'] == '') {
                     $result[$key]['email'] = '&nbsp;';
                 }
             }
             $tbl_addr->addColumn($this->lng->txt('email'), 'email', "15%");
         }
         $tbl_addr->setData($result);
         $tbl_addr->setDefaultOrderField('login');
         $tbl_addr->setPrefix('addr_');
         $tbl_addr->enable('select_all');
         $tbl_addr->setSelectAllCheckbox('search_name_to_addr');
         $tbl_addr->setFormName('recipients');
         $this->tpl->setVariable('TABLE_ADDR', $tbl_addr->getHTML());
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $all_results = new ilSearchResult();
     $query_parser = new ilQueryParser(addcslashes($_SESSION['mail_search_search'], '%_'));
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     $user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
     $user_search->enableActiveCheck(true);
     $user_search->setFields(array('login'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $user_search->setFields(array('firstname'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $user_search->setFields(array('lastname'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $all_results->setMaxHits(100000);
     $all_results->preventOverwritingMaxhits(true);
     $all_results->filter(ROOT_FOLDER_ID, true);
     // Filter users (depends on setting in user accounts)
     include_once 'Services/User/classes/class.ilUserFilter.php';
     $users = ilUserFilter::getInstance()->filter($all_results->getResultIds());
     if (count($users)) {
         $tbl_users = new ilTable2GUI($this);
         $tbl_users->setTitle($lng->txt('system') . ': ' . $lng->txt('persons'));
         $tbl_users->setRowTemplate('tpl.mail_search_users_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         foreach ($users as $user) {
             $login = ilObjUser::_lookupLogin($user);
             if ($_GET["ref"] != "wsp") {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_usr[]', $login) . ilUtil::formCheckbox(0, 'search_name_cc[]', $login) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $login);
             } else {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_usr[]', $user);
             }
             $result[$counter]['login'] = $login;
             if (in_array(ilObjUser::_lookupPref($user, 'public_profile'), array('y', "g"))) {
                 $name = ilObjUser::_lookupName($user);
                 $result[$counter]['firstname'] = $name['firstname'];
                 $result[$counter]['lastname'] = $name['lastname'];
             } else {
                 $result[$counter]['firstname'] = '';
                 $result[$counter]['lastname'] = '';
             }
             if (ilObjUser::_lookupPref($user, 'public_email') == 'y') {
                 $has_mail_usr = true;
                 $result[$counter]['email'] = ilObjUser::_lookupEmail($user);
             }
             ++$counter;
         }
         if ($_GET["ref"] != "wsp") {
             $tbl_users->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
         } else {
             $tbl_users->addColumn("", "", "1%");
         }
         $tbl_users->addColumn($this->lng->txt('login'), 'login', '15%');
         $tbl_users->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
         $tbl_users->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
         if ($has_mail_usr == true) {
             foreach ($result as $key => $val) {
                 if ($val['email'] == '') {
                     $result[$key]['email'] = '&nbsp;';
                 }
             }
             $tbl_users->addColumn($this->lng->txt('email'), 'email', '15%');
         }
         $tbl_users->setData($result);
         $tbl_users->setDefaultOrderField('login');
         $tbl_users->setPrefix('usr_');
         $tbl_users->enable('select_all');
         $tbl_users->setSelectAllCheckbox('search_name_to_usr');
         $tbl_users->setFormName('recipients');
         $this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     include_once 'Services/Membership/classes/class.ilParticipants.php';
     $group_results = new ilSearchResult();
     $query_parser = new ilQueryParser(addcslashes($_SESSION['mail_search_search'], '%_'));
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     $search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
     $search->setFilter(array('grp'));
     $result = $search->performSearch();
     $group_results->mergeEntries($result);
     $group_results->setMaxHits(PHP_INT_MAX);
     $group_results->preventOverwritingMaxhits(true);
     $group_results->setRequiredPermission('read');
     $group_results->filter(ROOT_FOLDER_ID, true);
     $visible_groups = array();
     if ($group_results->getResults()) {
         $tbl_grp = new ilTable2GUI($this);
         $tbl_grp->setTitle($lng->txt('system') . ': ' . $lng->txt('groups'));
         $tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         $ilObjDataCache->preloadReferenceCache(array_keys($group_results->getResults()));
         $groups = $group_results->getResults();
         foreach ($groups as $grp) {
             if (!ilParticipants::hasParticipantListAccess($grp['obj_id'])) {
                 continue;
             }
             if ($_GET["ref"] != "wsp") {
                 $members = array();
                 $roles = $rbacreview->getAssignableChildRoles($grp['ref_id']);
                 foreach ($roles as $role) {
                     if (substr($role['title'], 0, 14) == 'il_grp_member_' || substr($role['title'], 0, 13) == 'il_grp_admin_') {
                         // does not work if Pear is enabled and Mailbox Address contain special chars!!
                         //array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
                         // FIX for Mantis: 7523
                         array_push($members, '#' . $role['title']);
                     }
                 }
                 $str_members = implode(',', $members);
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_grp[]', $str_members) . ilUtil::formCheckbox(0, 'search_name_cc[]', $str_members) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $str_members);
             } else {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_grp[]', $grp['obj_id']);
             }
             $result[$counter]['title'] = $ilObjDataCache->lookupTitle($grp['obj_id']);
             $result[$counter]['description'] = $ilObjDataCache->lookupDescription($grp['obj_id']);
             ++$counter;
             $visible_groups[] = $grp;
         }
         if ($visible_groups) {
             $tbl_grp->setData($result);
             if ($_GET["ref"] != "wsp") {
                 $tbl_grp->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
             } else {
                 $tbl_grp->addColumn("", "", "1%");
             }
             $tbl_grp->addColumn($this->lng->txt('title'), 'title', '15%');
             $tbl_grp->addColumn($this->lng->txt('description'), 'description', '15%');
             $tbl_grp->setDefaultOrderField('title');
             $tbl_grp->setPrefix('grp_');
             $tbl_grp->enable('select_all');
             $tbl_grp->setSelectAllCheckbox('search_name_to_grp');
             $tbl_grp->setFormName('recipients');
             $this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
         }
     }
     if (count($users) || count($visible_groups) || count($entries)) {
         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
         $this->tpl->setVariable("ALT_ARROW", '');
         if ($_GET["ref"] != "wsp") {
             $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('adopt'));
         } else {
             $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('wsp_share_with_users'));
         }
     } else {
         $this->lng->loadLanguageModule('search');
         ilUtil::sendInfo($this->lng->txt('search_no_match'));
     }
     if ($_GET["ref"] != "wsp") {
         $this->tpl->show();
     }
 }
 /**
  * list definitions of a term
  */
 function listDefinitions($a_ref_id = 0, $a_term_id = 0, $a_get_html = false)
 {
     global $ilUser, $ilAccess, $ilias, $lng, $ilCtrl;
     if ($a_ref_id == 0) {
         $ref_id = (int) $_GET["ref_id"];
     } else {
         $ref_id = $a_ref_id;
     }
     if ($a_term_id == 0) {
         $term_id = $this->term_id;
     } else {
         $term_id = $a_term_id;
     }
     if (!$ilAccess->checkAccess("read", "", $ref_id)) {
         $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
     }
     // tabs
     if ($this->glossary->getPresentationMode() != "full_def") {
         $this->showDefinitionTabs("content");
     }
     $term = new ilGlossaryTerm($term_id);
     if (!$a_get_html) {
         $tpl = $this->tpl;
         require_once "./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php";
         $tpl->getStandardTemplate();
         //			$this->setTabs();
         if ($this->offlineMode()) {
             $style_name = $ilUser->prefs["style"] . ".css";
             $tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name);
         } else {
             $this->setLocator();
         }
         // content style
         $tpl->setCurrentBlock("ContentStyle");
         if (!$this->offlineMode()) {
             $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
         } else {
             $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
         }
         $tpl->parseCurrentBlock();
         // syntax style
         $tpl->setCurrentBlock("SyntaxStyle");
         if (!$this->offlineMode()) {
             $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         } else {
             $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
         }
         $tpl->parseCurrentBlock();
         $tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.png"));
         $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
         // load template for table
         $tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", "Modules/Glossary");
     } else {
         // content style
         $this->tpl->setCurrentBlock("ContentStyle");
         if (!$this->offlineMode()) {
             $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
         } else {
             $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
         }
         $this->tpl->parseCurrentBlock();
         // syntax style
         $this->tpl->setCurrentBlock("SyntaxStyle");
         if (!$this->offlineMode()) {
             $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         } else {
             $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
         }
         $this->tpl->parseCurrentBlock();
         $tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "Modules/Glossary");
     }
     $defs = ilGlossaryDefinition::getDefinitionList($term_id);
     $tpl->setVariable("TXT_TERM", $term->getTerm());
     $this->mobs = array();
     for ($j = 0; $j < count($defs); $j++) {
         $def = $defs[$j];
         $page_gui = new ilGlossaryDefPageGUI($def["id"]);
         $page_gui->setStyleId($this->glossary->getStyleSheetId());
         $page = $page_gui->getPageObject();
         // internal links
         $page->buildDom();
         $int_links = $page->getInternalLinks();
         $link_xml = $this->getLinkXML($int_links);
         $page_gui->setLinkXML($link_xml);
         if ($this->offlineMode()) {
             $page_gui->setOutputMode("offline");
             $page_gui->setOfflineDirectory($this->getOfflineDirectory());
         }
         $page_gui->setSourcecodeDownloadScript($this->getLink($ref_id));
         $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id, $def["id"]));
         $page_gui->setTemplateOutput(false);
         $page_gui->setRawPageContent(true);
         $page_gui->setFileDownloadLink($this->getLink($ref_id, "downloadFile"));
         if (!$this->offlineMode()) {
             $output = $page_gui->preview();
         } else {
             $output = $page_gui->presentation($page_gui->getOutputMode());
         }
         if (count($defs) > 1) {
             $tpl->setCurrentBlock("definition_header");
             $tpl->setVariable("TXT_DEFINITION", $this->lng->txt("cont_definition") . " " . ($j + 1));
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock("definition");
         $tpl->setVariable("PAGE_CONTENT", $output);
         $tpl->parseCurrentBlock();
     }
     // display possible backlinks
     $sources = ilInternalLink::_getSourcesOfTarget('git', $_GET['term_id'], 0);
     if ($sources) {
         $backlist_shown = false;
         foreach ($sources as $src) {
             $type = explode(':', $src['type']);
             if ($type[0] == 'lm') {
                 if ($type[1] == 'pg') {
                     $title = ilLMPageObject::_getPresentationTitle($src['id']);
                     $lm_id = ilLMObject::_lookupContObjID($src['id']);
                     $lm_title = ilObject::_lookupTitle($lm_id);
                     $tpl->setCurrentBlock('backlink_item');
                     $ref_ids = ilObject::_getAllReferences($lm_id);
                     $access = false;
                     foreach ($ref_ids as $rid) {
                         if ($ilAccess->checkAccess("read", "", $rid)) {
                             $access = true;
                         }
                     }
                     if ($access) {
                         $tpl->setCurrentBlock("backlink_item");
                         $tpl->setVariable("BACKLINK_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . $type[1] . "_" . $src['id']);
                         $tpl->setVariable("BACKLINK_ITEM", $lm_title . ": " . $title);
                         $tpl->parseCurrentBlock();
                         $backlist_shown = true;
                     }
                 }
             }
         }
         if ($backlist_shown) {
             $tpl->setCurrentBlock("backlink_list");
             $tpl->setVariable("BACKLINK_TITLE", $this->lng->txt('glo_term_used_in'));
             $tpl->parseCurrentBlock();
         }
     }
     if (!$a_get_html) {
         $tpl->setCurrentBlock("perma_link");
         $tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . "git" . "_" . $term_id . "_" . $ref_id . "&client_id=" . CLIENT_ID);
         $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
         $tpl->setVariable("PERMA_TARGET", "_top");
         $tpl->parseCurrentBlock();
     }
     // highlighting?
     if ($_GET["srcstring"] != "" && !$this->offlineMode()) {
         include_once './Services/Search/classes/class.ilUserSearchCache.php';
         $cache = ilUserSearchCache::_getInstance($ilUser->getId());
         $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
         $search_string = $cache->getQuery();
         include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php";
         include_once "./Services/Search/classes/class.ilQueryParser.php";
         $p = new ilQueryParser($search_string);
         $p->parse();
         $words = $p->getQuotedWords();
         if (is_array($words)) {
             foreach ($words as $w) {
                 ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
             }
         }
         $this->fill_on_load_code = true;
     }
     if ($this->offlineMode() || $a_get_html) {
         return $tpl->get();
     }
 }
 /**
  * parse query string, using query parser instance
  * @return object of query parser or error message if an error occured
  * @access public
  */
 function &__parseQueryString($a_string)
 {
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
     $query_parser->setCombination(QP_COMBINATION_OR);
     $query_parser->setMinWordLength(1, true);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $query_parser->getMessage();
     }
     return $query_parser;
 }
 /**
  * This function is only used by the ajax request if searching for ILIAS references. It builds the html for the search results.
  */
 public function searchObjects()
 {
     global $lng;
     $search = $_POST['search_for'];
     $dest = $_POST['dest'];
     $html = "";
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser($search);
     $query_parser->setMinWordLength(1, true);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         $html .= $query_parser->getMessage() . "<br />";
     }
     // only like search since fulltext does not support search with less than 3 characters
     include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
     $object_search = new ilLikeObjectSearch($query_parser);
     $res = $object_search->performSearch();
     //$res->setRequiredPermission('copy');
     $res->filter(ROOT_FOLDER_ID, true);
     if (!count($results = $res->getResultsByObjId())) {
         $html .= $lng->txt('dcl_no_search_results_found_for') . ' ' . $search . "<br />";
     }
     $results = $this->parseSearchResults($results);
     foreach ($results as $entry) {
         $tpl = new ilTemplate("tpl.dcl_tree.html", true, true, "Modules/DataCollection");
         foreach ((array) $entry['refs'] as $reference) {
             include_once './Services/Tree/classes/class.ilPathGUI.php';
             $path = new ilPathGUI();
             $tpl->setCurrentBlock('result');
             $tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " > " . $entry['title']);
             $tpl->setVariable('RESULT_REF', $reference);
             $tpl->setVariable('FIELD_ID', $dest);
             $tpl->parseCurrentBlock();
         }
         $html .= $tpl->get();
     }
     echo $html;
     exit;
 }
 /**
  * View wiki page.
  */
 function preview()
 {
     global $ilCtrl, $ilAccess, $lng, $tpl, $ilUser, $ilSetting, $ilToolbar;
     // block/unblock
     if ($this->getPageObject()->getBlocked()) {
         ilUtil::sendInfo($lng->txt("wiki_page_status_blocked"));
     }
     $this->increaseViewCount();
     $this->addHeaderAction();
     // content
     $this->setSideBlock();
     $wtpl = new ilTemplate("tpl.wiki_page_view_main_column.html", true, true, "Modules/Wiki");
     $callback = array($this, "observeNoteAction");
     // notes
     if (!$ilSetting->get("disable_comments") && ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId())) {
         $wtpl->setVariable("NOTES", $this->getNotesHTML($this->getPageObject(), true, ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), $ilAccess->checkAccess("write", "", $_GET["ref_id"]), $callback));
     }
     // permanent link
     $append = $_GET["page"] != "" ? "_" . ilWikiUtil::makeUrlTitle($_GET["page"]) : "";
     include_once "./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php";
     $perma_link = new ilPermanentLinkGUI("wiki", $_GET["ref_id"], $append);
     $wtpl->setVariable("PERMA_LINK", $perma_link->getHTML());
     // page content
     $this->setOutputMode(IL_PAGE_PRESENTATION);
     $this->setRenderPageContainer(true);
     $wtpl->setVariable("PAGE", $this->showPage());
     $tpl->setLoginTargetPar("wiki_" . $_GET["ref_id"] . $append);
     // last edited info
     include_once "./Services/User/classes/class.ilUserUtil.php";
     $wtpl->setVariable("LAST_EDITED_INFO", $lng->txt("wiki_last_edited") . ": " . ilDatePresentation::formatDate(new ilDateTime($this->getPageObject()->getLastChange(), IL_CAL_DATETIME)) . ", " . ilUserUtil::getNamePresentation($this->getPageObject()->getLastChangeUser(), false, true, $ilCtrl->getLinkTarget($this, "preview")));
     $tpl->setLoginTargetPar("wiki_" . $_GET["ref_id"] . $append);
     //highlighting
     if ($_GET["srcstring"] != "") {
         include_once './Services/Search/classes/class.ilUserSearchCache.php';
         $cache = ilUserSearchCache::_getInstance($ilUser->getId());
         $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
         $search_string = $cache->getQuery();
         include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php";
         include_once "./Services/Search/classes/class.ilQueryParser.php";
         $p = new ilQueryParser($search_string);
         $p->parse();
         $words = $p->getQuotedWords();
         if (is_array($words)) {
             foreach ($words as $w) {
                 ilTextHighlighterGUI::highlight("ilCOPageContent", $w, $tpl);
             }
         }
         $this->fill_on_load_code = true;
     }
     return $wtpl->get();
 }
 /**
  * Search source
  * @return 
  */
 protected function searchSource()
 {
     global $tree, $ilObjDataCache, $lng, $ilCtrl, $tpl;
     if (isset($_POST['tit'])) {
         ilUtil::sendInfo($this->lng->txt('wizard_search_list'));
         $_SESSION['source_query'] = $_POST['tit'];
     } else {
         $_POST['tit'] = $_SESSION['source_query'];
     }
     $this->initFormSearch();
     $this->form->setValuesByPost();
     if (!$this->form->checkInput()) {
         ilUtil::sendFailure($lng->txt('msg_no_search_string'), true);
         $ilCtrl->returnToParent($this);
         return false;
     }
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser($this->form->getInput('tit'));
     $query_parser->setMinWordLength(1, true);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         ilUtil::sendFailure($query_parser->getMessage(), true);
         $ilCtrl->returnToParent($this);
     }
     // only like search since fulltext does not support search with less than 3 characters
     include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
     $object_search = new ilLikeObjectSearch($query_parser);
     $object_search->setFilter(array($_REQUEST['new_type']));
     $res = $object_search->performSearch();
     $res->setRequiredPermission('copy');
     $res->filter(ROOT_FOLDER_ID, true);
     if (!count($results = $res->getResultsByObjId())) {
         ilUtil::sendFailure($this->lng->txt('search_no_match'), true);
         $ilCtrl->returnToParent($this);
     }
     include_once './Services/Object/classes/class.ilObjectCopySearchResultTableGUI.php';
     $table = new ilObjectCopySearchResultTableGUI($this, 'searchSource', $_REQUEST['new_type']);
     $table->setSelectedReference($this->getSource());
     $table->parseSearchResults($results);
     $tpl->setContent($table->getHTML());
 }
 /**
  * Load input from form
  * @return 
  * @param object $a_rule_id
  */
 protected function loadRoleAssignmentRule($a_rule_id, $a_from_form = true)
 {
     if (is_object($this->rule)) {
         return true;
     }
     include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php';
     $this->rule = ilLDAPRoleAssignmentRule::_getInstanceByRuleId($a_rule_id);
     if ($a_from_form) {
         if ($this->form->getInput('role_name') == 0) {
             $this->rule->setRoleId($this->form->getInput('role_id'));
         } elseif ($this->form->getInput('role_search')) {
             // Search role
             include_once './Services/Search/classes/class.ilQueryParser.php';
             $parser = new ilQueryParser($this->form->getInput('role_search'));
             // TODO: Handle minWordLength
             $parser->setMinWordLength(1, true);
             $parser->setCombination(QP_COMBINATION_AND);
             $parser->parse();
             include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
             $object_search = new ilLikeObjectSearch($parser);
             $object_search->setFilter(array('role'));
             $res = $object_search->performSearch();
             $entries = $res->getEntries();
             if (count($entries) == 1) {
                 $role = current($entries);
                 $this->rule->setRoleId($role['obj_id']);
             } elseif (count($entries) > 1) {
                 $this->rule->setRoleId(-1);
             }
         }
         $this->rule->setAttributeName($this->form->getInput('name'));
         $this->rule->setAttributeValue($this->form->getInput('value'));
         $this->rule->setDN($this->form->getInput('dn'));
         $this->rule->setMemberAttribute($this->form->getInput('at'));
         $this->rule->setMemberIsDN($this->form->getInput('isdn'));
         $this->rule->enableAddOnUpdate($this->form->getInput('add_missing'));
         $this->rule->enableRemoveOnUpdate($this->form->getInput('remove_deprecated'));
         $this->rule->setPluginId($this->form->getInput('plugin_id'));
         $this->rule->setType($this->form->getInput('type'));
         return true;
     }
     // LOAD from session
     $this->rule = ilLDAPRoleAssignmentRule::_getInstanceByRuleId($a_rule_id);
     $this->rule->setServerId(0);
     $this->rule->enableAddOnUpdate((int) $_SESSION['ldap_role_ass']['add_missing']);
     $this->rule->enableRemoveOnUpdate((int) $_SESSION['ldap_role_ass']['remove_deprecated']);
     $this->rule->setType(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['type']));
     $this->rule->setDN(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['dn']));
     $this->rule->setMemberAttribute(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['at']));
     $this->rule->setMemberIsDN(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['isdn']));
     $this->rule->setAttributeName(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['name']));
     $this->rule->setAttributeValue(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['value']));
     $this->rule->setPluginId(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['plugin_id']));
     return true;
 }
 /**
  * process <ilPage> content tag
  *
  * @param	object		page node
  * @param	integer		footer/header page id
  */
 function ilPage(&$a_page_node, $a_page_id = 0)
 {
     global $ilUser;
     if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == 'selected') {
         $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
         if (!$public) {
             return $this->showNoPublicAccess($this->getCurrentPageId());
         }
     }
     if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId())) {
         return $this->showPreconditionsOfPage($this->getCurrentPageId());
     }
     require_once "./Modules/LearningModule/classes/class.ilLMPageGUI.php";
     require_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     // page id is e.g. > 0 when footer or header page is processed
     if ($a_page_id == 0) {
         $page_id = $this->getCurrentPageId();
         //echo ":".$page_id.":";
         // highlighting?
         if ($_GET["srcstring"] != "" && !$this->offlineMode()) {
             include_once './Services/Search/classes/class.ilUserSearchCache.php';
             $cache = ilUserSearchCache::_getInstance($ilUser->getId());
             $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
             $search_string = $cache->getQuery();
             include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php";
             include_once "./Services/Search/classes/class.ilQueryParser.php";
             $p = new ilQueryParser($search_string);
             $p->parse();
             $words = $p->getQuotedWords();
             if (is_array($words)) {
                 foreach ($words as $w) {
                     ilTextHighlighterGUI::highlight("ilLMPageContent", $w, $this->tpl);
                 }
             }
             $this->fill_on_load_code = true;
         }
     } else {
         $page_id = $a_page_id;
     }
     // content style
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     // no active page found in chapter
     if ($this->chapter_has_no_active_page && ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
         $mtpl = new ilTemplate("tpl.no_content_message.html", true, true, "Modules/LearningModule");
         $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_no_page_in_chapter"));
         //$mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_st.png",
         //	false, "output", $this->offlineMode()));
         $mtpl->setVariable("ITEM_TITLE", ilLMObject::_lookupTitle($_GET["obj_id"]));
         $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
         return $mtpl->get();
     }
     // current page is deactivated
     if ($this->deactivated_page) {
         $mtpl = new ilTemplate("tpl.no_content_message.html", true, true, "Modules/LearningModule");
         $m = $this->lng->txt("cont_page_currently_deactivated");
         $act_data = ilLMPage::_lookupActivationData((int) $_GET["obj_id"], $this->lm->getType());
         if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
             $m .= "<p>" . sprintf($this->lng->txt("cont_page_activation_on"), ilDatePresentation::formatDate(new ilDateTime($act_data["activation_start"], IL_CAL_DATETIME))) . "</p>";
         }
         $mtpl->setVariable("MESSAGE", $m);
         //$mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_pg.png",
         //	false, "output", $this->offlineMode()));
         $mtpl->setVariable("ITEM_TITLE", ilLMObject::_lookupTitle($_GET["obj_id"]));
         $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
         return $mtpl->get();
     }
     // no page found
     if ($page_id == 0) {
         $cont = $this->lng->txt("cont_no_page");
         $this->tpl->setVariable("PAGE_CONTENT", $cont);
         return $cont;
     }
     $page_object_gui = $this->getLMPageGUI($page_id);
     $this->basicPageGuiInit($page_object_gui);
     $page_object = $page_object_gui->getPageObject();
     $page_object->buildDom();
     $page_object->registerOfflineHandler($this);
     $int_links = $page_object->getInternalLinks();
     $page_object_gui->setTemplateOutput(false);
     // Update personal desktop items
     $ilUser->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
     // Update course items
     include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
     ilCourseLMHistory::_updateLastAccess($ilUser->getId(), $this->lm->getRefId(), $page_id);
     // read link targets
     $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
     $link_xml .= $this->getLinkTargetsXML();
     //echo htmlentities($link_xml);
     // get lm page object
     $lm_pg_obj = new ilLMPageObject($this->lm, $page_id);
     $lm_pg_obj->setLMId($this->lm->getId());
     //$pg_obj->setParentId($this->lm->getId());
     $page_object_gui->setLinkXML($link_xml);
     // determine target frames for internal links
     //$pg_frame = $_GET["frame"];
     $page_object_gui->setLinkFrame($_GET["frame"]);
     // page title and tracking (not for header or footer page)
     if ($page_id == 0 || $page_id != $this->lm->getHeaderPage() && $page_id != $this->lm->getFooterPage()) {
         $page_object_gui->setPresentationTitle(ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(), $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation")));
         // update learning progress
         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
             // #9483
             include_once "./Services/Tracking/classes/class.ilLearningProgress.php";
             ilLearningProgress::_tracProgress($ilUser->getId(), $this->lm->getId(), $this->lm->getRefId(), $this->lm->getType());
             // obsolete?
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             ilLPStatusWrapper::_updateStatus($this->lm->getId(), $ilUser->getId());
         }
     } else {
         $page_object_gui->setEnabledPageFocus(false);
         $page_object_gui->getPageConfig()->setEnableSelfAssessment(false);
     }
     // ADDED FOR CITATION
     $page_object_gui->setLinkParams("ref_id=" . $this->lm->getRefId());
     $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
     $page_object_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadLink());
     // syntax style
     $this->tpl->setCurrentBlock("SyntaxStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
     } else {
         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
     }
     $this->tpl->parseCurrentBlock();
     $ret = $page_object_gui->presentation($page_object_gui->getOutputMode());
     // process header
     if ($this->lm->getHeaderPage() > 0 && $page_id != $this->lm->getHeaderPage() && ($page_id == 0 || $page_id != $this->lm->getFooterPage())) {
         if (ilLMObject::_exists($this->lm->getHeaderPage())) {
             $head = $this->ilPage($a_page_node, $this->lm->getHeaderPage());
         }
     }
     // process footer
     if ($this->lm->getFooterPage() > 0 && $page_id != $this->lm->getFooterPage() && ($page_id == 0 || $page_id != $this->lm->getHeaderPage())) {
         if (ilLMObject::_exists($this->lm->getFooterPage())) {
             $foot = $this->ilPage($a_page_node, $this->lm->getFooterPage());
         }
     }
     $this->tpl->setVariable("PAGE_CONTENT", $head . $ret . $foot);
     //echo htmlentities("-".$ret."-");
     return $head . $ret . $foot;
 }
 /**
  * process <ilPage> content tag
  *
  * @param	object		page node
  * @param	integer		footer/header page id
  */
 function ilPage(&$a_page_node, $a_page_id = 0)
 {
     global $ilUser, $ilHelp;
     global $ilHelp;
     $ilHelp->setScreenIdComponent("lm");
     $ilHelp->setScreenId("content");
     $ilHelp->setSubScreenId("content");
     $this->fill_on_load_code = true;
     // check if page is (not) visible in public area
     if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == 'selected') {
         $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
         if (!$public) {
             return $this->showNoPublicAccess($this->getCurrentPageId());
         }
     }
     if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId())) {
         return $this->showPreconditionsOfPage($this->getCurrentPageId());
     }
     // if navigation is restricted based on correct answered questions
     // check if we have preceeding pages including unsanswered/incorrect answered questions
     if (!$this->offlineMode()) {
         if ($this->lm->getRestrictForwardNavigation()) {
             if ($this->getTracker()->hasPredIncorrectAnswers($this->getCurrentPageId())) {
                 $this->showNavRestrictionDueToQuestions();
                 return;
             }
         }
     }
     require_once "./Modules/LearningModule/classes/class.ilLMPageGUI.php";
     require_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     // page id is e.g. > 0 when footer or header page is processed
     if ($a_page_id == 0) {
         $page_id = $this->getCurrentPageId();
         //echo ":".$page_id.":";
         // highlighting?
         if ($_GET["srcstring"] != "" && !$this->offlineMode()) {
             include_once './Services/Search/classes/class.ilUserSearchCache.php';
             $cache = ilUserSearchCache::_getInstance($ilUser->getId());
             $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
             $search_string = $cache->getQuery();
             // advanced search?
             if (is_array($search_string)) {
                 $search_string = $search_string["lom_content"];
             }
             include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php";
             include_once "./Services/Search/classes/class.ilQueryParser.php";
             $p = new ilQueryParser($search_string);
             $p->parse();
             $words = $p->getQuotedWords();
             if (is_array($words)) {
                 foreach ($words as $w) {
                     ilTextHighlighterGUI::highlight("ilLMPageContent", $w, $this->tpl);
                 }
             }
             $this->fill_on_load_code = true;
         }
     } else {
         $page_id = $a_page_id;
     }
     // content style
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     // no active page found in chapter
     if ($this->chapter_has_no_active_page && ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
         $mtpl = new ilTemplate("tpl.no_content_message.html", true, true, "Modules/LearningModule");
         $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_no_page_in_chapter"));
         //$mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_st.svg",
         //	false, "output", $this->offlineMode()));
         $mtpl->setVariable("ITEM_TITLE", ilLMObject::_lookupTitle($_GET["obj_id"]));
         $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
         return $mtpl->get();
     }
     // current page is deactivated
     if ($this->deactivated_page) {
         $mtpl = new ilTemplate("tpl.no_content_message.html", true, true, "Modules/LearningModule");
         $m = $this->lng->txt("cont_page_currently_deactivated");
         $act_data = ilLMPage::_lookupActivationData((int) $_GET["obj_id"], $this->lm->getType());
         if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
             $m .= "<p>" . sprintf($this->lng->txt("cont_page_activation_on"), ilDatePresentation::formatDate(new ilDateTime($act_data["activation_start"], IL_CAL_DATETIME))) . "</p>";
         }
         $mtpl->setVariable("MESSAGE", $m);
         //$mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_pg.svg",
         //	false, "output", $this->offlineMode()));
         $mtpl->setVariable("ITEM_TITLE", ilLMObject::_lookupTitle($_GET["obj_id"]));
         $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
         return $mtpl->get();
     }
     // check if page is out of focus
     $focus_mess = "";
     if ($this->focus_id > 0) {
         $path = $this->lm_tree->getPathId($page_id);
         // out of focus
         if (!in_array($this->focus_id, $path)) {
             $mtpl = new ilTemplate("tpl.out_of_focus_message.html", true, true, "Modules/LearningModule");
             $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_out_of_focus_message"));
             $mtpl->setVariable("TXT_SHOW_CONTENT", $this->lng->txt("cont_show_content_after_focus"));
             if ($_GET["focus_return"] == "" || ilObject::_lookupType((int) $_GET["focus_return"], true) != "crs") {
                 $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_beginning"));
                 $this->ctrl->setParameter($this, "obj_id", $this->focus_id);
                 $mtpl->setVariable("LINK_BACK_TO_BEGINNING", $this->ctrl->getLinkTarget($this, "layout"));
                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
             } else {
                 $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_return_crs"));
                 include_once "./Services/Link/classes/class.ilLink.php";
                 $mtpl->setVariable("LINK_BACK_TO_BEGINNING", ilLink::_getLink((int) $_GET["focus_return"]));
             }
             $this->ctrl->setParameter($this, "focus_id", "");
             $mtpl->setVariable("LINK_SHOW_CONTENT", $this->ctrl->getLinkTarget($this, "layout"));
             $this->ctrl->setParameter($this, "focus_id", $_GET["focus_id"]);
             $focus_mess = $mtpl->get();
         } else {
             $sp = $this->getSuccessorPage();
             $path2 = array();
             if ($sp > 0) {
                 $path2 = $this->lm_tree->getPathId($this->getSuccessorPage());
             }
             if ($sp == 0 || !in_array($this->focus_id, $path2)) {
                 $mtpl = new ilTemplate("tpl.out_of_focus_message.html", true, true, "Modules/LearningModule");
                 $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_out_of_focus_message_last_page"));
                 $mtpl->setVariable("TXT_SHOW_CONTENT", $this->lng->txt("cont_show_content_after_focus"));
                 if ($_GET["focus_return"] == "" || ilObject::_lookupType((int) $_GET["focus_return"], true) != "crs") {
                     $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_beginning"));
                     $this->ctrl->setParameter($this, "obj_id", $this->focus_id);
                     $mtpl->setVariable("LINK_BACK_TO_BEGINNING", $this->ctrl->getLinkTarget($this, "layout"));
                     $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
                 } else {
                     $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_return_crs"));
                     include_once "./Services/Link/classes/class.ilLink.php";
                     $mtpl->setVariable("LINK_BACK_TO_BEGINNING", ilLink::_getLink((int) $_GET["focus_return"]));
                 }
                 $this->ctrl->setParameter($this, "focus_id", "");
                 $mtpl->setVariable("LINK_SHOW_CONTENT", $this->ctrl->getLinkTarget($this, "layout"));
                 $this->ctrl->setParameter($this, "focus_id", $_GET["focus_id"]);
                 $focus_mess = $mtpl->get();
             }
         }
     }
     // no page found
     if ($page_id == 0) {
         $cont = $this->lng->txt("cont_no_page");
         $this->tpl->setVariable("PAGE_CONTENT", $cont);
         return $cont;
     }
     $page_object_gui = $this->getLMPageGUI($page_id);
     $this->basicPageGuiInit($page_object_gui);
     $page_object = $page_object_gui->getPageObject();
     $page_object->buildDom();
     $page_object->registerOfflineHandler($this);
     $int_links = $page_object->getInternalLinks();
     $page_object_gui->setTemplateOutput(false);
     // Update personal desktop items
     $ilUser->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
     // Update course items
     include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
     ilCourseLMHistory::_updateLastAccess($ilUser->getId(), $this->lm->getRefId(), $page_id);
     // read link targets
     $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
     $link_xml .= $this->getLinkTargetsXML();
     //echo htmlentities($link_xml);
     // get lm page object
     $lm_pg_obj = new ilLMPageObject($this->lm, $page_id);
     $lm_pg_obj->setLMId($this->lm->getId());
     //$pg_obj->setParentId($this->lm->getId());
     $page_object_gui->setLinkXML($link_xml);
     // determine target frames for internal links
     //$pg_frame = $_GET["frame"];
     $page_object_gui->setLinkFrame($_GET["frame"]);
     // page title and tracking (not for header or footer page)
     if ($page_id == 0 || $page_id != $this->lm->getHeaderPage() && $page_id != $this->lm->getFooterPage()) {
         $page_object_gui->setPresentationTitle(ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(), $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang));
         // track access
         if ($ilUser->getId() != ANONYMOUS_USER_ID && $page_id != 0 && !$this->offlineMode()) {
             $this->getTracker()->trackAccess($page_id);
         }
     } else {
         $page_object_gui->setEnabledPageFocus(false);
         $page_object_gui->getPageConfig()->setEnableSelfAssessment(false);
     }
     // ADDED FOR CITATION
     $page_object_gui->setLinkParams("ref_id=" . $this->lm->getRefId());
     $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
     $page_object_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadLink());
     // syntax style
     $this->tpl->setCurrentBlock("SyntaxStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
     } else {
         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
     }
     $this->tpl->parseCurrentBlock();
     $ret = $page_object_gui->presentation($page_object_gui->getOutputMode());
     // process header
     if ($this->lm->getHeaderPage() > 0 && $page_id != $this->lm->getHeaderPage() && ($page_id == 0 || $page_id != $this->lm->getFooterPage())) {
         if (ilLMObject::_exists($this->lm->getHeaderPage())) {
             $head = $this->ilPage($a_page_node, $this->lm->getHeaderPage());
         }
     }
     // process footer
     if ($this->lm->getFooterPage() > 0 && $page_id != $this->lm->getFooterPage() && ($page_id == 0 || $page_id != $this->lm->getHeaderPage())) {
         if (ilLMObject::_exists($this->lm->getFooterPage())) {
             $foot = $this->ilPage($a_page_node, $this->lm->getFooterPage());
         }
     }
     // rating
     $rating = "";
     if ($this->lm->hasRatingPages()) {
         include_once "./Services/Rating/classes/class.ilRatingGUI.php";
         $rating_gui = new ilRatingGUI();
         $rating_gui->setObject($this->lm->getId(), "lm", $page_id, "lm");
         $rating_gui->setYourRatingText($this->lng->txt("lm_rate_page"));
         /*			
         	$this->tpl->setVariable("VAL_RATING", $rating->getHTML(false, true, 
         		"il.ExcPeerReview.saveComments(".$a_set["peer_id"].", %rating%)"));				
         */
         $this->ctrl->setParameter($this, "pgid", $page_id);
         $this->tpl->addOnLoadCode("il.LearningModule.setRatingUrl('" . $this->ctrl->getLinkTarget($this, "updatePageRating", "", true, false) . "')");
         $this->ctrl->setParameter($this, "pgid", "");
         $rating = '<div id="ilrtrpg" style="text-align:right">' . $rating_gui->getHtml(true, true, "il.LearningModule.saveRating(%rating%);") . "</div>";
     }
     $this->tpl->setVariable("PAGE_CONTENT", $rating . $head . $focus_mess . $ret . $foot);
     //echo htmlentities("-".$ret."-");
     return $head . $focus_mess . $ret . $foot;
 }
 /**
  *  Search content that belongs to the current user and that meet the search criteria
  *
  */
 public function searchContentFile()
 {
     /**
      * @var $ilAccess ilAccessHandler
      */
     global $ilAccess;
     $this->initContentSearchForm();
     if ($this->csform->checkInput()) {
         $allowedExt = array('ppt', 'pptx', 'flv', 'swf', 'pdf', 'gif', 'jpg', 'png', 'mp3', 'html');
         $result = array();
         include_once './Services/Search/classes/class.ilSearchSettings.php';
         if (ilSearchSettings::getInstance()->enabledLucene()) {
             include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
             include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
             $qp = new ilLuceneQueryParser('+(type:file) ' . $this->csform->getInput('search_query'));
             $qp->parse();
             $searcher = ilLuceneSearcher::getInstance($qp);
             $searcher->search();
             include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
             include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
             $filter = ilLuceneSearchResultFilter::getInstance($this->user->getId());
             $filter->addFilter(new ilLucenePathFilter(ROOT_FOLDER_ID));
             $filter->setCandidates($searcher->getResult());
             $filter->filter();
             foreach ($filter->getResultIds() as $refId => $objId) {
                 $obj = ilObjectFactory::getInstanceByRefId($refId);
                 if (!in_array(strtolower($obj->getFileExtension()), $allowedExt)) {
                     continue;
                 }
                 if (!$ilAccess->checkAccessOfUser($this->user->getId(), 'read', '', $refId, '', $objId)) {
                     continue;
                 }
                 $result[$obj->getId()] = $obj->getId();
             }
         } else {
             include_once 'Services/Search/classes/class.ilQueryParser.php';
             $query_parser = new ilQueryParser($this->csform->getInput('search_query'));
             $query_parser->setCombination(QP_COMBINATION_OR);
             $query_parser->parse();
             if (!$query_parser->validate()) {
                 ilUtil::sendInfo($query_parser);
                 $this->csform->setValuesByPost();
                 return $this->showAddContent();
             }
             include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
             $object_search = new ilLikeObjectSearch($query_parser);
             $object_search->setFilter(array('file'));
             $res = $object_search->performSearch();
             $res->setUserId($this->user->getId());
             $res->setMaxHits(999999);
             $res->filter(ROOT_FOLDER_ID, false);
             $res->setRequiredPermission('read');
             foreach ($res->getUniqueResults() as $entry) {
                 $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id']);
                 if (!in_array(strtolower($obj->getFileExtension()), $allowedExt)) {
                     continue;
                 }
                 $result[$obj->getId()] = $obj->getId();
             }
         }
         if (count($result) > 0) {
             $this->showFileSearchResult($result);
             $_SESSION['contents']['search_result'] = $result;
         } else {
             ilUtil::sendInfo($this->txt('files_matches_in_no_results'));
             $this->csform->setValuesByPost();
             $this->showAddContent();
         }
     } else {
         $this->csform->setValuesByPost();
         return $this->showAddContent();
     }
 }
 private function parseQueryString()
 {
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
     $query_parser->setCombination($this->getCombination());
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $query_parser->getMessage();
     }
     return $query_parser;
 }
 function &__performKeywordSearch()
 {
     // Return if 'any'
     if (!$this->options['lom_keyword']) {
         return false;
     }
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword']));
     #$query_parser->setCombination($this->options['keyword_ao']);
     $query_parser->setCombination(QP_COMBINATION_OR);
     $query_parser->parse();
     $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
     $meta_search->setFilter($this->filter);
     $meta_search->setMode('keyword');
     $meta_search->setOptions($this->options);
     $res =& $meta_search->performSearch();
     return $res;
 }
Beispiel #13
0
 /**
  * Search in Wiki
  */
 static function _performSearch($a_wiki_id, $a_searchterm)
 {
     // query parser
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser($a_searchterm);
     $query_parser->setCombination("or");
     $query_parser->parse();
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $search_result = new ilSearchResult();
     if ($query_parser->validate()) {
         include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
         $wiki_search =& ilObjectSearchFactory::_getWikiContentSearchInstance($query_parser);
         $wiki_search->setFilter(array('wpg'));
         $search_result->mergeEntries($wiki_search->performSearch());
     }
     $entries = $search_result->getEntries();
     $found_pages = array();
     foreach ($entries as $entry) {
         if ($entry["obj_id"] == $a_wiki_id && is_array($entry["child"])) {
             foreach ($entry["child"] as $child) {
                 $found_pages[] = array("page_id" => $child);
             }
         }
     }
     return $found_pages;
 }
 protected function chooseRole()
 {
     $this->tabs_gui->setSubTabActive('shib_role_assignment');
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $parser = new ilQueryParser($_SESSION['shib_role_ass']['search']);
     $parser->setMinWordLength(1, true);
     $parser->setCombination(QP_COMBINATION_AND);
     $parser->parse();
     include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
     $object_search = new ilLikeObjectSearch($parser);
     $object_search->setFilter(array('role'));
     $res = $object_search->performSearch();
     $entries = $res->getEntries();
     include_once './Services/AccessControl/classes/class.ilRoleSelectionTableGUI.php';
     $table = new ilRoleSelectionTableGUI($this, 'chooseRole');
     $table->setTitle($this->lng->txt('shib_role_selection'));
     $table->addMultiCommand('saveRoleSelection', $this->lng->txt('shib_choose_role'));
     $table->addCommandButton('roleAssignment', $this->lng->txt('cancel'));
     $table->parse($entries);
     $this->tpl->setContent($table->getHTML());
     return true;
 }
 /**
  * parse query string, using query parser instance
  * @return object of query parser or error message if an error occured
  * @access public
  */
 function &__parseQueryString($a_string, $a_combination_or = true)
 {
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
     $query_parser->setCombination($a_combination_or ? QP_COMBINATION_OR : QP_COMBINATION_AND);
     $query_parser->setMinWordLength(1, true);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $query_parser->getMessage();
     }
     return $query_parser;
 }
Beispiel #16
0
 public function performSearch($oResult = null)
 {
     if (!is_object($oResult)) {
         $oResult = ilShopSearchResult::_getInstance(SHOP_CONTENT);
         if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
             ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
             ilShopTopics::_getInstance()->enableCustomSorting(true);
             ilShopTopics::_getInstance()->setSortingType((int) $this->getSortingTypeTopics());
             ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->getSortingDirectionTopics()));
             ilShopTopics::_getInstance()->read();
         } else {
             ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
             ilShopTopics::_getInstance()->enableCustomSorting(false);
             ilShopTopics::_getInstance()->setSortingType((int) $this->settings->get('topics_sorting_type'));
             ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->settings->get('topics_sorting_direction')));
             ilShopTopics::_getInstance()->read();
         }
         $topics = ilShopTopics::_getInstance()->getTopics();
         $oResult->setTopics($topics);
         $oResult->setResultPageNumber((int) $_GET['page_number']);
     }
     // query parser
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
     $query_parser->setMinWordLength(0);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         ilUtil::sendInfo($query_parser->getMessage());
     }
     // search
     $types = array('crs', 'lm', 'sahs', 'htlm', 'file', 'tst', 'exc', 'glo');
     if ($this->getType() == '' || $this->getType() == 'title' || $query_parser->getQueryString() == '') {
         include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
         $object_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
         $object_search->setFields(array('title'));
         $object_search->setFilter($types);
         $object_search->setCustomSearchResultObject($oResult);
         $object_search->setFilterShopTopicId((int) $this->getTopicId());
         $res = $object_search->performSearch();
     } else {
         if ($this->getType() == 'author') {
             include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('contribute');
             $meta_search->setFilter($types);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $meta_search->setCustomSearchResultObject($oResult);
             $res = $meta_search->performSearch();
         } else {
             include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('title');
             $meta_search->setFilter($types);
             $meta_search->setCustomSearchResultObject($oResult);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $res = $meta_search->performSearch();
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('keyword');
             $meta_search->setFilter($types);
             $meta_search->setCustomSearchResultObject($oResult);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $res->mergeEntries($meta_search->performSearch());
         }
     }
     $res->filter(ROOT_FOLDER_ID, true);
     $res->save();
     if (!count($res->getResults())) {
         ilUtil::sendInfo($this->lng->txt('payment_shop_not_objects_found'));
     }
     $this->showTopicsContent($res);
     $this->addPager($res);
     return;
 }
 /**
  * share perform search
  *
  * @access public
  * @return
  */
 public function sharePerformSearch()
 {
     global $ilTabs;
     $this->lng->loadLanguageModule('search');
     if (!$_GET['category_id']) {
         ilUtil::sendFailure($this->lng->txt('select_one'), true);
         $this->ctrl->returnToParent($this);
     }
     $this->ctrl->saveParameter($this, 'category_id');
     if (!isset($_POST['query'])) {
         $query = $_SESSION['cal_query'];
         $type = $_SESSION['cal_type'];
     } elseif ($_POST['query']) {
         $query = $_SESSION['cal_query'] = $_POST['query'];
         $type = $_SESSION['cal_type'] = $_POST['query_type'];
     }
     if (!$query) {
         ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
         $this->shareSearch();
         return false;
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $res_sum = new ilSearchResult();
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($query));
     $query_parser->setCombination(QP_COMBINATION_OR);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     switch ($type) {
         case self::SEARCH_USER:
             $search = ilObjectSearchFactory::_getUserSearchInstance($query_parser);
             $search->enableActiveCheck(true);
             $search->setFields(array('login'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $search->setFields(array('firstname'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $search->setFields(array('lastname'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $res_sum->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
             break;
         case self::SEARCH_ROLE:
             include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
             $search = new ilLikeObjectSearch($query_parser);
             $search->setFilter(array('role'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $res_sum->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
             break;
     }
     if (!count($res_sum->getResults())) {
         ilUtil::sendFailure($this->lng->txt('search_no_match'));
         $this->shareSearch();
         return true;
     }
     $ilTabs->clearTargets();
     $ilTabs->setBackTarget($this->lng->txt("cal_back_to_search"), $this->ctrl->getLinkTarget($this, "shareSearch"));
     switch ($type) {
         case self::SEARCH_USER:
             $this->showUserList($res_sum->getResultIds());
             break;
         case self::SEARCH_ROLE:
             $this->showRoleList($res_sum->getResultIds());
             break;
     }
 }
 private function parseQueryString($query_string)
 {
     $oQueryParser = new ilQueryParser($query_string);
     $oQueryParser->setCombination('or');
     $oQueryParser->parse();
     if (!$oQueryParser->validate()) {
         return $oQueryParser->getMessage();
     }
     return $oQueryParser;
 }