convert repeatable properties field in the field types view to subform field

This commit is contained in:
2017-09-18 04:20:50 +02:00
parent 06416e665d
commit 9e140b40da
249 changed files with 705 additions and 496 deletions

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.5
@build 17th September, 2017
@build 18th September, 2017
@created 30th April, 2015
@package Component Builder
@subpackage script.php
@ -1708,6 +1708,52 @@ class com_componentbuilderInstallerScript
}
}
}
// update the properties in the field types
$query = $db->getQuery(true);
// update all JCB lang translations
$query->select($db->quoteName(array('id', 'properties')));
$query->from($db->quoteName('#__componentbuilder_fieldtype'));
// Reset the query using our newly populated query object.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
$rows = $db->loadObjectList();
foreach ($rows as $row)
{
// check if it has translations
if (ComponentbuilderHelper::checkJson($row->properties))
{
// open the properties and convert
$properties = json_decode($row->properties, true);
if (ComponentbuilderHelper::checkArray($properties)
&& isset($properties['name']) && ComponentbuilderHelper::checkArray($properties['name'])
&& isset($properties['mandatory']) && ComponentbuilderHelper::checkArray($properties['mandatory']))
{
$bucket = array();
foreach ($properties as $key => $values)
{
foreach ($values as $nr => $value)
{
if (!isset($bucket['properties' . $nr]) || !ComponentbuilderHelper::checkArray($bucket['properties' . $nr]))
{
$bucket['properties' . $nr] = array();
}
$bucket['properties' . $nr][$key] = $value;
}
}
// set the bucket back to translation
$row->properties = json_encode($bucket);
$db->updateObject('#__componentbuilder_fieldtype', $row, 'id');
}
elseif (!ComponentbuilderHelper::checkArray($properties))
{
$row->properties = '';
$db->updateObject('#__componentbuilder_fieldtype', $row, 'id');
}
}
}
}
}
}
}