- Added method dropdownListValuesToString to udf.class.php

- Added enum element to UDF definition in method _getUDFDefinition
- Exports now show the values of dropdowns and not the id
This commit is contained in:
Paolo
2017-08-07 11:18:41 +02:00
parent 2edcfae0af
commit db63dd1dd0
3 changed files with 98 additions and 11 deletions
+49 -1
View File
@@ -172,6 +172,45 @@ class UDF extends basis_db
return $prestudentHasUDF;
}
/**
* Concatenates a list of values of a dropdown element to a string
*/
public function dropdownListValuesToString($listValues, $enum)
{
$toWrite = '';
foreach ($listValues as $value)
{
foreach ($enum as $element)
{
if (is_object($element))
{
if ($element->id == $value)
{
$toWrite .= $element->description;
break;
}
}
else if (is_array($element))
{
if ($element[0] == $value)
{
$toWrite .= $element[1];
break;
}
}
else if ($element == $value)
{
$toWrite .= $element;
break;
}
}
$toWrite .= ' ';
}
return $toWrite;
}
/**
* Loads the UDF definitions related to the given schema and table
*/
@@ -243,7 +282,16 @@ class UDF extends basis_db
{
if (isset($udfJsonShema->name) && isset($udfJsonShema->title))
{
$names[] = array('name' => $udfJsonShema->name, 'title' => $udfJsonShema->title);
$tmpArray = array('name' => $udfJsonShema->name, 'title' => $udfJsonShema->title);
if (isset($udfJsonShema->type)
&& ($udfJsonShema->type == 'dropdown' || $udfJsonShema->type == 'multipledropdown')
&& isset($udfJsonShema->listValues) && isset($udfJsonShema->listValues->enum))
{
$tmpArray['enum'] = $udfJsonShema->listValues->enum;
}
$names[] = $tmpArray;
}
}
}