ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilOrgUnitTypeTranslation Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilOrgUnitTypeTranslation:

Public Member Functions

 __construct (int $a_org_type_id=0, string $a_lang_code='')
 
 getMember (string $a_member)
 Get translated value for a member, returns null if no translation exists. More...
 
 setMember (string $a_member, string $a_value)
 Set translation value for a member, either update or add value. More...
 
 create ()
 Insert all translated member into database. More...
 
 update ()
 Update translations in database. More...
 
 delete ()
 Delete object. More...
 
 setLang (string $lang)
 Getters & Setters. More...
 
 getLang ()
 
 getMembers ()
 
 getOrguTypeId ()
 
 setOrguTypeId (int $id)
 

Static Public Member Functions

static getInstance (int $a_orgu_type_id, string $a_lang_code)
 Get instance of an ilOrgUnitType object Returns object from cache or from database, returns null if no object was found. More...
 

Data Fields

const TABLE_NAME = 'orgu_types_trans'
 

Protected Member Functions

 insertMember (string $member, string $value)
 Protected. More...
 
 updateMember (string $member, string $value)
 Update a (member,value) pair in database. More...
 
 trackChange (string $a_member, bool $is_new)
 Track a member that was either updated or added. More...
 
 resetTrackChanges ()
 Reset tracked members. More...
 
 read ()
 Read object data from database. More...
 

Protected Attributes

int $orgu_type_id
 
string $lang = ''
 
array $members = []
 
array $changes = []
 
array $members_new = []
 
ilDBInterface $db
 
ILIAS DI LoggingServices $log
 

Static Protected Attributes

static array $instances = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilOrgUnitTypeTranslation This class represents a translation for a given ilOrgUnit object and language.

Author
: Stefan Wanzenried sw@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 24 of file class.ilOrgUnitTypeTranslation.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitTypeTranslation::__construct ( int  $a_org_type_id = 0,
string  $a_lang_code = '' 
)

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

References $DIC, ILIAS\Repository\int(), and read().

38  {
39  global $DIC;
40  $this->db = $DIC->database();
41  $this->log = $DIC->logger();
42  if ($a_org_type_id && $a_lang_code) {
43  $this->orgu_type_id = (int) $a_org_type_id;
44  $this->lang = $a_lang_code;
45  $this->read();
46  }
47  }
read()
Read object data from database.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilOrgUnitTypeTranslation::create ( )

Insert all translated member into database.

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

References insertMember(), and resetTrackChanges().

154  : void
155  {
156  foreach ($this->members as $member => $value) {
157  $this->insertMember($member, $value);
158  }
159  $this->resetTrackChanges();
160  }
resetTrackChanges()
Reset tracked members.
insertMember(string $member, string $value)
Protected.
+ Here is the call graph for this function:

◆ delete()

ilOrgUnitTypeTranslation::delete ( )

Delete object.

Definition at line 181 of file class.ilOrgUnitTypeTranslation.php.

References $DIC, $ilDB, getLang(), and getOrguTypeId().

181  : void
182  {
183  $sql = 'DELETE FROM ' . self::TABLE_NAME . ' WHERE orgu_type_id = ' . $this->db->quote(
184  $this->getOrguTypeId(),
185  'integer'
186  ) .
187  ' AND lang = ' . $this->db->quote($this->getLang(), 'text');
188  $this->db->manipulate($sql);
189  }
+ Here is the call graph for this function:

◆ getInstance()

static ilOrgUnitTypeTranslation::getInstance ( int  $a_orgu_type_id,
string  $a_lang_code 
)
static

Get instance of an ilOrgUnitType object Returns object from cache or from database, returns null if no object was found.

Parameters
int$a_orgu_type_idID of an ilOrgUnitType object
string$a_lang_codeLanguage code
Returns
ilOrgUnitTypeTranslation|null

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

References $DIC, Vendor\Package\$e, ilDBInterface\fetchObject(), null, ilDBInterface\numRows(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilOrgUnitType\loadTranslation().

58  {
59  if (!$a_orgu_type_id || !$a_lang_code) {
60  return null;
61  }
62  $cache_id = $a_orgu_type_id . $a_lang_code;
63  if (isset(self::$instances[$cache_id])) {
64  return self::$instances[$cache_id];
65  } else {
66  try {
67  $trans = new self($a_orgu_type_id, $a_lang_code);
68  self::$instances[$cache_id] = $trans;
69 
70  return $trans;
71  } catch (ilOrgUnitTypeException $e) {
72  return null;
73  }
74  }
75  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLang()

ilOrgUnitTypeTranslation::getLang ( )

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

References $lang.

Referenced by delete(), insertMember(), and updateMember().

289  : string
290  {
291  return $this->lang;
292  }
+ Here is the caller graph for this function:

◆ getMember()

ilOrgUnitTypeTranslation::getMember ( string  $a_member)

Get translated value for a member, returns null if no translation exists.

Parameters
string$a_memberName of the variable, e.g. title,description
Returns
string|null

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

References null.

Referenced by update().

134  : ?string
135  {
136  return (isset($this->members[$a_member])) ? (string) $this->members[$a_member] : null;
137  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getMembers()

ilOrgUnitTypeTranslation::getMembers ( )

Definition at line 294 of file class.ilOrgUnitTypeTranslation.php.

References $members.

294  : array
295  {
296  return $this->members;
297  }

◆ getOrguTypeId()

ilOrgUnitTypeTranslation::getOrguTypeId ( )

Definition at line 299 of file class.ilOrgUnitTypeTranslation.php.

References $orgu_type_id.

Referenced by delete(), insertMember(), and updateMember().

299  : int
300  {
301  return $this->orgu_type_id;
302  }
+ Here is the caller graph for this function:

◆ insertMember()

ilOrgUnitTypeTranslation::insertMember ( string  $member,
string  $value 
)
protected

Protected.

Insert a (member,value) pair in database

Definition at line 211 of file class.ilOrgUnitTypeTranslation.php.

References getLang(), and getOrguTypeId().

Referenced by create(), and update().

211  : void
212  {
213  $this->db->insert(self::TABLE_NAME, array(
214  'orgu_type_id' => array('integer', $this->getOrguTypeId()),
215  'lang' => array('text', $this->getLang()),
216  'member' => array('text', $member),
217  'value' => array('text', $value),
218  ));
219  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilOrgUnitTypeTranslation::read ( )
protected

Read object data from database.

Exceptions
ilOrgUnitTypeException

Definition at line 263 of file class.ilOrgUnitTypeTranslation.php.

Referenced by __construct().

263  : void
264  {
265  $sql = 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE orgu_type_id = ' . $this->db->quote(
266  $this->orgu_type_id,
267  'integer'
268  ) .
269  ' AND lang = ' . $this->db->quote($this->lang, 'text');
270  $set = $this->db->query($sql);
271  if (!$this->db->numRows($set)) {
272  throw new ilOrgUnitTypeException("OrgUnit type translation for OrgUnit type {$this->orgu_type_id} and language {$this->lang} does not exist in database");
273  }
274  while ($rec = $this->db->fetchObject($set)) {
275  $this->members[$rec->member] = (string) $rec->value;
276  }
277  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ resetTrackChanges()

ilOrgUnitTypeTranslation::resetTrackChanges ( )
protected

Reset tracked members.

Definition at line 253 of file class.ilOrgUnitTypeTranslation.php.

Referenced by create(), and update().

253  : void
254  {
255  $this->changes = array();
256  $this->members_new = array();
257  }
+ Here is the caller graph for this function:

◆ setLang()

ilOrgUnitTypeTranslation::setLang ( string  $lang)

Getters & Setters.

Definition at line 284 of file class.ilOrgUnitTypeTranslation.php.

References $lang.

284  : void
285  {
286  $this->lang = $lang;
287  }

◆ setMember()

ilOrgUnitTypeTranslation::setMember ( string  $a_member,
string  $a_value 
)

Set translation value for a member, either update or add value.

Parameters
string$a_memberName of the variable, e.g. title,description
string$a_valueValue of the translation

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

References trackChange().

145  {
146  $is_new = !isset($this->members[$a_member]);
147  $this->members[$a_member] = (string) $a_value;
148  $this->trackChange($a_member, $is_new);
149  }
trackChange(string $a_member, bool $is_new)
Track a member that was either updated or added.
+ Here is the call graph for this function:

◆ setOrguTypeId()

ilOrgUnitTypeTranslation::setOrguTypeId ( int  $id)

Definition at line 304 of file class.ilOrgUnitTypeTranslation.php.

References $id.

304  : void
305  {
306  $this->orgu_type_id = $id;
307  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ trackChange()

ilOrgUnitTypeTranslation::trackChange ( string  $a_member,
bool  $is_new 
)
protected

Track a member that was either updated or added.

Parameters
string$a_memberName of a variable, e.g. title,description
bool$is_newTrue if the member did not exist before

Definition at line 240 of file class.ilOrgUnitTypeTranslation.php.

Referenced by setMember().

240  : void
241  {
242  if (!in_array($a_member, $this->changes)) {
243  $this->changes[] = $a_member;
244  }
245  if ($is_new && !in_array($a_member, $this->members_new)) {
246  $this->members_new[] = $a_member;
247  }
248  }
+ Here is the caller graph for this function:

◆ update()

ilOrgUnitTypeTranslation::update ( )

Update translations in database.

Newly added members are inserted.

Definition at line 165 of file class.ilOrgUnitTypeTranslation.php.

References getMember(), insertMember(), resetTrackChanges(), and updateMember().

165  : void
166  {
167  foreach ($this->changes as $changed_member) {
168  // Check if the member needs to be updated or inserted into database
169  if (in_array($changed_member, $this->members_new)) {
170  $this->insertMember($changed_member, $this->getMember($changed_member));
171  } else {
172  $this->updateMember($changed_member, $this->getMember($changed_member));
173  }
174  }
175  $this->resetTrackChanges();
176  }
updateMember(string $member, string $value)
Update a (member,value) pair in database.
resetTrackChanges()
Reset tracked members.
getMember(string $a_member)
Get translated value for a member, returns null if no translation exists.
insertMember(string $member, string $value)
Protected.
+ Here is the call graph for this function:

◆ updateMember()

ilOrgUnitTypeTranslation::updateMember ( string  $member,
string  $value 
)
protected

Update a (member,value) pair in database.

Definition at line 224 of file class.ilOrgUnitTypeTranslation.php.

References getLang(), and getOrguTypeId().

Referenced by update().

224  : void
225  {
226  $this->db->update(self::TABLE_NAME, array(
227  'value' => array('text', $value),
228  ), array(
229  'orgu_type_id' => array('integer', $this->getOrguTypeId()),
230  'lang' => array('text', $this->getLang()),
231  'member' => array('text', $member),
232  ));
233  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $changes

array ilOrgUnitTypeTranslation::$changes = []
protected

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

◆ $db

ilDBInterface ilOrgUnitTypeTranslation::$db
protected

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

◆ $instances

array ilOrgUnitTypeTranslation::$instances = []
staticprotected

Definition at line 35 of file class.ilOrgUnitTypeTranslation.php.

◆ $lang

string ilOrgUnitTypeTranslation::$lang = ''
protected

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

Referenced by getLang(), and setLang().

◆ $log

ILIAS DI LoggingServices ilOrgUnitTypeTranslation::$log
protected

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

◆ $members

array ilOrgUnitTypeTranslation::$members = []
protected

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

Referenced by getMembers().

◆ $members_new

array ilOrgUnitTypeTranslation::$members_new = []
protected

Definition at line 31 of file class.ilOrgUnitTypeTranslation.php.

◆ $orgu_type_id

int ilOrgUnitTypeTranslation::$orgu_type_id
protected

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

Referenced by getOrguTypeId().

◆ TABLE_NAME

const ilOrgUnitTypeTranslation::TABLE_NAME = 'orgu_types_trans'

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


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