Few bug fixes to the translation manager

This commit is contained in:
Llewellyn van der Merwe 2018-01-20 14:23:36 +02:00
parent c6884571bd
commit 850b5867e1
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
7 changed files with 105 additions and 53 deletions

View File

@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
+ *First Build*: 30th April, 2015
+ *Last Build*: 19th January, 2018
+ *Last Build*: 20th January, 2018
+ *Version*: 2.6.12
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **180465**
+ *Line count*: **180517**
+ *Field count*: **1573**
+ *File count*: **1160**
+ *Folder count*: **186**

View File

@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
+ *First Build*: 30th April, 2015
+ *Last Build*: 19th January, 2018
+ *Last Build*: 20th January, 2018
+ *Version*: 2.6.12
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **180465**
+ *Line count*: **180517**
+ *Field count*: **1573**
+ *File count*: **1160**
+ *Folder count*: **186**

View File

@ -501,9 +501,10 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
// raw items import & update!
$query = $db->getQuery(true);
$query
->select('version')
->select($db->quoteName(array('version', 'translation')))
->from($db->quoteName('#__componentbuilder_'.$table))
->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key]));
->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key]))
->where($db->quoteName('entranslation') . ' = '. $db->quote($row[$english_key]));
// Reset the query using our newly populated query object.
$db->setQuery($query);
$db->execute();
@ -514,14 +515,25 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
{
// update item
$id = $row[$id_key];
$version = $db->loadResult();
$item = $db->loadObject();
// load previous translation strings
if (ComponentbuilderHelper::checkJson($item->translation))
{
$translations = json_decode($item->translation, true);
$counter = count($translations) + 2;
$pre = true;
}
else
{
$translations = array();
$counter = 0;
$pre = false;
}
// get languages
$languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag');
// reset all buckets
$query = $db->getQuery(true);
$fields = array();
$translations = array();
$counter = 0;
// Fields to update.
foreach($row as $key => $cell)
{
@ -533,7 +545,7 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
// update version
if ('version' == $target[$key])
{
$cell = (int) $version + 1;
$cell = (int) $item->version + 1;
}
// verify publish authority
if ('published' == $target[$key] && !$canState)
@ -546,6 +558,20 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
// only add if it has a string
if (ComponentbuilderHelper::checkString($cell))
{
// remove if was set previously
if ($pre)
{
$tag = $target[$key];
$translations = array_filter(
$translations,
function($trans) use($tag) {
if ($trans['language'] !== $tag)
{
return true;
}
return false;
});
}
$translations['translation'.$counter] = array('language' => $target[$key], 'translation' => $cell);
$counter++;
}
@ -569,22 +595,18 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
if (ComponentbuilderHelper::checkArray($translations))
{
$fields[] = $db->quoteName('translation') . ' = ' . $db->quote(json_encode($translations, JSON_FORCE_OBJECT));
}
// load the defaults
$fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
$fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = ' . $id
);
// load the defaults
$fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
$fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = ' . $id
);
$query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
else
{
return false;
$query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
}
return true;

View File

@ -418,6 +418,8 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
// prep the lang strings for export
if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items))
{
// insure we have the same order in the languages
$languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag');
foreach ($items as $nr => &$item)
{
// remove some values completely
@ -432,18 +434,26 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
unset($item->hits);
unset($item->access);
unset($item->ordering);
// now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
// set the lang order
if ($nr != 0)
{
$translations = json_decode($item->translation, true);
if (ComponentbuilderHelper::checkArray($translations))
foreach ($languages as $lanTag)
{
foreach ($translations as $language)
$item->{$lanTag} = '';
}
// now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{
$translations = json_decode($item->translation, true);
if (ComponentbuilderHelper::checkArray($translations))
{
if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation'])
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['language']))
foreach ($translations as $language)
{
$item->{$language['language']} = $language['translation'];
if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation'])
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['language']))
{
$item->{$language['language']} = $language['translation'];
}
}
}
}

View File

@ -111,7 +111,7 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin
if (!empty($item->components))
{
// JSON Decode components.
$item->components = json_decode($item->components);
$item->components = json_decode($item->components, true);
}

View File

@ -164,6 +164,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// prep the lang strings for export
if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items))
{
// insure we have the same order in the languages
$languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag');
foreach ($items as $nr => &$item)
{
// remove some values completely
@ -178,18 +180,26 @@ class ComponentbuilderModelLanguage_translations extends JModelList
unset($item->hits);
unset($item->access);
unset($item->ordering);
// now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
// set the lang order
if ($nr != 0)
{
$translations = json_decode($item->translation, true);
if (ComponentbuilderHelper::checkArray($translations))
foreach ($languages as $lanTag)
{
foreach ($translations as $language)
$item->{$lanTag} = '';
}
// now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{
$translations = json_decode($item->translation, true);
if (ComponentbuilderHelper::checkArray($translations))
{
if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation'])
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['language']))
foreach ($translations as $language)
{
$item->{$language['language']} = $language['translation'];
if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation'])
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['language']))
{
$item->{$language['language']} = $language['translation'];
}
}
}
}
@ -387,6 +397,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// prep the lang strings for export
if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items))
{
// insure we have the same order in the languages
$languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag');
foreach ($items as $nr => &$item)
{
// remove some values completely
@ -401,18 +413,26 @@ class ComponentbuilderModelLanguage_translations extends JModelList
unset($item->hits);
unset($item->access);
unset($item->ordering);
// now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
// set the lang order
if ($nr != 0)
{
$translations = json_decode($item->translation, true);
if (ComponentbuilderHelper::checkArray($translations))
foreach ($languages as $lanTag)
{
foreach ($translations as $language)
$item->{$lanTag} = '';
}
// now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{
$translations = json_decode($item->translation, true);
if (ComponentbuilderHelper::checkArray($translations))
{
if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation'])
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['language']))
foreach ($translations as $language)
{
$item->{$language['language']} = $language['translation'];
if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation'])
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['language']))
{
$item->{$language['language']} = $language['translation'];
}
}
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>19th January, 2018</creationDate>
<creationDate>20th January, 2018</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://joomlacomponentbuilder.com</authorUrl>