ILIAS  release_7 Revision v7.30-3-g800a261c036
ilADTLocalizedTextDBBridge Class Reference

Class ilADTLocalizedTextDBBridge. More...

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

Public Member Functions

 getTable ()
 Get table name. More...
 
 __construct (ilADT $a_adt)
 Constructor. More...
 
 readRecord (array $a_row)
 @inheritDoc More...
 
 prepareInsert (array &$a_fields)
 @inheritDoc More...
 
 afterInsert ()
 After insert hook to enable sub-tables. More...
 
 afterUpdate ()
 After update hook to enable sub-tables. More...
 
- Public Member Functions inherited from ilADTDBBridge
 __construct (ilADT $a_adt)
 Constructor. More...
 
 getADT ()
 Get ADT. More...
 
 setTable ($a_table)
 Set table name. More...
 
 getTable ()
 Get table name. More...
 
 setElementId ($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...
 
 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)
 Prepare ADT values for update. More...
 
 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)
 @inheritDoc More...
 
 deleteTranslations ()
 delete translations More...
 
 insertTranslations ()
 Save all translations. More...
 
- Protected Member Functions inherited from ilADTDBBridge
 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 

Private Attributes

 $db
 

Additional Inherited Members

- Protected Attributes inherited from ilADTDBBridge
 $adt
 
 $table
 
 $id
 
 $primary = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilADTLocalizedTextDBBridge::__construct ( ilADT  $a_adt)

Constructor.

Parameters
ilADT$a_adt
Returns
self

Reimplemented from ilADTDBBridge.

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

22 {
23 global $DIC;
24
25 $this->db = $DIC->database();
26 parent::__construct($a_adt);
27 }
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ afterInsert()

ilADTLocalizedTextDBBridge::afterInsert ( )

After insert hook to enable sub-tables.

Reimplemented from ilADTDBBridge.

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

71 {
72 $this->afterUpdate();
73 }
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.

79 {
80 if (!$this->getADT()->getCopyOfDefinition()->supportsTranslations()) {
81 return;
82 }
83 $this->deleteTranslations();
84 $this->insertTranslations();
85 }

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

delete translations

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

92 {
93 $this->db->manipulate($q =
94 'delete from ' . $this->getTable() . ' ' .
95 'where ' . $this->buildPrimaryWhere() . ' ' .
96 'and value_index != ' . $this->db->quote('', ilDBConstants::T_TEXT)
97 );
98 }
buildPrimaryWhere()
Convert primary keys array to sql string.

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

◆ getTable()

ilADTLocalizedTextDBBridge::getTable ( )

Get table name.

Returns
string

Reimplemented from ilADTDBBridge.

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

11 {
12 return 'adv_md_values_ltext';
13 }

Referenced by deleteTranslations(), and insertTranslations().

+ Here is the caller graph for this function:

◆ insertTranslations()

ilADTLocalizedTextDBBridge::insertTranslations ( )
protected

Save all translations.

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

104 {
105 foreach ($this->getADT()->getTranslations() as $language => $value) {
106 $fields = $this->getPrimary();
107 $fields['value_index'] = [ilDBConstants::T_TEXT,$language];
108 $fields['value'] = [ilDBConstants::T_TEXT,$value];
109 $this->db->insert($this->getTable(), $fields);
110 }
111 }
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

@inheritDoc

Reimplemented from ilADTDBBridge.

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

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

References ilADTDBBridge\$adt.

◆ prepareInsert()

ilADTLocalizedTextDBBridge::prepareInsert ( array &  $a_fields)

@inheritDoc

Reimplemented from ilADTDBBridge.

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

63 {
64 $a_fields[$this->getElementId()] = [ilDBConstants::T_TEXT, $this->getADT()->getText()];
65 }
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)

@inheritDoc

Reimplemented from ilADTDBBridge.

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

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilADTLocalizedTextDBBridge::$db
private

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


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