/**
  * Get completion list
  */
 static function getList($a_str)
 {
     global $ilDB;
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     if (ilSearchSettings::getInstance()->enabledLucene()) {
         return self::getLuceneList($a_str);
     }
     $a_str = str_replace('"', "", $a_str);
     $settings = new ilSearchSettings();
     $object_types = array('cat', 'dbk', 'crs', 'fold', 'frm', 'grp', 'lm', 'sahs', 'glo', 'mep', 'htlm', 'exc', 'file', 'qpl', 'tst', 'svy', 'spl', 'chat', 'icrs', 'icla', 'webr', 'mcst', 'sess', 'pg', 'st', 'gdf', 'wiki');
     $set = $ilDB->query("SELECT title, obj_id FROM object_data WHERE " . $ilDB->like('title', 'text', $a_str . "%") . " AND " . $ilDB->in('type', $object_types, false, 'text') . " ORDER BY title");
     $max = $settings->getAutoCompleteLength() > 0 ? $settings->getAutoCompleteLength() : 10;
     $cnt = 0;
     $list = array();
     $checked = array();
     $lim = "";
     while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max) {
         if (strpos($rec["title"], " ") > 0 || strpos($rec["title"], "-") > 0) {
             $rec["title"] = '"' . $rec["title"] . '"';
         }
         if (!in_array($rec["title"], $list) && !in_array($rec["obj_id"], $checked)) {
             if (ilSearchAutoComplete::checkObjectPermission($rec["obj_id"])) {
                 $list[] = $lim . $rec["title"];
                 $cnt++;
             }
             $checked[] = $rec["obj_id"];
         }
     }
     $set = $ilDB->query("SELECT rbac_id,obj_id,obj_type, keyword FROM il_meta_keyword WHERE " . $ilDB->like('keyword', 'text', $a_str . "%") . " AND " . $ilDB->in('obj_type', $object_types, false, 'text') . " ORDER BY keyword");
     while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max) {
         if (strpos($rec["keyword"], " ") > 0) {
             $rec["keyword"] = '"' . $rec["keyword"] . '"';
         }
         if (!in_array($rec["keyword"], $list) && !in_array($rec["rbac_id"], $checked)) {
             if (ilSearchAutoComplete::checkObjectPermission($rec["rbac_id"])) {
                 $list[] = $lim . $rec["keyword"];
                 $cnt++;
             }
         }
         $checked[] = $rec["rbac_id"];
     }
     $i = 0;
     $result = array();
     foreach ($list as $l) {
         $result[$i] = new stdClass();
         $result[$i]->value = $l;
         $i++;
     }
     include_once './Services/JSON/classes/class.ilJsonUtil.php';
     return ilJsonUtil::encode($result);
 }
 /**
  * 
  *
  * @static
  * @return ilSearchSettings
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         return self::$instance = new ilSearchSettings();
     }
     return self::$instance;
 }
 /**
  * Singleton constructor 
  * @param int $a_usr_id user id
  * @return
  */
 protected function __construct($a_user_id)
 {
     $this->user_id = $a_user_id;
     $this->settings = ilSearchSettings::getInstance();
     include_once 'Services/Search/classes/class.ilUserSearchCache.php';
     $this->cache = ilUserSearchCache::_getInstance($this->getUserId());
     $this->offset = $this->settings->getMaxHits() * ($this->cache->getResultPageNumber() - 1);
 }
 public function getHTML()
 {
     global $ilCtrl, $tpl, $lng, $ilUser;
     if (!$this->isContainer) {
         #return '';
     }
     if ($_GET['baseClass'] == 'ilSearchController') {
         //			return '';
     }
     include_once "Services/jQuery/classes/class.iljQueryUtil.php";
     iljQueryUtil::initjQuery();
     iljQueryUtil::initjQueryUI();
     $this->tpl = new ilTemplate('tpl.main_menu_search.html', true, true, 'Services/Search');
     if ($ilUser->getId() != ANONYMOUS_USER_ID) {
         if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled() or (int) $_GET['ref_id']) {
             $this->tpl->setCurrentBlock("position");
             $this->tpl->setVariable('TXT_GLOBALLY', $lng->txt("search_globally"));
             $this->tpl->setVariable('ROOT_ID', ROOT_FOLDER_ID);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("position_hid");
             $this->tpl->setVariable('ROOT_ID_HID', ROOT_FOLDER_ID);
             $this->tpl->parseCurrentBlock();
         }
         if ((int) $_GET['ref_id']) {
             $this->tpl->setCurrentBlock('position_rep');
             $this->tpl->setVariable('TXT_CURRENT_POSITION', $lng->txt("search_at_current_position"));
             $this->tpl->setVariable('REF_ID', (int) $_GET["ref_id"]);
             $this->tpl->parseCurrentBlock();
         }
     }
     if ($ilUser->getId() != ANONYMOUS_USER_ID && ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
         $this->tpl->setCurrentBlock('usr_search');
         $this->tpl->setVariable('TXT_USR_SEARCH', $this->lng->txt('search_users'));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable('FORMACTION', 'ilias.php?baseClass=ilSearchController&cmd=post' . '&rtoken=' . $ilCtrl->getRequestToken() . '&fallbackCmd=remoteSearch');
     $this->tpl->setVariable('BTN_SEARCH', $this->lng->txt('search'));
     // $this->tpl->setVariable('ID_AUTOCOMPLETE', "mm_sr_auto");
     $this->tpl->setVariable('AC_DATASOURCE', "ilias.php?baseClass=ilSearchController&cmd=autoComplete");
     $this->tpl->setVariable('IMG_MM_SEARCH', ilUtil::img(ilUtil::getImagePath("icon_seas.svg"), $lng->txt("search")));
     if ($ilUser->getId() != ANONYMOUS_USER_ID) {
         $this->tpl->setVariable('HREF_SEARCH_LINK', "ilias.php?baseClass=ilSearchController");
         $this->tpl->setVariable('TXT_SEARCH_LINK', $lng->txt("last_search_result"));
     }
     // #10555 - we need the overlay for the autocomplete which is always active
     $this->tpl->setVariable('TXT_SEARCH', $lng->txt("search"));
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     $ov = new ilOverlayGUI("mm_search_menu");
     //$ov->setTrigger("main_menu_search", "none",
     //	"main_menu_search", "tr", "br");
     //$ov->setAnchor("main_menu_search", "tr", "br");
     $ov->setAutoHide(false);
     $ov->add();
     return $this->tpl->get();
 }
 /**
  * Constructor
  * @access public
  */
 function ilQueryParser($a_query_str)
 {
     global $lng;
     define(MIN_WORD_LENGTH, 3);
     $this->lng =& $lng;
     $this->query_str = $a_query_str;
     $this->message = '';
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     $this->settings = ilSearchSettings::getInstance();
     if (!$this->setMinWordLength(1)) {
         $this->setMinWordLength(MIN_WORD_LENGTH);
     }
 }
 /**
  * @param int $mode
  */
 public function __construct($mode)
 {
     /**
      * @var $ilUser     ilObjUser
      * @var $rbacsystem ilRbacSystem
      */
     global $ilUser, $rbacsystem;
     $this->allow_smtp = $rbacsystem->checkAccess('smtp_mail', MAIL_SETTINGS_ID);
     $this->user_id = $ilUser->getId();
     $this->max_entries = ilSearchSettings::getInstance()->getAutoCompleteLength();
     $this->result['items'] = array();
     $this->result['hasMoreResults'] = false;
     $this->initMode($mode);
 }
 function &executeCommand()
 {
     global $rbacsystem, $ilUser;
     // Check for incomplete profile
     if ($ilUser->getProfileIncomplete()) {
         ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
     }
     // check whether password of user have to be changed
     // due to first login or password of user is expired
     if ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired()) {
         ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
     }
     include_once 'Services/Search/classes/class.ilSearchSettings.php';
     // Check hacks
     if (!$rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     $forward_class = $this->ctrl->getNextClass($this) ? $this->ctrl->getNextClass($this) : $this->getLastClass();
     switch ($forward_class) {
         case 'illucenesearchgui':
             $this->setLastClass('illucenesearchgui');
             include_once './Services/Search/classes/Lucene/class.ilLuceneSearchGUI.php';
             $this->ctrl->forwardCommand(new ilLuceneSearchGUI());
             break;
         case 'illuceneadvancedsearchgui':
             $this->setLastClass('illuceneadvancedsearchgui');
             include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedSearchGUI.php';
             $this->ctrl->forwardCommand(new ilLuceneAdvancedSearchGUI());
             break;
         case 'iladvancedsearchgui':
             // Remember last class
             $this->setLastClass('iladvancedsearchgui');
             include_once 'Services/Search/classes/class.ilAdvancedSearchGUI.php';
             $this->ctrl->forwardCommand(new ilAdvancedSearchGUI());
             break;
         case 'ilsearchgui':
             // Remember last class
             $this->setLastClass('ilsearchgui');
         default:
             include_once 'Services/Search/classes/class.ilSearchGUI.php';
             $search_gui = new ilSearchGUI();
             $this->ctrl->forwardCommand($search_gui);
             break;
     }
     $this->tpl->show();
     return true;
 }
 /**
  * Update lucene index
  * @param type $a_obj_ids
  */
 public static function updateLuceneIndex($a_obj_ids)
 {
     global $ilSetting;
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     if (!ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
         return false;
     }
     try {
         include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
         ilRpcClientFactory::factory('RPCIndexHandler')->indexObjects(CLIENT_ID . '_' . $ilSetting->get('inst_id', 0), $a_obj_ids);
     } catch (XML_RPC2_FaultException $e) {
         $error_message = $e->getMessage();
         $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $e->getMessage());
     } catch (Exception $e) {
         $error_message = $e->getMessage();
         $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $e->getMessage());
     }
 }
 /**
  * Return an array of all meta data fields
  */
 public static function getFields()
 {
     global $lng;
     $lng->loadLanguageModule('meta');
     $fields['lom_content'] = $lng->txt('content');
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     if (ilSearchSettings::getInstance()->enabledLucene()) {
         $fields['general_offline'] = $lng->txt('lucene_offline_filter');
     }
     //'lom_type'					= $lng->txt('type');
     $fields['lom_language'] = $lng->txt('language');
     $fields['lom_keyword'] = $lng->txt('meta_keyword');
     $fields['lom_coverage'] = $lng->txt('meta_coverage');
     $fields['lom_structure'] = $lng->txt('meta_structure');
     $fields['lom_status'] = $lng->txt('meta_status');
     $fields['lom_version'] = $lng->txt('meta_version');
     $fields['lom_contribute'] = $lng->txt('meta_contribute');
     $fields['lom_format'] = $lng->txt('meta_format');
     $fields['lom_operating_system'] = $lng->txt('meta_operating_system');
     $fields['lom_browser'] = $lng->txt('meta_browser');
     $fields['lom_interactivity'] = $lng->txt('meta_interactivity_type');
     $fields['lom_resource'] = $lng->txt('meta_learning_resource_type');
     $fields['lom_level'] = $lng->txt('meta_interactivity_level');
     $fields['lom_density'] = $lng->txt('meta_semantic_density');
     $fields['lom_user_role'] = $lng->txt('meta_intended_end_user_role');
     $fields['lom_context'] = $lng->txt('meta_context');
     $fields['lom_difficulty'] = $lng->txt('meta_difficulty');
     $fields['lom_costs'] = $lng->txt('meta_cost');
     $fields['lom_copyright'] = $lng->txt('meta_copyright_and_other_restrictions');
     $fields['lom_purpose'] = $lng->txt('meta_purpose');
     $fields['lom_taxon'] = $lng->txt('meta_taxon');
     // Append all advanced meta data fields
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     foreach (ilAdvancedMDRecord::_getRecords() as $record) {
         foreach (ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $def) {
             if ($def->isSearchable()) {
                 $fields['adv_' . $def->getFieldId()] = $def->getTitle();
             }
         }
     }
     return $fields;
 }
 function &executeCommand()
 {
     global $rbacsystem;
     include_once 'Services/Search/classes/class.ilSearchSettings.php';
     // Check hacks
     if (!$rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     $forward_class = $this->ctrl->getNextClass($this) ? $this->ctrl->getNextClass($this) : $this->getLastClass();
     switch ($forward_class) {
         case 'illucenesearchgui':
             $this->setLastClass('illucenesearchgui');
             include_once './Services/Search/classes/Lucene/class.ilLuceneSearchGUI.php';
             $this->ctrl->forwardCommand(new ilLuceneSearchGUI());
             break;
         case 'illuceneadvancedsearchgui':
             $this->setLastClass('illuceneadvancedsearchgui');
             include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedSearchGUI.php';
             $this->ctrl->forwardCommand(new ilLuceneAdvancedSearchGUI());
             break;
         case 'illuceneusersearchgui':
             $this->setLastClass('illuceneusersearchgui');
             include_once './Services/Search/classes/Lucene/class.ilLuceneUserSearchGUI.php';
             $this->ctrl->forwardCommand(new ilLuceneUserSearchGUI());
             break;
         case 'iladvancedsearchgui':
             // Remember last class
             $this->setLastClass('iladvancedsearchgui');
             include_once 'Services/Search/classes/class.ilAdvancedSearchGUI.php';
             $this->ctrl->forwardCommand(new ilAdvancedSearchGUI());
             break;
         case 'ilsearchgui':
             // Remember last class
             $this->setLastClass('ilsearchgui');
         default:
             include_once 'Services/Search/classes/class.ilSearchGUI.php';
             $search_gui = new ilSearchGUI();
             $this->ctrl->forwardCommand($search_gui);
             break;
     }
     $this->tpl->show();
     return true;
 }
 /**
  * Save Lucene settings 
  * @return
  */
 protected function saveLuceneSettingsObject()
 {
     global $ilBench, $ilLog, $ilSetting;
     $this->initFormLuceneSettings();
     $settings = ilSearchSettings::getInstance();
     $settings->enableLuceneUserSearch((int) $_POST['user_search_enabled']);
     $settings->setFragmentCount((int) $_POST['fragmentCount']);
     $settings->setFragmentSize((int) $_POST['fragmentSize']);
     $settings->setMaxSubitems((int) $_POST['maxSubitems']);
     $settings->showRelevance((int) $_POST['relevance']);
     $settings->enableLuceneOfflineFilter((int) $_POST['offline_filter']);
     $settings->enableLuceneMimeFilter((int) $_POST['mime_enabled']);
     $settings->setLuceneMimeFilter((array) $_POST['mime']);
     $settings->showSubRelevance((int) $_POST['subrelevance']);
     $settings->enablePrefixWildcardQuery((int) $_POST['prefix']);
     if ($this->form->checkInput()) {
         $settings->setLastIndexTime($this->form->getItemByPostVar('last_index')->getDate());
         $settings->update();
         // refresh lucene server
         $ilBench->start('Lucene', 'LuceneRefreshSettings');
         try {
             include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
             ilRpcClientFactory::factory('RPCAdministration')->refreshSettings(CLIENT_ID . '_' . $ilSetting->get('inst_id', 0));
             ilUtil::sendInfo($this->lng->txt('settings_saved'));
             $this->luceneSettingsObject();
             return true;
         } catch (Exception $e) {
             $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
             ilUtil::sendFailure($e->getMessage());
             $this->luceneSettingsObject();
             return false;
         }
     }
     ilUtil::sendInfo($this->lng->txt('err_check_input'));
     $this->luceneSettingsObject();
     return false;
 }
 /**
  * set all template variables (images, scripts, target frames, ...)
  */
 function setTemplateVars()
 {
     global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting, $ilPluginAdmin;
     if ($this->logo_only) {
         $this->tpl->setVariable("HEADER_URL", $this->getHeaderURL());
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.svg"));
         return;
     }
     // get user interface plugins
     $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
     if ($this->getMode() != self::MODE_TOPBAR_REDUCED && $this->getMode() != self::MODE_TOPBAR_MEMBERVIEW) {
         // search
         include_once 'Services/Search/classes/class.ilSearchSettings.php';
         if ($rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
             include_once './Services/Search/classes/class.ilMainMenuSearchGUI.php';
             $main_search = new ilMainMenuSearchGUI();
             $html = "";
             // user interface plugin slot + default rendering
             include_once "./Services/UIComponent/classes/class.ilUIHookProcessor.php";
             $uip = new ilUIHookProcessor("Services/MainMenu", "main_menu_search", array("main_menu_gui" => $this, "main_menu_search_gui" => $main_search));
             if (!$uip->replaced()) {
                 $html = $main_search->getHTML();
             }
             $html = $uip->getHTML($html);
             if (strlen($html)) {
                 $this->tpl->setVariable('SEARCHBOX', $html);
             }
         }
         $this->renderStatusBox($this->tpl);
         // online help
         $this->renderHelpButtons();
     }
     if ($this->getMode() == self::MODE_FULL) {
         $mmle_html = "";
         // user interface plugin slot + default rendering
         include_once "./Services/UIComponent/classes/class.ilUIHookProcessor.php";
         $uip = new ilUIHookProcessor("Services/MainMenu", "main_menu_list_entries", array("main_menu_gui" => $this));
         if (!$uip->replaced()) {
             $mmle_tpl = new ilTemplate("tpl.main_menu_list_entries.html", true, true, "Services/MainMenu");
             $mmle_html = $this->renderMainMenuListEntries($mmle_tpl);
         }
         $mmle_html = $uip->getHTML($mmle_html);
         $this->tpl->setVariable("MAIN_MENU_LIST_ENTRIES", $mmle_html);
     }
     if ($this->getMode() != self::MODE_TOPBAR_MEMBERVIEW) {
         $link_dir = defined("ILIAS_MODULE") ? "../" : "";
         // login stuff
         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID) {
             include_once 'Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
             if (ilRegistrationSettings::_lookupRegistrationType() != IL_REG_DISABLED) {
                 $this->tpl->setCurrentBlock("registration_link");
                 $this->tpl->setVariable("TXT_REGISTER", $lng->txt("register"));
                 $this->tpl->setVariable("LINK_REGISTER", $link_dir . "register.php?client_id=" . rawurlencode(CLIENT_ID) . "&lang=" . $ilias->account->getCurrentLanguage());
                 $this->tpl->parseCurrentBlock();
             }
             // language selection
             $selection = self::getLanguageSelection();
             if ($selection) {
                 // bs-patch start
                 global $ilUser, $lng;
                 $this->tpl->setVariable("TXT_LANGSELECT", $lng->txt("language"));
                 // bs-patch end
                 $this->tpl->setVariable("LANG_SELECT", $selection);
             }
             $this->tpl->setCurrentBlock("userisanonymous");
             $this->tpl->setVariable("TXT_NOT_LOGGED_IN", $lng->txt("not_logged_in"));
             $this->tpl->setVariable("TXT_LOGIN", $lng->txt("log_in"));
             // #13058
             $target_str = $this->getLoginTargetPar() != "" ? $this->getLoginTargetPar() : ilTemplate::buildLoginTarget();
             $this->tpl->setVariable("LINK_LOGIN", $link_dir . "login.php?target=" . $target_str . "&client_id=" . rawurlencode(CLIENT_ID) . "&cmd=force_login&lang=" . $ilias->account->getCurrentLanguage());
             $this->tpl->parseCurrentBlock();
         } else {
             if ($this->getMode() != self::MODE_TOPBAR_REDUCED) {
                 $notificationSettings = new ilSetting('notifications');
                 $chatSettings = new ilSetting('chatroom');
                 /**
                  * @var $tpl ilTemplate
                  */
                 global $tpl;
                 if ($chatSettings->get('chat_enabled') && $notificationSettings->get('enable_osd')) {
                     $this->tpl->touchBlock('osd_enabled');
                     $this->tpl->touchBlock('osd_container');
                     include_once "Services/jQuery/classes/class.iljQueryUtil.php";
                     iljQueryUtil::initjQuery();
                     include_once 'Services/MediaObjects/classes/class.ilPlayerUtil.php';
                     ilPlayerUtil::initMediaElementJs();
                     $tpl->addJavaScript('Services/Notifications/templates/default/notifications.js');
                     $tpl->addCSS('Services/Notifications/templates/default/osd.css');
                     require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
                     require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
                     $notifications = ilNotificationOSDHandler::getNotificationsForUser($ilUser->getId());
                     $this->tpl->setVariable('NOTIFICATION_CLOSE_HTML', json_encode(ilGlyphGUI::get(ilGlyphGUI::CLOSE, $lng->txt('close'))));
                     $this->tpl->setVariable('INITIAL_NOTIFICATIONS', json_encode($notifications));
                     $this->tpl->setVariable('OSD_POLLING_INTERVALL', $notificationSettings->get('osd_polling_intervall') ? $notificationSettings->get('osd_polling_intervall') : '5');
                     $this->tpl->setVariable('OSD_PLAY_SOUND', $chatSettings->get('play_invitation_sound') && $ilUser->getPref('chat_play_invitation_sound') ? 'true' : 'false');
                     foreach ($notifications as $notification) {
                         if ($notification['type'] == 'osd_maint') {
                             continue;
                         }
                         $this->tpl->setCurrentBlock('osd_notification_item');
                         $this->tpl->setVariable('NOTIFICATION_ICON_PATH', $notification['data']->iconPath);
                         $this->tpl->setVariable('NOTIFICATION_TITLE', $notification['data']->title);
                         $this->tpl->setVariable('NOTIFICATION_LINK', $notification['data']->link);
                         $this->tpl->setVariable('NOTIFICATION_LINKTARGET', $notification['data']->linktarget);
                         $this->tpl->setVariable('NOTIFICATION_ID', $notification['notification_osd_id']);
                         $this->tpl->setVariable('NOTIFICATION_SHORT_DESCRIPTION', $notification['data']->shortDescription);
                         $this->tpl->parseCurrentBlock();
                     }
                 }
             }
             $this->tpl->setCurrentBlock("userisloggedin");
             $this->tpl->setVariable("TXT_LOGIN_AS", $lng->txt("login_as"));
             $user_img_src = $ilias->account->getPersonalPicturePath("small", true);
             $user_img_alt = $ilias->account->getFullname();
             $this->tpl->setVariable("USER_IMG", ilUtil::img($user_img_src, $user_img_alt));
             $this->tpl->setVariable("USR_LINK_PROFILE", "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToProfile");
             $this->tpl->setVariable("USR_TXT_PROFILE", $lng->txt("personal_profile"));
             $this->tpl->setVariable("USR_LINK_SETTINGS", "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSettings");
             $this->tpl->setVariable("USR_TXT_SETTINGS", $lng->txt("personal_settings"));
             $this->tpl->setVariable("TXT_LOGOUT2", $lng->txt("logout"));
             $this->tpl->setVariable("LINK_LOGOUT2", $link_dir . "logout.php?lang=" . $ilias->account->getCurrentLanguage());
             $this->tpl->setVariable("USERNAME", $ilias->account->getFullname());
             $this->tpl->setVariable("LOGIN", $ilias->account->getLogin());
             $this->tpl->setVariable("MATRICULATION", $ilias->account->getMatriculation());
             $this->tpl->setVariable("EMAIL", $ilias->account->getEmail());
             $this->tpl->parseCurrentBlock();
         }
     } else {
         // member view info
         $this->tpl->setVariable("TOPBAR_CLASS", " ilMemberViewMainHeader");
         $this->tpl->setVariable("MEMBER_VIEW_INFO", $lng->txt("mem_view_long"));
     }
     if (!$this->topbar_back_url) {
         include_once "./Modules/SystemFolder/classes/class.ilObjSystemFolder.php";
         $header_top_title = ilObjSystemFolder::_getHeaderTitle();
         if (trim($header_top_title) != "" && $this->tpl->blockExists("header_top_title")) {
             $this->tpl->setCurrentBlock("header_top_title");
             $this->tpl->setVariable("TXT_HEADER_TITLE", $header_top_title);
             $this->tpl->parseCurrentBlock();
         }
     } else {
         $this->tpl->setCurrentBlock("header_back_bl");
         $this->tpl->setVariable("URL_HEADER_BACK", $this->topbar_back_url);
         $this->tpl->setVariable("TXT_HEADER_BACK", $this->topbar_back_caption ? $this->topbar_back_caption : $lng->txt("back"));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     if ($this->getMode() == self::MODE_FULL) {
         // $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
         $this->tpl->setVariable("HEADER_URL", $this->getHeaderURL());
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.svg"));
     }
     include_once "./Modules/SystemFolder/classes/class.ilObjSystemFolder.php";
     // set link to return to desktop, not depending on a specific position in the hierarchy
     //$this->tpl->setVariable("SCRIPT_START", $this->getScriptTarget("start.php"));
     /*
     else
     {
     	$this->tpl->setVariable("HEADER_URL", $this->getHeaderURL());
     	$this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.svg"));
     }
     */
     $this->tpl->setVariable("TXT_MAIN_MENU", $lng->txt("main_menu"));
     $this->tpl->parseCurrentBlock();
 }
 /**
  * get tabs 
  */
 protected function getTabs()
 {
     $this->tabs_gui->addTarget('search', $this->ctrl->getLinkTargetByClass('illucenesearchgui'));
     if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
         $this->tabs_gui->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui'));
     }
     $fields = ilLuceneAdvancedSearchFields::getInstance();
     if (!ilSearchSettings::getInstance()->getHideAdvancedSearch() and $fields->getActiveFields()) {
         $this->tabs_gui->addTarget('search_advanced', $this->ctrl->getLinkTargetByClass('illuceneadvancedsearchgui'));
     }
     $this->tabs_gui->setTabActive('search_user');
 }
 /**
  * @return bool
  */
 protected function isLuceneSearchEnabled()
 {
     include_once 'Services/Search/classes/class.ilSearchSettings.php';
     if (ilSearchSettings::getInstance()->enabledLucene() && strlen($this->filter['mail_filter'])) {
         return true;
     }
 }
 /**
  * Append relevance 
  * @return
  */
 protected function appendRelevance($a_obj_id)
 {
     if ($this->getMode() != self::MODE_LUCENE) {
         return '';
     }
     if (!(int) $this->getRelevance($a_obj_id)) {
         return '';
     }
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     if (!ilSearchSettings::getInstance()->isRelevanceVisible()) {
         return '';
     }
     $tpl = new ilTemplate('tpl.lucene_relevance.html', true, true, 'Services/Search');
     $width1 = (int) $this->getRelevance($a_obj_id);
     $width2 = (int) (100 - $width1);
     $tpl->setCurrentBlock('relevance');
     $tpl->setVariable('VAL_REL', sprintf("%d %%", $this->getRelevance($a_obj_id)));
     $tpl->setVariable('WIDTH_A', $width1);
     $tpl->setVariable('WIDTH_B', $width2);
     $tpl->setVariable('IMG_A', ilUtil::getImagePath("relevance_blue.png"));
     $tpl->setVariable('IMG_B', ilUtil::getImagePath("relevance_dark.png"));
     $tpl->parseCurrentBlock();
     $html = $tpl->get();
     return $html;
 }
 /**
  * Get completion list
  * @param string $a_str
  * @return string
  */
 public function getList($a_str)
 {
     /**
      * @var $ilDB  ilDB
      * @var $ilLog ilLog
      */
     global $ilDB, $ilLog;
     $select_part = $this->getSelectPart();
     $where_part = $this->getWherePart($a_str);
     $order_by_part = $this->getOrderByPart();
     $query = implode(" ", array('SELECT ' . $select_part, 'FROM ' . $this->getFromPart(), $where_part ? 'WHERE ' . $where_part : '', $order_by_part ? 'ORDER BY ' . $order_by_part : ''));
     $ilLog->write(__METHOD__ . ': Query: ' . $query);
     $res = $ilDB->query($query);
     // add email only if it is "searchable"
     $add_email = true;
     include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
     if ($this->isFieldSearchableCheckEnabled() && !ilUserSearchOptions::_isEnabled("email")) {
         $add_email = false;
     }
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     $max = $this->getLimit() ? $this->getLimit() : ilSearchSettings::getInstance()->getAutoCompleteLength();
     $cnt = 0;
     $more_results = FALSE;
     $result = array();
     while (($rec = $ilDB->fetchAssoc($res)) && $cnt < $max + 1) {
         if ($cnt >= $max) {
             $more_results = TRUE;
             break;
         }
         // @todo: Open discussion: We should remove all non public fields from result
         $label = $rec['lastname'] . ', ' . $rec['firstname'] . ' [' . $rec['login'] . ']';
         if ($add_email && $rec['email'] && (self::PRIVACY_MODE_RESPECT_USER_SETTING != $this->getPrivacyMode() || 'y' == $rec['email_value'])) {
             $label .= ', ' . $rec['email'];
         }
         $result[$cnt]['value'] = (string) $rec[$this->result_field];
         $result[$cnt]['label'] = $label;
         $result[$cnt]['id'] = $rec['usr_id'];
         $cnt++;
     }
     include_once 'Services/JSON/classes/class.ilJsonUtil.php';
     $result_json['items'] = $result;
     $result_json['hasMoreResults'] = $more_results;
     $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($result_json, TRUE));
     return ilJsonUtil::encode($result_json);
 }
 /**
  * Append relevance 
  * @return
  */
 protected function appendRelevance($a_obj_id)
 {
     if ($this->getMode() != self::MODE_LUCENE) {
         return '';
     }
     if (!(int) $this->getRelevance($a_obj_id)) {
         return '';
     }
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     if (!ilSearchSettings::getInstance()->isRelevanceVisible()) {
         return '';
     }
     $tpl = new ilTemplate('tpl.lucene_relevance.html', true, true, 'Services/Search');
     include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
     $pbar = ilProgressBar::getInstance();
     $pbar->setCurrent($this->getRelevance());
     $this->tpl->setCurrentBlock('relevance');
     $this->tpl->setVariable('REL_PBAR', $pbar->render());
     $this->tpl->parseCurrentBlock();
     $html = $tpl->get();
     return $html;
 }
 /**
  *  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();
     }
 }
 function performSearch()
 {
     global $ilUser;
     $this->initSearchType(self::TYPE_LOM);
     if (!isset($_GET['page_number']) and $this->search_mode != 'in_results') {
         unset($_SESSION['adv_max_page']);
         $this->search_cache->deleteCachedEntries();
     }
     if (isset($_POST['query'])) {
         $this->search_cache->setQuery($_POST['query']);
     }
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $res =& new ilSearchResult();
     if ($res_con =& $this->__performContentSearch()) {
         $this->__storeEntries($res, $res_con);
     }
     if ($res_lan =& $this->__performLanguageSearch()) {
         $this->__storeEntries($res, $res_lan);
     }
     if ($res_gen =& $this->__performGeneralSearch()) {
         $this->__storeEntries($res, $res_gen);
     }
     if ($res_lif =& $this->__performLifecycleSearch()) {
         $this->__storeEntries($res, $res_lif);
     }
     if ($res_con =& $this->__performContributeSearch()) {
         $this->__storeEntries($res, $res_con);
     }
     if ($res_ent =& $this->__performEntitySearch()) {
         $this->__storeEntries($res, $res_ent);
     }
     if ($res_req =& $this->__performRequirementSearch()) {
         $this->__storeEntries($res, $res_req);
     }
     if ($res_for =& $this->__performFormatSearch()) {
         $this->__storeEntries($res, $res_for);
     }
     if ($res_edu =& $this->__performEducationalSearch()) {
         $this->__storeEntries($res, $res_edu);
     }
     if ($res_typ =& $this->__performTypicalAgeRangeSearch()) {
         $this->__storeEntries($res, $res_typ);
     }
     if ($res_rig =& $this->__performRightsSearch()) {
         $this->__storeEntries($res, $res_rig);
     }
     if ($res_cla =& $this->__performClassificationSearch()) {
         $this->__storeEntries($res, $res_cla);
     }
     if ($res_tax =& $this->__performTaxonSearch()) {
         $this->__storeEntries($res, $res_tax);
     }
     if ($res_key =& $this->__performKeywordSearch()) {
         $this->__storeEntries($res, $res_key);
     }
     $this->searchAdvancedMD($res);
     if ($this->search_mode == 'in_results') {
         include_once 'Services/Search/classes/class.ilSearchResult.php';
         $old_result_obj = new ilSearchResult($ilUser->getId());
         $old_result_obj->read(ADVANCED_MD_SEARCH);
         $res->diffEntriesFromResult($old_result_obj);
     }
     $res->filter($this->getRootNode(), ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND);
     $res->save();
     $this->showSearch();
     if (!count($res->getResults())) {
         ilUtil::sendInfo($this->lng->txt('search_no_match'));
     }
     if ($res->isLimitReached()) {
         #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
         #ilUtil::sendInfo($message);
     }
     $this->addPager($res, 'adv_max_page');
     include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
     $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD);
     $presentation->setResults($res->getResultsForPresentation());
     $presentation->setPreviousNext($this->prev_link, $this->next_link);
     if ($presentation->render()) {
         $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
     }
     return true;
 }
 function keywordAutocomplete()
 {
     $force_all = (bool) $_GET["fetchall"];
     include_once "./Services/MetaData/classes/class.ilMDKeyword.php";
     $res = ilMDKeyword::_getMatchingKeywords(ilUtil::stripSlashes($_GET["term"]), "blp", $this->getParentObjId());
     include_once "./Services/Search/classes/class.ilSearchSettings.php";
     $cut = (int) ilSearchSettings::getInstance()->getAutoCompleteLength();
     $has_more = false;
     $result = array();
     foreach ($res as $r) {
         if (!$force_all && sizeof($result["items"]) >= $cut) {
             $has_more = true;
             break;
         }
         $entry = new stdClass();
         $entry->value = $r;
         $entry->label = $r;
         $result["items"][] = $entry;
     }
     $result["hasMoreResults"] = $has_more;
     include_once './Services/JSON/classes/class.ilJsonUtil.php';
     echo ilJsonUtil::encode($result);
     exit;
 }
 /**
  * get tabs 
  */
 protected function getTabs()
 {
     if (ilSearchSettings::getInstance()->getHideAdvancedSearch()) {
         return false;
     }
     $this->tabs_gui->addTarget('search', $this->ctrl->getLinkTargetByClass('illucenesearchgui'));
     if ($this->fields->getActiveFields()) {
         $this->tabs_gui->addTarget('search_advanced', $this->ctrl->getLinkTarget($this));
     }
     $this->tabs_gui->setTabActive('search_advanced');
 }
 /**
  * Init standard search form.
  */
 public function getSearchAreaForm()
 {
     global $lng, $ilCtrl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setOpenTag(false);
     $form->setCloseTag(false);
     // term combination
     $radg = new ilHiddenInputGUI('search_term_combination');
     $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
     $form->addItem($radg);
     // search area
     include_once "./Services/Form/classes/class.ilRepositorySelectorInputGUI.php";
     $ti = new ilRepositorySelectorInputGUI($lng->txt("search_area"), "area");
     $ti->setSelectText($lng->txt("search_select_search_area"));
     $form->addItem($ti);
     $ti->readFromSession();
     // alex, 15.8.2012: Added the following lines to get the value
     // from the main menu top right input search form
     if (isset($_POST["root_id"])) {
         $ti->setValue($_POST["root_id"]);
         $ti->writeToSession();
     }
     $form->setFormAction($ilCtrl->getFormAction($this, 'performSearch'));
     return $form;
 }
 /**
  * get reference of ilFulltextWikiContentSearch
  * 
  * @param object query parser object
  * @return object reference of ilFulltextWikiContentSearch
  */
 public static function _getWikiContentSearchInstance($query_parser)
 {
     if (ilSearchSettings::getInstance()->enabledIndex()) {
         include_once 'Services/Search/classes/Fulltext/class.ilFulltextWikiContentSearch.php';
         return new ilFulltextWikiContentSearch($query_parser);
     } else {
         include_once 'Services/Search/classes/Like/class.ilLikeWikiContentSearch.php';
         return new ilLikeWikiContentSearch($query_parser);
     }
 }
 /**
  * Show search form
  * @return boolean
  */
 protected function showSearchForm()
 {
     global $ilCtrl, $lng;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_search.html', 'Services/Search');
     // include js needed
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     ilOverlayGUI::initJavascript();
     $this->tpl->addJavascript("./Services/Search/js/Search.js");
     $this->tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, 'performSearch'));
     $this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
     $this->tpl->setVariable("TXT_SEARCH", $lng->txt("search"));
     $this->tpl->setVariable("TXT_OPTIONS", $lng->txt("options"));
     $this->tpl->setVariable("ARR_IMG", ilUtil::img(ilUtil::getImagePath("mm_down_arrow_dark.png")));
     $this->tpl->setVariable("TXT_COMBINATION", $lng->txt("search_term_combination"));
     $this->tpl->setVariable('TXT_COMBINATION_DEFAULT', ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND ? $lng->txt('search_all_words') : $lng->txt('search_any_word'));
     $this->tpl->setVariable('TXT_TYPE_DEFAULT', $lng->txt("search_off"));
     $this->tpl->setVariable("TXT_AREA", $lng->txt("search_area"));
     $this->tpl->setVariable("TXT_FILTER_BY_TYPE", $lng->txt("search_filter_by_type"));
     $this->tpl->setVariable('FORM', $this->form->getHTML());
     // search area form
     $this->tpl->setVariable('SEARCH_AREA_FORM', $this->getSearchAreaForm()->getHTML());
     $this->tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
     return true;
 }
 protected function parseRelevance($sub_item)
 {
     if (!ilSearchSettings::getInstance()->isSubRelevanceVisible() || !ilSearchSettings::enabledLucene()) {
         return '';
     }
     $relevance = $this->getHighlighter()->getRelevance($this->getObjId(), $sub_item);
     $this->tpl->addBlockFile('SUB_REL', 'sub_rel', 'tpl.lucene_sub_relevance.html', 'Services/Search');
     include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
     $pbar = ilProgressBar::getInstance();
     $pbar->setCurrent($relevance);
     $this->tpl->setCurrentBlock('relevance');
     $this->tpl->setVariable('REL_PBAR', $pbar->render());
     $this->tpl->parseCurrentBlock();
 }
 function searchObjects($sid, $types, $key, $combination, $user_id)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!is_array($types)) {
         return $this->__raiseError('Types must be an array of object types.', 'Client');
     }
     if ($combination != 'and' and $combination != 'or') {
         return $this->__raiseError('No valid combination given. Must be "and" or "or".', 'Client');
     }
     // begin-patch fm
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     if (ilSearchSettings::getInstance()->enabledLucene()) {
         ilSearchSettings::getInstance()->setMaxHits(25);
         include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
         $query_parser = new ilLuceneQueryParser($key);
         $query_parser->parse();
         include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
         $searcher = ilLuceneSearcher::getInstance($query_parser);
         $searcher->search();
         include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
         include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
         $filter = ilLuceneSearchResultFilter::getInstance($user_id);
         $filter->setCandidates($searcher->getResult());
         $filter->filter();
         $result_ids = $filter->getResults();
         $objs = array();
         $objs[ROOT_FOLDER_ID] = ilObjectFactory::getInstanceByRefId(ROOT_FOLDER_ID, false);
         foreach ((array) $result_ids as $ref_id => $obj_id) {
             $obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
             if ($obj instanceof ilObject) {
                 $objs[] = $obj;
             }
         }
         include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
         $highlighter = new ilLuceneHighlighterResultParser();
         if ($filter->getResultObjIds()) {
             $highlighter = $searcher->highlight($filter->getResultObjIds());
         }
     } else {
         include_once './Services/Search/classes/class.ilQueryParser.php';
         $query_parser =& new ilQueryParser($key);
         #$query_parser->setMinWordLength(3);
         $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
         $query_parser->parse();
         if (!$query_parser->validate()) {
             return $this->__raiseError($query_parser->getMessage(), 'Client');
         }
         #include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
         #$object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
         include_once './Services/Search/classes/Like/class.ilLikeObjectSearch.php';
         $object_search = new ilLikeObjectSearch($query_parser);
         $object_search->setFilter($types);
         $res =& $object_search->performSearch();
         if ($user_id) {
             $res->setUserId($user_id);
         }
         // begin-patch fm
         $res->setMaxHits(100);
         // begin-patch fm
         $res->filter(ROOT_FOLDER_ID, $combination == 'and' ? true : false);
         $counter = 0;
         $objs = array();
         foreach ($res->getUniqueResults() as $entry) {
             $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false);
             if ($obj instanceof ilObject) {
                 $objs[] = $obj;
             }
         }
     }
     if (!count($objs)) {
         //rku: todo: das ist nicht soap konform! - hier muss ein XML zurück geliefert werden
         return '';
     }
     include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
     $xml_writer = new ilObjectXMLWriter();
     // begin-patch fm
     if (ilSearchSettings::getInstance()->enabledLucene()) {
         $xml_writer->enableReferences(false);
         $xml_writer->setMode(ilObjectXmlWriter::MODE_SEARCH_RESULT);
         $xml_writer->setHighlighter($highlighter);
     }
     $xml_writer->enablePermissionCheck(true);
     if ($user_id) {
         $xml_writer->setUserId($user_id);
         $xml_writer->enableOperations(true);
     }
     $xml_writer->setObjects($objs);
     if ($xml_writer->start()) {
         #$GLOBALS['ilLog']->write(__METHOD__.': '.$xml_writer->xmlDumpMem(true));
         return $xml_writer->getXML();
     }
     return $this->__raiseError('Cannot create object xml !', 'Server');
 }
 /**
  * desc
  *
  * @param
  * @return
  */
 function renderMainMenuListEntries($a_tpl, $a_call_get = true)
 {
     global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting, $ilAccess;
     // personal desktop
     if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID) {
         /*$this->renderEntry($a_tpl, "desktop",
         		$lng->txt("personal_desktop"),
         		$this->getScriptTarget("ilias.php?baseClass=ilPersonalDesktopGUI"),
         		$this->target);*/
         //			$this->renderDropDown($a_tpl, "desktop");
         $this->renderEntry($a_tpl, "desktop", $lng->txt("personal_desktop"), "#");
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $ov = new ilOverlayGUI("mm_desk_ov");
         $ov->setTrigger("mm_desk_tr");
         $ov->setAnchor("mm_desk_tr");
         $ov->setAutoHide(false);
         $ov->add();
     }
     // repository
     if ($ilAccess->checkAccess('visible', '', ROOT_FOLDER_ID)) {
         include_once './Services/Link/classes/class.ilLink.php';
         $nd = $tree->getNodeData(ROOT_FOLDER_ID);
         $title = $nd["title"];
         if ($title == "ILIAS") {
             $title = $lng->txt("repository");
         }
         //$this->renderEntry($a_tpl, "repository",
         //	$title,
         //	ilLink::_getStaticLink(1,'root',true),
         //	$this->target);
         if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID || IS_PAYMENT_ENABLED) {
             $this->renderEntry($a_tpl, "repository", $title, "#");
             include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
             $ov = new ilOverlayGUI("mm_rep_ov");
             $ov->setTrigger("mm_rep_tr");
             $ov->setAnchor("mm_rep_tr");
             $ov->setAutoHide(false);
             $ov->add();
         }
     }
     // search
     include_once 'Services/Search/classes/class.ilSearchSettings.php';
     if ($rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
         /*			$this->renderEntry($a_tpl, "search",
         				$lng->txt("search"),
         				$this->getScriptTarget('ilias.php?baseClass=ilSearchController'),
         				$this->target); */
     }
     // webshop
     if (IS_PAYMENT_ENABLED) {
         $title = $lng->txt("shop");
         $this->renderEntry($a_tpl, "shop", $title, "#");
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $ov = new ilOverlayGUI("mm_shop_ov");
         $ov->setTrigger("mm_shop_tr");
         $ov->setAnchor("mm_shop_tr");
         $ov->setAutoHide(false);
         $ov->add();
     }
     // administration
     if (ilMainMenuGUI::_checkAdministrationPermission()) {
         //$this->renderEntry($a_tpl, "administration",
         //	$lng->txt("administration"),
         //	$this->getScriptTarget("ilias.php?baseClass=ilAdministrationGUI"),
         //	$this->target);
         $this->renderDropDown($a_tpl, "administration");
     }
     // navigation history
     /*		require_once("Services/Navigation/classes/class.ilNavigationHistoryGUI.php");
     		$nav_hist = new ilNavigationHistoryGUI();
     		$nav_html = $nav_hist->getHTML();
     		if ($nav_html != "")
     		{
     
     			$a_tpl->setCurrentBlock("nav_history");
     			$a_tpl->setVariable("TXT_LAST_VISITED", $lng->txt("last_visited"));
     			$a_tpl->setVariable("NAVIGATION_HISTORY", $nav_html);
     			$a_tpl->parseCurrentBlock();
     		}*/
     if ($a_call_get) {
         return $a_tpl->get();
     }
     return "";
 }
 /**
  * Show search form
  * @return boolean
  */
 protected function showSearchForm()
 {
     global $ilCtrl, $lng;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_search.html', 'Services/Search');
     // include js needed
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     ilOverlayGUI::initJavascript();
     $this->tpl->addJavascript("./Services/Search/js/Search.js");
     include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     $this->tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, 'performSearch'));
     $this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
     include_once "./Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $btn = ilSubmitButton::getInstance();
     $btn->setCommand("performSearch");
     $btn->setCaption("search");
     $this->tpl->setVariable("SUBMIT_BTN", $btn->render());
     $this->tpl->setVariable("TXT_OPTIONS", $lng->txt("options"));
     $this->tpl->setVariable("ARR_IMG", ilGlyphGUI::get(ilGlyphGUI::CARET));
     $this->tpl->setVariable("TXT_COMBINATION", $lng->txt("search_term_combination"));
     $this->tpl->setVariable('TXT_COMBINATION_DEFAULT', ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND ? $lng->txt('search_all_words') : $lng->txt('search_any_word'));
     $this->tpl->setVariable("TXT_AREA", $lng->txt("search_area"));
     if (ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
         $this->tpl->setCurrentBlock("type_sel");
         $this->tpl->setVariable('TXT_TYPE_DEFAULT', $lng->txt("search_off"));
         $this->tpl->setVariable("ARR_IMGT", ilGlyphGUI::get(ilGlyphGUI::CARET));
         $this->tpl->setVariable("TXT_FILTER_BY_TYPE", $lng->txt("search_filter_by_type"));
         $this->tpl->setVariable('FORM', $this->form->getHTML());
         $this->tpl->parseCurrentBlock();
     }
     // search area form
     $this->tpl->setVariable('SEARCH_AREA_FORM', $this->getSearchAreaForm()->getHTML());
     $this->tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
     return true;
 }
 /**
  * Check if relevance is visible
  * @return 
  */
 protected function enabledRelevance()
 {
     return ilSearchSettings::getInstance()->enabledLucene() and ilSearchSettings::getInstance()->isRelevanceVisible();
 }
 /**
  * Constructor 
  * @param
  * @return
  */
 public function __construct($a_cmd_class)
 {
     $this->cmdClass = $a_cmd_class;
     self::$MAX_SUBITEMS = ilSearchSettings::getInstance()->getMaxSubitems();
 }