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)
|
||||
+ *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**
|
||||
|
@ -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**
|
||||
|
@ -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;
|
||||
|
@ -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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,13 +107,13 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin
|
||||
$translation->loadString($item->translation);
|
||||
$item->translation = $translation->toArray();
|
||||
}
|
||||
|
||||
|
||||
if (!empty($item->components))
|
||||
{
|
||||
// JSON Decode components.
|
||||
$item->components = json_decode($item->components);
|
||||
$item->components = json_decode($item->components, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (empty($item->id))
|
||||
{
|
||||
|
@ -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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user