ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMDKeyword Class Reference
+ Inheritance diagram for ilMDKeyword:
+ Collaboration diagram for ilMDKeyword:

Public Member Functions

 setKeyword ($a_keyword)
 
 getKeyword ()
 
 setKeywordLanguage (&$lng_obj)
 
getKeywordLanguage ()
 
 getKeywordLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (&$writer)
 
 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
 __construct ($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)
 
 __construct ($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 _getIds ($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
 
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
 
- Protected Attributes inherited from ilMDBase
 $log
 

Detailed Description

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

Member Function Documentation

◆ __getFields() [1/2]

ilMDKeyword::__getFields ( )

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

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

Referenced by save().

108  {
109  return array('rbac_id' => array('integer',$this->getRBACId()),
110  'obj_id' => array('integer', $this->getObjId()),
111  'obj_type' => array('text', $this->getObjType()),
112  'parent_type' => array('text', $this->getParentType()),
113  'parent_id' => array('integer', $this->getParentId()),
114  'keyword' => array('text', $this->getKeyword()),
115  'keyword_language' => array('text', $this->getKeywordLanguageCode()));
116  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getFields() [2/2]

ilMDKeyword::__getFields ( )

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

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

108  {
109  return array('rbac_id' => $this->getRBACId(),
110  'obj_id' => $this->getObjId(),
111  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
112  'parent_type' => $this->getParentType(),
113  'parent_id' => $this->getParentId(),
114  'keyword' => ilUtil::prepareDBString($this->getKeyword()),
115  'keyword_language' => ilUtil::prepareDBString($this->getKeywordLanguageCode()));
116  }
Create styles array
The data for the language used.
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 156 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

157  {
158  global $ilDB;
159 
160  $query = "SELECT meta_keyword_id FROM il_meta_keyword ".
161  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
162  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
163  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
164  "AND parent_type = ".$ilDB->quote($a_parent_type);
165 
166  $res = $ilDB->query($query);
167  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
168  {
169  $ids[] = $row->meta_keyword_id;
170  }
171  return $ids ? $ids : array();
172  }
Create styles array
The data for the language used.
global $ilDB

◆ _getIds() [2/2]

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

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

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

160  {
161  global $ilDB;
162 
163  $query = "SELECT meta_keyword_id FROM il_meta_keyword ".
164  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
165  "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
166  "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
167  "AND parent_type = ".$ilDB->quote($a_parent_type ,'text')." ".
168  "ORDER BY meta_keyword_id ";
169 
170  $res = $ilDB->query($query);
171  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
172  {
173  $ids[] = $row->meta_keyword_id;
174  }
175  return $ids ? $ids : array();
176  }
Create styles array
The data for the language used.
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 188 of file class.ilMDKeyword.php.

References $a_type, $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _getKeywordsByLanguageAsString().

189  {
190  global $ilDB,$ilObjDataCache;
191 
192  $query = "SELECT keyword,keyword_language ".
193  "FROM il_meta_keyword ".
194  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
195  "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
196  "AND obj_type = ".$ilDB->quote($a_type ,'text')." ";
197  $res = $ilDB->query($query);
198  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
199  {
200  if($row->keyword)
201  {
202  $keywords[$row->keyword_language][] = $row->keyword;
203  }
204  }
205  return $keywords ? $keywords : array();
206  }
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
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 217 of file class.ilMDKeyword.php.

References $a_type, _getKeywordsByLanguage(), and array.

Referenced by ilMDUtils\_fillHTMLMetaTags().

218  {
219  foreach(ilMDKeyword::_getKeywordsByLanguage($a_rbac_id,$a_obj_id,$a_type) as $lng_code => $keywords)
220  {
221  $key_string[$lng_code] = implode(",",$keywords);
222  }
223  return $key_string ? $key_string : array();
224  }
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
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 279 of file class.ilMDKeyword.php.

References $a_type, $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

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

280  {
281  global $ilDB;
282 
283  $query = "SELECT DISTINCT keyword FROM il_meta_keyword ".
284  'WHERE obj_type = '.$ilDB->quote($a_type,'text').' '.
285  'AND '.$ilDB->like('keyword','text','%'.trim($a_query).'%').' ';
286 
287  if($a_rbac_id)
288  {
289  $query .= "AND rbac_id = ".$ilDB->quote($a_rbac_id,'integer').' ';
290  }
291 
292  $res = $ilDB->query($query);
293  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
294  {
295  $kws[] = $row->keyword;
296  }
297  return (array) $kws;
298  }
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
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 233 of file class.ilMDKeyword.php.

References $a_type, $counter, $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjMediaPool\getMediaObjects().

234  {
235  global $ilDB;
236 
237  $qs = 'AND ';
238  $counter = 0;
239  foreach((array) explode(' ',$a_query) as $part)
240  {
241  if($counter++)
242  {
243  $qs .= 'OR ';
244  }
245  $qs .= ($ilDB->like('keyword','text',$part).' ');
246  }
247 
248  if($a_rbac_id)
249  {
250  $query = "SELECT obj_id FROM il_meta_keyword ".
251  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id,'integer').' '.
252  'AND obj_type = '.$ilDB->quote($a_type,'text').' '.
253  $qs;
254  }
255  else
256  {
257  $query = "SELECT obj_id FROM il_meta_keyword ".
258  'WHERE obj_type = '.$ilDB->quote($a_type,'text').' '.
259  $qs;
260  }
261 
262  $res = $ilDB->query($query);
263  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
264  {
265  $obj_ids[] = $row->obj_id;
266  }
267 
268  return (array) $obj_ids;
269  }
$counter
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ delete() [1/2]

ilMDKeyword::delete ( )

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

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

91  {
92  global $ilDB;
93 
94  if($this->getMetaId())
95  {
96  $query = "DELETE FROM il_meta_keyword ".
97  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId());
98 
99  $this->db->query($query);
100 
101  return true;
102  }
103  return false;
104  }
global $ilDB
+ Here is the call graph for this function:

◆ delete() [2/2]

ilMDKeyword::delete ( )

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

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

92  {
93  global $ilDB;
94 
95  if($this->getMetaId())
96  {
97  $query = "DELETE FROM il_meta_keyword ".
98  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId() ,'integer');
99  $res = $ilDB->manipulate($query);
100 
101  return true;
102  }
103  return false;
104  }
global $ilDB
+ Here is the call graph for this function:

