ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 26 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 198 of file class.ilMDClassification.php.

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

Referenced by save(), and update().

198  : array
199  {
203  $purpose = (string) array_search(
204  $this->getPurpose(),
205  self::PURPOSE_TRANSLATION
206  );
207 
208  return array(
209  'rbac_id' => array('integer', $this->getRBACId()),
210  'obj_id' => array('integer', $this->getObjId()),
211  'obj_type' => array('text', $this->getObjType()),
212  'purpose' => array('text', $purpose),
213  'description' => array('text', $this->getDescription()),
214  'description_language' => array('text', $this->getDescriptionLanguageCode())
215  );
216  }
+ 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 288 of file class.ilMDClassification.php.

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

Referenced by ilMD\getClassificationIds().

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

◆ addKeyword()

ilMDClassification::addKeyword ( )

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

References ILIAS\LTI\ToolProvider\$key, ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

93  : ilMDKeyword
94  {
95  $key = new ilMDKeyword($this->getRBACId(), $this->getObjId(), $this->getObjType());
96  $key->setParentId($this->getMetaId());
97  $key->setParentType('meta_classification');
98 
99  return $key;
100  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ addTaxonPath()

ilMDClassification::addTaxonPath ( )

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

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

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

◆ delete()

ilMDClassification::delete ( )

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

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

174  : bool
175  {
176  if ($this->getMetaId()) {
177  $query = "DELETE FROM il_meta_classification " .
178  "WHERE meta_classification_id = " . $this->db->quote($this->getMetaId(), 'integer');
179  $res = $this->db->manipulate($query);
180 
181  foreach ($this->getTaxonPathIds() as $id) {
182  $tax = $this->getTaxonPath($id);
183  $tax->delete();
184  }
185  foreach ($this->getKeywordIds() as $id) {
186  $key = $this->getKeyword($id);
187  $key->delete();
188  }
189 
190  return true;
191  }
192  return false;
193  }
$res
Definition: ltiservices.php:69
getTaxonPath(int $a_taxon_path_id)
string $key
Consumer key/client ID value.
Definition: System.php:193
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 133 of file class.ilMDClassification.php.

References $description.

Referenced by __getFields(), and toXML().

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

◆ getDescriptionLanguage()

ilMDClassification::getDescriptionLanguage ( )

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

144  {
145  return is_object($this->description_language) ? $this->description_language : null;
146  }

◆ getDescriptionLanguageCode()

ilMDClassification::getDescriptionLanguageCode ( )

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

Referenced by __getFields(), and toXML().

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

◆ getKeyword()

ilMDClassification::getKeyword ( int  $a_keyword_id)

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

References ILIAS\LTI\ToolProvider\$key.

Referenced by delete(), and toXML().

82  : ?ilMDKeyword
83  {
84  if (!$a_keyword_id) {
85  return null;
86  }
87  $key = new ilMDKeyword();
88  $key->setMetaId($a_keyword_id);
89 
90  return $key;
91  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ getKeywordIds()

ilMDClassification::getKeywordIds ( )

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

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

Referenced by delete(), and toXML().

77  : ?array
78  {
79  return ilMDKeyword::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_classification');
80  }
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 123 of file class.ilMDClassification.php.

References $purpose.

Referenced by __getFields(), and toXML().

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

◆ getTaxonPath()

ilMDClassification::getTaxonPath ( int  $a_taxon_path_id)

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

Referenced by delete(), and toXML().

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

◆ getTaxonPathIds()

ilMDClassification::getTaxonPathIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

52  : array
53  {
54  return ilMDTaxonPath::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_classification');
55  }
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 218 of file class.ilMDClassification.php.

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

218  : bool
219  {
220  if ($this->getMetaId()) {
221  $query = "SELECT * FROM il_meta_classification " .
222  "WHERE meta_classification_id = " . $this->db->quote($this->getMetaId(), 'integer');
223 
224  $res = $this->db->query($query);
225  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
229  if (key_exists($row->purpose ?? '', self::PURPOSE_TRANSLATION)) {
230  $row->purpose = self::PURPOSE_TRANSLATION[$row->purpose ?? ''];
231  }
232 
233  $this->setRBACId((int) $row->rbac_id);
234  $this->setObjId((int) $row->obj_id);
235  $this->setObjType($row->obj_type);
236  $this->setPurpose($row->purpose ?? '');
237  $this->setDescription($row->description ?? '');
238  $this->description_language = new ilMDLanguageItem($row->description_language ?? '');
239  }
240  }
241  return true;
242  }
$res
Definition: ltiservices.php:69
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 153 of file class.ilMDClassification.php.

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

153  : int
154  {
155  $fields = $this->__getFields();
156  $fields['meta_classification_id'] = array('integer', $next_id = $this->db->nextId('il_meta_classification'));
157 
158  if ($this->db->insert('il_meta_classification', $fields)) {
159  $this->setMetaId($next_id);
160  return $this->getMetaId();
161  }
162  return 0;
163  }
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 128 of file class.ilMDClassification.php.

Referenced by read().

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

◆ setDescriptionLanguage()

ilMDClassification::setDescriptionLanguage ( ilMDLanguageItem  $lng_obj)

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

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

◆ setPurpose()

ilMDClassification::setPurpose ( string  $a_purpose)

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

Referenced by read().

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

◆ toXML()

ilMDClassification::toXML ( ilXmlWriter  $writer)

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

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

244  : void
245  {
246  $writer->xmlStartTag('Classification', array(
247  'Purpose' => $this->getPurpose() ?: 'Idea'
248  ));
249 
250  // Taxon Path
251  $taxs = $this->getTaxonPathIds();
252  foreach ($taxs as $id) {
253  $tax = $this->getTaxonPath($id);
254  $tax->toXML($writer);
255  }
256  if (!count($taxs)) {
257  $tax = new ilMDTaxonPath($this->getRBACId(), $this->getObjId());
258  $tax->toXML($writer);
259  }
260 
261  // Description
262  $writer->xmlElement(
263  'Description',
264  array(
265  'Language' => $this->getDescriptionLanguageCode() ?: 'en'
266  ),
267  $this->getDescription()
268  );
269 
270  // Keyword
271  $keys = $this->getKeywordIds();
272  foreach ($keys as $id) {
273  $key = $this->getKeyword($id);
274  $key->toXML($writer);
275  }
276  if (!count($keys)) {
277  $key = new ilMDKeyword($this->getRBACId(), $this->getObjId());
278  $key->toXML($writer);
279  }
280  $writer->xmlEndTag('Classification');
281  }
getTaxonPath(int $a_taxon_path_id)
xmlEndTag(string $tag)
Writes an endtag.
string $key
Consumer key/client ID value.
Definition: System.php:193
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 165 of file class.ilMDClassification.php.

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

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

Field Documentation

◆ $description

string ilMDClassification::$description = ''
private

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

Referenced by getDescription().

◆ $description_language

ilMDLanguageItem ilMDClassification::$description_language = null
private

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

◆ $purpose

const string ilMDClassification::$purpose = ''
private

Definition at line 43 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 31 of file class.ilMDClassification.php.


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