ILIAS  release_8 Revision v8.24
class.ilMDSearch.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/*
5 +-----------------------------------------------------------------------------+
6 | ILIAS open source |
7 +-----------------------------------------------------------------------------+
8 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
9 | |
10 | This program is free software; you can redistribute it and/or |
11 | modify it under the terms of the GNU General Public License |
12 | as published by the Free Software Foundation; either version 2 |
13 | of the License, or (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 +-----------------------------------------------------------------------------+
24*/
25
34{
35 private string $mode = '';
36
40
41 public function __construct(ilQueryParser $qp_obj)
42 {
43 global $DIC;
44
45 $this->query_parser = $qp_obj;
46 $this->db = $DIC->database();
47 $this->search_result = new ilSearchResult();
48 }
49
50 public function setMode(string $a_mode): void
51 {
52 $this->mode = $a_mode;
53 }
54
55 public function getMode(): string
56 {
57 return $this->mode;
58 }
59
60 public function performSearch(): ?ilSearchResult
61 {
62 switch ($this->getMode()) {
63 case 'all':
64 break;
65 case 'keyword':
66 return $this->__searchKeywordsOnly();
67 break;
68
69 default:
70 echo "ilMDSearch::performSearch() no mode given";
71 return null;
72 }
73 return null;
74 }
75
77 {
78 $where = " WHERE ";
79 $field = " keyword ";
80 $counter = 0;
81 foreach ($this->query_parser->getQuotedWords() as $word) {
82 if ($counter++) {
83 $where .= strtoupper($this->query_parser->getCombination());
84 }
85 $where .= $field;
86 $where .= ("LIKE (" . $this->db->quote("%" . $word . "%", ilDBConstants::T_TEXT) . ")");
87 }
88
89 $query = "SELECT * FROM il_meta_keyword" .
90 $where .
91 "ORDER BY meta_keyword_id DESC";
92
93 $res = $this->db->query($query);
94 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
95 $this->search_result->addEntry($row->obj_id, $row->obj_type, $row->rbac_id);
96 }
98 }
99}
setMode(string $a_mode)
ilDBInterface $db
ilQueryParser $query_parser
ilSearchResult $search_result
__construct(ilQueryParser $qp_obj)
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query