Fixed few bugs in import/export of JCB packages. Resolved gh-204. Made some updates to the Dropbox class, more coming.

This commit is contained in:
Llewellyn van der Merwe 2017-12-25 14:46:35 +02:00
parent edafb6e688
commit cd5f1f2c87
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
8 changed files with 229 additions and 186 deletions

View File

@ -111,11 +111,11 @@ Component Builder is mapped as a component in itself on my local development env
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](http://vdm.bz/component-builder) + *Name*: [Component Builder](http://vdm.bz/component-builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 22nd December, 2017 + *Last Build*: 25th December, 2017
+ *Version*: 2.6.7 + *Version*: 2.6.7
+ *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*: **178381** + *Line count*: **178415**
+ *File count*: **1145** + *File count*: **1145**
+ *Folder count*: **184** + *Folder count*: **184**

View File

@ -111,11 +111,11 @@ Component Builder is mapped as a component in itself on my local development env
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](http://vdm.bz/component-builder) + *Name*: [Component Builder](http://vdm.bz/component-builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 22nd December, 2017 + *Last Build*: 25th December, 2017
+ *Version*: 2.6.7 + *Version*: 2.6.7
+ *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*: **178381** + *Line count*: **178415**
+ *File count*: **1145** + *File count*: **1145**
+ *Folder count*: **184** + *Folder count*: **184**

View File

@ -1,4 +1,5 @@
<?php <?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/ /*----------------------------------------------------------------------------------| www.vdm.io |----/
Vast Development Method Vast Development Method
/-------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------/
@ -20,6 +21,7 @@ defined('_JEXEC') or die;
*/ */
class Dropbox class Dropbox
{ {
/** /**
* final url * final url
*/ */
@ -223,7 +225,6 @@ class Dropbox
protected function makeGetCall() protected function makeGetCall()
{ {
$options = array( $options = array(
'http' => array( 'http' => array(
'header' => "Content-Type: application/json\r\n" . 'header' => "Content-Type: application/json\r\n" .
@ -241,18 +242,20 @@ class Dropbox
$context = stream_context_create($options); $context = stream_context_create($options);
$response = file_get_contents($this->url . $this->domainpath[$this->type], false, $context); $response = file_get_contents($this->url . $this->domainpath[$this->type], false, $context);
// store the result
return $this->getCallResult($response);
}
protected function getCallResult($response)
{
if ($response === FALSE) if ($response === FALSE)
{ {
$this->error_summary[] = $this->type . '_error'; $this->error_summary[] = $this->type . '_error';
return false; return false;
} }
else
{
// store the result // store the result
return $this->setTheResult(json_decode($response)); return $this->setTheResult(json_decode($response));
} }
}
protected function makeCurlCall() protected function makeCurlCall()
{ {
@ -277,6 +280,12 @@ class Dropbox
curl_close($ch); curl_close($ch);
// store the result
return $this->curlCallResult($response);
}
public function curlCallResult($response)
{
if ($this->checkJson($response)) if ($this->checkJson($response))
{ {
$response = json_decode($response); $response = json_decode($response);

View File

@ -41,12 +41,16 @@ abstract class ComponentbuilderHelper
self::loadSession(); self::loadSession();
} }
/**
* The global updater
**/
protected static $globalUpdater = array();
/* /*
* Convert repeatable field to subform * Convert repeatable field to subform
* *
* @param array $item The array to convert * @param array $item The array to convert
* @param string $name The main field name * @param string $name The main field name
* @param array $updater The updater (dynamic) option
* *
* @return array * @return array
*/ */
@ -72,11 +76,6 @@ abstract class ComponentbuilderHelper
return $item; return $item;
} }
/**
* The global updater
**/
protected static $globalUpdater = array();
/* /*
* Convert repeatable field to subform * Convert repeatable field to subform
* *
@ -90,9 +89,11 @@ abstract class ComponentbuilderHelper
{ {
// update the repeatable fields // update the repeatable fields
foreach ($searcher as $key => $sleutel) foreach ($searcher as $key => $sleutel)
{
if (isset($object->{$key}))
{ {
$isJson = false; $isJson = false;
if (isset($object->{$key}) && self::checkJson($object->{$key})) if (self::checkJson($object->{$key}))
{ {
$object->{$key} = json_decode($object->{$key}, true); $object->{$key} = json_decode($object->{$key}, true);
$isJson = true; $isJson = true;
@ -143,16 +144,17 @@ abstract class ComponentbuilderHelper
} }
} }
// no set back to json if came in as json // no set back to json if came in as json
if (isset($object->{$key}) && $isJson && self::checkArray($object->{$key})) if ($isJson && self::checkArray($object->{$key}))
{ {
$object->{$key} = json_encode($object->{$key}); $object->{$key} = json_encode($object->{$key});
} }
// remove if not json or array // remove if not json or array
elseif (isset($object->{$key}) && !self::checkArray($object->{$key}) && !self::checkJson($object->{$key})) elseif (!self::checkArray($object->{$key}) && !self::checkJson($object->{$key}))
{ {
unset($object->{$key}); unset($object->{$key});
} }
} }
}
return $object; return $object;
} }

View File

@ -958,7 +958,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// update the fields // update the fields
$object = new stdClass; $object = new stdClass;
$object->id = $adminview; $object->id = $adminview;
$object->addlinked_views = json_encode($addlinked_views); $object->addlinked_views = json_encode($addlinked_views, JSON_FORCE_OBJECT);
// update the admin view // update the admin view
$this->_db->updateObject('#__componentbuilder_admin_view', $object, 'id'); $this->_db->updateObject('#__componentbuilder_admin_view', $object, 'id');
} }
@ -1013,7 +1013,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
if (ComponentbuilderHelper::checkArray($updateArray)) if (ComponentbuilderHelper::checkArray($updateArray))
{ {
// load it back // load it back
$item->{$field} = json_encode($this->updateSubformIDs($updateArray, $table, $targetArray)); $item->{$field} = json_encode($this->updateSubformIDs($updateArray, $table, $targetArray), JSON_FORCE_OBJECT);
} }
} }
} }
@ -1052,7 +1052,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
} }
if ($isJson) if ($isJson)
{ {
return json_encode($values); return json_encode($values, JSON_FORCE_OBJECT);
} }
return $values; return $values;
} }
@ -1076,7 +1076,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$item = json_decode($item, true); $item = json_decode($item, true);
$isJson = true; $isJson = true;
} }
if (ComponentbuilderHelper::checkArray($item)) if (ComponentbuilderHelper::checkArray($item) && isset($item[$target]))
{ {
// set item ID // set item ID
$itemId = (isset($item['id'])) ? $item['id'] : 'newItem'; $itemId = (isset($item['id'])) ? $item['id'] : 'newItem';
@ -1135,7 +1135,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$item[$target] = json_encode($item[$target]); $item[$target] = json_encode($item[$target]);
} }
} }
elseif (ComponentbuilderHelper::checkObject($item)) elseif (ComponentbuilderHelper::checkObject($item) && isset($item->{$target}))
{ {
// set item ID // set item ID
$itemId = (isset($item->id)) ? $item->id : 'newItem'; $itemId = (isset($item->id)) ? $item->id : 'newItem';
@ -1550,7 +1550,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// subform fields to target // subform fields to target
$updaterT = array( $updaterT = array(
// subformfield => array( field => type_value ) // subformfield => array( field => type_value )
'addcustom_admin_views' => array('customadminview' => 'custom_admin_view') 'addcustom_admin_views' => array('customadminview' => 'custom_admin_view', 'adminviews' => 'admin_view', 'before' => 'admin_view')
); );
// update the subform ids // update the subform ids
$this->updateSubformsIDs($item, 'component_custom_admin_views', $updaterT); $this->updateSubformsIDs($item, 'component_custom_admin_views', $updaterT);
@ -1743,7 +1743,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// only update if we have translations // only update if we have translations
if (ComponentbuilderHelper::checkArray($translations)) if (ComponentbuilderHelper::checkArray($translations))
{ {
$item->translation = json_encode($translations); $item->translation = json_encode($translations, JSON_FORCE_OBJECT);
} }
} }
elseif (isset($item->localTranslation) && ComponentbuilderHelper::checkJson($item->localTranslation)) elseif (isset($item->localTranslation) && ComponentbuilderHelper::checkJson($item->localTranslation))

View File

@ -258,7 +258,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
} }
} }
$item->{$_value} = $bucket; $item->{$_value} = $bucket;
$objectUpdate->{$_value} = json_encode($bucket); $objectUpdate->{$_value} = json_encode($bucket, JSON_FORCE_OBJECT);
} }
} }
// be sure to update the table if we found repeatable fields that are still not converted // be sure to update the table if we found repeatable fields that are still not converted

View File

@ -500,6 +500,38 @@ class ComponentbuilderModelJoomla_components extends JModelList
{ {
continue; continue;
} }
// actions to take before storing the item if table is template, layout, site_view, or custom_admin_view
if ('layout' === $table || 'template' === $table || 'site_view' === $table || 'custom_admin_view' === $table)
{
// unset snippets (we no longer export snippets)
if (isset($item->snippet))
{
unset($item->snippet);
}
}
// actions to take before storing the item if table is joomla_component
if ('joomla_component' === $table)
{
// make sure old fields are not exported any more
unset($item->addconfig);
unset($item->addadmin_views);
unset($item->addcustom_admin_views);
unset($item->addsite_views);
unset($item->version_update);
unset($item->sql_tweak);
unset($item->addcustommenus);
unset($item->dashboard_tab);
unset($item->php_dashboard_methods);
unset($item->addfiles);
unset($item->addfolders);
}
// actions to take before storing the item if table is admin_view
if ('admin_view' === $table)
{
// make sure old fields are not exported any more
unset($item->addfields);
unset($item->addconditions);
}
// load to global object // load to global object
$this->smartExport[$table][$item->id] = $item; $this->smartExport[$table][$item->id] = $item;
// set the custom code ID's // set the custom code ID's

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>22nd December, 2017</creationDate> <creationDate>25th December, 2017</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>http://vdm.bz/component-builder</authorUrl> <authorUrl>http://vdm.bz/component-builder</authorUrl>