Added Joomla Module to import and export of JCB packages. Improved the export/import to insure IDs of fields in the Joomla module and plugins are also correctly exported and imported.
This commit is contained in:
parent
6c2ca03ebc
commit
8c284aaed4
@ -144,11 +144,11 @@ TODO
|
||||
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
||||
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 6th December, 2019
|
||||
+ *Last Build*: 7th December, 2019
|
||||
+ *Version*: 2.10.8
|
||||
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **277334**
|
||||
+ *Line count*: **277493**
|
||||
+ *Field count*: **1491**
|
||||
+ *File count*: **1766**
|
||||
+ *Folder count*: **287**
|
||||
|
@ -144,11 +144,11 @@ TODO
|
||||
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
||||
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 6th December, 2019
|
||||
+ *Last Build*: 7th December, 2019
|
||||
+ *Version*: 2.10.8
|
||||
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **277334**
|
||||
+ *Line count*: **277493**
|
||||
+ *Field count*: **1491**
|
||||
+ *File count*: **1766**
|
||||
+ *Folder count*: **287**
|
||||
|
@ -700,11 +700,12 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
$tables = array(
|
||||
'validation_rule', 'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view',
|
||||
'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code', 'placeholder', 'class_extends',
|
||||
'joomla_module', 'joomla_module_files_folders_urls', 'joomla_module_updates',
|
||||
'joomla_plugin_group', 'class_property', 'class_method', 'joomla_plugin', 'joomla_plugin_files_folders_urls', 'joomla_plugin_updates',
|
||||
'admin_fields', 'admin_fields_conditions', 'admin_fields_relations', 'admin_custom_tabs', 'component_admin_views',
|
||||
'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks',
|
||||
'component_custom_admin_menus', 'component_config', 'component_dashboard', 'component_files_folders',
|
||||
'component_placeholders', 'component_plugins'
|
||||
'component_placeholders', 'component_modules', 'component_plugins'
|
||||
);
|
||||
// get prefix
|
||||
$prefix = $this->_db->getPrefix();
|
||||
@ -2065,6 +2066,21 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
$item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type);
|
||||
}
|
||||
break;
|
||||
case 'component_modules':
|
||||
// diverged id already updated
|
||||
if (!$diverged)
|
||||
{
|
||||
// update the joomla_component ID where needed
|
||||
$item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type);
|
||||
}
|
||||
// subform fields to target
|
||||
$updaterT = array(
|
||||
// subformfield => array( field => type_value )
|
||||
'addjoomla_modules' => array('module' => 'joomla_module')
|
||||
);
|
||||
// update the subform ids
|
||||
$this->updateSubformsIDs($item, 'component_modules', $updaterT);
|
||||
break;
|
||||
case 'component_plugins':
|
||||
// diverged id already updated
|
||||
if (!$diverged)
|
||||
@ -2096,6 +2112,31 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
// update the repeatable fields
|
||||
$item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR);
|
||||
break;
|
||||
case 'joomla_module':
|
||||
// update the custom_get
|
||||
$item = $this->setNewID($item, 'custom_get', 'dynamic_get', $type);
|
||||
// if we can't merge add postfix to name
|
||||
if ($this->postfix)
|
||||
{
|
||||
$item->system_name = $item->system_name.$this->postfix;
|
||||
}
|
||||
// subform fields to target
|
||||
$updaterT = array(
|
||||
// subformfield => array( field => type_value )
|
||||
'fields' => array('field' => 'field')
|
||||
);
|
||||
// update the subform ids
|
||||
$this->updateSubformsIDs($item, 'joomla_module', $updaterT);
|
||||
break;
|
||||
case 'joomla_module_files_folders_urls':
|
||||
case 'joomla_module_updates':
|
||||
// diverged id already updated
|
||||
if (!$diverged)
|
||||
{
|
||||
// update the joomla_module ID where needed
|
||||
$item = $this->setNewID($item, 'joomla_module', 'joomla_module', $type);
|
||||
}
|
||||
break;
|
||||
case 'joomla_plugin_group':
|
||||
// diverged id already updated
|
||||
if (!$diverged)
|
||||
@ -2925,6 +2966,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
case 'component_dashboard':
|
||||
case 'component_placeholders':
|
||||
case 'component_files_folders':
|
||||
case 'component_modules':
|
||||
case 'component_plugins':
|
||||
// get by joomla_component (since there should only be one of each component)
|
||||
$getter = array('joomla_component');
|
||||
@ -2956,6 +2998,46 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
// get by language tag since there should just be one
|
||||
$getter = 'langtag';
|
||||
break;
|
||||
case 'joomla_module':
|
||||
// get
|
||||
if ($retry == 3)
|
||||
{
|
||||
// get by names, exteneded and group only
|
||||
$getter = array('name', 'system_name');
|
||||
}
|
||||
elseif ($retry == 2)
|
||||
{
|
||||
// get by description
|
||||
$getter = array('name', 'system_name', 'description');
|
||||
$retryAgain = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// get by id
|
||||
$getter = array('id', 'name', 'system_name');
|
||||
$retryAgain = 2;
|
||||
}
|
||||
break;
|
||||
case 'joomla_module_files_folders_urls':
|
||||
case 'joomla_module_updates':
|
||||
// get by admin_view (since there should only be one of each name)
|
||||
$getter = array('joomla_module');
|
||||
$this->specialValue = array();
|
||||
// Yet if diverged it makes sense that the ID is updated.
|
||||
if ($diverged)
|
||||
{
|
||||
$this->specialValue['joomla_module'] = (int) $item->joomla_module;
|
||||
}
|
||||
elseif (isset($this->newID['joomla_module'][(int) $item->joomla_module]))
|
||||
{
|
||||
$this->specialValue['joomla_module'] = $this->newID['joomla_module'][(int) $item->joomla_module];
|
||||
}
|
||||
// (TODO) I have seen this happen, seems dangerous!
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'joomla_plugin':
|
||||
// get
|
||||
if ($retry == 3)
|
||||
|
@ -304,6 +304,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
'component_custom_admin_menus' => 'joomla_component',
|
||||
'component_dashboard' => 'joomla_component',
|
||||
'component_placeholders' => 'joomla_component',
|
||||
'component_modules' => 'joomla_component',
|
||||
'component_plugins' => 'joomla_component');
|
||||
// load all tables linked to joomla_component
|
||||
foreach($linkedTables as $table => $field)
|
||||
@ -318,6 +319,13 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
$this->setData('admin_fields_relations', array_values($this->smartIDs['admin_view']), 'admin_view');
|
||||
$this->setData('admin_custom_tabs', array_values($this->smartIDs['admin_view']), 'admin_view');
|
||||
}
|
||||
// add joomla module
|
||||
if (isset($this->smartIDs['joomla_module']) && ComponentbuilderHelper::checkArray($this->smartIDs['joomla_module']))
|
||||
{
|
||||
$this->setData('joomla_module', array_values($this->smartIDs['joomla_module']), 'id');
|
||||
$this->setData('joomla_module_updates', array_values($this->smartIDs['joomla_module']), 'joomla_module');
|
||||
$this->setData('joomla_module_files_folders_urls', array_values($this->smartIDs['joomla_module']), 'joomla_module');
|
||||
}
|
||||
// add joomla plugin
|
||||
if (isset($this->smartIDs['joomla_plugin']) && ComponentbuilderHelper::checkArray($this->smartIDs['joomla_plugin']))
|
||||
{
|
||||
@ -572,6 +580,41 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
return array_unique($bucket);
|
||||
}
|
||||
}
|
||||
// check if the key is an array (targeting subform subform)
|
||||
if ('subform++' === $type && strpos($key, '.') !== false)
|
||||
{
|
||||
$_key = explode('.', $key);
|
||||
foreach ($values as $value)
|
||||
{
|
||||
if (isset($value[$_key[0]]) && ComponentbuilderHelper::checkArray($value[$_key[0]]))
|
||||
{
|
||||
foreach ($value[$_key[0]] as $_value)
|
||||
{
|
||||
if (is_numeric($_value[$_key[1]]))
|
||||
{
|
||||
$bucket[] = $_value[$_key[1]];
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkString($_value[$_key[1]]))
|
||||
{
|
||||
if ('table' === $prep)
|
||||
{
|
||||
$bucket[] = $this->_db->quote($_value[$_key[1]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bucket[] = $_value[$_key[1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// only return if we set the ids
|
||||
if (ComponentbuilderHelper::checkArray($bucket))
|
||||
{
|
||||
// now set the values back
|
||||
return array_unique($bucket);
|
||||
}
|
||||
}
|
||||
// check if the key is an array (targeting repeatable)
|
||||
if ('repeatable' === $type && $key)
|
||||
{
|
||||
@ -711,7 +754,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
// set the placeholder ID's
|
||||
$this->setCodePlaceholdersIds($item, $table, 'placeholder');
|
||||
// actions to take if table is component_files_folders
|
||||
if (('component_files_folders' === $table || 'joomla_plugin_files_folders_urls' === $table) && 'clone' !== $this->activeType)
|
||||
if (('component_files_folders' === $table || 'joomla_plugin_files_folders_urls' === $table || 'joomla_module_files_folders_urls' === $table) && 'clone' !== $this->activeType)
|
||||
{
|
||||
// build files
|
||||
$this->moveIt($this->getValues($item->addfiles, 'subform', 'file', null), 'file');
|
||||
@ -746,6 +789,27 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
// add custom admin views
|
||||
$this->setData('custom_admin_view', $this->getValues($item->addcustom_admin_views, 'subform', 'customadminview'), 'id');
|
||||
}
|
||||
// actions to take if table is component_modules
|
||||
if ('component_modules' === $table)
|
||||
{
|
||||
// we remove those modules not part of the export
|
||||
if (isset($item->addjoomla_modules) && ComponentbuilderHelper::checkJson($item->addjoomla_modules))
|
||||
{
|
||||
$item->addjoomla_modules = array_filter(
|
||||
json_decode($item->addjoomla_modules, true),
|
||||
function ($module) {
|
||||
// target 2 is only export and target 0 is both (1 is only compile)
|
||||
if (isset($module['target']) && ($module['target'] == 2 || $module['target'] == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
// add custom admin views
|
||||
$this->setData('joomla_module', $this->getValues($item->addjoomla_modules, 'subform', 'module'), 'id');
|
||||
}
|
||||
// actions to take if table is component_plugins
|
||||
if ('component_plugins' === $table)
|
||||
{
|
||||
@ -894,6 +958,18 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
// add dynamic gets
|
||||
$this->setSmartIDs((int) $item->dynamic_get, 'dynamic_get');
|
||||
}
|
||||
// actions to take if table is joomla_module
|
||||
if ('joomla_module' === $table)
|
||||
{
|
||||
// add the updates and folder stuff
|
||||
$this->setSmartIDs($item->id, 'joomla_module');
|
||||
// add class_extends
|
||||
$this->setSmartIDs((int) $item->class_extends, 'class_extends');
|
||||
// add fields
|
||||
$this->setData('field', $this->getValues($item->fields, 'subform++', 'fields.field'), 'id');
|
||||
// add dynamic gets
|
||||
$this->setSmartIDs($item->custom_get, 'dynamic_get');
|
||||
}
|
||||
// actions to take if table is joomla_plugin
|
||||
if ('joomla_plugin' === $table)
|
||||
{
|
||||
@ -904,7 +980,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
// add joomla_plugin_group
|
||||
$this->setSmartIDs((int) $item->joomla_plugin_group, 'joomla_plugin_group');
|
||||
// add fields
|
||||
$this->setData('field', $this->getValues($item->fields, 'subform', 'field'), 'id');
|
||||
$this->setData('field', $this->getValues($item->fields, 'subform++', 'fields.field'), 'id');
|
||||
// add property_selection
|
||||
$this->setData('class_property', $this->getValues($item->property_selection, 'subform', 'property'), 'id');
|
||||
// add class_method
|
||||
@ -959,11 +1035,12 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
$tables = array(
|
||||
'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view',
|
||||
'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code', 'placeholder',
|
||||
'joomla_module', 'joomla_module_files_folders_urls', 'joomla_module_updates',
|
||||
'joomla_plugin', 'joomla_plugin_files_folders_urls', 'joomla_plugin_updates',
|
||||
'admin_fields', 'admin_fields_conditions', 'admin_fields_relations', 'admin_custom_tabs', 'component_admin_views',
|
||||
'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks',
|
||||
'component_custom_admin_menus', 'component_config', 'component_dashboard', 'component_files_folders',
|
||||
'component_placeholders', 'component_plugins'
|
||||
'component_placeholders', 'component_modules', 'component_plugins'
|
||||
);
|
||||
// smart table loop
|
||||
foreach ($tables as $table)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.2" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>6th December, 2019</creationDate>
|
||||
<creationDate>7th December, 2019</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
||||
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
|
||||
|
@ -857,7 +857,7 @@
|
||||
<version>2.10.6</version>
|
||||
<infourl title="Component Builder!">http://www.joomlacomponentbuilder.com</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.7/JCB_v2.10.7.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.8/JCB_v2.10.8.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>stable</tag>
|
||||
@ -874,7 +874,7 @@
|
||||
<version>2.10.7</version>
|
||||
<infourl title="Component Builder!">http://www.joomlacomponentbuilder.com</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.7/JCB_v2.10.7.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.8/JCB_v2.10.8.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>stable</tag>
|
||||
@ -891,7 +891,7 @@
|
||||
<version>2.10.8</version>
|
||||
<infourl title="Component Builder!">http://www.joomlacomponentbuilder.com</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">http://domain.com/demo.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.8/JCB_v2.10.8.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>stable</tag>
|
||||
|
Loading…
Reference in New Issue
Block a user