ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 __construct (ilADT $a_adt)
 
 readRecord (array $a_row)
 
 prepareInsert (array &$a_fields)
 
 afterInsert ()
 
 afterUpdate ()
 
- 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)
 
 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)

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

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

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)
+ Here is the call graph for this function:

Member Function Documentation

◆ afterInsert()

ilADTLocalizedTextDBBridge::afterInsert ( )

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

References afterUpdate().

+ Here is the call graph for this function:

◆ afterUpdate()

ilADTLocalizedTextDBBridge::afterUpdate ( )

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

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

Referenced by afterInsert().

79  {
80  if (!$this->getADT()->getCopyOfDefinition()->supportsTranslations()) {
81  return;
82  }
83  $this->deleteTranslations();
84  $this->insertTranslations();
85  }
+ 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.

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

Referenced by afterUpdate().

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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTable()

ilADTLocalizedTextDBBridge::getTable ( )

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

Referenced by deleteTranslations(), and insertTranslations().

11  {
12  return 'adv_md_values_ltext';
13  }
+ Here is the caller graph for this function:

◆ insertTranslations()

ilADTLocalizedTextDBBridge::insertTranslations ( )
protected

Save all translations.

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

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

Referenced by afterUpdate().

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

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

◆ prepareInsert()

ilADTLocalizedTextDBBridge::prepareInsert ( array &  $a_fields)

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

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

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

◆ readRecord()

ilADTLocalizedTextDBBridge::readRecord ( array  $a_row)

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

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

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  }
getElementId()
Get element id.
+ 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: