31 include_once
'class.ilMDBase.php';
35 function ilMDKeyword($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type =
'')
45 $this->keyword = $a_keyword;
49 return $this->keyword;
53 if(is_object($lng_obj))
55 $this->keyword_language = $lng_obj;
60 return is_object($this->keyword_language) ? $this->keyword_language :
false;
64 return is_object($this->keyword_language) ? $this->keyword_language->getLanguageCode() :
false;
72 $fields[
'meta_keyword_id'] = array(
'integer',$next_id = $ilDB->nextId(
'il_meta_keyword'));
74 if($this->db->insert(
'il_meta_keyword',$fields))
88 if($this->db->update(
'il_meta_keyword',
90 array(
"meta_keyword_id" => array(
'integer',$this->
getMetaId()))))
104 $query =
"DELETE FROM il_meta_keyword ".
105 "WHERE meta_keyword_id = ".$ilDB->quote($this->
getMetaId() ,
'integer');
116 return array(
'rbac_id' => array(
'integer',$this->
getRBACId()),
117 'obj_id' => array(
'integer', $this->
getObjId()),
118 'obj_type' => array(
'text', $this->
getObjType()),
120 'parent_id' => array(
'integer', $this->
getParentId()),
121 'keyword' => array(
'text', $this->
getKeyword()),
129 include_once
'Services/MetaData/classes/class.ilMDLanguageItem.php';
133 $query =
"SELECT * FROM il_meta_keyword ".
134 "WHERE meta_keyword_id = ".$ilDB->quote($this->
getMetaId() ,
'integer');
166 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
170 $query =
"SELECT meta_keyword_id FROM il_meta_keyword ".
171 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,
'integer').
" ".
172 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
173 "AND parent_id = ".$ilDB->quote($a_parent_id ,
'integer').
" ".
174 "AND parent_type = ".$ilDB->quote($a_parent_type ,
'text').
" ".
175 "ORDER BY meta_keyword_id ";
180 $ids[] =
$row->meta_keyword_id;
182 return $ids ? $ids : array();
197 global $ilDB,$ilObjDataCache;
199 $query =
"SELECT keyword,keyword_language ".
200 "FROM il_meta_keyword ".
201 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,
'integer').
" ".
202 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
203 "AND obj_type = ".$ilDB->quote($a_type ,
'text').
" ";
209 $keywords[
$row->keyword_language][] =
$row->keyword;
212 return $keywords ? $keywords : array();
228 $key_string[$lng_code] = implode(
",",$keywords);
230 return $key_string ? $key_string : array();
246 foreach((array) explode(
' ',$a_query) as $part)
252 $qs .= ($ilDB->like(
'keyword',
'text',$part).
' ');
257 $query =
"SELECT obj_id FROM il_meta_keyword ".
258 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id,
'integer').
' '.
259 'AND obj_type = '.$ilDB->quote($a_type,
'text').
' '.
264 $query =
"SELECT obj_id FROM il_meta_keyword ".
265 'WHERE obj_type = '.$ilDB->quote($a_type,
'text').
' '.
272 $obj_ids[] =
$row->obj_id;
275 return (array) $obj_ids;
290 $query =
"SELECT DISTINCT keyword FROM il_meta_keyword ".
291 'WHERE obj_type = '.$ilDB->quote($a_type,
'text').
' '.
292 'AND '.$ilDB->like(
'keyword',
'text',
'%'.trim($a_query).
'%').
' ';
296 $query .=
"AND rbac_id = ".$ilDB->quote($a_rbac_id,
'integer').
' ';
302 $kws[] =
$row->keyword;
314 public static function lookupKeywords($a_rbac_id, $a_obj_id, $a_return_ids =
false)
318 $query =
"SELECT * FROM il_meta_keyword ".
319 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id,
'integer').
' '.
320 "AND obj_id = ".$ilDB->quote($a_obj_id,
'integer').
' ';
326 if(strlen(
$row->keyword))
328 $kws[] =
$row->keyword;
333 $kws[] =
$row->meta_keyword_id;
347 $new_keywords = array();
348 foreach($a_keywords as
$lang => $keywords)
350 foreach($keywords as $keyword)
352 $keyword = trim($keyword);
353 if ($keyword !=
"" &&
354 !(is_array($new_keywords[
$lang]) && in_array($keyword, $new_keywords[$lang])))
356 $new_keywords[
$lang][] = $keyword;
365 $lang = $md_key->getKeywordLanguageCode();
368 if (is_array($new_keywords[
$lang]) &&
369 in_array($md_key->getKeyword(), $new_keywords[
$lang]))
371 unset($new_keywords[$lang]
372 [array_search($md_key->getKeyword(), $new_keywords[
$lang])]);
381 foreach ($new_keywords as
$lang => $key_arr)
383 foreach($key_arr as $keyword)