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)
+ *Name*: [Component Builder](http://vdm.bz/component-builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 22nd December, 2017
+ *Last Build*: 25th December, 2017
+ *Version*: 2.6.7
+ *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*: **178381**
+ *Line count*: **178415**
+ *File count*: **1145**
+ *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)
+ *Name*: [Component Builder](http://vdm.bz/component-builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 22nd December, 2017
+ *Last Build*: 25th December, 2017
+ *Version*: 2.6.7
+ *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*: **178381**
+ *Line count*: **178415**
+ *File count*: **1145**
+ *Folder count*: **184**

View File

@ -1,4 +1,5 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Vast Development Method
/-------------------------------------------------------------------------------------------------------/
@ -20,6 +21,7 @@ defined('_JEXEC') or die;
*/
class Dropbox
{
/**
* final url
*/
@ -99,7 +101,7 @@ class Dropbox
/**
* force the update to reset
**/
* */
public $forceReset = false;
/**
@ -108,7 +110,7 @@ class Dropbox
public function __construct(JModelLegacy $model, $buildType)
{
// set the url at this point for now
$this->url = $this->postUrl["protocol"].$this->postUrl["suddomain"].$this->postUrl["domain"].$this->postUrl["path"];
$this->url = $this->postUrl["protocol"] . $this->postUrl["suddomain"] . $this->postUrl["domain"] . $this->postUrl["path"];
// set the local model
$this->model = $model;
// set the build type
@ -185,7 +187,7 @@ class Dropbox
if (2 == $this->dropboxOption)
{
// simply set the path
$this->targetPath = '/'.trim(strtolower($this->dropboxTarget), '/');
$this->targetPath = '/' . trim(strtolower($this->dropboxTarget), '/');
return true;
}
@ -223,11 +225,10 @@ class Dropbox
protected function makeGetCall()
{
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n".
"Authorization: Bearer ".$this->oauthToken,
'header' => "Content-Type: application/json\r\n" .
"Authorization: Bearer " . $this->oauthToken,
'method' => "POST"
),
);
@ -239,28 +240,30 @@ class Dropbox
$options['http']['content'] = $this->query;
$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)
{
$this->error_summary[] = $this->type.'_error';
$this->error_summary[] = $this->type . '_error';
return false;
}
else
{
// store the result
return $this->setTheResult(json_decode($response));
}
}
protected function makeCurlCall()
{
$headers = array('Authorization: Bearer '. $this->oauthToken,
$headers = array('Authorization: Bearer ' . $this->oauthToken,
'Content-Type: application/json'
);
$ch = curl_init($this->url.$this->domainpath[$this->type]);
$ch = curl_init($this->url . $this->domainpath[$this->type]);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// check if query is set
@ -277,6 +280,12 @@ class Dropbox
curl_close($ch);
// store the result
return $this->curlCallResult($response);
}
public function curlCallResult($response)
{
if ($this->checkJson($response))
{
$response = json_decode($response);
@ -318,15 +327,15 @@ class Dropbox
return true;
}
}
$this->error_summary[] = $this->type.'_error';
$this->error_summary[] = $this->type . '_error';
break;
case "create_shared_link":
if (isset($data->url) && isset($data->path) && $this->storeSharedLink($this->fixPath($data->path), str_replace('?dl=0','?dl=1',$data->url)))
if (isset($data->url) && isset($data->path) && $this->storeSharedLink($this->fixPath($data->path), str_replace('?dl=0', '?dl=1', $data->url)))
{
// we stored the link
return true;
}
$this->error_summary[] = $this->type.'_error';
$this->error_summary[] = $this->type . '_error';
break;
case "get_shared_link_metadata":
if (isset($data->path_lower))
@ -334,14 +343,14 @@ class Dropbox
$this->targetPath = $data->path_lower;
return true;
}
$this->error_summary[] = $this->type.'_error';
$this->error_summary[] = $this->type . '_error';
break;
case "revoke":
if (is_null($data))
{
return true;
}
$this->error_summary[] = $this->type.'_error';
$this->error_summary[] = $this->type . '_error';
break;
}
$this->forceReset = true;
@ -386,7 +395,7 @@ class Dropbox
{
foreach ($this->addTypes as $add)
{
if (strpos($item->name,$add) !== false)
if (strpos($item->name, $add) !== false)
{
$addLink = true;
}
@ -417,7 +426,7 @@ class Dropbox
}
else
{
$path = 'VDM_pLeK_h0uEr'.$path;
$path = 'VDM_pLeK_h0uEr' . $path;
}
return $path;
}

View File

@ -41,12 +41,16 @@ abstract class ComponentbuilderHelper
self::loadSession();
}
/**
* The global updater
**/
protected static $globalUpdater = array();
/*
* Convert repeatable field to subform
*
* @param array $item The array to convert
* @param string $name The main field name
* @param array $updater The updater (dynamic) option
*
* @return array
*/
@ -72,11 +76,6 @@ abstract class ComponentbuilderHelper
return $item;
}
/**
* The global updater
**/
protected static $globalUpdater = array();
/*
* Convert repeatable field to subform
*
@ -90,9 +89,11 @@ abstract class ComponentbuilderHelper
{
// update the repeatable fields
foreach ($searcher as $key => $sleutel)
{
if (isset($object->{$key}))
{
$isJson = false;
if (isset($object->{$key}) && self::checkJson($object->{$key}))
if (self::checkJson($object->{$key}))
{
$object->{$key} = json_decode($object->{$key}, true);
$isJson = true;
@ -143,16 +144,17 @@ abstract class ComponentbuilderHelper
}
}
// 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});
}
// 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});
}
}
}
return $object;
}

View File

@ -958,7 +958,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// update the fields
$object = new stdClass;
$object->id = $adminview;
$object->addlinked_views = json_encode($addlinked_views);
$object->addlinked_views = json_encode($addlinked_views, JSON_FORCE_OBJECT);
// update the admin view
$this->_db->updateObject('#__componentbuilder_admin_view', $object, 'id');
}
@ -1013,7 +1013,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
if (ComponentbuilderHelper::checkArray($updateArray))
{
// 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)
{
return json_encode($values);
return json_encode($values, JSON_FORCE_OBJECT);
}
return $values;
}
@ -1076,7 +1076,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$item = json_decode($item, true);
$isJson = true;
}
if (ComponentbuilderHelper::checkArray($item))
if (ComponentbuilderHelper::checkArray($item) && isset($item[$target]))
{
// set item ID
$itemId = (isset($item['id'])) ? $item['id'] : 'newItem';
@ -1135,7 +1135,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$item[$target] = json_encode($item[$target]);
}
}
elseif (ComponentbuilderHelper::checkObject($item))
elseif (ComponentbuilderHelper::checkObject($item) && isset($item->{$target}))
{
// set item ID
$itemId = (isset($item->id)) ? $item->id : 'newItem';
@ -1550,7 +1550,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// subform fields to target
$updaterT = array(
// 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
$this->updateSubformsIDs($item, 'component_custom_admin_views', $updaterT);
@ -1743,7 +1743,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// only update if we have 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))

View File

@ -258,7 +258,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
}
}
$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

View File

@ -500,6 +500,38 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
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
$this->smartExport[$table][$item->id] = $item;
// set the custom code ID's

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>22nd December, 2017</creationDate>
<creationDate>25th December, 2017</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>http://vdm.bz/component-builder</authorUrl>