◆ getKeyword() [1/2]

ilMDKeyword::getKeyword ( )

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

Referenced by __getFields(), and toXML().

41  {
42  return $this->keyword;
43  }
+ Here is the caller graph for this function:

◆ getKeyword() [2/2]

ilMDKeyword::getKeyword ( )

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

41  {
42  return $this->keyword;
43  }

◆ getKeywordLanguage() [1/2]

& ilMDKeyword::getKeywordLanguage ( )

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

52  {
53  return is_object($this->keyword_language) ? $this->keyword_language : false;
54  }

◆ getKeywordLanguage() [2/2]

& ilMDKeyword::getKeywordLanguage ( )

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

52  {
53  return is_object($this->keyword_language) ? $this->keyword_language : false;
54  }

◆ getKeywordLanguageCode() [1/2]

ilMDKeyword::getKeywordLanguageCode ( )

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

Referenced by __getFields(), and toXML().

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

◆ getKeywordLanguageCode() [2/2]

ilMDKeyword::getKeywordLanguageCode ( )

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

56  {
57  return is_object($this->keyword_language) ? $this->keyword_language->getLanguageCode() : false;
58  }

◆ 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 307 of file class.ilMDKeyword.php.

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

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

308  {
309  global $ilDB;
310 
311  $query = "SELECT * FROM il_meta_keyword ".
312  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id,'integer').' '.
313  "AND obj_id = ".$ilDB->quote($a_obj_id,'integer').' ';
314  $res = $ilDB->query($query);
315  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
316  {
317  if(!$a_return_ids)
318  {
319  if(strlen($row->keyword))
320  {
321  $kws[] = $row->keyword;
322  }
323  }
324  else
325  {
326  $kws[] = $row->meta_keyword_id;
327  }
328  }
329  return (array) $kws;
330  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ read() [1/2]

ilMDKeyword::read ( )

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

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

119  {
120  global $ilDB;
121 
122  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
123 
124  if($this->getMetaId())
125  {
126  $query = "SELECT * FROM il_meta_keyword ".
127  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId() ,'integer');
128 
129  $res = $this->db->query($query);
130  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
131  {
132  $this->setRBACId($row->rbac_id);
133  $this->setObjId($row->obj_id);
134  $this->setObjType($row->obj_type);
135  $this->setParentId($row->parent_id);
136  $this->setParentType($row->parent_type);
137  $this->setKeyword($row->keyword);
138  $this->setKeywordLanguage( new ilMDLanguageItem($row->keyword_language));
139  }
140  }
141  return true;
142  }
setObjType($a_type)
setKeyword($a_keyword)
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 118 of file class.ilMDKeyword.php.

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

119  {
120  global $ilDB;
121 
122  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
123 
124  if($this->getMetaId())
125  {
126  $query = "SELECT * FROM il_meta_keyword ".
127  "WHERE meta_keyword_id = ".$ilDB->quote($this->getMetaId());
128 
129  $res = $this->db->query($query);
130  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
131  {
132  $this->setRBACId($row->rbac_id);
133  $this->setObjId($row->obj_id);
134  $this->setObjType($row->obj_type);
135  $this->setParentId($row->parent_id);
136  $this->setParentType($row->parent_type);
137  $this->setKeyword(ilUtil::stripSlashes($row->keyword));
138  $this->setKeywordLanguage( new ilMDLanguageItem($row->keyword_language));
139  }
140  }
141  return true;
142  }
setObjType($a_type)
setKeyword($a_keyword)
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 60 of file class.ilMDKeyword.php.

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

