ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMDClassification Class Reference
+ Inheritance diagram for ilMDClassification:
+ Collaboration diagram for ilMDClassification:

Public Member Functions

 getTaxonPathIds ()
 
 getTaxonPath (int $a_taxon_path_id)
 
 addTaxonPath ()
 
 getKeywordIds ()
 
 getKeyword (int $a_keyword_id)
 
 addKeyword ()
 
 setPurpose (string $a_purpose)
 
 getPurpose ()
 
 setDescription (string $a_description)
 
 getDescription ()
 
 setDescriptionLanguage (ilMDLanguageItem $lng_obj)
 
 getDescriptionLanguage ()
 
 getDescriptionLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (ilXmlWriter $writer)
 
- Public Member Functions inherited from ilMDBase
 __construct (int $a_rbac_id=0, int $a_obj_id=0, string $a_type='')
 constructor More...
 
 read ()
 
 setRBACId (int $a_id)
 
 getRBACId ()
 
 setObjId (int $a_id)
 
 getObjId ()
 
 setObjType (string $a_type)
 
 getObjType ()
 
 setMetaId (int $a_meta_id, bool $a_read_data=true)
 
 getMetaId ()
 
 setParentType (string $a_parent_type)
 
 getParentType ()
 
 setParentId (int $a_id)
 
 getParentId ()
 
 setExportMode (bool $a_export_mode=true)
 
 getExportMode ()
 
 validate ()
 
 update ()
 
 save ()
 
 delete ()
 
 toXML (ilXmlWriter $writer)
 

Static Public Member Functions

static _getIds (int $a_rbac_id, int $a_obj_id)
 

Private Attributes

const PURPOSE_TRANSLATION
 Compatibility fix for legacy MD classes for new db tables. More...
 
const string $purpose = ''
 
string $description = ''
 
ilMDLanguageItem $description_language = null
 

Additional Inherited Members

- Protected Attributes inherited from ilMDBase
ilLogger $log
 
ilDBInterface $db
 

Detailed Description

Definition at line 27 of file class.ilMDClassification.php.

Member Function Documentation

◆ __getFields()

ilMDClassification::__getFields ( )
Returns
array<string, array<string, mixed>>

Compatibility fix for legacy MD classes for new db tables

Definition at line 199 of file class.ilMDClassification.php.

References getDescription(), getDescriptionLanguageCode(), ilMDBase\getObjId(), ilMDBase\getObjType(), getPurpose(), and ilMDBase\getRBACId().

Referenced by save(), and update().

