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) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 19th January, 2018 + *Last Build*: 20th January, 2018
+ *Version*: 2.6.12 + *Version*: 2.6.12
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *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** + *Field count*: **1573**
+ *File count*: **1160** + *File count*: **1160**
+ *Folder count*: **186** + *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) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 19th January, 2018 + *Last Build*: 20th January, 2018
+ *Version*: 2.6.12 + *Version*: 2.6.12
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *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** + *Field count*: **1573**
+ *File count*: **1160** + *File count*: **1160**
+ *Folder count*: **186** + *Folder count*: **186**

View File

@ -501,9 +501,10 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
// raw items import & update! // raw items import & update!
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query $query
->select('version') ->select($db->quoteName(array('version', 'translation')))
->from($db->quoteName('#__componentbuilder_'.$table)) ->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. // Reset the query using our newly populated query object.
$db->setQuery($query); $db->setQuery($query);
$db->execute(); $db->execute();
@ -514,14 +515,25 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
{ {
// update item // update item
$id = $row[$id_key]; $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 // get languages
$languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag');
// reset all buckets // reset all buckets
$query = $db->getQuery(true); $query = $db->getQuery(true);
$fields = array(); $fields = array();
$translations = array();
$counter = 0;
// Fields to update. // Fields to update.
foreach($row as $key => $cell) foreach($row as $key => $cell)
{ {
@ -533,7 +545,7 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
// update version // update version
if ('version' == $target[$key]) if ('version' == $target[$key])
{ {
$cell = (int) $version + 1; $cell = (int) $item->version + 1;
} }
// verify publish authority // verify publish authority
if ('published' == $target[$key] && !$canState) if ('published' == $target[$key] && !$canState)
@ -546,6 +558,20 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
// only add if it has a string // only add if it has a string
if (ComponentbuilderHelper::checkString($cell)) 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); $translations['translation'.$counter] = array('language' => $target[$key], 'translation' => $cell);
$counter++; $counter++;
} }
@ -569,7 +595,6 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
if (ComponentbuilderHelper::checkArray($translations)) if (ComponentbuilderHelper::checkArray($translations))
{ {
$fields[] = $db->quoteName('translation') . ' = ' . $db->quote(json_encode($translations, JSON_FORCE_OBJECT)); $fields[] = $db->quoteName('translation') . ' = ' . $db->quote(json_encode($translations, JSON_FORCE_OBJECT));
}
// load the defaults // load the defaults
$fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id); $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
$fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate); $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
@ -582,9 +607,6 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy
$db->setQuery($query); $db->setQuery($query);
$db->execute(); $db->execute();
} }
else
{
return false;
} }
} }
return true; return true;

View File

@ -418,6 +418,8 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
// prep the lang strings for export // prep the lang strings for export
if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items)) 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) foreach ($items as $nr => &$item)
{ {
// remove some values completely // remove some values completely
@ -432,6 +434,13 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
unset($item->hits); unset($item->hits);
unset($item->access); unset($item->access);
unset($item->ordering); unset($item->ordering);
// set the lang order
if ($nr != 0)
{
foreach ($languages as $lanTag)
{
$item->{$lanTag} = '';
}
// now adapt the entranslation // now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{ {
@ -448,6 +457,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
} }
} }
} }
}
// remove translation // remove translation
unset($item->translation); unset($item->translation);
} }

View File

@ -111,7 +111,7 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin
if (!empty($item->components)) if (!empty($item->components))
{ {
// JSON Decode 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 // prep the lang strings for export
if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items)) 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) foreach ($items as $nr => &$item)
{ {
// remove some values completely // remove some values completely
@ -178,6 +180,13 @@ class ComponentbuilderModelLanguage_translations extends JModelList
unset($item->hits); unset($item->hits);
unset($item->access); unset($item->access);
unset($item->ordering); unset($item->ordering);
// set the lang order
if ($nr != 0)
{
foreach ($languages as $lanTag)
{
$item->{$lanTag} = '';
}
// now adapt the entranslation // now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{ {
@ -194,6 +203,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
} }
} }
} }
}
// remove translation // remove translation
unset($item->translation); unset($item->translation);
} }
@ -387,6 +397,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// prep the lang strings for export // prep the lang strings for export
if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items)) 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) foreach ($items as $nr => &$item)
{ {
// remove some values completely // remove some values completely
@ -401,6 +413,13 @@ class ComponentbuilderModelLanguage_translations extends JModelList
unset($item->hits); unset($item->hits);
unset($item->access); unset($item->access);
unset($item->ordering); unset($item->ordering);
// set the lang order
if ($nr != 0)
{
foreach ($languages as $lanTag)
{
$item->{$lanTag} = '';
}
// now adapt the entranslation // now adapt the entranslation
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
{ {
@ -417,6 +436,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
} }
} }
} }
}
// remove translation // remove translation
unset($item->translation); unset($item->translation);
} }

View File

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