ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSearchBaseGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once 'Services/Search/classes/class.ilSearchSettings.php';
5include_once './Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
6include_once './Services/Administration/interfaces/interface.ilAdministrationCommandHandling.php';
7
23{
24 const SEARCH_FAST = 1;
25 const SEARCH_DETAILS = 2;
26 const SEARCH_AND = 'and';
27 const SEARCH_OR = 'or';
28
32
33 var $settings = null;
34
35 protected $ctrl = null;
36 var $ilias = null;
37 var $lng = null;
38 var $tpl = null;
39
44 function ilSearchBaseGUI()
45 {
46 global $ilCtrl,$ilias,$lng,$tpl,$ilMainMenu;
47
48 $this->ilias =& $ilias;
49 $this->ctrl =& $ilCtrl;
50 $this->tpl =& $tpl;
51 $this->lng =& $lng;
52 $this->lng->loadLanguageModule('search');
53
54 $ilMainMenu->setActive('search');
55 $this->settings =& new ilSearchSettings();
56 }
57
58 function prepareOutput()
59 {
60 global $ilLocator, $lng;
61
62 $this->tpl->getStandardTemplate();
63
64// $ilLocator->addItem($this->lng->txt('search'),$this->ctrl->getLinkTarget($this));
65// $this->tpl->setLocator();
66
67 //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_src_b.gif"),
68 // $lng->txt("search"));
69 $this->tpl->setTitleIcon(ilObject::_getIcon("","big", "src"),
70 "");
71 $this->tpl->setTitle($lng->txt("search"));
72
74
75 }
76
80 public function initStandardSearchForm($a_mode)
81 {
82 global $lng, $ilCtrl;
83
84 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
85 $this->form = new ilPropertyFormGUI();
86 $this->form->setOpenTag(false);
87 $this->form->setCloseTag(false);
88
89 // term combination
90 $radg = new ilHiddenInputGUI('search_term_combination');
91 $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
92 $this->form->addItem($radg);
93
94 if(ilSearchSettings::getInstance()->isLuceneItemFilterEnabled())
95 {
96 if($a_mode == self::SEARCH_FORM_STANDARD)
97 {
98 // search type
99 $radg = new ilRadioGroupInputGUI($lng->txt("search_type"), "type");
100 $radg->setValue(
101 $this->getType() ==
105 );
106 $op1 = new ilRadioOption($lng->txt("search_fast_info"), ilSearchBaseGUI::SEARCH_FAST);
107 $radg->addOption($op1);
108 $op2 = new ilRadioOption($lng->txt("search_details_info"), ilSearchBaseGUI::SEARCH_DETAILS);
109 }
110 else
111 {
112 $op2 = new ilCheckboxInputGUI($this->lng->txt('search_filter_by_type'),'item_filter_enabled');
113 $op2->setValue(1);
114// $op2->setChecked($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS);
115 }
116
117
118 $cbgr = new ilCheckboxGroupInputGUI('','filter_type');
119 $cbgr->setUseValuesAsKeys(true);
120 $details = $this->getDetails();
121 $det = false;
122 foreach(ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions() as $type => $data)
123 {
124 $cb = new ilCheckboxOption($lng->txt($data['trans']), $type);
125 if ($details[$type])
126 {
127 $det = true;
128 }
129 $cbgr->addOption($cb);
130 }
131 if($a_mode == self::SEARCH_FORM_LUCENE)
132 {
133 if(ilSearchSettings::getInstance()->isLuceneMimeFilterEnabled())
134 {
135 $mimes = $this->getMimeDetails();
136 foreach(ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions() as $type => $data)
137 {
138 $op3 = new ilCheckboxOption($this->lng->txt($data['trans']),$type);
139 if($mimes[$type])
140 {
141 $det = true;
142 }
143 $cbgr->addOption($op3);
144 }
145 }
146 }
147
148 $cbgr->setValue(array_merge((array) $details,(array) $mimes));
149 $op2->addSubItem($cbgr);
150
151 if($a_mode != self::SEARCH_FORM_STANDARD && $det)
152 {
153 $op2->setChecked(true);
154 }
155
157 {
158 $radg->addOption($op2);
159 $this->form->addItem($radg);
160 }
161 else
162 {
163 $this->form->addItem($op2);
164 }
165 }
166
167 $this->form->setFormAction($ilCtrl->getFormAction($this,'performSearch'));
168 }
169
173 public function getSearchAreaForm()
174 {
175 global $lng, $ilCtrl;
176
177 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
178 $form = new ilPropertyFormGUI();
179 $form->setOpenTag(false);
180 $form->setCloseTag(false);
181
182 // term combination
183 $radg = new ilHiddenInputGUI('search_term_combination');
184 $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
185 $form->addItem($radg);
186
187 // search area
188 include_once("./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
189 $ti = new ilRepositorySelectorInputGUI($lng->txt("search_area"), "area");
190 $ti->setSelectText($lng->txt("search_select_search_area"));
191 $form->addItem($ti);
192 $ti->readFromSession();
193
194 // alex, 15.8.2012: Added the following lines to get the value
195 // from the main menu top right input search form
196 if (isset($_POST["root_id"]))
197 {
198 $ti->setValue($_POST["root_id"]);
199 $ti->writeToSession();
200 }
201 $form->setFormAction($ilCtrl->getFormAction($this,'performSearch'));
202
203 return $form;
204 }
205
206
211 public function handleCommand($a_cmd)
212 {
213 if(method_exists($this, $a_cmd))
214 {
215 $this->$a_cmd();
216 }
217 else
218 {
219 $a_cmd .= 'Object';
220 $this->$a_cmd();
221 }
222 }
223
227 public function addToDeskObject()
228 {
229 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
231 $this->showSavedResults();
232 }
233
237 public function removeFromDeskObject()
238 {
239 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
241 $this->showSavedResults();
242 }
243
247 public function delete()
248 {
249 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
250 $admin = new ilAdministrationCommandGUI($this);
251 $admin->delete();
252 }
253
257 public function cancelDelete()
258 {
259 $this->showSavedResults();
260 }
261
262 public function cancelMoveLinkObject()
263 {
264 $this->showSavedResults();
265 }
266
270 public function performDelete()
271 {
272 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
273 $admin = new ilAdministrationCommandGUI($this);
274 $admin->performDelete();
275 }
276
280 public function cut()
281 {
282
283
284 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
285 $admin = new ilAdministrationCommandGUI($this);
286 $admin->cut();
287 }
288
292 public function link()
293 {
294 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
295 $admin = new ilAdministrationCommandGUI($this);
296 $admin->link();
297 }
298
299 public function paste()
300 {
301 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
302 $admin = new ilAdministrationCommandGUI($this);
303 $admin->paste();
304 }
305
307 {
308 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
309 $admin = new ilAdministrationCommandGUI($this);
310 $admin->showLinkIntoMultipleObjectsTree();
311 }
312
313 public function showMoveIntoObjectTree()
314 {
315 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
316 $admin = new ilAdministrationCommandGUI($this);
317 $admin->showMoveIntoObjectTree();
318 }
319
321 {
322 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
323 $admin = new ilAdministrationCommandGUI($this);
324 $admin->performPasteIntoMultipleObjects();
325 }
326
327 public function clear()
328 {
329 unset($_SESSION['clipboard']);
330 $this->ctrl->redirect($this);
331 }
332
334 {
335 $_SESSION["il_cont_admin_panel"] = true;
336 $this->ctrl->redirect($this);
337 }
338
340 {
341 $_SESSION["il_cont_admin_panel"] = false;
342 $this->ctrl->redirect($this);
343 }
344
345
349 public function addLocator()
350 {
351 $ilLocator->addItem($this->lng->txt('search'),$this->ctrl->getLinkTarget($this));
352 $this->tpl->setLocator();
353 }
354
362 protected function addPager($result,$a_session_key)
363 {
364 global $tpl;
365
366 $_SESSION["$a_session_key"] = max($_SESSION["$a_session_key"],$this->search_cache->getResultPageNumber());
367
368 if($_SESSION["$a_session_key"] == 1 and
369 (count($result->getResults()) < $result->getMaxHits()))
370 {
371 return true;
372 }
373
374 if($this->search_cache->getResultPageNumber() > 1)
375 {
376 $this->ctrl->setParameter($this,'page_number',$this->search_cache->getResultPageNumber() - 1);
377/* $this->tpl->setCurrentBlock('prev');
378 $this->tpl->setVariable('PREV_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
379 $this->tpl->setVariable('TXT_PREV',$this->lng->txt('search_page_prev'));
380 $this->tpl->parseCurrentBlock();
381*/
382 $this->prev_link = $this->ctrl->getLinkTarget($this,'performSearch');
383 }
384 for($i = 1;$i <= $_SESSION["$a_session_key"];$i++)
385 {
386 if($i == $this->search_cache->getResultPageNumber())
387 {
388/* $this->tpl->setCurrentBlock('pages_link');
389 $this->tpl->setVariable('NUMBER',$i);
390 $this->tpl->parseCurrentBlock();
391*/
392 continue;
393 }
394
395 $this->ctrl->setParameter($this,'page_number',$i);
396 $link = '<a href="'.$this->ctrl->getLinkTarget($this,'performSearch').'" /a>'.$i.'</a> ';
397/* $this->tpl->setCurrentBlock('pages_link');
398 $this->tpl->setVariable('NUMBER',$link);
399 $this->tpl->parseCurrentBlock();
400*/
401 }
402
403
404 if(count($result->getResults()) >= $result->getMaxHits())
405 {
406 $this->ctrl->setParameter($this,'page_number',$this->search_cache->getResultPageNumber() + 1);
407/* $this->tpl->setCurrentBlock('next');
408 $this->tpl->setVariable('NEXT_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
409 $this->tpl->setVariable('TXT_NEXT',$this->lng->txt('search_page_next'));
410 $this->tpl->parseCurrentBlock();
411*/
412$this->next_link = $this->ctrl->getLinkTarget($this,'performSearch');
413 }
414
415/* $this->tpl->setCurrentBlock('prev_next');
416 $this->tpl->setVariable('SEARCH_PAGE',$this->lng->txt('search_page'));
417 $this->tpl->parseCurrentBlock();
418*/
419
420 $this->ctrl->clearParameters($this);
421 }
422
427 protected function buildSearchAreaPath($a_root_node)
428 {
429 global $tree;
430
431 $path_arr = $tree->getPathFull($a_root_node,ROOT_FOLDER_ID);
432 $counter = 0;
433 foreach($path_arr as $data)
434 {
435 if($counter++)
436 {
437 $path .= " > ";
438 $path .= $data['title'];
439 }
440 else
441 {
442 $path .= $this->lng->txt('repository');
443 }
444
445 }
446 return $path;
447 }
448
452 function autoComplete()
453 {
454 $q = $_REQUEST["term"];
455 include_once("./Services/Search/classes/class.ilSearchAutoComplete.php");
457 echo $list;
458 exit;
459 }
460
461 // begin-patch creation_date
462 protected function getCreationDateForm()
463 {
464 $options = $this->search_cache->getCreationFilter();
465
466 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
467 $form = new ilPropertyFormGUI();
468 $form->setOpenTag(false);
469 $form->setCloseTag(false);
470
471 $enabled = new ilCheckboxInputGUI($this->lng->txt('search_filter_cd'),'screation');
472 $enabled->setValue(1);
473 $enabled->setChecked((bool) $options['enabled']);
474 $form->addItem($enabled);
475
476 #$group = new ilRadioGroupInputGUI('', 'screation_type');
477 #$group->setValue((int) $options['type']);
478 #$group->addOption($opt1 = new ilRadioOption($this->lng->txt('search_filter_date'), 1));
479
480 $limit_sel = new ilSelectInputGUI('','screation_ontype');
481 $limit_sel->setValue($options['ontype']);
482 $limit_sel->setOptions(
483 array(
484 1 => $this->lng->txt('search_created_after'),
485 2 => $this->lng->txt('search_created_before'),
486 3 => $this->lng->txt('search_created_on')
487 )
488 );
489 $enabled->addSubItem($limit_sel);
490
491
492 if($options['date'])
493 {
494 $now = new ilDate($options['date'],IL_CAL_UNIX);
495 }
496 else
497 {
498 $now = new ilDate(time(),IL_CAL_UNIX);
499 }
500 $ds = new ilDateTimeInputGUI('','screation_date');
501 #$ds->setMode(ilDateTimeInputGUI::MODE_INPUT);
502 $ds->setDate($now);
503 $enabled->addSubItem($ds);
504
505 #$group->addOption($opt2 = new ilRadioOption($this->lng->txt('search_filter_duration'), 2));
506
507 #$duration = new ilDurationInputGUI($this->lng->txt('search_filter_duration'), 'screation_duration');
508 #$duration->setMonths((int) $options['duration']['MM']);
509 #$duration->setDays((int) $options['duration']['dd']);
510 #$duration->setShowMonths(true);
511 #$duration->setShowDays(true);
512 #$duration->setShowHours(false);
513 #$duration->setShowMinutes(false);
514 #$duration->setTitle($this->lng->txt('search_newer_than'));
515 #$opt2->addSubItem($duration);
516
517 #$enabled->addSubItem($group);
518
519 $form->setFormAction($GLOBALS['ilCtrl']->getFormAction($this,'performSearch'));
520
521 return $form;
522
523 }
524
529 protected function getSearchCache()
530 {
531 return $this->search_cache;
532 }
533
534 protected function loadCreationFilter()
535 {
536 $form = $this->getCreationDateForm();
537 $options = array();
538 if($form->checkInput())
539 {
540 $options['enabled'] = $form->getInput('screation');
541 $options['type'] = $form->getInput('screation_type');
542 $options['ontype'] = $form->getInput('screation_ontype');
543 $options['date'] = $form->getItemByPostVar('screation_date')->getDate()->get(IL_CAL_UNIX);
544 $options['duration'] = $form->getInput('screation_duration');
545 }
546 return $options;
547 }
548
549
550
551}
552?>
$result
$_SESSION["AccountId"]
const IL_CAL_UNIX
Handles Administration commands (cut, delete paste)
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
This class represents a date/time property in a property form.
Class for single dates.
static addToDesktop()
Add desktop item @access public.
static removeFromDesktop()
Remove item from personal desktop @access public.
This class represents a hidden form property in a property form.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a repository selector in a property form.
static getList($a_str)
Get completion list.
initStandardSearchForm($a_mode)
Init standard search form.
disableAdministrationPanel()
Disable administration panel.
enableAdministrationPanel()
Enable administration panel.
addPager($result, $a_session_key)
Add Pager.
getSearchCache()
Get user search cache.
getSearchAreaForm()
Init standard search form.
cut()
Interface ilAdministrationCommandHandler.
showMoveIntoObjectTree()
Target selection cut.
performPasteIntoMultipleObjects()
Perform paste into multiple objects.
link()
Interface ilAdministrationCommandHandler.
cancelMoveLinkObject()
Cancel move/link.
showLinkIntoMultipleObjectsTree()
Target selection link.
autoComplete()
Data resource for autoComplete.
performDelete()
Delete objects.
ilSearchBaseGUI()
Constructor @access public.
addToDeskObject()
Interface methods.
cancelDelete()
Cancel delete.
removeFromDeskObject()
Remove from dektop
buildSearchAreaPath($a_root_node)
Build path for search area.
clear()
clear clipboard
handleCommand($a_cmd)
Handle command.
This class represents a selection list property in a property form.
static infoPanel($a_keep=true)
$_POST['username']
Definition: cron.php:12
$data
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
Interface for GUI classes (PDGUI, LuceneSearchGUI...) that have to handle administration commands (cu...
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options