ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMDLanguage Class Reference
+ Inheritance diagram for ilMDLanguage:
+ Collaboration diagram for ilMDLanguage:

Public Member Functions

 setLanguage (ilMDLanguageItem $lng_obj)
 
 getLanguage ()
 
 getLanguageCode ()
 
 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 _lookupFirstLanguage (int $a_rbac_id, int $a_obj_id, string $a_obj_type)
 
static _getIds (int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
 

Private Attributes

ilMDLanguageItem $language = null
 

Additional Inherited Members

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

Detailed Description

Definition at line 26 of file class.ilMDLanguage.php.

Member Function Documentation

◆ __getFields()

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

Definition at line 102 of file class.ilMDLanguage.php.

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

Referenced by save(), and update().

102  : array
103  {
104  return array(
105  'rbac_id' => array('integer', $this->getRBACId()),
106  'obj_id' => array('integer', $this->getObjId()),
107  'obj_type' => array('text', $this->getObjType()),
108  'parent_type' => array('text', $this->getParentType()),
109  'parent_id' => array('integer', $this->getParentId()),
110  'language' => array('text', $this->getLanguageCode())
111  );
112  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIds()

static ilMDLanguage::_getIds ( int  $a_rbac_id,
int  $a_obj_id,
int  $a_parent_id,
string  $a_parent_type 
)
static
Returns
int[]

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

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

Referenced by ilMDGeneral\getLanguageIds(), and ilMDEducational\getLanguageIds().

149  : array
150  {
151  global $DIC;
152 
153  $ilDB = $DIC->database();
154 
155  $query = "SELECT meta_language_id FROM il_meta_language " .
156  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
157  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
158  "AND parent_id = " . $ilDB->quote($a_parent_id, 'integer') . " " .
159  "AND parent_type = " . $ilDB->quote($a_parent_type, 'text');
160 
161  $res = $ilDB->query($query);
162  $ids = [];
163  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
164  $ids[] = (int) $row->meta_language_id;
165  }
166  return $ids;
167  }
$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:

◆ _lookupFirstLanguage()

static ilMDLanguage::_lookupFirstLanguage ( int  $a_rbac_id,
int  $a_obj_id,
string  $a_obj_type 
)
static

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

References $DIC, $ilDB, $lang, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilECSCourseSettings\buildJson().

30  : string
31  {
32  global $DIC;
33 
34  $ilDB = $DIC->database();
35 
36  $lang = '';
37  $query = "SELECT language FROM il_meta_language " .
38  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
39  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
40  "AND obj_type = " . $ilDB->quote($a_obj_type, 'text') . " " .
41  "AND parent_type = 'meta_general' " .
42  "ORDER BY meta_language_id ";
43  $ilDB->setLimit(1, 0);
44  $res = $ilDB->query($query);
45  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
46  $lang = $row->language;
47  }
48  return $lang;
49  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
$lang
Definition: xapiexit.php:26
+ Here is the caller graph for this function:

◆ delete()

ilMDLanguage::delete ( )

Definition at line 87 of file class.ilMDLanguage.php.

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

87  : bool
88  {
89  if ($this->getMetaId()) {
90  $query = "DELETE FROM il_meta_language " .
91  "WHERE meta_language_id = " . $this->db->quote($this->getMetaId(), 'integer');
92  $res = $this->db->manipulate($query);
93 
94  return true;
95  }
96  return false;
97  }
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:

◆ getLanguage()

ilMDLanguage::getLanguage ( )

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

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by toXML().

58  {
59  return is_object($this->language) ? $this->language : null;
60  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLanguageCode()

ilMDLanguage::getLanguageCode ( )

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

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by __getFields(), and toXML().

62  : string
63  {
64  return is_object($this->language) ? $this->language->getLanguageCode() : '';
65  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilMDLanguage::read ( )

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

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), setLanguage(), ilMDBase\setObjId(), ilMDBase\setObjType(), ilMDBase\setParentId(), ilMDBase\setParentType(), and ilMDBase\setRBACId().

114  : bool
115  {
116  if ($this->getMetaId()) {
117  $query = "SELECT * FROM il_meta_language " .
118  "WHERE meta_language_id = " . $this->db->quote($this->getMetaId(), 'integer');
119 
120  $res = $this->db->query($query);
121  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
122  $this->setRBACId((int) $row->rbac_id);
123  $this->setObjId((int) $row->obj_id);
124  $this->setObjType($row->obj_type);
125  $this->setParentId((int) $row->parent_id);
126  $this->setParentType($row->parent_type);
127  $this->setLanguage(new ilMDLanguageItem($row->language ?? ''));
128  }
129  }
130  return true;
131  }
$res
Definition: ltiservices.php:69
setRBACId(int $a_id)
setObjId(int $a_id)
setLanguage(ilMDLanguageItem $lng_obj)
$query
setParentId(int $a_id)
setParentType(string $a_parent_type)
setObjType(string $a_type)
+ Here is the call graph for this function:

◆ save()

ilMDLanguage::save ( )

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

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

67  : int
68  {
69  $fields = $this->__getFields();
70  $fields['meta_language_id'] = array('integer', $next_id = $this->db->nextId('il_meta_language'));
71  if ($this->db->insert('il_meta_language', $fields)) {
72  $this->setMetaId($next_id);
73  return $this->getMetaId();
74  }
75  return 0;
76  }
setMetaId(int $a_meta_id, bool $a_read_data=true)
+ Here is the call graph for this function:

◆ setLanguage()

ilMDLanguage::setLanguage ( ilMDLanguageItem  $lng_obj)

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

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by read().

52  : void
53  {
54  $this->language = $lng_obj;
55  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

ilMDLanguage::toXML ( ilXmlWriter  $writer)

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

References getLanguage(), getLanguageCode(), and ilXmlWriter\xmlElement().

133  : void
134  {
135  $writer->xmlElement(
136  'Language',
137  array(
138  'Language' => $this->getLanguageCode() ?: 'en'
139  ),
140  $this->getLanguage()
141  );
142  }
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()

ilMDLanguage::update ( )

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

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

78  : bool
79  {
80  return $this->getMetaId() && $this->db->update(
81  'il_meta_language',
82  $this->__getFields(),
83  array("meta_language_id" => array('integer', $this->getMetaId()))
84  );
85  }
+ Here is the call graph for this function:

Field Documentation

◆ $language

ilMDLanguageItem ilMDLanguage::$language = null
private

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


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