forked from joomla/Component-Builder
Few bug fixes to the translation manager
This commit is contained in:
parent
c6884571bd
commit
850b5867e1
@ -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**
|
||||||
|
@ -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**
|
||||||
|
@ -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,22 +595,18 @@ 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);
|
// Conditions for which records should be updated.
|
||||||
// Conditions for which records should be updated.
|
$conditions = array(
|
||||||
$conditions = array(
|
$db->quoteName('id') . ' = ' . $id
|
||||||
$db->quoteName('id') . ' = ' . $id
|
);
|
||||||
);
|
|
||||||
|
|
||||||
$query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions);
|
$query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions);
|
||||||
$db->setQuery($query);
|
$db->setQuery($query);
|
||||||
$db->execute();
|
$db->execute();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -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,18 +434,26 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
|
|||||||
unset($item->hits);
|
unset($item->hits);
|
||||||
unset($item->access);
|
unset($item->access);
|
||||||
unset($item->ordering);
|
unset($item->ordering);
|
||||||
// now adapt the entranslation
|
// set the lang order
|
||||||
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
|
if ($nr != 0)
|
||||||
{
|
{
|
||||||
$translations = json_decode($item->translation, true);
|
foreach ($languages as $lanTag)
|
||||||
if (ComponentbuilderHelper::checkArray($translations))
|
|
||||||
{
|
{
|
||||||
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'])
|
foreach ($translations as $language)
|
||||||
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,13 +107,13 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin
|
|||||||
$translation->loadString($item->translation);
|
$translation->loadString($item->translation);
|
||||||
$item->translation = $translation->toArray();
|
$item->translation = $translation->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (empty($item->id))
|
if (empty($item->id))
|
||||||
{
|
{
|
||||||
|
@ -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,18 +180,26 @@ class ComponentbuilderModelLanguage_translations extends JModelList
|
|||||||
unset($item->hits);
|
unset($item->hits);
|
||||||
unset($item->access);
|
unset($item->access);
|
||||||
unset($item->ordering);
|
unset($item->ordering);
|
||||||
// now adapt the entranslation
|
// set the lang order
|
||||||
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
|
if ($nr != 0)
|
||||||
{
|
{
|
||||||
$translations = json_decode($item->translation, true);
|
foreach ($languages as $lanTag)
|
||||||
if (ComponentbuilderHelper::checkArray($translations))
|
|
||||||
{
|
{
|
||||||
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'])
|
foreach ($translations as $language)
|
||||||
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['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
|
// 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,18 +413,26 @@ class ComponentbuilderModelLanguage_translations extends JModelList
|
|||||||
unset($item->hits);
|
unset($item->hits);
|
||||||
unset($item->access);
|
unset($item->access);
|
||||||
unset($item->ordering);
|
unset($item->ordering);
|
||||||
// now adapt the entranslation
|
// set the lang order
|
||||||
if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation))
|
if ($nr != 0)
|
||||||
{
|
{
|
||||||
$translations = json_decode($item->translation, true);
|
foreach ($languages as $lanTag)
|
||||||
if (ComponentbuilderHelper::checkArray($translations))
|
|
||||||
{
|
{
|
||||||
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'])
|
foreach ($translations as $language)
|
||||||
&& isset($language['language']) && ComponentbuilderHelper::checkString($language['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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user