• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Search/classes/class.ilAdvancedSearchGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00035 include_once 'Services/Search/classes/class.ilSearchBaseGUI.php';
00036 include_once 'Services/MetaData/classes/class.ilMDUtilSelect.php';
00037 
00038 class ilAdvancedSearchGUI extends ilSearchBaseGUI
00039 {
00040 
00045         var $options = array();
00046 
00051         function ilAdvancedSearchGUI()
00052         {
00053                 parent::ilSearchBaseGUI();
00054 
00055                 $this->lng->loadLanguageModule('meta');
00056 
00057                 $this->__setSearchOptions($_POST);
00058         }
00059 
00060         function getRootNode()
00061         {
00062                 return ROOT_FOLDER_ID;
00063         }
00064 
00065 
00070         function &executeCommand()
00071         {
00072                 global $rbacsystem;
00073 
00074                 $next_class = $this->ctrl->getNextClass($this);
00075                 $cmd = $this->ctrl->getCmd();
00076 
00077                 switch($next_class)
00078                 {
00079                         default:
00080                                 if(!$cmd)
00081                                 {
00082                                         $cmd = "showSavedResults";
00083                                 }
00084 
00085                                 $this->prepareOutput();
00086                                 $this->$cmd();
00087                                 break;
00088                 }
00089                 return true;
00090         }
00091         function reset()
00092         {
00093                 $this->options = array();
00094                 $this->showSearch();
00095         }
00096 
00097         function searchInResults()
00098         {
00099                 $this->search_mode = 'in_results';
00100                 $this->performSearch();
00101 
00102                 return true;
00103         }
00104 
00105 
00106         function performSearch()
00107         {
00108                 global $ilUser;
00109 
00110                 include_once 'Services/Search/classes/class.ilSearchResult.php';
00111 
00112                 $res =& new ilSearchResult();
00113 
00114                 if($res_con =& $this->__performContentSearch())
00115                 {
00116                         $this->__storeEntries($res,$res_con);
00117                 }
00118                 if($res_tit =& $this->__performTitleSearch())
00119                 {
00120                         $this->__storeEntries($res,$res_tit);
00121                 }
00122                 if($res_lan =& $this->__performLanguageSearch())
00123                 {
00124                         $this->__storeEntries($res,$res_lan);
00125                 }
00126                 if($res_gen =& $this->__performGeneralSearch())
00127                 {
00128                         $this->__storeEntries($res,$res_gen);
00129                 }
00130                 if($res_lif =& $this->__performLifecycleSearch())
00131                 {
00132                         $this->__storeEntries($res,$res_lif);
00133                 }
00134                 if($res_con =& $this->__performContributeSearch())
00135                 {
00136                         $this->__storeEntries($res,$res_con);
00137                 }
00138                 if($res_ent =& $this->__performEntitySearch())
00139                 {
00140                         $this->__storeEntries($res,$res_ent);
00141                 }
00142                 if($res_req =& $this->__performRequirementSearch())
00143                 {
00144                         $this->__storeEntries($res,$res_req);
00145                 }
00146                 if($res_for =& $this->__performFormatSearch())
00147                 {
00148                         $this->__storeEntries($res,$res_for);
00149                 }
00150                 if($res_edu =& $this->__performEducationalSearch())
00151                 {
00152                         $this->__storeEntries($res,$res_edu);
00153                 }
00154                 if($res_typ =& $this->__performTypicalAgeRangeSearch())
00155                 {
00156                         $this->__storeEntries($res,$res_typ);
00157                 }
00158                 if($res_rig =& $this->__performRightsSearch())
00159                 {
00160                         $this->__storeEntries($res,$res_rig);
00161                 }
00162                 if($res_cla =& $this->__performClassificationSearch())
00163                 {
00164                         $this->__storeEntries($res,$res_cla);
00165                 }
00166                 if($res_tax =& $this->__performTaxonSearch())
00167                 {
00168                         $this->__storeEntries($res,$res_tax);
00169                 }
00170                 if($res_key =& $this->__performKeywordSearch())
00171                 {
00172                         $this->__storeEntries($res,$res_key);
00173                 }
00174 
00175                 if($this->search_mode == 'in_results')
00176                 {
00177                         include_once 'Services/Search/classes/class.ilSearchResult.php';
00178 
00179                         $old_result_obj = new ilSearchResult($ilUser->getId());
00180                         $old_result_obj->read(ADVANCED_SEARCH);
00181 
00182                         $res->diffEntriesFromResult($old_result_obj);
00183                 }
00184 
00185                 
00186                 $res->filter($this->getRootNode(),true);
00187 
00188                 if(!count($res->getResults()))
00189                 {
00190                         sendInfo($this->lng->txt('search_no_match'));
00191                 }
00192                 else
00193                 {
00194                         $this->__showSearchInResults();
00195                 }                       
00196 
00197                 if($res->isLimitReached())
00198                 {
00199                         $message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
00200                         sendInfo($message);
00201                 }
00202 
00203                 $this->showSearch();
00204 
00205                 include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00206 
00207                 $search_result_presentation = new ilSearchResultPresentationGUI($res);
00208                 $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00209 
00210                 $res->setUserId($ilUser->getId());
00211                 $res->save(ADVANCED_SEARCH);
00212 
00213 
00214                 return true;
00215         }
00216 
00217 
00218         function showSearch()
00219         {
00220                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.advanced_search.html','Services/Search');
00221 
00222                 // Header
00223                 $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormAction($this));
00224                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('search_advanced'));
00225 
00226                 // Content
00227                 $this->tpl->setVariable("TXT_CONTENT",$this->lng->txt('content'));
00228                 $this->tpl->setVariable("TXT_OR",$this->lng->txt('search_any_word'));
00229                 $this->tpl->setVariable("TXT_AND",$this->lng->txt('search_all_words'));
00230 
00231                 if($this->options['content_ao'] == 'and')
00232                 {
00233                         $this->tpl->setVariable("CONTENT_AND_CHECKED",'checked=checked');
00234                 }
00235                 else
00236                 {
00237                         $this->tpl->setVariable("CONTENT_OR_CHECKED",'checked=checked');
00238                 }
00239                 $this->tpl->setVariable("FRM_CONTENT",ilUtil::prepareFormOutput($this->options['content']));
00240 
00241                 // Type
00242                 $this->tpl->setVariable("TXT_TYPE",$this->lng->txt('type'));
00243                 $this->tpl->setVariable("SEL_TYPE",$this->__getFilterSelect());
00244 
00245                 // General
00246                 $this->tpl->setVariable("TXT_GEN",$this->lng->txt('meta_general'));
00247                 $this->tpl->setVariable("TXT_LAN",$this->lng->txt('language'));
00248                 $this->tpl->setVariable("SEL_LAN",ilMDUtilSelect::_getLanguageSelect($this->options['language'],
00249                                                                                                                                                          'search_adv[language]'
00250                                                                                                                                                          ,array(0 => $this->lng->txt('meta_please_select'))));
00251 
00252                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('meta_title').'/'.
00253                                                                 $this->lng->txt('meta_keyword').'/'.
00254                                                                 $this->lng->txt('meta_description'));
00255                 $this->tpl->setVariable("TXT_COV",$this->lng->txt('meta_coverage'));
00256                 $this->tpl->setVariable("TXT_STRUCT",$this->lng->txt('meta_structure'));
00257                 $this->tpl->setVariable("SEL_STRUCT",ilMDUtilSelect::_getStructureSelect($this->options['structure'],
00258                                                                                                                                                                  'search_adv[structure]',
00259                                                                                                                                                                  array(0 => $this->lng->txt('meta_please_select'))));
00260                 $this->tpl->setVariable("FRM_TITLE",ilUtil::prepareFormOutput($this->options['title'],true));
00261                 $this->tpl->setVariable("FRM_COVERAGE",ilUtil::prepareFormOutput($this->options['coverage'],true));
00262 
00263                 if($this->options['title_ao'] == 'and')
00264                 {
00265                         $this->tpl->setVariable("TITLE_AND_CHECKED",'checked=checked');
00266                 }
00267                 else
00268                 {
00269                         $this->tpl->setVariable("TITLE_OR_CHECKED",'checked=checked');
00270                 }
00271                 if($this->options['coverage_ao'] == 'and')
00272                 {
00273                         $this->tpl->setVariable("COVERAGE_AND_CHECKED",'checked=checked');
00274                 }
00275                 else
00276                 {
00277                         $this->tpl->setVariable("COVERAGE_OR_CHECKED",'checked=checked');
00278                 }
00279 
00280                 
00281 
00282                 // Lifecycle
00283                 $this->tpl->setVariable("TXT_LIFECYCLE",$this->lng->txt('meta_lifecycle'));
00284                 $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('meta_status'));
00285                 $this->tpl->setVariable("SEL_STATUS",
00286                                                                 ilMDUtilSelect::_getStatusSelect($this->options['status'],
00287                                                                                                                                  'search_adv[status]',
00288                                                                                                                                  array(0 => $this->lng->txt('meta_please_select'))));
00289                 $this->tpl->setVariable("TXT_VERSION",$this->lng->txt('meta_version'));
00290                 $this->tpl->setVariable("FRM_VERSION",ilUtil::prepareFormOutput($this->options['version'],true));
00291 
00292                 $this->tpl->setVariable("TXT_CONTRIBUTOR",$this->lng->txt('meta_contribute'));
00293                 $this->tpl->setVariable("SEL_CONTRIBUTOR",
00294                                                                 ilMDUtilSelect::_getRoleSelect($this->options['role'],
00295                                                                                                                            'search_adv[role]',
00296                                                                                                                            array(0 => $this->lng->txt('meta_please_select'))));
00297                 $this->tpl->setVariable("FRM_ENTITY",ilUtil::prepareFormOutput($this->options['entity'],true));
00298 
00299                 if($this->options['entity_ao'] == 'and')
00300                 {
00301                         $this->tpl->setVariable("ENTITY_AND_CHECKED",'checked=checked');
00302                 }
00303                 else
00304                 {
00305                         $this->tpl->setVariable("ENTITY_OR_CHECKED",'checked=checked');
00306                 }
00307                 if($this->options['version_ao'] == 'and')
00308                 {
00309                         $this->tpl->setVariable("VERSION_AND_CHECKED",'checked=checked');
00310                 }
00311                 else
00312                 {
00313                         $this->tpl->setVariable("VERSION_OR_CHECKED",'checked=checked');
00314                 }
00315 
00316                 // Technical
00317                 $this->tpl->setVariable("TXT_TECHNICAL",$this->lng->txt('meta_technical'));
00318                 $this->tpl->setVariable("TXT_FORMAT",$this->lng->txt('meta_format'));
00319                 $this->tpl->setVariable("TXT_OS",$this->lng->txt('meta_operating_system'));
00320                 $this->tpl->setVariable("TXT_BROWSER",$this->lng->txt('meta_browser'));
00321                 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('meta_duration'));
00322                 $this->tpl->setVariable("FROM",$this->lng->txt('from'));
00323                 $this->tpl->setVariable("TIL",$this->lng->txt('until'));
00324                 
00325                 $this->tpl->setVariable("SEL_FORMAT",
00326                                                                 ilMDUtilSelect::_getFormatSelect($this->options['format'],
00327                                                                                                                                  'search_adv[format]',
00328                                                                                                                                  array(0 => $this->lng->txt('meta_please_select'))));
00329                 $this->tpl->setVariable("SEL_OS",
00330                                                                 ilMDUtilSelect::_getOperatingSystemSelect($this->options['os'],
00331                                                                                                                                                   'search_adv[os]',
00332                                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00333                 $this->tpl->setVariable("SEL_BROWSER",
00334                                                                 ilMDUtilSelect::_getBrowserSelect($this->options['browser'],
00335                                                                                                                                   'search_adv[browser]',
00336                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00337                 $this->tpl->setVariable("SEL_DURATION_1",
00338                                                                 ilMDUtilSelect::_getDurationSelect('','md_lan',array(0 => $this->lng->txt('meta_please_select'))));
00339                 $this->tpl->setVariable("SEL_DURATION_2",
00340                                                                 ilMDUtilSelect::_getDurationSelect('','md_lan',array(0 => $this->lng->txt('meta_please_select'))));
00341 
00342                 // Educational
00343                 $this->tpl->setVariable("TXT_EDUCATIONAL",$this->lng->txt('meta_education'));
00344                 $this->tpl->setVariable("TXT_INTERACTIVITY",$this->lng->txt('meta_interactivity_type'));
00345                 $this->tpl->setVariable("TXT_RESOURCE",$this->lng->txt('meta_learning_resource_type'));
00346                 $this->tpl->setVariable("TXT_LEVEL",$this->lng->txt('meta_interactivity_level'));
00347                 $this->tpl->setVariable("TXT_DENSITY",$this->lng->txt('meta_semantic_density'));
00348                 $this->tpl->setVariable("TXT_END_USER",$this->lng->txt('meta_intended_end_user_role'));
00349                 $this->tpl->setVariable("TXT_CONTEXT",$this->lng->txt('meta_context'));
00350                 $this->tpl->setVariable("TXT_DIFFICULTY",$this->lng->txt('meta_difficulty'));
00351                 $this->tpl->setVariable("TXT_AGE_RANGE",$this->lng->txt('meta_typical_age_range'));
00352                 $this->tpl->setVariable("TXT_LEARNING_TIME",$this->lng->txt('meta_typical_learning_time'));
00353 
00354 
00355                 $this->tpl->setVariable("SEL_INTERACTIVITY",
00356                                                                 ilMDUtilSelect::_getInteractivityTypeSelect($this->options['int_type'],
00357                                                                                                                                                         'search_adv[int_type]',
00358                                                                                                                                                         array(0 => $this->lng->txt('meta_please_select'))));
00359                 $this->tpl->setVariable("SEL_RESOURCE",
00360                                                                 ilMDUtilSelect::_getLearningResourceTypeSelect($this->options['lea_type'],
00361                                                                                                                                                            'search_adv[lea_type]',
00362                                                                                                                                                            array(0 => $this->lng->txt('meta_please_select'))));
00363                 $this->tpl->setVariable("SEL_LEVEL_1",
00364                                                                 ilMDUtilSelect::_getInteractivityLevelSelect($this->options['int_level_1'],
00365                                                                                                                                                          'search_adv[int_level_1]',
00366                                                                                                                                                          array(0 => $this->lng->txt('meta_please_select'))));
00367                 $this->tpl->setVariable("SEL_LEVEL_2",
00368                                                                 ilMDUtilSelect::_getInteractivityLevelSelect($this->options['int_level_2'],
00369                                                                                                                                                          'search_adv[int_level_2]',
00370                                                                                                                                                          array(0 => $this->lng->txt('meta_please_select'))));
00371                 $this->tpl->setVariable("SEL_DENSITY_1",
00372                                                                 ilMDUtilSelect::_getSemanticDensitySelect($this->options['sem_1'],
00373                                                                                                                                                   'search_adv[sem_1]',
00374                                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00375                 $this->tpl->setVariable("SEL_DENSITY_2",
00376                                                                 ilMDUtilSelect::_getSemanticDensitySelect($this->options['sem_2'],
00377                                                                                                                                                   'search_adv[sem_2]',
00378                                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00379                 $this->tpl->setVariable("SEL_END_USER",
00380                                                                 ilMDUtilSelect::_getIntendedEndUserRoleSelect($this->options['int_role'],
00381                                                                                                                                                           'search_adv[int_role]',
00382                                                                                                                                                           array(0 => $this->lng->txt('meta_please_select'))));
00383                 $this->tpl->setVariable("SEL_CONTEXT",
00384                                                                 ilMDUtilSelect::_getContextSelect($this->options['con'],
00385                                                                                                                                   'search_adv[con]',
00386                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00387                 $this->tpl->setVariable("SEL_DIFFICULTY_1",
00388                                                                 ilMDUtilSelect::_getDifficultySelect($this->options['dif_1'],
00389                                                                                                                                          'search_adv[dif_1]',
00390                                                                                                                                          array(0 => $this->lng->txt('meta_please_select'))));
00391                 $this->tpl->setVariable("SEL_DIFFICULTY_2",
00392                                                                 ilMDUtilSelect::_getDifficultySelect($this->options['dif_2'],
00393                                                                                                                                          'search_adv[dif_2]',
00394                                                                                                                                          array(0 => $this->lng->txt('meta_please_select'))));
00395                 $this->tpl->setVariable("SEL_AGE_RANGE_1",
00396                                                                 ilMDUtilSelect::_getTypicalAgeRangeSelect($this->options['typ_age_1'],
00397                                                                                                                                                   'search_adv[typ_age_1]',
00398                                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00399                 $this->tpl->setVariable("SEL_AGE_RANGE_2",
00400                                                                 ilMDUtilSelect::_getTypicalAgeRangeSelect($this->options['typ_age_2'],
00401                                                                                                                                                   'search_adv[typ_age_2]',
00402                                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00403                 $this->tpl->setVariable("SEL_LEARNING_TIME_1",
00404                                                                 ilMDUtilSelect::_getTypicalLearningTimeSelect($this->options['typ_lea_1'],
00405                                                                                                                                                           'search_adv[typ_lea_1]',
00406                                                                                                                                                           array(0 => $this->lng->txt('meta_please_select'))));
00407                 $this->tpl->setVariable("SEL_LEARNING_TIME_2",
00408                                                                 ilMDUtilSelect::_getTypicalLearningTimeSelect($this->options['typ_lea_2'],
00409                                                                                                                                                           'search_adv[typ_lea_2]',
00410                                                                                                                                                           array(0 => $this->lng->txt('meta_please_select'))));
00411 
00412                 // RIGHTS
00413                 $this->tpl->setVariable("TXT_RIGHTS",$this->lng->txt('meta_rights'));
00414                 $this->tpl->setVariable("TXT_COSTS",$this->lng->txt('meta_cost'));
00415                 $this->tpl->setVariable("TXT_COPYRIGHT",$this->lng->txt('meta_copyright_and_other_restrictions'));
00416                 
00417                 $this->tpl->setVariable("SEL_COSTS",
00418                                                                 ilMDUtilSelect::_getCostsSelect($this->options['costs'],
00419                                                                                                                                 'search_adv[costs]',array(0 => $this->lng->txt('meta_please_select'))));
00420                 $this->tpl->setVariable("SEL_COPYRIGHT",
00421                                                                 ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect($this->options['copyright'],
00422                                                                                                                                                                                 'search_adv[copyright]',
00423                                                                                                                                                                                 array(0 => $this->lng->txt('meta_please_select'))));
00424 
00425                 // CLASSIFICATION
00426                 $this->tpl->setVariable("TXT_CLASSIFICATION",$this->lng->txt('meta_classification'));
00427                 $this->tpl->setVariable("TXT_PURPOSE",$this->lng->txt('meta_purpose'));
00428                 $this->tpl->setVariable("TXT_TAXON",$this->lng->txt('meta_taxon'));
00429                 $this->tpl->setVariable("TXT_KEYWORD",$this->lng->txt('meta_keyword'));
00430                 
00431                 $this->tpl->setVariable("SEL_PURPOSE",
00432                                                                 ilMDUtilSelect::_getPurposeSelect($this->options['purpose'],
00433                                                                                                                                   'search_adv[purpose]',
00434                                                                                                                                   array(0 => $this->lng->txt('meta_please_select'))));
00435 
00436                 if($this->options['taxon_ao'] == 'and')
00437                 {
00438                         $this->tpl->setVariable("TAXON_AND_CHECKED",'checked=checked');
00439                 }
00440                 else
00441                 {
00442                         $this->tpl->setVariable("TAXON_OR_CHECKED",'checked=checked');
00443                 }
00444                 $this->tpl->setVariable("FRM_TAXON",ilUtil::prepareFormOutput($this->options['taxon'],true));
00445 
00446                 if($this->options['keyword_ao'] == 'and')
00447                 {
00448                         $this->tpl->setVariable("KEYWORD_AND_CHECKED",'checked=checked');
00449                 }
00450                 else
00451                 {
00452                         $this->tpl->setVariable("KEYWORD_OR_CHECKED",'checked=checked');
00453                 }
00454                 $this->tpl->setVariable("FRM_KEYWORD",ilUtil::prepareFormOutput($this->options['keyword'],true));
00455 
00456                 $this->tpl->setVariable("BTN_SEARCH",$this->lng->txt('search'));
00457                 $this->tpl->setVariable("BTN_RESET",$this->lng->txt('reset'));
00458 
00459                 return true;
00460         }
00461 
00462         function prepareOutput()
00463         {
00464                 parent::prepareOutput();
00465 
00466                 $this->tpl->setVariable("H_FORMACTION",$this->ctrl->getFormAction($this));
00467                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('search'));
00468 
00469                 $this->tpl->addBlockFile("TABS","tabs","tpl.tabs.html");
00470 
00471                 $this->tpl->setCurrentBlock("tab");
00472                 $this->tpl->setVariable("TAB_TYPE","tabinactive");
00473                 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTargetByClass('ilsearchgui'));
00474                 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search"));
00475                 $this->tpl->parseCurrentBlock();
00476 
00477                 $this->tpl->setCurrentBlock("tab");
00478                 $this->tpl->setVariable("TAB_TYPE","tabactive");
00479                 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTarget($this));
00480                 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search_advanced"));
00481                 $this->tpl->parseCurrentBlock();
00482 
00483                 $this->tpl->setCurrentBlock("tab");
00484                 $this->tpl->setVariable("TAB_TYPE","tabinactive");
00485                 $this->tpl->setVariable("TAB_LINK",$this->ctrl->getLinkTargetByClass('ilsearchresultgui'));
00486                 $this->tpl->setVariable("TAB_TEXT",$this->lng->txt("search_search_results"));
00487                 $this->tpl->parseCurrentBlock();
00488                 
00489         }
00490         function saveResult()
00491         {
00492                 include_once 'Services/Search/classes/class.ilUserResult.php';
00493                 include_once 'Services/Search/classes/class.ilSearchFolder.php';
00494 
00495                 global $ilUser;
00496 
00497                 if(!$_POST['folder'])
00498                 {
00499                         sendInfo($this->lng->txt('search_select_one'));
00500                         $this->showSavedResults();
00501 
00502                         return false;
00503                 }
00504                 if(!count($_POST['result']))
00505                 {
00506                         sendInfo($this->lng->txt('search_select_one_result'));
00507                         $this->showSavedResults();
00508 
00509                         return false;
00510                 }
00511 
00512                 $folder_obj =& new ilSearchFolder($ilUser->getId(),(int) $_POST['folder']);
00513 
00514                 foreach($_POST['result'] as $ref_id)
00515                 {
00516 
00517                         $title = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
00518                         $target = addslashes(serialize(array('type' => ilObject::_lookupType(ilObject::_lookupObjId($ref_id)),
00519                                                                                                  'id'   => $ref_id)));
00520 
00521                         $search_res_obj =& new ilUserResult($ilUser->getId());
00522                         $search_res_obj->setTitle($title);
00523                         $search_res_obj->setTarget($target);
00524 
00525                         $folder_obj->assignResult($search_res_obj);
00526                         unset($search_res_obj);
00527                 }
00528                 sendInfo($this->lng->txt('search_results_saved'));
00529                 $this->showSavedResults();
00530 
00531         }
00532 
00533 
00534         // PRIVATE
00535         function showSavedResults()
00536         {
00537                 global $ilUser;
00538 
00539                 // Read old result sets
00540                 include_once 'Services/Search/classes/class.ilSearchResult.php';
00541         
00542                 $result_obj = new ilSearchResult($ilUser->getId());
00543                 $result_obj->read(ADVANCED_SEARCH);
00544 
00545                 $this->showSearch();
00546 
00547                 // Show them
00548                 if(count($result_obj->getResults()))
00549                 {
00550                         $this->__showSearchInResults();
00551 
00552                         include_once 'Services/Search/classes/class.ilSearchResultPresentationGUI.php';
00553                         
00554                         $search_result_presentation = new ilSearchResultPresentationGUI($result_obj);
00555                         $this->tpl->setVariable("RESULTS",$search_result_presentation->showResults());
00556                 }
00557 
00558                 return true;
00559         }
00560 
00561         function &__performContentSearch()
00562         {
00563                 if(!$this->options['content'])
00564                 {
00565                         return false;
00566                 }
00567                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00568                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00569                 include_once 'Services/Search/classes/class.ilSearchResult.php';
00570 
00571                 $res =& new ilSearchResult();
00572 
00573 
00574                 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['content']));
00575                 $query_parser->setCombination($this->options['content_ao']);
00576                 $query_parser->parse();
00577 
00578                 if($this->options['type'] == 'all' or $this->options['type'] == 'lms')
00579                 {
00580                         // LM content search
00581                         $lm_search =& ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
00582                         $res_cont =& $lm_search->performSearch();
00583                         $res->mergeEntries($res_cont);
00584                         
00585                         if($this->settings->enabledLucene())
00586                         {
00587 
00588                                 // HTLM content search
00589                                 $htlm_search =& ilObjectSearchFactory::_getHTLMSearchInstance($query_parser);
00590                                 $res_htlm =& $htlm_search->performSearch();
00591                                 $res->mergeEntries($res_htlm);
00592                         }
00593                 }
00594                 if($this->options['type'] == 'all' or $this->options['type'] == 'tst')
00595                 {
00596                         $tst_search =& ilObjectSearchFactory::_getTestSearchInstance($query_parser);
00597                         $res_tes =& $tst_search->performSearch();
00598                         $res->mergeEntries($res_tes);
00599                 }
00600                 if($this->options['type'] == 'all' or $this->options['type'] == 'mep')
00601                 {
00602                         $med_search =& ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
00603                         $res_med =& $med_search->performSearch();
00604                         $res->mergeEntries($res_med);
00605                 }
00606                 if($this->options['type'] == 'all' or $this->options['type'] == 'glo')
00607                 {
00608                         $glo_search =& ilObjectSearchFactory::_getGlossaryDefinitionSearchInstance($query_parser);
00609                         $res_glo =& $glo_search->performSearch();
00610                         $res->mergeEntries($res_glo);
00611                 }
00612                 if($this->options['type'] == 'all' or $this->options['type'] == 'webr')
00613                 {
00614                         $web_search =& ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser);
00615                         $res_web =& $web_search->performSearch();
00616                         $res->mergeEntries($res_web);
00617                 }
00618 
00619                 return $res;
00620         }
00621 
00622 
00623         function &__performTitleSearch()
00624         {
00625                 if(!$this->options['title'])
00626                 {
00627                         return false;
00628                 }
00629 
00630                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00631                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00632 
00633                 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['title']));
00634                 $query_parser->setCombination($this->options['title_ao']);
00635                 $query_parser->parse();
00636 
00637                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00638                 $meta_search->setFilter($this->filter);
00639                 $meta_search->setMode('title_description');
00640                 $meta_search->setOptions($this->options);
00641                 $res_tit =& $meta_search->performSearch();
00642 
00643                 $meta_search->setMode('keyword_all');
00644                 $res_key =& $meta_search->performSearch();
00645                 
00646                 // merge them
00647                 $res_tit->mergeEntries($res_key);
00648                 
00649                 return $res_tit;
00650         }
00651 
00652 
00653 
00654         function &__performGeneralSearch()
00655         {
00656                 if(!$this->options['coverage'] and !$this->options['structure'])
00657                 {
00658                         return false;
00659                 }
00660 
00661                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00662                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00663 
00664                 if($this->options['coverage'])
00665                 {
00666                         $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['coverage']));
00667                         $query_parser->setCombination($this->options['coverage_ao']);
00668                         $query_parser->parse();
00669                 }
00670                 else
00671                 {
00672                         $query_parser = new ilQueryParser('');
00673                 }
00674 
00675                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00676                 $meta_search->setFilter($this->filter);
00677                 $meta_search->setMode('general');
00678                 $meta_search->setOptions($this->options);
00679                 $res =& $meta_search->performSearch();
00680 
00681                 return $res;
00682         }
00683 
00684         function &__performLifecycleSearch()
00685         {
00686                 // Return if 'any'
00687                 if(!$this->options['status'] and !$this->options['version'])
00688                 {
00689                         return false;
00690                 }
00691                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00692                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00693 
00694                 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['version']));
00695                 $query_parser->setCombination($this->options['version_ao']);
00696                 $query_parser->parse();
00697 
00698                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00699                 $meta_search->setFilter($this->filter);
00700                 $meta_search->setMode('lifecycle');
00701                 $meta_search->setOptions($this->options);
00702                 $res =& $meta_search->performSearch();
00703 
00704                 return $res;
00705         }               
00706         function &__performLanguageSearch()
00707         {
00708                 if(!$this->options['language'])
00709                 {
00710                         return false;
00711                 }
00712                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00713                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00714 
00715 
00716                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00717                 $meta_search->setFilter($this->filter);
00718                 $meta_search->setMode('language');
00719                 $meta_search->setOptions($this->options);
00720                 $res =& $meta_search->performSearch();
00721 
00722                 return $res;
00723         }
00724         function &__performContributeSearch()
00725         {
00726                 if(!strlen($this->options['role']))
00727                 {
00728                         return false;
00729                 }
00730                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00731                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00732 
00733 
00734                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00735                 $meta_search->setFilter($this->filter);
00736                 $meta_search->setMode('contribute');
00737                 $meta_search->setOptions($this->options);
00738                 $res =& $meta_search->performSearch();
00739 
00740                 return $res;
00741         }
00742         function &__performEntitySearch()
00743         {
00744                 // Return if 'any'
00745                 if(!$this->options['entity'])
00746                 {
00747                         return false;
00748                 }
00749                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00750                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00751 
00752                 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['entity']));
00753                 $query_parser->setCombination($this->options['entity_ao']);
00754                 $query_parser->parse();
00755 
00756                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00757                 $meta_search->setFilter($this->filter);
00758                 $meta_search->setMode('entity');
00759                 $meta_search->setOptions($this->options);
00760                 $res =& $meta_search->performSearch();
00761 
00762                 return $res;
00763         }               
00764 
00765 
00766         function &__performRequirementSearch()
00767         {
00768                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00769                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00770 
00771 
00772                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00773                 $meta_search->setFilter($this->filter);
00774                 $meta_search->setMode('requirement');
00775                 $meta_search->setOptions($this->options);
00776                 $res =& $meta_search->performSearch();
00777 
00778                 return $res;
00779         }
00780         function &__performFormatSearch()
00781         {
00782                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00783                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00784 
00785 
00786                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00787                 $meta_search->setFilter($this->filter);
00788                 $meta_search->setMode('format');
00789                 $meta_search->setOptions($this->options);
00790                 $res =& $meta_search->performSearch();
00791 
00792                 return $res;
00793         }
00794         function &__performEducationalSearch()
00795         {
00796                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00797                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00798 
00799 
00800                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00801                 $meta_search->setFilter($this->filter);
00802                 $meta_search->setMode('educational');
00803                 $meta_search->setOptions($this->options);
00804                 $res =& $meta_search->performSearch();
00805 
00806                 return $res;
00807         }
00808         function &__performTypicalAgeRangeSearch()
00809         {
00810                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00811                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00812 
00813 
00814                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00815                 $meta_search->setFilter($this->filter);
00816                 $meta_search->setMode('typical_age_range');
00817                 $meta_search->setOptions($this->options);
00818                 $res =& $meta_search->performSearch();
00819 
00820                 return $res;
00821         }
00822         function &__performRightsSearch()
00823         {
00824                 if(!$this->options['copyright'] and !$this->options['costs'])
00825                 {
00826                         return false;
00827                 }
00828                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00829                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00830 
00831 
00832                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00833                 $meta_search->setFilter($this->filter);
00834                 $meta_search->setMode('rights');
00835                 $meta_search->setOptions($this->options);
00836                 $res =& $meta_search->performSearch();
00837 
00838                 return $res;
00839         }
00840 
00841         function &__performClassificationSearch()
00842         {
00843                 // Return if 'any'
00844                 if(!$this->options['purpose'])
00845                 {
00846                         return false;
00847                 }
00848                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00849                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00850 
00851 
00852                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser(''));
00853                 $meta_search->setFilter($this->filter);
00854                 $meta_search->setMode('classification');
00855                 $meta_search->setOptions($this->options);
00856                 $res =& $meta_search->performSearch();
00857 
00858                 return $res;
00859         }
00860 
00861         function &__performTaxonSearch()
00862         {
00863                 // Return if 'any'
00864                 if(!$this->options['taxon'])
00865                 {
00866                         return false;
00867                 }
00868                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00869                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00870 
00871                 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['taxon']));
00872                 $query_parser->setCombination($this->options['taxon_ao']);
00873                 $query_parser->parse();
00874 
00875                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00876                 $meta_search->setFilter($this->filter);
00877                 $meta_search->setMode('taxon');
00878                 $meta_search->setOptions($this->options);
00879                 $res =& $meta_search->performSearch();
00880 
00881                 return $res;
00882         }
00883 
00884         function &__performKeywordSearch()
00885         {
00886                 // Return if 'any'
00887                 if(!$this->options['keyword'])
00888                 {
00889                         return false;
00890                 }
00891                 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
00892                 include_once 'Services/Search/classes/class.ilQueryParser.php';
00893 
00894                 $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['keyword']));
00895                 $query_parser->setCombination($this->options['keyword_ao']);
00896                 $query_parser->parse();
00897 
00898                 $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
00899                 $meta_search->setFilter($this->filter);
00900                 $meta_search->setMode('keyword');
00901                 $meta_search->setOptions($this->options);
00902                 $res =& $meta_search->performSearch();
00903 
00904                 return $res;
00905         }
00906 
00907         function __setSearchOptions(&$post_vars)
00908         {
00909                 if(isset($_POST['cmd']['performSearch']))
00910                 {
00911                         $this->options = $_SESSION['search_adv'] = $_POST['search_adv'];
00912                 }
00913                 else
00914                 {
00915                         $this->options = $_SESSION['search_adv'];
00916                 }
00917                 
00918                 $_POST['result'] = $_POST['rep_item_id'];
00919 
00920                 $this->filter = array();
00921 
00922                 switch($this->options['type'])
00923                 {
00924                         case 'webr':
00925                                 $this->filter[] = 'webr';
00926                                 break;
00927 
00928                         case 'lms':
00929                                 $this->filter[] = 'lm';
00930                                 $this->filter[] = 'dbk';
00931                                 $this->filter[] = 'pg';
00932                                 $this->filter[] = 'st';
00933                                 $this->filter[] = 'sahs';
00934                                 $this->filter[] = 'htlm';
00935                                 break;
00936 
00937                         case 'glo':
00938                                 $this->filter[] = 'glo';
00939                                 break;
00940 
00941                         case 'tst':
00942                                 $this->filter[] = 'tst';
00943                                 $this->filter[] = 'svy';
00944                                 $this->filter[] = 'qpl';
00945                                 $this->filter[] = 'spl';
00946                                 break;
00947 
00948                         case 'mep':
00949                                 $this->filter[] = 'mep';
00950                                 break;
00951                                         
00952                         case 'crs':
00953                                 $this->filter[] = 'crs';
00954                                 break;
00955 
00956                         case 'all':
00957                         default:
00958                                 $this->filter[] = 'webr';
00959                                 $this->filter[] = 'crs';
00960                                 $this->filter[] = 'mep';
00961                                 $this->filter[] = 'tst';
00962                                 $this->filter[] = 'svy';
00963                                 $this->filter[] = 'qpl';
00964                                 $this->filter[] = 'spl';
00965                                 $this->filter[] = 'glo';
00966                                 $this->filter[] = 'lm';
00967                                 $this->filter[] = 'dbk';
00968                                 $this->filter[] = 'pg';
00969                                 $this->filter[] = 'st';
00970                                 $this->filter[] = 'sahs';
00971                                 $this->filter[] = 'htlm';
00972                 }
00973                 return true;
00974         }
00975 
00976         function __getFilterSelect()
00977         {
00978                 $options = array('all' => $this->lng->txt('search_any'),
00979                                                  'lms' => $this->lng->txt('learning_resources'),
00980                                                  'crs' => $this->lng->txt('objs_crs'),
00981                                                  'tst' => $this->lng->txt('search_tst_svy'),
00982                                                  'mep' => $this->lng->txt('objs_mep'),
00983                                                  'glo' => $this->lng->txt('objs_glo'),
00984                                                  'webr' => $this->lng->txt('objs_webr'));
00985 
00986 
00987                 return ilUtil::formSelect($this->options['type'],'search_adv[type]',$options,false,true);
00988         }
00989 
00990 
00991         function __storeEntries(&$res,&$new_res)
00992         {
00993 
00994                 if($this->stored == false)
00995                 {
00996                         
00997 
00998                         $res->mergeEntries($new_res);
00999                         $this->stored = true;
01000 
01001                         return true;
01002                 }
01003                 else
01004                 {
01005                         $res->intersectEntries($new_res);
01006                         
01007                         return true;
01008                 }
01009         }
01015         function __showSearchInResults()
01016         {
01017                 $this->tpl->setCurrentBlock("search_results");
01018                 $this->tpl->setVariable("BTN_SEARCHRESULTS",$this->lng->txt('search_in_result'));
01019                 $this->tpl->parseCurrentBlock();
01020 
01021                 $this->tpl->setCurrentBlock("save_result");
01022                 $this->tpl->setVariable("DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
01023                 $this->tpl->setVariable("BTN_SAVE_RESULT",$this->lng->txt('save'));
01024                 $this->tpl->setVariable("SELECT_FOLDER",$this->__getFolderSelect());
01025                 $this->tpl->parseCurrentBlock();
01026 
01027                 return true;
01028         }
01029         function __getFolderSelect()
01030         {
01031                 global $ilUser;
01032 
01033                 include_once 'Services/Search/classes/class.ilSearchFolder.php';
01034 
01035                 // INITIATE SEARCH FOLDER OBJECT
01036                 $folder_obj =& new ilSearchFolder($ilUser->getId());
01037 
01038 
01039                 $subtree = $folder_obj->getSubtree();
01040 
01041                 $options[0] = $this->lng->txt("search_select_one_folder_select");
01042                 $options[$folder_obj->getRootId()] = $this->lng->txt("search_save_as_select")." ".$this->lng->txt("search_search_results");
01043                 
01044                 foreach($subtree as $node)
01045                 {
01046                         if($node["obj_id"] == $folder_obj->getRootId())
01047                         {
01048                                 continue;
01049                         }
01050                         // CREATE PREFIX
01051                         $prefix = $this->lng->txt("search_save_as_select");
01052                         for($i = 1; $i < $node["depth"];++$i)
01053                         {
01054                                 $prefix .= "&nbsp;&nbsp;";
01055                         }
01056                         $options[$node["obj_id"]] = $prefix.$node["title"];
01057                 }
01058                 return ilUtil::formSelect(0,'folder',$options,false,true);
01059         }
01060 
01061                 
01062 }
01063 ?>

Generated on Fri Dec 13 2013 10:18:31 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1