ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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

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>>

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

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

Referenced by save(), and update().

183  : array
184  {
185  return array(
186  'rbac_id' => array('integer', $this->getRBACId()),
187  'obj_id' => array('integer', $this->getObjId()),
188  'obj_type' => array('text', $this->getObjType()),
189  'purpose' => array('text', $this->getPurpose()),
190  'description' => array('text', $this->getDescription()),
191  'description_language' => array('text', $this->getDescriptionLanguageCode())
192  );
193  }
+ 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 258 of file class.ilMDClassification.php.

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

Referenced by ilMD\getClassificationIds().

258  : array
259  {
260  global $DIC;
261 
262  $ilDB = $DIC['ilDB'];
263 
264  $query = "SELECT meta_classification_id FROM il_meta_classification " .
265  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
266  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
267 
268  $res = $ilDB->query($query);
269  $ids = [];
270  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
271  $ids[] = (int) $row->meta_classification_id;
272  }
273  return $ids;
274  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addKeyword()

ilMDClassification::addKeyword ( )

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

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

78  : ilMDKeyword
79  {
80  $key = new ilMDKeyword($this->getRBACId(), $this->getObjId(), $this->getObjType());
81  $key->setParentId($this->getMetaId());
82  $key->setParentType('meta_classification');
83 
84  return $key;
85  }
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 53 of file class.ilMDClassification.php.

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

54  {
55  $tax = new ilMDTaxonPath($this->getRBACId(), $this->getObjId(), $this->getObjType());
56  $tax->setParentId($this->getMetaId());
57  $tax->setParentType('meta_classification');
58 
59  return $tax;
60  }
+ Here is the call graph for this function:

◆ delete()

ilMDClassification::delete ( )

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

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

159  : bool
160  {
161  if ($this->getMetaId()) {
162  $query = "DELETE FROM il_meta_classification " .
163  "WHERE meta_classification_id = " . $this->db->quote($this->getMetaId(), 'integer');
164  $res = $this->db->manipulate($query);
165 
166  foreach ($this->getTaxonPathIds() as $id) {
167  $tax = $this->getTaxonPath($id);
168  $tax->delete();
169  }
170  foreach ($this->getKeywordIds() as $id) {
171  $key = $this->getKeyword($id);
172  $key->delete();
173  }
174 
175  return true;
176  }
177  return false;
178  }
$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)
$query
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getDescription()

ilMDClassification::getDescription ( )

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

References $description.

Referenced by __getFields(), and toXML().

118  : string
119  {
120  return $this->description;
121  }
+ Here is the caller graph for this function:

◆ getDescriptionLanguage()

ilMDClassification::getDescriptionLanguage ( )

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

129  {
130  return is_object($this->description_language) ? $this->description_language : null;
131  }

◆ getDescriptionLanguageCode()

ilMDClassification::getDescriptionLanguageCode ( )

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

Referenced by __getFields(), and toXML().

133  : string
134  {
135  return is_object($this->description_language) ? $this->description_language->getLanguageCode() : '';
136  }
+ Here is the caller graph for this function:

◆ getKeyword()

ilMDClassification::getKeyword ( int  $a_keyword_id)

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

References ILIAS\LTI\ToolProvider\$key.

Referenced by delete(), and toXML().

67  : ?ilMDKeyword
68  {
69  if (!$a_keyword_id) {
70  return null;
71  }
72  $key = new ilMDKeyword();
73  $key->setMetaId($a_keyword_id);
74 
75  return $key;
76  }
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 62 of file class.ilMDClassification.php.

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

Referenced by delete(), and toXML().

62  : ?array
63  {
64  return ilMDKeyword::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_classification');
65  }
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 108 of file class.ilMDClassification.php.

References $purpose.

Referenced by __getFields(), and toXML().

108  : string
109  {
110  return $this->purpose;
111  }
+ Here is the caller graph for this function:

◆ getTaxonPath()

ilMDClassification::getTaxonPath ( int  $a_taxon_path_id)

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

Referenced by delete(), and toXML().

42  : ?ilMDTaxonPath
43  {
44  if (!$a_taxon_path_id) {
45  return null;
46  }
47  $tax = new ilMDTaxonPath();
48  $tax->setMetaId($a_taxon_path_id);
49 
50  return $tax;
51  }
+ Here is the caller graph for this function:

◆ getTaxonPathIds()

ilMDClassification::getTaxonPathIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

