ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADTLocalizedTextDBBridge Class Reference

Class ilADTLocalizedTextDBBridge. More...

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

Public Member Functions

 getTable ()
 
 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...
 
 getAdditionalPrimaryFields ()
 
 afterUpdate ()
 After update hook to enable sub-tables. More...
 
- 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 ()
 
 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 ( )

After insert hook to enable sub-tables.

Reimplemented from ilADTDBBridge.

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

66 : void
67 {
68 $this->afterUpdate();
69 }
afterUpdate()
After update hook to enable sub-tables.

References afterUpdate().

+ Here is the call graph for this function:

◆ afterUpdate()

ilADTLocalizedTextDBBridge::afterUpdate ( )

After update hook to enable sub-tables.

Reimplemented from ilADTDBBridge.

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

78 : void
79 {
80 if (!$this->getADT()->getCopyOfDefinition()->supportsTranslations()) {
81 return;
82 }
83 $this->deleteTranslations();
84 $this->insertTranslations();
85 }
insertTranslations()
Save all translations TODO: Translations are always persisted for all active languages,...

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

Referenced by afterInsert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTranslations()

ilADTLocalizedTextDBBridge::deleteTranslations ( )
protected

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

87 : void
88 {
89 $this->db->manipulate(
90 $q =
91 'delete from ' . $this->getTable() . ' ' .
92 'where ' . $this->buildPrimaryWhere() . ' ' .
93 'and value_index != ' . $this->db->quote('', ilDBConstants::T_TEXT)
94 );
95 }
buildPrimaryWhere()
Convert primary keys array to sql string.
$q
Definition: shib_logout.php:23

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

Referenced by afterUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalPrimaryFields()

ilADTLocalizedTextDBBridge::getAdditionalPrimaryFields ( )

Reimplemented from ilADTDBBridge.

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

71 : array
72 {
73 return [
74 'value_index' => [ilDBConstants::T_TEXT, '']
75 ];
76 }

References ilDBConstants\T_TEXT.

◆ getTable()

ilADTLocalizedTextDBBridge::getTable ( )

Reimplemented from ilADTDBBridge.

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

27 : ?string
28 {
29 return 'adv_md_values_ltext';
30 }

Referenced by deleteTranslations(), and insertTranslations().

+ 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 102 of file class.ilADTLocalizedTextDBBridge.php.

102 : void
103 {
104 foreach ($this->getADT()->getTranslations() as $language => $value) {
105 $fields = $this->getPrimary();
106 $fields['value_index'] = [ilDBConstants::T_TEXT, $language];
107 $fields['value'] = [ilDBConstants::T_TEXT, $value];
108 $this->db->insert($this->getTable(), $fields);
109 }
110 }
getPrimary()
Get primary fields.

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

Referenced by afterUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidADT()

ilADTLocalizedTextDBBridge::isValidADT ( ilADT  $adt)
protected

Reimplemented from ilADTDBBridge.

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

32 : bool
33 {
34 return $adt instanceof ilADTLocalizedText;
35 }
Class ilADTLocalizedText.

References ilADTDBBridge\$adt.

◆ prepareInsert()

ilADTLocalizedTextDBBridge::prepareInsert ( array &  $a_fields)

Prepare ADT values for insert.

Parameters
array&$a_fields

Reimplemented from ilADTDBBridge.

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

58 : void
59 {
60 $a_fields[$this->getElementId()] = [ilDBConstants::T_TEXT, $this->getADT()->getText()];
61 }
getElementId()
Get element id.

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

+ Here is the call graph for this function:

◆ readRecord()

ilADTLocalizedTextDBBridge::readRecord ( array  $a_row)

Import DB values to ADT.

Parameters
array$a_row

Reimplemented from ilADTDBBridge.

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

37 : void
38 {
39 $active_languages = $this->getADT()->getCopyOfDefinition()->getActiveLanguages();
40 $default_language = $this->getADT()->getCopyOfDefinition()->getDefaultLanguage();
41 $language = $a_row[$this->getElementId() . '_language'] ?? '';
42
43 if (!$this->getADT()->getCopyOfDefinition()->getMultilingualValueSupport()) {
44 $this->getADT()->setText($a_row[$this->getElementId() . '_translation' ]);
45 } elseif (strcmp($language, $default_language) === 0) {
46 $this->getADT()->setText($a_row[$this->getElementId() . '_translation']);
47 } elseif (!strlen($default_language)) {
48 $this->getADT()->setText($a_row[$this->getElementId() . '_translation']);
49 }
50 if (in_array($language, $active_languages)) {
51 $this->getADT()->setTranslation(
52 $language,
53 (string) $a_row[$this->getElementId() . '_translation']
54 );
55 }
56 }

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

+ Here is the call graph for this function:

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