61  {
62  global $ilDB;
63 
64  $fields = $this->__getFields();
65  $fields['meta_keyword_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_keyword'));
66 
67  if($this->db->insert('il_meta_keyword',$fields))
68  {
69  $this->setMetaId($next_id);
70  return $this->getMetaId();
71  }
72  return false;
73  }
setMetaId($a_meta_id, $a_read_data=true)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ save() [2/2]

ilMDKeyword::save ( )

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

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

61  {
62  if($this->db->autoExecute('il_meta_keyword',
63  $this->__getFields(),
65  {
66  $this->setMetaId($this->db->getLastInsertId());
67 
68  return $this->getMetaId();
69  }
70  return false;
71  }
setMetaId($a_meta_id, $a_read_data=true)
+ Here is the call graph for this function:

◆ setKeyword() [1/2]

ilMDKeyword::setKeyword (   $a_keyword)

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

Referenced by read().

37  {
38  $this->keyword = $a_keyword;
39  }
+ Here is the caller graph for this function:

◆ setKeyword() [2/2]

ilMDKeyword::setKeyword (   $a_keyword)

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

37  {
38  $this->keyword = $a_keyword;
39  }

◆ setKeywordLanguage() [1/2]

ilMDKeyword::setKeywordLanguage ( $lng_obj)

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

45  {
46  if(is_object($lng_obj))
47  {
48  $this->keyword_language = $lng_obj;
49  }
50  }

◆ setKeywordLanguage() [2/2]

ilMDKeyword::setKeywordLanguage ( $lng_obj)

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

Referenced by read().

45  {
46  if(is_object($lng_obj))
47  {
48  $this->keyword_language = $lng_obj;
49  }
50  }
+ Here is the caller graph for this function:

◆ toXML() [1/2]

ilMDKeyword::toXML ( $writer)

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

References array, getKeyword(), and getKeywordLanguageCode().

150  {
151  $writer->xmlElement('Keyword',array('Language' => $this->getKeywordLanguageCode() ?
152  $this->getKeywordLanguageCode() :
153  'en'),
154  $this->getKeyword());
155  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ toXML() [2/2]

ilMDKeyword::toXML ( $writer)

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

References array, getKeyword(), and getKeywordLanguageCode().

150  {
151  $writer->xmlElement('Keyword',array('Language' => $this->getKeywordLanguageCode()),$this->getKeyword());
152  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ update() [1/2]

ilMDKeyword::update ( )

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

References $ilDB, ilMDBase\getMetaId(), and ilDBConstants\MDB2_AUTOQUERY_UPDATE.

74  {
75  global $ilDB;
76 
77  if($this->getMetaId())
78  {
79  if($this->db->autoExecute('il_meta_keyword',
80  $this->__getFields(),
82  "meta_keyword_id = ".$ilDB->quote($this->getMetaId())))
83  {
84  return true;
85  }
86  }
87  return false;
88  }
global $ilDB
+ Here is the call graph for this function:

◆ update() [2/2]

ilMDKeyword::update ( )

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

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

76  {
77  global $ilDB;
78 
79  if($this->getMetaId())
80  {
81  if($this->db->update('il_meta_keyword',
82  $this->__getFields(),
83  array("meta_keyword_id" => array('integer',$this->getMetaId()))))
84  {
85  return true;
86  }
87  }
88  return false;
89  }
Create styles array
The data for the language used.
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 337 of file class.ilMDKeyword.php.

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

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

338  {
339  // trim keywords
340  $new_keywords = array();
341  foreach($a_keywords as $lang => $keywords)
342  {
343  foreach($keywords as $keyword)
344  {
345  $keyword = trim($keyword);
346  if ($keyword != "" &&
347  !(is_array($new_keywords[$lang]) && in_array($keyword, $new_keywords[$lang])))
348  {
349  $new_keywords[$lang][] = $keyword;
350  }
351  }
352  }
353 
354  // update existing author entries (delete if not entered)
355  foreach($ids = $a_md_section->getKeywordIds() as $id)
356  {
357  $md_key = $a_md_section->getKeyword($id);
358  $lang = $md_key->getKeywordLanguageCode();
359 
360  // entered keyword already exists
361  if (is_array($new_keywords[$lang]) &&
362  in_array($md_key->getKeyword(), $new_keywords[$lang]))
363  {
364  unset($new_keywords[$lang]
365  [array_search($md_key->getKeyword(), $new_keywords[$lang])]);
366  }
367  else // existing keyword has not been entered again -> delete
368  {
369  $md_key->delete();
370  }
371  }
372 
373  // insert entered, but not existing keywords
374  foreach ($new_keywords as $lang => $key_arr)
375  {
376  foreach($key_arr as $keyword)
377  {
378  if ($keyword != "")
379  {
380  $md_key = $a_md_section->addKeyword();
381  $md_key->setKeyword(ilUtil::stripSlashes($keyword));
382  $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
383  $md_key->save();
384  }
385  }
386  }
387  }
& getKeyword($a_keyword_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
+ 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: