31 include_once
'class.ilMDBase.php';
38 $this->keyword = $a_keyword;
42 return $this->keyword;
46 if (is_object($lng_obj)) {
47 $this->keyword_language = $lng_obj;
52 return is_object($this->keyword_language) ? $this->keyword_language :
false;
56 return is_object($this->keyword_language) ? $this->keyword_language->getLanguageCode() :
false;
66 $fields[
'meta_keyword_id'] = array(
'integer',$next_id =
$ilDB->nextId(
'il_meta_keyword'));
68 if ($this->db->insert(
'il_meta_keyword', $fields)) {
82 if ($this->db->update(
85 array(
"meta_keyword_id" => array(
'integer',$this->
getMetaId()))
93 public function delete()
100 $query =
"DELETE FROM il_meta_keyword " .
101 "WHERE meta_keyword_id = " .
$ilDB->quote($this->
getMetaId(),
'integer');
112 return array(
'rbac_id' => array(
'integer',$this->
getRBACId()),
113 'obj_id' => array(
'integer', $this->
getObjId()),
114 'obj_type' => array(
'text', $this->
getObjType()),
116 'parent_id' => array(
'integer', $this->
getParentId()),
117 'keyword' => array(
'text', $this->
getKeyword()),
125 $ilDB = $DIC[
'ilDB'];
127 include_once
'Services/MetaData/classes/class.ilMDLanguageItem.php';
130 $query =
"SELECT * FROM il_meta_keyword " .
131 "WHERE meta_keyword_id = " .
$ilDB->quote($this->
getMetaId(),
'integer');
165 public static function _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
169 $ilDB = $DIC[
'ilDB'];
171 $query =
"SELECT meta_keyword_id FROM il_meta_keyword " .
172 "WHERE rbac_id = " .
$ilDB->quote($a_rbac_id,
'integer') .
" " .
173 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
174 "AND parent_id = " .
$ilDB->quote($a_parent_id,
'integer') .
" " .
175 "AND parent_type = " .
$ilDB->quote($a_parent_type,
'text') .
" " .
176 "ORDER BY meta_keyword_id ";
180 $ids[] =
$row->meta_keyword_id;
182 return $ids ? $ids : array();
199 $ilDB = $DIC[
'ilDB'];
200 $ilObjDataCache = $DIC[
'ilObjDataCache'];
202 $query =
"SELECT keyword,keyword_language " .
203 "FROM il_meta_keyword " .
204 "WHERE rbac_id = " .
$ilDB->quote($a_rbac_id,
'integer') .
" " .
205 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
206 "AND obj_type = " .
$ilDB->quote(
$a_type,
'text') .
" ";
210 $keywords[
$row->keyword_language][] =
$row->keyword;
213 return $keywords ? $keywords : array();
228 $key_string[$lng_code] = implode(
",", $keywords);
230 return $key_string ? $key_string : array();
244 $ilDB = $DIC[
'ilDB'];
248 foreach ((array) explode(
' ', $a_query) as $part) {
252 $qs .= (
$ilDB->like(
'keyword',
'text', $part) .
' ');
256 $query =
"SELECT obj_id FROM il_meta_keyword " .
257 "WHERE rbac_id = " .
$ilDB->quote($a_rbac_id,
'integer') .
' ' .
258 'AND obj_type = ' .
$ilDB->quote(
$a_type,
'text') .
' ' .
261 $query =
"SELECT obj_id FROM il_meta_keyword " .
262 'WHERE obj_type = ' .
$ilDB->quote(
$a_type,
'text') .
' ' .
268 $obj_ids[] =
$row->obj_id;
271 return (array) $obj_ids;
286 $ilDB = $DIC[
'ilDB'];
288 $query =
"SELECT DISTINCT keyword FROM il_meta_keyword " .
289 'WHERE obj_type = ' .
$ilDB->quote(
$a_type,
'text') .
' ' .
290 'AND ' .
$ilDB->like(
'keyword',
'text',
'%' . trim($a_query) .
'%') .
' ';
293 $query .=
"AND rbac_id = " .
$ilDB->quote($a_rbac_id,
'integer') .
' ';
298 $kws[] =
$row->keyword;
310 public static function lookupKeywords($a_rbac_id, $a_obj_id, $a_return_ids =
false)
314 $ilDB = $DIC[
'ilDB'];
316 $query =
"SELECT * FROM il_meta_keyword " .
317 "WHERE rbac_id = " .
$ilDB->quote($a_rbac_id,
'integer') .
' ' .
318 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
' ';
321 if (!$a_return_ids) {
322 if (strlen(
$row->keyword)) {
323 $kws[] =
$row->keyword;
326 $kws[] =
$row->meta_keyword_id;
340 $new_keywords = array();
341 foreach ($a_keywords as
$lang => $keywords) {
342 foreach ((array) $keywords as $keyword) {
343 $keyword = trim($keyword);
344 if ($keyword !=
"" &&
345 !(is_array($new_keywords[
$lang]) && in_array($keyword, $new_keywords[$lang]))) {
346 $new_keywords[
$lang][] = $keyword;
354 $lang = $md_key->getKeywordLanguageCode();
357 if (is_array($new_keywords[
$lang]) &&
358 in_array($md_key->getKeyword(), $new_keywords[
$lang])) {
359 unset($new_keywords[$lang]
360 [array_search($md_key->getKeyword(), $new_keywords[
$lang])]);
367 foreach ($new_keywords as
$lang => $key_arr) {
368 foreach ($key_arr as $keyword) {
369 if ($keyword !=
"") {
& getKeyword($a_keyword_id)
static _searchKeywords($a_query, $a_type, $a_rbac_id=0)
Search for objects by keywords.
if(!array_key_exists('StateId', $_REQUEST)) $id
static updateKeywords(ilMDGeneral $a_md_section, array $a_keywords)
Update keywords from input array.
setMetaId($a_meta_id, $a_read_data=true)
foreach($_POST as $key=> $value) $res
setKeywordLanguage(&$lng_obj)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _getMatchingKeywords($a_query, $a_type, $a_rbac_id=0)
Search for keywords.
static _getKeywordsByLanguage($a_rbac_id, $a_obj_id, $a_type)
Get keywords by language.
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
setParentType($a_parent_type)
static lookupKeywords($a_rbac_id, $a_obj_id, $a_return_ids=false)
Lookup Keywords.
static _getKeywordsByLanguageAsString($a_rbac_id, $a_obj_id, $a_type)
Get keywords by language as string.