37  : array
38  {
39  return ilMDTaxonPath::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_classification');
40  }
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 ( )

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

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

195  : bool
196  {
197  if ($this->getMetaId()) {
198  $query = "SELECT * FROM il_meta_classification " .
199  "WHERE meta_classification_id = " . $this->db->quote($this->getMetaId(), 'integer');
200 
201  $res = $this->db->query($query);
202  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
203  $this->setRBACId((int) $row->rbac_id);
204  $this->setObjId((int) $row->obj_id);
205  $this->setObjType($row->obj_type);
206  $this->setPurpose($row->purpose ?? '');
207  $this->setDescription($row->description ?? '');
208  $this->description_language = new ilMDLanguageItem($row->description_language ?? '');
209  }
210  }
211  return true;
212  }
$res
Definition: ltiservices.php:69
setRBACId(int $a_id)
setPurpose(string $a_purpose)
setObjId(int $a_id)
$query
setObjType(string $a_type)
setDescription(string $a_description)
+ Here is the call graph for this function:

◆ save()

ilMDClassification::save ( )

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

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

138  : int
139  {
140  $fields = $this->__getFields();
141  $fields['meta_classification_id'] = array('integer', $next_id = $this->db->nextId('il_meta_classification'));
142 
143  if ($this->db->insert('il_meta_classification', $fields)) {
144  $this->setMetaId($next_id);
145  return $this->getMetaId();
146  }
147  return 0;
148  }
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 113 of file class.ilMDClassification.php.

Referenced by read().

113  : void
114  {
115  $this->description = $a_description;
116  }
+ Here is the caller graph for this function:

◆ setDescriptionLanguage()

ilMDClassification::setDescriptionLanguage ( ilMDLanguageItem  $lng_obj)

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

123  : void
124  {
125  $this->description_language = $lng_obj;
126  }

◆ setPurpose()

ilMDClassification::setPurpose ( string  $a_purpose)

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

Referenced by read().

88  : bool
89  {
90  switch ($a_purpose) {
91  case 'Discipline':
92  case 'Idea':
93  case 'Prerequisite':
94  case 'EducationalObjective':
95  case 'AccessibilityRestrictions':
96  case 'EducationalLevel':
97  case 'SkillLevel':
98  case 'SecurityLevel':
99  case 'Competency':
100  $this->purpose = $a_purpose;
101  return true;
102 
103  default:
104  return false;
105  }
106  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDClassification::toXML ( ilXmlWriter  $writer)

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

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

214  : void
215  {
216  $writer->xmlStartTag('Classification', array(
217  'Purpose' => $this->getPurpose() ?: 'Idea'
218  ));
219 
220  // Taxon Path
221  $taxs = $this->getTaxonPathIds();
222  foreach ($taxs as $id) {
223  $tax = $this->getTaxonPath($id);
224  $tax->toXML($writer);
225  }
226  if (!count($taxs)) {
227  $tax = new ilMDTaxonPath($this->getRBACId(), $this->getObjId());
228  $tax->toXML($writer);
229  }
230 
231  // Description
232  $writer->xmlElement(
233  'Description',
234  array(
235  'Language' => $this->getDescriptionLanguageCode() ?: 'en'
236  ),
237  $this->getDescription()
238  );
239 
240  // Keyword
241  $keys = $this->getKeywordIds();
242  foreach ($keys as $id) {
243  $key = $this->getKeyword($id);
244  $key->toXML($writer);
245  }
246  if (!count($keys)) {
247  $key = new ilMDKeyword($this->getRBACId(), $this->getObjId());
248  $key->toXML($writer);
249  }
250  $writer->xmlEndTag('Classification');
251  }
getTaxonPath(int $a_taxon_path_id)
xmlEndTag(string $tag)
Writes an endtag.
$keys
Definition: metadata.php:204
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 150 of file class.ilMDClassification.php.

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

150  : bool
151  {
152  return $this->getMetaId() && $this->db->update(
153  'il_meta_classification',
154  $this->__getFields(),
155  ["meta_classification_id" => ['integer', $this->getMetaId()]]
156  );
157  }
+ Here is the call graph for this function:

Field Documentation

◆ $description

string ilMDClassification::$description = ''
private

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

Referenced by getDescription().

◆ $description_language

ilMDLanguageItem ilMDClassification::$description_language = null
private

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

◆ $purpose

string ilMDClassification::$purpose = ''
private

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

Referenced by getPurpose().


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