ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilMDKeyword Class Reference
+ Inheritance diagram for ilMDKeyword:
+ Collaboration diagram for ilMDKeyword:

Public Member Functions

 ilMDKeyword ($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
 
 setKeyword ($a_keyword)
 
 getKeyword ()
 
 setKeywordLanguage (&$lng_obj)
 
getKeywordLanguage ()
 
 getKeywordLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (&$writer)
 
 _getIds ($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
 
 ilMDKeyword ($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
 
 setKeyword ($a_keyword)
 
 getKeyword ()
 
 setKeywordLanguage (&$lng_obj)
 
getKeywordLanguage ()
 
 getKeywordLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (&$writer)
 
 _getIds ($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
 
- Public Member Functions inherited from ilMDBase
 ilMDBase ($a_rbac_id=0, $a_obj_id=0, $a_type=0)
 
 setRBACId ($a_id)
 
 getRBACId ()
 
 setObjId ($a_id)
 
 getObjId ()
 
 setObjType ($a_type)
 
 getObjType ()
 
 setMetaId ($a_meta_id, $a_read_data=true)
 
 getMetaId ()
 
 setParentType ($a_parent_type)
 
 getParentType ()
 
 setParentId ($a_id)
 
 getParentId ()
 
 setExportMode ($a_export_mode=true)
 
 getExportMode ()
 
 validate ()
 
 update ()
 
 save ()
 
 delete ()
 
 toXML (&$writer)
 
 ilMDBase ($a_rbac_id=0, $a_obj_id=0, $a_type=0)
 
 setRBACId ($a_id)
 
 getRBACId ()
 
 setObjId ($a_id)
 
 getObjId ()
 
 setObjType ($a_type)
 
 getObjType ()
 
 setMetaId ($a_meta_id, $a_read_data=true)
 
 getMetaId ()
 
 setParentType ($a_parent_type)
 
 getParentType ()
 
 setParentId ($a_id)
 
 getParentId ()
 
 validate ()
 
 update ()
 
 save ()
 
 delete ()
 
 toXML (&$writer)
 

Static Public Member Functions

static _getKeywordsByLanguage ($a_rbac_id, $a_obj_id, $a_type)
 Get keywords by language. More...
 
static _getKeywordsByLanguageAsString ($a_rbac_id, $a_obj_id, $a_type)
 Get keywords by language as string. More...
 
static _searchKeywords ($a_query, $a_type, $a_rbac_id=0)
 Search for objects by keywords. More...
 
static _getMatchingKeywords ($a_query, $a_type, $a_rbac_id=0)
 Search for keywords. More...
 
static lookupKeywords ($a_rbac_id, $a_obj_id, $a_return_ids=false)
 Lookup Keywords. More...
 
static updateKeywords (ilMDGeneral $a_md_section, array $a_keywords)
 Update keywords from input array. More...
 

Additional Inherited Members

- Data Fields inherited from ilMDBase
 $rbac_id
 
 $obj_id
 
 $obj_type
 
 $export_mode = false
 

Detailed Description

Definition at line 33 of file class.ilMDKeyword.php.

Member Function Documentation

◆ __getFields() [1/2]

ilMDKeyword::__getFields ( )

Definition at line 114 of file class.ilMDKeyword.php.

References getKeyword(), getKeywordLanguageCode(), ilMDBase\getObjId(), ilMDBase\getObjType(), ilMDBase\getParentId(), ilMDBase\getParentType(), and ilMDBase\getRBACId().

Referenced by save().

115  {
116  return array('rbac_id' => array('integer',$this->getRBACId()),
117  'obj_id' => array('integer', $this->getObjId()),
118  'obj_type' => array('text', $this->getObjType()),
119  'parent_type' => array('text', $this->getParentType()),
120  'parent_id' => array('integer', $this->getParentId()),
121  'keyword' => array('text', $this->getKeyword()),
122  'keyword_language' => array('text', $this->getKeywordLanguageCode()));
123  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getFields() [2/2]

ilMDKeyword::__getFields ( )

Definition at line 114 of file class.ilMDKeyword.php.

References getKeyword(), getKeywordLanguageCode(), ilMDBase\getObjId(), ilMDBase\getObjType(), ilMDBase\getParentId(), ilMDBase\getParentType(), ilMDBase\getRBACId(), and ilUtil\prepareDBString().

115  {
116  return array('rbac_id' => $this->getRBACId(),
117  'obj_id' => $this->getObjId(),
118  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
119  'parent_type' => $this->getParentType(),
120  'parent_id' => $this->getParentId(),
121  'keyword' => ilUtil::prepareDBString($this->getKeyword()),
122  'keyword_language' => ilUtil::prepareDBString($this->getKeywordLanguageCode()));
123  }
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
+ Here is the call graph for this function:

◆ _getIds() [1/2]

ilMDKeyword::_getIds (   $a_rbac_id,
  $a_obj_id,
  $a_parent_id,
  $a_parent_type 
)

Definition at line 163 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

164  {
165  global $ilDB;
166 
167  $query = "SELECT meta_keyword_id FROM il_meta_keyword ".
168  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
169  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
170  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
171  "AND parent_type = ".$ilDB->quote($a_parent_type);
172 
173  $res = $ilDB->query($query);
174  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
175  {
176  $ids[] = $row->meta_keyword_id;
177  }
178  return $ids ? $ids : array();
179  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB

◆ _getIds() [2/2]

ilMDKeyword::_getIds (   $a_rbac_id,
  $a_obj_id,
  $a_parent_id,
  $a_parent_type 
)

Definition at line 166 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilMDClassification\getKeywordIds(), and ilMDGeneral\getKeywordIds().

167  {
168  global $ilDB;
169 
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 ";
176 
177  $res = $ilDB->query($query);
178  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
179  {
180  $ids[] = $row->meta_keyword_id;
181  }
182  return $ids ? $ids : array();
183  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ _getKeywordsByLanguage()

static ilMDKeyword::_getKeywordsByLanguage (   $a_rbac_id,
  $a_obj_id,
  $a_type 
)
static

Get keywords by language.

public

Parameters
intrbac_id
intobj_id
stringobj type

Definition at line 195 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by _getKeywordsByLanguageAsString().

196  {
197  global $ilDB,$ilObjDataCache;
198 
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')." ";
204  $res = $ilDB->query($query);
205  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
206  {
207  if($row->keyword)
208  {
209  $keywords[$row->keyword_language][] = $row->keyword;
210  }
211  }
212  return $keywords ? $keywords : array();
213  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ _getKeywordsByLanguageAsString()

static ilMDKeyword::_getKeywordsByLanguageAsString (   $a_rbac_id,
  $a_obj_id,
  $a_type 
)
static

Get keywords by language as string.

public

Parameters
intrbac_id
intobj_id
stringobj type

Definition at line 224 of file class.ilMDKeyword.php.

References _getKeywordsByLanguage().

Referenced by ilMDUtils\_fillHTMLMetaTags().

225  {
226  foreach(ilMDKeyword::_getKeywordsByLanguage($a_rbac_id,$a_obj_id,$a_type) as $lng_code => $keywords)
227  {
228  $key_string[$lng_code] = implode(",",$keywords);
229  }
230  return $key_string ? $key_string : array();
231  }
static _getKeywordsByLanguage($a_rbac_id, $a_obj_id, $a_type)
Get keywords by language.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getMatchingKeywords()

static ilMDKeyword::_getMatchingKeywords (   $a_query,
  $a_type,
  $a_rbac_id = 0 
)
static

Search for keywords.

Parameters
string$a_query
string$a_type
int$a_rbac_id[optional]
Returns

Definition at line 286 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilMDEditorGUI\keywordAutocomplete(), and ilBlogPostingGUI\keywordAutocomplete().

287  {
288  global $ilDB;
289 
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).'%').' ';
293 
294  if($a_rbac_id)
295  {
296  $query .= "AND rbac_id = ".$ilDB->quote($a_rbac_id,'integer').' ';
297  }
298 
299  $res = $ilDB->query($query);
300  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
301  {
302  $kws[] = $row->keyword;
303  }
304  return (array) $kws;
305  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ _searchKeywords()

static ilMDKeyword::_searchKeywords (   $a_query,
  $a_type,
  $a_rbac_id = 0 
)
static

Search for objects by keywords.

Parameters
string$a_query
string$a_type
int$a_rbac_id[optional]
Returns

Definition at line 240 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjMediaPool\getMediaObjects().

241  {
242  global $ilDB;
243 
244  $qs = 'AND ';
245  $counter = 0;
246  foreach((array) explode(' ',$a_query) as $part)
247  {
248  if($counter++)
249  {
250  $qs .= 'OR ';
251  }
252  $qs .= ($ilDB->like('keyword','text',$part).' ');
253  }
254 
255  if($a_rbac_id)
256  {
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').' '.
260  $qs;
261  }
262  else
263  {
264  $query = "SELECT obj_id FROM il_meta_keyword ".
265  'WHERE obj_type = '.$ilDB->quote($a_type,'text').' '.
266  $qs;
267  }
268 
269  $res = $ilDB->query($query);
270  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
271  {
272  $obj_ids[] = $row->obj_id;
273  }
274 
275  return (array) $obj_ids;
276  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ delete() [1/2]

ilMDKeyword::delete ( )

Definition at line 97 of file class.ilMDKeyword.php.

References $ilDB, $query, and ilMDBase\getMetaId().

98  {
99  global $ilDB;
100 
101  if($this->getMetaId())
102  {
103  $query = "DELETE FROM il_meta_keyword ".
104  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId());
105 
106  $this->db->query($query);
107 
108  return true;
109  }
110  return false;
111  }
global $ilDB
+ Here is the call graph for this function:

◆ delete() [2/2]

ilMDKeyword::delete ( )

Definition at line 98 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, and ilMDBase\getMetaId().

99  {
100  global $ilDB;
101 
102  if($this->getMetaId())
103  {
104  $query = "DELETE FROM il_meta_keyword ".
105  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId() ,'integer');
106  $res = $ilDB->manipulate($query);
107 
108  return true;
109  }
110  return false;
111  }
global $ilDB
+ Here is the call graph for this function:

◆ getKeyword() [1/2]

ilMDKeyword::getKeyword ( )

Definition at line 47 of file class.ilMDKeyword.php.

Referenced by __getFields(), and toXML().

48  {
49  return $this->keyword;
50  }
+ Here is the caller graph for this function:

◆ getKeyword() [2/2]

ilMDKeyword::getKeyword ( )

Definition at line 47 of file class.ilMDKeyword.php.

48  {
49  return $this->keyword;
50  }

◆ getKeywordLanguage() [1/2]

& ilMDKeyword::getKeywordLanguage ( )

Definition at line 58 of file class.ilMDKeyword.php.

59  {
60  return is_object($this->keyword_language) ? $this->keyword_language : false;
61  }

◆ getKeywordLanguage() [2/2]

& ilMDKeyword::getKeywordLanguage ( )

Definition at line 58 of file class.ilMDKeyword.php.

59  {
60  return is_object($this->keyword_language) ? $this->keyword_language : false;
61  }

◆ getKeywordLanguageCode() [1/2]

ilMDKeyword::getKeywordLanguageCode ( )

Definition at line 62 of file class.ilMDKeyword.php.

63  {
64  return is_object($this->keyword_language) ? $this->keyword_language->getLanguageCode() : false;
65  }

◆ getKeywordLanguageCode() [2/2]

ilMDKeyword::getKeywordLanguageCode ( )

Definition at line 62 of file class.ilMDKeyword.php.

Referenced by __getFields(), and toXML().

63  {
64  return is_object($this->keyword_language) ? $this->keyword_language->getLanguageCode() : false;
65  }
+ Here is the caller graph for this function:

◆ ilMDKeyword() [1/2]

ilMDKeyword::ilMDKeyword (   $a_rbac_id = 0,
  $a_obj_id = 0,
  $a_obj_type = '' 
)

Definition at line 35 of file class.ilMDKeyword.php.

36  {
37  parent::ilMDBase($a_rbac_id,
38  $a_obj_id,
39  $a_obj_type);
40  }

◆ ilMDKeyword() [2/2]

ilMDKeyword::ilMDKeyword (   $a_rbac_id = 0,
  $a_obj_id = 0,
  $a_obj_type = '' 
)

Definition at line 35 of file class.ilMDKeyword.php.

36  {
37  parent::ilMDBase($a_rbac_id,
38  $a_obj_id,
39  $a_obj_type);
40  }

◆ lookupKeywords()

static ilMDKeyword::lookupKeywords (   $a_rbac_id,
  $a_obj_id,
  $a_return_ids = false 
)
static

Lookup Keywords.

Parameters
object$a_rbac_id
object$a_obj_id
bool$a_return_kw
Returns

Definition at line 314 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjMediaObjectGUI\_getMediaInfoHTML(), and ilBlogPosting\getKeywords().

315  {
316  global $ilDB;
317 
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').' ';
321  $res = $ilDB->query($query);
322  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
323  {
324  if(!$a_return_ids)
325  {
326  if(strlen($row->keyword))
327  {
328  $kws[] = $row->keyword;
329  }
330  }
331  else
332  {
333  $kws[] = $row->meta_keyword_id;
334  }
335  }
336  return (array) $kws;
337  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ read() [1/2]

ilMDKeyword::read ( )

Definition at line 125 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, ilMDBase\getMetaId(), setKeyword(), setKeywordLanguage(), ilMDBase\setObjId(), ilMDBase\setObjType(), ilMDBase\setParentId(), ilMDBase\setParentType(), and ilMDBase\setRBACId().

126  {
127  global $ilDB;
128 
129  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
130 
131  if($this->getMetaId())
132  {
133  $query = "SELECT * FROM il_meta_keyword ".
134  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId() ,'integer');
135 
136  $res = $this->db->query($query);
137  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
138  {
139  $this->setRBACId($row->rbac_id);
140  $this->setObjId($row->obj_id);
141  $this->setObjType($row->obj_type);
142  $this->setParentId($row->parent_id);
143  $this->setParentType($row->parent_type);
144  $this->setKeyword($row->keyword);
145  $this->setKeywordLanguage( new ilMDLanguageItem($row->keyword_language));
146  }
147  }
148  return true;
149  }
setObjType($a_type)
setKeyword($a_keyword)
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setKeywordLanguage(&$lng_obj)
setObjId($a_id)
setRBACId($a_id)
setParentId($a_id)
global $ilDB
setParentType($a_parent_type)
+ Here is the call graph for this function:

◆ read() [2/2]

ilMDKeyword::read ( )

Definition at line 125 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, ilMDBase\getMetaId(), setKeyword(), setKeywordLanguage(), ilMDBase\setObjId(), ilMDBase\setObjType(), ilMDBase\setParentId(), ilMDBase\setParentType(), ilMDBase\setRBACId(), and ilUtil\stripSlashes().

126  {
127  global $ilDB;
128 
129  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
130 
131  if($this->getMetaId())
132  {
133  $query = "SELECT * FROM il_meta_keyword ".
134  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId());
135 
136  $res = $this->db->query($query);
137  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
138  {
139  $this->setRBACId($row->rbac_id);
140  $this->setObjId($row->obj_id);
141  $this->setObjType($row->obj_type);
142  $this->setParentId($row->parent_id);
143  $this->setParentType($row->parent_type);
144  $this->setKeyword(ilUtil::stripSlashes($row->keyword));
145  $this->setKeywordLanguage( new ilMDLanguageItem($row->keyword_language));
146  }
147  }
148  return true;
149  }
setObjType($a_type)
setKeyword($a_keyword)
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setKeywordLanguage(&$lng_obj)
setObjId($a_id)
setRBACId($a_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setParentId($a_id)
global $ilDB
setParentType($a_parent_type)
+ Here is the call graph for this function:

◆ save() [1/2]

ilMDKeyword::save ( )

Definition at line 67 of file class.ilMDKeyword.php.

References ilMDBase\getMetaId(), and ilMDBase\setMetaId().

68  {
69  if($this->db->autoExecute('il_meta_keyword',
70  $this->__getFields(),
71  DB_AUTOQUERY_INSERT))
72  {
73  $this->setMetaId($this->db->getLastInsertId());
74 
75  return $this->getMetaId();
76  }
77  return false;
78  }
setMetaId($a_meta_id, $a_read_data=true)
+ Here is the call graph for this function:

◆ save() [2/2]

ilMDKeyword::save ( )

Definition at line 67 of file class.ilMDKeyword.php.

References $ilDB, __getFields(), ilMDBase\getMetaId(), and ilMDBase\setMetaId().

68  {
69  global $ilDB;
70 
71  $fields = $this->__getFields();
72  $fields['meta_keyword_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_keyword'));
73 
74  if($this->db->insert('il_meta_keyword',$fields))
75  {
76  $this->setMetaId($next_id);
77  return $this->getMetaId();
78  }
79  return false;
80  }
setMetaId($a_meta_id, $a_read_data=true)
global $ilDB
+ Here is the call graph for this function:

◆ setKeyword() [1/2]

ilMDKeyword::setKeyword (   $a_keyword)

Definition at line 43 of file class.ilMDKeyword.php.

Referenced by read().

44  {
45  $this->keyword = $a_keyword;
46  }
+ Here is the caller graph for this function:

◆ setKeyword() [2/2]

ilMDKeyword::setKeyword (   $a_keyword)

Definition at line 43 of file class.ilMDKeyword.php.

44  {
45  $this->keyword = $a_keyword;
46  }

◆ setKeywordLanguage() [1/2]

ilMDKeyword::setKeywordLanguage ( $lng_obj)

Definition at line 51 of file class.ilMDKeyword.php.

Referenced by read().

52  {
53  if(is_object($lng_obj))
54  {
55  $this->keyword_language = $lng_obj;
56  }
57  }
+ Here is the caller graph for this function:

◆ setKeywordLanguage() [2/2]

ilMDKeyword::setKeywordLanguage ( $lng_obj)

Definition at line 51 of file class.ilMDKeyword.php.

52  {
53  if(is_object($lng_obj))
54  {
55  $this->keyword_language = $lng_obj;
56  }
57  }

◆ toXML() [1/2]

ilMDKeyword::toXML ( $writer)

Definition at line 156 of file class.ilMDKeyword.php.

References getKeyword(), and getKeywordLanguageCode().

157  {
158  $writer->xmlElement('Keyword',array('Language' => $this->getKeywordLanguageCode()),$this->getKeyword());
159  }
+ Here is the call graph for this function:

◆ toXML() [2/2]

ilMDKeyword::toXML ( $writer)

Definition at line 156 of file class.ilMDKeyword.php.

References getKeyword(), and getKeywordLanguageCode().

157  {
158  $writer->xmlElement('Keyword',array('Language' => $this->getKeywordLanguageCode() ?
159  $this->getKeywordLanguageCode() :
160  'en'),
161  $this->getKeyword());
162  }
+ Here is the call graph for this function:

◆ update() [1/2]

ilMDKeyword::update ( )

Definition at line 80 of file class.ilMDKeyword.php.

References $ilDB, and ilMDBase\getMetaId().

81  {
82  global $ilDB;
83 
84  if($this->getMetaId())
85  {
86  if($this->db->autoExecute('il_meta_keyword',
87  $this->__getFields(),
88  DB_AUTOQUERY_UPDATE,
89  "meta_keyword_id = ".$ilDB->quote($this->getMetaId())))
90  {
91  return true;
92  }
93  }
94  return false;
95  }
global $ilDB
+ Here is the call graph for this function:

◆ update() [2/2]

ilMDKeyword::update ( )

Definition at line 82 of file class.ilMDKeyword.php.

References $ilDB, and ilMDBase\getMetaId().

83  {
84  global $ilDB;
85 
86  if($this->getMetaId())
87  {
88  if($this->db->update('il_meta_keyword',
89  $this->__getFields(),
90  array("meta_keyword_id" => array('integer',$this->getMetaId()))))
91  {
92  return true;
93  }
94  }
95  return false;
96  }
global $ilDB
+ Here is the call graph for this function:

◆ updateKeywords()

static ilMDKeyword::updateKeywords ( ilMDGeneral  $a_md_section,
array  $a_keywords 
)
static

Update keywords from input array.

Parameters
ilMDGeneral$a_md_section
array$a_keywordslang => keywords

Definition at line 344 of file class.ilMDKeyword.php.

References $lang, ilMDGeneral\addKeyword(), ilMDGeneral\getKeyword(), ilMDGeneral\getKeywordIds(), and ilUtil\stripSlashes().

Referenced by ilBlogPosting\updateKeywords(), and ilMDEditorGUI\updateQuickEdit().

345  {
346  // trim keywords
347  $new_keywords = array();
348  foreach($a_keywords as $lang => $keywords)
349  {
350  foreach($keywords as $keyword)
351  {
352  $keyword = trim($keyword);
353  if ($keyword != "" &&
354  !(is_array($new_keywords[$lang]) && in_array($keyword, $new_keywords[$lang])))
355  {
356  $new_keywords[$lang][] = $keyword;
357  }
358  }
359  }
360 
361  // update existing author entries (delete if not entered)
362  foreach($ids = $a_md_section->getKeywordIds() as $id)
363  {
364  $md_key = $a_md_section->getKeyword($id);
365  $lang = $md_key->getKeywordLanguageCode();
366 
367  // entered keyword already exists
368  if (is_array($new_keywords[$lang]) &&
369  in_array($md_key->getKeyword(), $new_keywords[$lang]))
370  {
371  unset($new_keywords[$lang]
372  [array_search($md_key->getKeyword(), $new_keywords[$lang])]);
373  }
374  else // existing keyword has not been entered again -> delete
375  {
376  $md_key->delete();
377  }
378  }
379 
380  // insert entered, but not existing keywords
381  foreach ($new_keywords as $lang => $key_arr)
382  {
383  foreach($key_arr as $keyword)
384  {
385  if ($keyword != "")
386  {
387  $md_key = $a_md_section->addKeyword();
388  $md_key->setKeyword(ilUtil::stripSlashes($keyword));
389  $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
390  $md_key->save();
391  }
392  }
393  }
394  }
& getKeyword($a_keyword_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: