ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTLocalizedTextDBBridge Class Reference

Class ilADTLocalizedTextDBBridge. More...

+ Inheritance diagram for ilADTLocalizedTextDBBridge:
+ Collaboration diagram for ilADTLocalizedTextDBBridge:

Public Member Functions

 getTable ()
 
 readRecord (array $a_row)
 
 prepareInsert (array &$a_fields)
 
 afterInsert ()
 
 getAdditionalPrimaryFields ()
 
 afterUpdate ()
 
- Public Member Functions inherited from ilADTDBBridge
 __construct (ilADT $a_adt)
 Constructor. More...
 
 getADT ()
 
 setTable (string $a_table)
 
 getTable ()
 
 setElementId (string $a_value)
 Set element id (aka DB column[s] [prefix]) More...
 
 getElementId ()
 Get element id. More...
 
 setPrimary (array $a_value)
 Set primary fields (in MDB2 format) More...
 
 getAdditionalPrimaryFields ()
 
 getPrimary ()
 Get primary fields. More...
 
 buildPrimaryWhere ()
 Convert primary keys array to sql string. More...
 
 readRecord (array $a_row)
 Import DB values to ADT. More...
 
 prepareInsert (array &$a_fields)
 Prepare ADT values for insert. More...
 
 afterInsert ()
 After insert hook to enable sub-tables. More...
 
 prepareUpdate (array &$a_fields)
 
 afterUpdate ()
 After update hook to enable sub-tables. More...
 
 afterDelete ()
 After delete hook to enable sub-tables. More...
 
 supportsDefaultValueColumn ()
 true if table storage relies on the default 'value' column More...
 

Protected Member Functions

 isValidADT (ilADT $adt)
 
 deleteTranslations ()
 delete translations More...
 
 insertTranslations ()
 Save all translations TODO: Translations are always persisted for all active languages, even if the translation is an empty string. More...
 
- Protected Member Functions inherited from ilADTDBBridge
 isValidADT (ilADT $a_adt)
 
 setADT (ilADT $a_adt)
 

Additional Inherited Members

- Protected Attributes inherited from ilADTDBBridge
ilADT $adt
 
string $table
 
string $id
 
array $primary = []
 
ilDBInterface $db
 

Detailed Description

Member Function Documentation

◆ afterInsert()

ilADTLocalizedTextDBBridge::afterInsert ( )

Definition at line 73 of file class.ilADTLocalizedTextDBBridge.php.

References afterUpdate().

73  : void
74  {
75  $this->afterUpdate();
76  }
+ Here is the call graph for this function:

◆ afterUpdate()

ilADTLocalizedTextDBBridge::afterUpdate ( )

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

References deleteTranslations(), ilADTDBBridge\getADT(), and insertTranslations().

Referenced by afterInsert().

88  : void
89  {
90  if (!$this->getADT()->getCopyOfDefinition()->supportsTranslations()) {
91  return;
92  }
93  $this->deleteTranslations();
94  $this->insertTranslations();
95  }
insertTranslations()
Save all translations TODO: Translations are always persisted for all active languages, even if the translation is an empty string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTranslations()

ilADTLocalizedTextDBBridge::deleteTranslations ( )
protected

delete translations

Definition at line 100 of file class.ilADTLocalizedTextDBBridge.php.

References ilADTDBBridge\buildPrimaryWhere(), getTable(), and ilDBConstants\T_TEXT.

Referenced by afterUpdate().

100  : void
101  {
102  $this->db->manipulate(
103  $q =
104  'delete from ' . $this->getTable() . ' ' .
105  'where ' . $this->buildPrimaryWhere() . ' ' .
106  'and value_index != ' . $this->db->quote('', ilDBConstants::T_TEXT)
107  );
108  }
buildPrimaryWhere()
Convert primary keys array to sql string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalPrimaryFields()

ilADTLocalizedTextDBBridge::getAdditionalPrimaryFields ( )

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

References ilDBConstants\T_TEXT.

78  : array
79  {
80  return [
81  'value_index' => [ilDBConstants::T_TEXT, '']
82  ];
83  }

◆ getTable()

ilADTLocalizedTextDBBridge::getTable ( )

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

Referenced by deleteTranslations(), and insertTranslations().

27  : ?string
28  {
29  return 'adv_md_values_ltext';
30  }
+ Here is the caller graph for this function:

◆ insertTranslations()

ilADTLocalizedTextDBBridge::insertTranslations ( )
protected

Save all translations TODO: Translations are always persisted for all active languages, even if the translation is an empty string.

This shouldn't work that way.

Definition at line 115 of file class.ilADTLocalizedTextDBBridge.php.

References ilADTDBBridge\getADT(), ilADTDBBridge\getPrimary(), getTable(), and ilDBConstants\T_TEXT.

Referenced by afterUpdate().

115  : void
116  {
117  foreach ($this->getADT()->getTranslations() as $language => $value) {
118  $fields = $this->getPrimary();
119  $fields['value_index'] = [ilDBConstants::T_TEXT, $language];
120  $fields['value'] = [ilDBConstants::T_TEXT, $value];
121  $this->db->insert($this->getTable(), $fields);
122  }
123  }
getPrimary()
Get primary fields.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidADT()

ilADTLocalizedTextDBBridge::isValidADT ( ilADT  $adt)
protected

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

35  : bool
36  {
37  return $adt instanceof ilADTLocalizedText;
38  }
Class ilADTLocalizedText.

◆ prepareInsert()

ilADTLocalizedTextDBBridge::prepareInsert ( array &  $a_fields)

Definition at line 65 of file class.ilADTLocalizedTextDBBridge.php.

References ilADTDBBridge\getADT(), ilADTDBBridge\getElementId(), and ilDBConstants\T_TEXT.

65  : void
66  {
67  $a_fields[$this->getElementId()] = [ilDBConstants::T_TEXT, $this->getADT()->getText()];
68  }
getElementId()
Get element id.
+ Here is the call graph for this function:

◆ readRecord()

ilADTLocalizedTextDBBridge::readRecord ( array  $a_row)

Definition at line 43 of file class.ilADTLocalizedTextDBBridge.php.

References ilADTDBBridge\getADT(), and ilADTDBBridge\getElementId().

43  : void
44  {
45  $active_languages = $this->getADT()->getCopyOfDefinition()->getActiveLanguages();
46  $default_language = $this->getADT()->getCopyOfDefinition()->getDefaultLanguage();
47  $language = $a_row[$this->getElementId() . '_language'];
48 
49  if (strcmp($language, $default_language) === 0) {
50  $this->getADT()->setText($a_row[$this->getElementId() . '_translation']);
51  } elseif (!strlen($default_language)) {
52  $this->getADT()->setText($a_row[$this->getElementId() . '_translation']);
53  }
54  if (in_array($language, $active_languages)) {
55  $this->getADT()->setTranslation(
56  $language,
57  (string) $a_row[$this->getElementId() . '_translation']
58  );
59  }
60  }
getElementId()
Get element id.
+ Here is the call graph for this function:

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