ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
36 protected $settings = null;
37
38 protected $ctrl = null;
39 public $ilias = null;
40 public $lng = null;
41 public $tpl = null;
42
47 public function __construct()
48 {
49 global $DIC;
50
51 $ilCtrl = $DIC['ilCtrl'];
52 $ilias = $DIC['ilias'];
53 $lng = $DIC['lng'];
54 $tpl = $DIC['tpl'];
55 $ilMainMenu = $DIC['ilMainMenu'];
56
57 $this->ilias = &$ilias;
58 $this->ctrl = &$ilCtrl;
59 $this->tpl = &$tpl;
60 $this->lng = &$lng;
61 $this->lng->loadLanguageModule('search');
62
63 $ilMainMenu->setActive('search');
64 $this->settings = new ilSearchSettings();
65 }
66
67 public function prepareOutput()
68 {
69 global $DIC;
70
71 $ilLocator = $DIC['ilLocator'];
72 $lng = $DIC['lng'];
73
74 $this->tpl->getStandardTemplate();
75
76 // $ilLocator->addItem($this->lng->txt('search'),$this->ctrl->getLinkTarget($this));
77 // $this->tpl->setLocator();
78
79 //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_src_b.gif"),
80 // $lng->txt("search"));
81 $this->tpl->setTitleIcon(
82 ilObject::_getIcon("", "big", "src"),
83 ""
84 );
85 $this->tpl->setTitle($lng->txt("search"));
86
88 }
89
93 public function initStandardSearchForm($a_mode)
94 {
95 global $DIC;
96
97 $lng = $DIC['lng'];
98 $ilCtrl = $DIC['ilCtrl'];
99
100 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
101 $this->form = new ilPropertyFormGUI();
102 $this->form->setOpenTag(false);
103 $this->form->setCloseTag(false);
104
105 // term combination
106 $radg = new ilHiddenInputGUI('search_term_combination');
107 $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
108 $this->form->addItem($radg);
109
110 if (ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
111 if ($a_mode == self::SEARCH_FORM_STANDARD) {
112 // search type
113 $radg = new ilRadioGroupInputGUI($lng->txt("search_type"), "type");
114 $radg->setValue(
115 $this->getType() ==
119 );
120 $op1 = new ilRadioOption($lng->txt("search_fast_info"), ilSearchBaseGUI::SEARCH_FAST);
121 $radg->addOption($op1);
122 $op2 = new ilRadioOption($lng->txt("search_details_info"), ilSearchBaseGUI::SEARCH_DETAILS);
123 } else {
124 $op2 = new ilCheckboxInputGUI($this->lng->txt('search_filter_by_type'), 'item_filter_enabled');
125 $op2->setValue(1);
126 // $op2->setChecked($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS);
127 }
128
129
130 $cbgr = new ilCheckboxGroupInputGUI('', 'filter_type');
131 $cbgr->setUseValuesAsKeys(true);
132 $details = $this->getDetails();
133 $det = false;
134 foreach (ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions() as $type => $data) {
135 $cb = new ilCheckboxOption($lng->txt($data['trans']), $type);
136 if ($details[$type]) {
137 $det = true;
138 }
139 $cbgr->addOption($cb);
140 }
141 if ($a_mode == self::SEARCH_FORM_LUCENE) {
142 if (ilSearchSettings::getInstance()->isLuceneMimeFilterEnabled()) {
143 $mimes = $this->getMimeDetails();
144 foreach (ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions() as $type => $data) {
145 $op3 = new ilCheckboxOption($this->lng->txt($data['trans']), $type);
146 if ($mimes[$type]) {
147 $det = true;
148 }
149 $cbgr->addOption($op3);
150 }
151 }
152 }
153
154 $cbgr->setValue(array_merge((array) $details, (array) $mimes));
155 $op2->addSubItem($cbgr);
156
157 if ($a_mode != self::SEARCH_FORM_STANDARD && $det) {
158 $op2->setChecked(true);
159 }
160
162 $radg->addOption($op2);
163 $this->form->addItem($radg);
164 } else {
165 $this->form->addItem($op2);
166 }
167 }
168
169 $this->form->setFormAction($ilCtrl->getFormAction($this, 'performSearch'));
170 }
171
175 public function getSearchAreaForm()
176 {
177 global $DIC;
178
179 $lng = $DIC['lng'];
180 $ilCtrl = $DIC['ilCtrl'];
181
182 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
183 $form = new ilPropertyFormGUI();
184 $form->setOpenTag(false);
185 $form->setCloseTag(false);
186
187 // term combination
188 $radg = new ilHiddenInputGUI('search_term_combination');
189 $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
190 $form->addItem($radg);
191
192 // search area
193 include_once("./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
194 $ti = new ilRepositorySelectorInputGUI($lng->txt("search_area"), "area");
195 $ti->setSelectText($lng->txt("search_select_search_area"));
196 $form->addItem($ti);
197 $ti->readFromSession();
198
199 // alex, 15.8.2012: Added the following lines to get the value
200 // from the main menu top right input search form
201 if (isset($_POST["root_id"])) {
202 $ti->setValue($_POST["root_id"]);
203 $ti->writeToSession();
204 }
205 $form->setFormAction($ilCtrl->getFormAction($this, 'performSearch'));
206
207 return $form;
208 }
209
210
215 public function handleCommand($a_cmd)
216 {
217 if (method_exists($this, $a_cmd)) {
218 $this->$a_cmd();
219 } else {
220 $a_cmd .= 'Object';
221 $this->$a_cmd();
222 }
223 }
224
228 public function addToDeskObject()
229 {
230 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
232 $this->showSavedResults();
233 }
234
238 public function removeFromDeskObject()
239 {
240 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
242 $this->showSavedResults();
243 }
244
248 public function delete()
249 {
250 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
251 $admin = new ilAdministrationCommandGUI($this);
252 $admin->delete();
253 }
254
258 public function cancelDelete()
259 {
260 $this->showSavedResults();
261 }
262
263 public function cancelMoveLinkObject()
264 {
265 $this->showSavedResults();
266 }
267
271 public function performDelete()
272 {
273 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
274 $admin = new ilAdministrationCommandGUI($this);
275 $admin->performDelete();
276 }
277
281 public function cut()
282 {
283 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
284 $admin = new ilAdministrationCommandGUI($this);
285 $admin->cut();
286 }
287
291 public function link()
292 {
293 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
294 $admin = new ilAdministrationCommandGUI($this);
295 $admin->link();
296 }
297
298 public function paste()
299 {
300 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
301 $admin = new ilAdministrationCommandGUI($this);
302 $admin->paste();
303 }
304
306 {
307 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
308 $admin = new ilAdministrationCommandGUI($this);
309 $admin->showLinkIntoMultipleObjectsTree();
310 }
311
312 public function showPasteTree()
313 {
314 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
315 $admin = new ilAdministrationCommandGUI($this);
316 $admin->showPasteTree();
317 }
318
320 {
321 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
322 $admin = new ilAdministrationCommandGUI($this);
323 $admin->performPasteIntoMultipleObjects();
324 }
325
326 public function clear()
327 {
328 unset($_SESSION['clipboard']);
329 $this->ctrl->redirect($this);
330 }
331
333 {
334 $_SESSION["il_cont_admin_panel"] = true;
335 $this->ctrl->redirect($this);
336 }
337
339 {
340 $_SESSION["il_cont_admin_panel"] = false;
341 $this->ctrl->redirect($this);
342 }
343
348 {
349 $this->ctrl->redirect($this);
350 }
351
352
356 public function addLocator()
357 {
358 $ilLocator->addItem($this->lng->txt('search'), $this->ctrl->getLinkTarget($this));
359 $this->tpl->setLocator();
360 }
361
369 protected function addPager($result, $a_session_key)
370 {
371 global $DIC;
372
373 $tpl = $DIC['tpl'];
374
375 $_SESSION["$a_session_key"] = max($_SESSION["$a_session_key"], $this->search_cache->getResultPageNumber());
376
377 if ($_SESSION["$a_session_key"] == 1 and
378 (count($result->getResults()) < $result->getMaxHits())) {
379 return true;
380 }
381
382 if ($this->search_cache->getResultPageNumber() > 1) {
383 $this->ctrl->setParameter($this, 'page_number', $this->search_cache->getResultPageNumber() - 1);
384 /* $this->tpl->setCurrentBlock('prev');
385 $this->tpl->setVariable('PREV_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
386 $this->tpl->setVariable('TXT_PREV',$this->lng->txt('search_page_prev'));
387 $this->tpl->parseCurrentBlock();
388 */
389 $this->prev_link = $this->ctrl->getLinkTarget($this, 'performSearch');
390 }
391 for ($i = 1;$i <= $_SESSION["$a_session_key"];$i++) {
392 if ($i == $this->search_cache->getResultPageNumber()) {
393 /* $this->tpl->setCurrentBlock('pages_link');
394 $this->tpl->setVariable('NUMBER',$i);
395 $this->tpl->parseCurrentBlock();
396 */
397 continue;
398 }
399
400 $this->ctrl->setParameter($this, 'page_number', $i);
401 $link = '<a href="' . $this->ctrl->getLinkTarget($this, 'performSearch') . '" /a>' . $i . '</a> ';
402 /* $this->tpl->setCurrentBlock('pages_link');
403 $this->tpl->setVariable('NUMBER',$link);
404 $this->tpl->parseCurrentBlock();
405 */
406 }
407
408
409 if (count($result->getResults()) >= $result->getMaxHits()) {
410 $this->ctrl->setParameter($this, 'page_number', $this->search_cache->getResultPageNumber() + 1);
411 /* $this->tpl->setCurrentBlock('next');
412 $this->tpl->setVariable('NEXT_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
413 $this->tpl->setVariable('TXT_NEXT',$this->lng->txt('search_page_next'));
414 $this->tpl->parseCurrentBlock();
415 */
416 $this->next_link = $this->ctrl->getLinkTarget($this, 'performSearch');
417 }
418
419 /* $this->tpl->setCurrentBlock('prev_next');
420 $this->tpl->setVariable('SEARCH_PAGE',$this->lng->txt('search_page'));
421 $this->tpl->parseCurrentBlock();
422 */
423
424 $this->ctrl->clearParameters($this);
425 }
426
431 protected function buildSearchAreaPath($a_root_node)
432 {
433 global $DIC;
434
435 $tree = $DIC['tree'];
436
437 $path_arr = $tree->getPathFull($a_root_node, ROOT_FOLDER_ID);
438 $counter = 0;
439 foreach ($path_arr as $data) {
440 if ($counter++) {
441 $path .= " > ";
442 $path .= $data['title'];
443 } else {
444 $path .= $this->lng->txt('repository');
445 }
446 }
447 return $path;
448 }
449
453 public function autoComplete()
454 {
455 $q = $_REQUEST["term"];
456 include_once("./Services/Search/classes/class.ilSearchAutoComplete.php");
458 echo $list;
459 exit;
460 }
461
462 // begin-patch creation_date
463 protected function getCreationDateForm()
464 {
465 $options = $this->search_cache->getCreationFilter();
466
467 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
468 $form = new ilPropertyFormGUI();
469 $form->setOpenTag(false);
470 $form->setCloseTag(false);
471
472 $enabled = new ilCheckboxInputGUI($this->lng->txt('search_filter_cd'), 'screation');
473 $enabled->setValue(1);
474 $enabled->setChecked((bool) $options['enabled']);
475 $form->addItem($enabled);
476
477 #$group = new ilRadioGroupInputGUI('', 'screation_type');
478 #$group->setValue((int) $options['type']);
479 #$group->addOption($opt1 = new ilRadioOption($this->lng->txt('search_filter_date'), 1));
480
481 $limit_sel = new ilSelectInputGUI('', 'screation_ontype');
482 $limit_sel->setValue($options['ontype']);
483 $limit_sel->setOptions(
484 array(
485 1 => $this->lng->txt('search_created_after'),
486 2 => $this->lng->txt('search_created_before'),
487 3 => $this->lng->txt('search_created_on')
488 )
489 );
490 $enabled->addSubItem($limit_sel);
491
492
493 if ($options['date']) {
494 $now = new ilDate($options['date'], IL_CAL_UNIX);
495 } else {
496 $now = new ilDate(time(), IL_CAL_UNIX);
497 }
498 $ds = new ilDateTimeInputGUI('', 'screation_date');
499 $ds->setRequired(true);
500 $ds->setDate($now);
501 $enabled->addSubItem($ds);
502
503 #$group->addOption($opt2 = new ilRadioOption($this->lng->txt('search_filter_duration'), 2));
504
505 #$duration = new ilDurationInputGUI($this->lng->txt('search_filter_duration'), 'screation_duration');
506 #$duration->setMonths((int) $options['duration']['MM']);
507 #$duration->setDays((int) $options['duration']['dd']);
508 #$duration->setShowMonths(true);
509 #$duration->setShowDays(true);
510 #$duration->setShowHours(false);
511 #$duration->setShowMinutes(false);
512 #$duration->setTitle($this->lng->txt('search_newer_than'));
513 #$opt2->addSubItem($duration);
514
515 #$enabled->addSubItem($group);
516
517 $form->setFormAction($GLOBALS['DIC']['ilCtrl']->getFormAction($this, 'performSearch'));
518
519 return $form;
520 }
521
526 protected function getSearchCache()
527 {
528 return $this->search_cache;
529 }
530
535 protected function loadCreationFilter()
536 {
537 if (!$this->settings->isDateFilterEnabled()) {
538 return array();
539 }
540
541
542 $form = $this->getCreationDateForm();
543 $options = array();
544 if ($form->checkInput()) {
545 $options['enabled'] = $form->getInput('screation');
546 $options['type'] = $form->getInput('screation_type');
547 $options['ontype'] = $form->getInput('screation_ontype');
548 $options['date'] = $form->getItemByPostVar('screation_date')->getDate()->get(IL_CAL_UNIX);
549 $options['duration'] = $form->getInput('screation_duration');
550 }
551 return $options;
552 }
553}
$result
$path
Definition: aliased.php:25
exit
Definition: backend.php:16
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
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.
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.
__construct()
Constructor @access public.
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.
showPasteTree()
Target selection cut.
getSearchAreaForm()
Init standard search form.
cut()
Interface ilAdministrationCommandHandler.
performPasteIntoMultipleObjects()
Perform paste into multiple objects.
link()
Interface ilAdministrationCommandHandler.
cancelMoveLinkObject()
Cancel move/link.
showLinkIntoMultipleObjectsTree()
Target selection link.
loadCreationFilter()
Load creation date filter.
keepObjectsInClipboardObject()
cancel action but keep objects in clipboardvoid
autoComplete()
Data resource for autoComplete.
performDelete()
Delete objects.
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)
$i
Definition: disco.tpl.php:19
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.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
redirection script todo: (a better solution should control the processing via a xml file)
$type
if(isset($_POST['submit'])) $form
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$data
Definition: bench.php:6