Skip to content

Commit 937dc2f

Browse files
committed
Implement missing methods
1 parent a873bcb commit 937dc2f

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

src/MetaModels/Attribute/TranslatedTableText/TranslatedTableText.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ public function getFieldDefinition($arrOverrides = array())
9999
*
100100
* @param mixed $mixIds One, none or many ids to use.
101101
*
102-
* @param string $strLangCode The language code.
102+
* @param string $strLangCode The language code, optional.
103103
*
104104
* @param int $intRow The row number, optional.
105105
*
106106
* @param int $intCol The col number, optional.
107107
*
108108
* @return string
109109
*/
110-
protected function getWhere($mixIds, $strLangCode, $intRow = null, $intCol = null)
110+
protected function getWhere($mixIds, $strLangCode = null, $intRow = null, $intCol = null)
111111
{
112112
$arrReturn = array(
113113
'procedure' => 'att_id=?',
@@ -327,8 +327,7 @@ public function getFilterOptions($idList, $usedOnly, &$arrCount = null)
327327
*/
328328
public function setDataFor($arrValues)
329329
{
330-
// TODO: implement.
331-
return array();
330+
$this->setTranslatedDataFor($arrValues, $this->getMetaModel()->getActiveLanguage());
332331
}
333332

334333
/**
@@ -338,8 +337,29 @@ public function setDataFor($arrValues)
338337
*/
339338
public function getDataFor($arrIds)
340339
{
341-
// TODO: implement.
342-
return array();
340+
$strActiveLanguage = $this->getMetaModel()->getActiveLanguage();
341+
$strFallbackLanguage = $this->getMetaModel()->getFallbackLanguage();
342+
343+
$arrReturn = $this->getTranslatedDataFor($arrIds, $strActiveLanguage);
344+
345+
// Second round, fetch fallback languages if not all items could be resolved.
346+
if ((count($arrReturn) < count($arrIds)) && ($strActiveLanguage != $strFallbackLanguage)) {
347+
$arrFallbackIds = array();
348+
foreach ($arrIds as $intId) {
349+
if (empty($arrReturn[$intId])) {
350+
$arrFallbackIds[] = $intId;
351+
}
352+
}
353+
354+
if ($arrFallbackIds) {
355+
$arrFallbackData = $this->getTranslatedDataFor($arrFallbackIds, $strFallbackLanguage);
356+
// Cannot use array_merge here as it would renumber the keys.
357+
foreach ($arrFallbackData as $intId => $arrValue) {
358+
$arrReturn[$intId] = $arrValue;
359+
}
360+
}
361+
}
362+
return $arrReturn;
343363
}
344364

345365
/**

0 commit comments

Comments
 (0)