199  : array
200  {
204  $purpose = (string) array_search(
205  $this->getPurpose(),
206  self::PURPOSE_TRANSLATION
207  );
208 
209  return array(
210  'rbac_id' => array('integer', $this->getRBACId()),
211  'obj_id' => array('integer', $this->getObjId()),
212  'obj_type' => array('text', $this->getObjType()),
213  'purpose' => array('text', $purpose),
214  'description' => array('text', $this->getDescription()),
215  'description_language' => array('text', $this->getDescriptionLanguageCode())
216  );
217  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIds()

static ilMDClassification::_getIds ( int  $a_rbac_id,
int  $a_obj_id 
)
static
Returns
int[]

Definition at line 289 of file class.ilMDClassification.php.

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilMD\getClassificationIds().

289  : array
290  {
291  global $DIC;
292 
293  $ilDB = $DIC['ilDB'];
294 
295  $query = "SELECT meta_classification_id FROM il_meta_classification " .
296  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
297  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
298 
299  $res = $ilDB->query($query);
300  $ids = [];
301  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
302  $ids[] = (int) $row->meta_classification_id;
303  }
304  return $ids;
305  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addKeyword()

ilMDClassification::addKeyword ( )

Definition at line 94 of file class.ilMDClassification.php.

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

94  : ilMDKeyword
95  {
96  $key = new ilMDKeyword($this->getRBACId(), $this->getObjId(), $this->getObjType());
97  $key->setParentId($this->getMetaId());
98  $key->setParentType('meta_classification');
99 
100  return $key;
101  }
+ Here is the call graph for this function:

◆ addTaxonPath()

ilMDClassification::addTaxonPath ( )

Definition at line 69 of file class.ilMDClassification.php.

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

70  {
71  $tax = new ilMDTaxonPath($this->getRBACId(), $this->getObjId(), $this->getObjType());
72  $tax->setParentId($this->getMetaId());
73  $tax->setParentType('meta_classification');
74 
75  return $tax;
76  }
+ Here is the call graph for this function:

◆ delete()

ilMDClassification::delete ( )

Definition at line 175 of file class.ilMDClassification.php.

References $id, $res, getKeyword(), getKeywordIds(), ilMDBase\getMetaId(), getTaxonPath(), and getTaxonPathIds().

175  : bool
176  {
177  if ($this->getMetaId()) {
178  $query = "DELETE FROM il_meta_classification " .
179  "WHERE meta_classification_id = " . $this->db->quote($this->getMetaId(), 'integer');
180  $res = $this->db->manipulate($query);
181 
182  foreach ($this->getTaxonPathIds() as $id) {
183  $tax = $this->getTaxonPath($id);
184  $tax->delete();
185  }
186  foreach ($this->getKeywordIds() as $id) {
187  $key = $this->getKeyword($id);
188  $key->delete();
189  }
190 
191  return true;
192  }
193  return false;
194  }
$res
Definition: ltiservices.php:66
getTaxonPath(int $a_taxon_path_id)
getKeyword(int $a_keyword_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getDescription()

ilMDClassification::getDescription ( )

Definition at line 134 of file class.ilMDClassification.php.

References $description.

Referenced by __getFields(), and toXML().

134  : string
135  {
136  return $this->description;
137  }
+ Here is the caller graph for this function:

◆ getDescriptionLanguage()

ilMDClassification::getDescriptionLanguage ( )

Definition at line 144 of file class.ilMDClassification.php.

References null.

145  {
146  return is_object($this->description_language) ? $this->description_language : null;
147  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescriptionLanguageCode()

ilMDClassification::getDescriptionLanguageCode ( )

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

Referenced by __getFields(), and toXML().

149  : string
150  {
151  return is_object($this->description_language) ? $this->description_language->getLanguageCode() : '';
152  }
+ Here is the caller graph for this function:

◆ getKeyword()

ilMDClassification::getKeyword ( int  $a_keyword_id)

Definition at line 83 of file class.ilMDClassification.php.

References null.

Referenced by delete(), and toXML().

83  : ?ilMDKeyword
84  {
85  if (!$a_keyword_id) {
86  return null;
87  }
88  $key = new ilMDKeyword();
89  $key->setMetaId($a_keyword_id);
90 
91  return $key;
92  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getKeywordIds()

ilMDClassification::getKeywordIds ( )

Definition at line 78 of file class.ilMDClassification.php.

References ilMDKeyword\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

78  : ?array
79  {
80  return ilMDKeyword::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_classification');
81  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPurpose()

ilMDClassification::getPurpose ( )

Definition at line 124 of file class.ilMDClassification.php.

References $purpose.

Referenced by __getFields(), and toXML().

124  : string
125  {
126  return $this->purpose;
127  }
+ Here is the caller graph for this function:

◆ getTaxonPath()

ilMDClassification::getTaxonPath ( int  $a_taxon_path_id)

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

References null.

Referenced by delete(), and toXML().

58  : ?ilMDTaxonPath
59  {
60  if (!$a_taxon_path_id) {
61  return null;
62  }
63  $tax = new ilMDTaxonPath();
64  $tax->setMetaId($a_taxon_path_id);
65 
66  return $tax;
67  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getTaxonPathIds()

ilMDClassification::getTaxonPathIds ( )
Returns
int[]

Definition at line 53 of file class.ilMDClassification.php.

References ilMDTaxonPath\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

53  : array
54  {
55  return ilMDTaxonPath::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_classification');
56  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilMDClassification::read ( )

Compatibility fix for legacy MD classes for new db tables

Definition at line 219 of file class.ilMDClassification.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), setDescription(), ilMDBase\setObjId(), ilMDBase\setObjType(), setPurpose(), and ilMDBase\setRBACId().

219  : bool
220  {
221  if ($this->getMetaId()) {
222  $query = "SELECT * FROM il_meta_classification " .
223  "WHERE meta_classification_id = " . $this->db->quote($this->getMetaId(), 'integer');
224 
225  $res = $this->db->query($query);
226  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
230  if (key_exists($row->purpose ?? '', self::PURPOSE_TRANSLATION)) {
231  $row->purpose = self::PURPOSE_TRANSLATION[$row->purpose ?? ''];
232  }
233 
234  $this->setRBACId((int) $row->rbac_id);
235  $this->setObjId((int) $row->obj_id);
236  $this->setObjType($row->obj_type);
237  $this->setPurpose($row->purpose ?? '');
238  $this->setDescription($row->description ?? '');
239  $this->description_language = new ilMDLanguageItem($row->description_language ?? '');
240  }
241  }
242  return true;
243  }
$res
Definition: ltiservices.php:66
setRBACId(int $a_id)
setPurpose(string $a_purpose)
setObjId(int $a_id)
setObjType(string $a_type)
setDescription(string $a_description)
+ Here is the call graph for this function:

◆ save()

ilMDClassification::save ( )

Definition at line 154 of file class.ilMDClassification.php.

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

154  : int
155  {
156  $fields = $this->__getFields();
157  $fields['meta_classification_id'] = array('integer', $next_id = $this->db->nextId('il_meta_classification'));
158 
159  if ($this->db->insert('il_meta_classification', $fields)) {
160  $this->setMetaId($next_id);
161  return $this->getMetaId();
162  }
163  return 0;
164  }
setMetaId(int $a_meta_id, bool $a_read_data=true)
+ Here is the call graph for this function:

◆ setDescription()

ilMDClassification::setDescription ( string  $a_description)

Definition at line 129 of file class.ilMDClassification.php.

Referenced by read().

129  : void
130  {
131  $this->description = $a_description;
132  }
+ Here is the caller graph for this function:

◆ setDescriptionLanguage()

ilMDClassification::setDescriptionLanguage ( ilMDLanguageItem  $lng_obj)

Definition at line 139 of file class.ilMDClassification.php.

139  : void
140  {
141  $this->description_language = $lng_obj;
142  }

◆ setPurpose()

ilMDClassification::setPurpose ( string  $a_purpose)

Definition at line 104 of file class.ilMDClassification.php.

Referenced by read().

104  : bool
105  {
106  switch ($a_purpose) {
107  case 'Discipline':
108  case 'Idea':
109  case 'Prerequisite':
110  case 'EducationalObjective':
111  case 'AccessibilityRestrictions':
112  case 'EducationalLevel':
113  case 'SkillLevel':
114  case 'SecurityLevel':
115  case 'Competency':
116  $this->purpose = $a_purpose;
117  return true;
118 
119  default:
120  return false;
121  }
122  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDClassification::toXML ( ilXmlWriter  $writer)

Definition at line 245 of file class.ilMDClassification.php.

References $id, getDescription(), getDescriptionLanguageCode(), getKeyword(), getKeywordIds(), ilMDBase\getObjId(), getPurpose(), ilMDBase\getRBACId(), getTaxonPath(), getTaxonPathIds(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

245  : void
246  {
247  $writer->xmlStartTag('Classification', array(
248  'Purpose' => $this->getPurpose() ?: 'Idea'
249  ));
250 
251  // Taxon Path
252  $taxs = $this->getTaxonPathIds();
253  foreach ($taxs as $id) {
254  $tax = $this->getTaxonPath($id);
255  $tax->toXML($writer);
256  }
257  if (!count($taxs)) {
258  $tax = new ilMDTaxonPath($this->getRBACId(), $this->getObjId());
259  $tax->toXML($writer);
260  }
261 
262  // Description
263  $writer->xmlElement(
264  'Description',
265  array(
266  'Language' => $this->getDescriptionLanguageCode() ?: 'en'
267  ),
268  $this->getDescription()
269  );
270 
271  // Keyword
272  $keys = $this->getKeywordIds();
273  foreach ($keys as $id) {
274  $key = $this->getKeyword($id);
275  $key->toXML($writer);
276  }
277  if (!count($keys)) {
278  $key = new ilMDKeyword($this->getRBACId(), $this->getObjId());
279  $key->toXML($writer);
280  }
281  $writer->xmlEndTag('Classification');
282  }
getTaxonPath(int $a_taxon_path_id)
xmlEndTag(string $tag)
Writes an endtag.
getKeyword(int $a_keyword_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ update()

ilMDClassification::update ( )

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

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

166  : bool
167  {
168  return $this->getMetaId() && $this->db->update(
169  'il_meta_classification',
170  $this->__getFields(),
171  ["meta_classification_id" => ['integer', $this->getMetaId()]]
172  );
173  }
+ Here is the call graph for this function:

Field Documentation

◆ $description

string ilMDClassification::$description = ''
private

Definition at line 45 of file class.ilMDClassification.php.

Referenced by getDescription().

◆ $description_language

ilMDLanguageItem ilMDClassification::$description_language = null
private

Definition at line 46 of file class.ilMDClassification.php.

◆ $purpose

const string ilMDClassification::$purpose = ''
private

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

Referenced by getPurpose().

◆ PURPOSE_TRANSLATION

const ilMDClassification::PURPOSE_TRANSLATION
private
Initial value:
= [
'discipline' => 'Discipline'

Compatibility fix for legacy MD classes for new db tables.

Definition at line 32 of file class.ilMDClassification.php.


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