ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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/Administration/interfaces/interface.ilAdministrationCommandHandling.php';
6
22{
23 const SEARCH_FAST = 1;
24 const SEARCH_DETAILS = 2;
25 const SEARCH_AND = 'and';
26 const SEARCH_OR = 'or';
27
31
35 protected $settings = null;
36
37 protected $ctrl = null;
38 public $ilias = null;
39 public $lng = null;
40 public $tpl = null;
41
45 protected $favourites;
46
50 protected $user;
51
56 public function __construct()
57 {
58 global $DIC;
59
60 $ilCtrl = $DIC['ilCtrl'];
61 $ilias = $DIC['ilias'];
62 $lng = $DIC['lng'];
63 $tpl = $DIC['tpl'];
64 $ilMainMenu = $DIC['ilMainMenu'];
65
66 $this->ilias = &$ilias;
67 $this->ctrl = &$ilCtrl;
68 $this->tpl = &$tpl;
69 $this->lng = &$lng;
70 $this->lng->loadLanguageModule('search');
71
72 $ilMainMenu->setActive('search');
73 $this->settings = new ilSearchSettings();
74 $this->favourites = new ilFavouritesManager();
75 $this->user = $DIC->user();
76 }
77
78 public function prepareOutput()
79 {
80 global $DIC;
81
82 $ilLocator = $DIC['ilLocator'];
83 $lng = $DIC['lng'];
84
85 $this->tpl->loadStandardTemplate();
86
87 // $ilLocator->addItem($this->lng->txt('search'),$this->ctrl->getLinkTarget($this));
88 // $this->tpl->setLocator();
89
90 //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_src_b.gif"),
91 // $lng->txt("search"));
92 $this->tpl->setTitleIcon(
93 ilObject::_getIcon("", "big", "src"),
94 ""
95 );
96 $this->tpl->setTitle($lng->txt("search"));
97
99 }
100
104 public function initStandardSearchForm($a_mode)
105 {
106 global $DIC;
107
108 $lng = $DIC['lng'];
109 $ilCtrl = $DIC['ilCtrl'];
110
111 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
112 $this->form = new ilPropertyFormGUI();
113 $this->form->setOpenTag(false);
114 $this->form->setCloseTag(false);
115
116 // term combination
117 $radg = new ilHiddenInputGUI('search_term_combination');
118 $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
119 $this->form->addItem($radg);
120
121 if (ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
122 if ($a_mode == self::SEARCH_FORM_STANDARD) {
123 // search type
124 $radg = new ilRadioGroupInputGUI($lng->txt("search_type"), "type");
125 $radg->setValue(
126 $this->getType() ==
130 );
131 $op1 = new ilRadioOption($lng->txt("search_fast_info"), ilSearchBaseGUI::SEARCH_FAST);
132 $radg->addOption($op1);
133 $op2 = new ilRadioOption($lng->txt("search_details_info"), ilSearchBaseGUI::SEARCH_DETAILS);
134 } else {
135 $op2 = new ilCheckboxInputGUI($this->lng->txt('search_filter_by_type'), 'item_filter_enabled');
136 $op2->setValue(1);
137 // $op2->setChecked($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS);
138 }
139
140
141 $cbgr = new ilCheckboxGroupInputGUI('', 'filter_type');
142 $cbgr->setUseValuesAsKeys(true);
143 $details = $this->getDetails();
144 $det = false;
145 foreach (ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions() as $type => $data) {
146 $cb = new ilCheckboxOption($lng->txt($data['trans']), $type);
147 if ($details[$type]) {
148 $det = true;
149 }
150 $cbgr->addOption($cb);
151 }
152 if ($a_mode == self::SEARCH_FORM_LUCENE) {
153 if (ilSearchSettings::getInstance()->isLuceneMimeFilterEnabled()) {
154 $mimes = $this->getMimeDetails();
155 foreach (ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions() as $type => $data) {
156 $op3 = new ilCheckboxOption($this->lng->txt($data['trans']), $type);
157 if ($mimes[$type]) {
158 $det = true;
159 }
160 $cbgr->addOption($op3);
161 }
162 }
163 }
164
165 $cbgr->setValue(array_merge((array) $details, (array) $mimes));
166 $op2->addSubItem($cbgr);
167
168 if ($a_mode != self::SEARCH_FORM_STANDARD && $det) {
169 $op2->setChecked(true);
170 }
171
173 $radg->addOption($op2);
174 $this->form->addItem($radg);
175 } else {
176 $this->form->addItem($op2);
177 }
178 }
179
180 $this->form->setFormAction($ilCtrl->getFormAction($this, 'performSearch'));
181 }
182
186 public function getSearchAreaForm()
187 {
188 global $DIC;
189
190 $lng = $DIC['lng'];
191 $ilCtrl = $DIC['ilCtrl'];
192
193 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
194 $form = new ilPropertyFormGUI();
195 $form->setOpenTag(false);
196 $form->setCloseTag(false);
197
198 // term combination
199 $radg = new ilHiddenInputGUI('search_term_combination');
200 $radg->setValue(ilSearchSettings::getInstance()->getDefaultOperator());
201 $form->addItem($radg);
202
203 // search area
204 include_once("./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
205 $ti = new ilRepositorySelectorInputGUI($lng->txt("search_area"), "area");
206 $ti->setSelectText($lng->txt("search_select_search_area"));
207 $form->addItem($ti);
208 $ti->readFromSession();
209
210 // alex, 15.8.2012: Added the following lines to get the value
211 // from the main menu top right input search form
212 if (isset($_POST["root_id"])) {
213 $ti->setValue($_POST["root_id"]);
214 $ti->writeToSession();
215 }
216 $form->setFormAction($ilCtrl->getFormAction($this, 'performSearch'));
217
218 return $form;
219 }
220
221
226 public function handleCommand($a_cmd)
227 {
228 if (method_exists($this, $a_cmd)) {
229 $this->$a_cmd();
230 } else {
231 $a_cmd .= 'Object';
232 $this->$a_cmd();
233 }
234 }
235
239 public function addToDeskObject()
240 {
241 $this->favourites->add($this->user->getId(), (int) $_GET["item_ref_id"]);
242 $this->showSavedResults();
243 }
244
248 public function removeFromDeskObject()
249 {
250 $this->favourites->remove($this->user->getId(), (int) $_GET["item_ref_id"]);
251 $this->showSavedResults();
252 }
253
257 public function delete()
258 {
259 $admin = new ilAdministrationCommandGUI($this);
260 $admin->delete();
261 }
262
266 public function cancelDelete()
267 {
268 $this->showSavedResults();
269 }
270
271 public function cancelMoveLinkObject()
272 {
273 $this->showSavedResults();
274 }
275
279 public function performDelete()
280 {
281 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
282 $admin = new ilAdministrationCommandGUI($this);
283 $admin->performDelete();
284 }
285
289 public function cut()
290 {
291 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
292 $admin = new ilAdministrationCommandGUI($this);
293 $admin->cut();
294 }
295
299 public function link()
300 {
301 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
302 $admin = new ilAdministrationCommandGUI($this);
303 $admin->link();
304 }
305
306 public function paste()
307 {
308 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
309 $admin = new ilAdministrationCommandGUI($this);
310 $admin->paste();
311 }
312
314 {
315 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
316 $admin = new ilAdministrationCommandGUI($this);
317 $admin->showLinkIntoMultipleObjectsTree();
318 }
319
320 public function showPasteTree()
321 {
322 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
323 $admin = new ilAdministrationCommandGUI($this);
324 $admin->showPasteTree();
325 }
326
328 {
329 include_once './Services/Administration/classes/class.ilAdministrationCommandGUI.php';
330 $admin = new ilAdministrationCommandGUI($this);
331 $admin->performPasteIntoMultipleObjects();
332 }
333
334 public function clear()
335 {
336 unset($_SESSION['clipboard']);
337 $this->ctrl->redirect($this);
338 }
339
341 {
342 $_SESSION["il_cont_admin_panel"] = true;
343 $this->ctrl->redirect($this);
344 }
345
347 {
348 $_SESSION["il_cont_admin_panel"] = false;
349 $this->ctrl->redirect($this);
350 }
351
356 {
357 $this->ctrl->redirect($this);
358 }
359
360
364 public function addLocator()
365 {
366 $ilLocator->addItem($this->lng->txt('search'), $this->ctrl->getLinkTarget($this));
367 $this->tpl->setLocator();
368 }
369
377 protected function addPager($result, $a_session_key)
378 {
379 global $DIC;
380
381 $tpl = $DIC['tpl'];
382
383 $_SESSION["$a_session_key"] = max($_SESSION["$a_session_key"], $this->search_cache->getResultPageNumber());
384
385 if ($_SESSION["$a_session_key"] == 1 and
386 (count($result->getResults()) < $result->getMaxHits())) {
387 return true;
388 }
389
390 if ($this->search_cache->getResultPageNumber() > 1) {
391 $this->ctrl->setParameter($this, 'page_number', $this->search_cache->getResultPageNumber() - 1);
392 /* $this->tpl->setCurrentBlock('prev');
393 $this->tpl->setVariable('PREV_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
394 $this->tpl->setVariable('TXT_PREV',$this->lng->txt('search_page_prev'));
395 $this->tpl->parseCurrentBlock();
396 */
397 $this->prev_link = $this->ctrl->getLinkTarget($this, 'performSearch');
398 }
399 for ($i = 1;$i <= $_SESSION["$a_session_key"];$i++) {
400 if ($i == $this->search_cache->getResultPageNumber()) {
401 /* $this->tpl->setCurrentBlock('pages_link');
402 $this->tpl->setVariable('NUMBER',$i);
403 $this->tpl->parseCurrentBlock();
404 */
405 continue;
406 }
407
408 $this->ctrl->setParameter($this, 'page_number', $i);
409 $link = '<a href="' . $this->ctrl->getLinkTarget($this, 'performSearch') . '" /a>' . $i . '</a> ';
410 /* $this->tpl->setCurrentBlock('pages_link');
411 $this->tpl->setVariable('NUMBER',$link);
412 $this->tpl->parseCurrentBlock();
413 */
414 }
415
416
417 if (count($result->getResults()) >= $result->getMaxHits()) {
418 $this->ctrl->setParameter($this, 'page_number', $this->search_cache->getResultPageNumber() + 1);
419 /* $this->tpl->setCurrentBlock('next');
420 $this->tpl->setVariable('NEXT_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
421 $this->tpl->setVariable('TXT_NEXT',$this->lng->txt('search_page_next'));
422 $this->tpl->parseCurrentBlock();
423 */
424 $this->next_link = $this->ctrl->getLinkTarget($this, 'performSearch');
425 }
426
427 /* $this->tpl->setCurrentBlock('prev_next');
428 $this->tpl->setVariable('SEARCH_PAGE',$this->lng->txt('search_page'));
429 $this->tpl->parseCurrentBlock();
430 */
431
432 $this->ctrl->clearParameters($this);
433 }
434
439 protected function buildSearchAreaPath($a_root_node)
440 {
441 global $DIC;
442
443 $tree = $DIC['tree'];
444
445 $path_arr = $tree->getPathFull($a_root_node, ROOT_FOLDER_ID);
446 $counter = 0;
447 foreach ($path_arr as $data) {
448 if ($counter++) {
449 $path .= " > ";
450 $path .= $data['title'];
451 } else {
452 $path .= $this->lng->txt('repository');
453 }
454 }
455 return $path;
456 }
457
461 public function autoComplete()
462 {
463 $q = $_REQUEST["term"];
464 include_once("./Services/Search/classes/class.ilSearchAutoComplete.php");
466 echo $list;
467 exit;
468 }
469
470 // begin-patch creation_date
471 protected function getCreationDateForm()
472 {
473 $options = $this->search_cache->getCreationFilter();
474
475 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
476 $form = new ilPropertyFormGUI();
477 $form->setOpenTag(false);
478 $form->setCloseTag(false);
479
480 $enabled = new ilCheckboxInputGUI($this->lng->txt('search_filter_cd'), 'screation');
481 $enabled->setValue(1);
482 $enabled->setChecked((bool) $options['enabled']);
483 $form->addItem($enabled);
484
485 #$group = new ilRadioGroupInputGUI('', 'screation_type');
486 #$group->setValue((int) $options['type']);
487 #$group->addOption($opt1 = new ilRadioOption($this->lng->txt('search_filter_date'), 1));
488
489 $limit_sel = new ilSelectInputGUI('', 'screation_ontype');
490 $limit_sel->setValue($options['ontype']);
491 $limit_sel->setOptions(
492 array(
493 1 => $this->lng->txt('search_created_after'),
494 2 => $this->lng->txt('search_created_before'),
495 3 => $this->lng->txt('search_created_on')
496 )
497 );
498 $enabled->addSubItem($limit_sel);
499
500
501 if ($options['date']) {
502 $now = new ilDate($options['date'], IL_CAL_UNIX);
503 } else {
504 $now = new ilDate(time(), IL_CAL_UNIX);
505 }
506 $ds = new ilDateTimeInputGUI('', 'screation_date');
507 $ds->setRequired(true);
508 $ds->setDate($now);
509 $enabled->addSubItem($ds);
510
511 #$group->addOption($opt2 = new ilRadioOption($this->lng->txt('search_filter_duration'), 2));
512
513 #$duration = new ilDurationInputGUI($this->lng->txt('search_filter_duration'), 'screation_duration');
514 #$duration->setMonths((int) $options['duration']['MM']);
515 #$duration->setDays((int) $options['duration']['dd']);
516 #$duration->setShowMonths(true);
517 #$duration->setShowDays(true);
518 #$duration->setShowHours(false);
519 #$duration->setShowMinutes(false);
520 #$duration->setTitle($this->lng->txt('search_newer_than'));
521 #$opt2->addSubItem($duration);
522
523 #$enabled->addSubItem($group);
524
525 $form->setFormAction($GLOBALS['DIC']['ilCtrl']->getFormAction($this, 'performSearch'));
526
527 return $form;
528 }
529
534 protected function getSearchCache()
535 {
536 return $this->search_cache;
537 }
538
543 protected function loadCreationFilter()
544 {
545 if (!$this->settings->isDateFilterEnabled()) {
546 return array();
547 }
548
549
550 $form = $this->getCreationDateForm();
551 $options = array();
552 if ($form->checkInput()) {
553 $options['enabled'] = $form->getInput('screation');
554 $options['type'] = $form->getInput('screation_type');
555 $options['ontype'] = $form->getInput('screation_ontype');
556 $options['date'] = $form->getItemByPostVar('screation_date')->getDate()->get(IL_CAL_UNIX);
557 $options['duration'] = $form->getInput('screation_duration');
558 }
559 return $options;
560 }
561}
$result
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_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.
Manages favourites, currently the interface for other components, needs discussion.
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)
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:29
$i
Definition: metadata.php:24
redirection script todo: (a better solution should control the processing via a xml file)
$type
settings()
Definition: settings.php:2
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46