forked from joomla/Component-Builder
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:
parent
edafb6e688
commit
cd5f1f2c87
@ -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**
|
||||||
|
|
||||||
|
@ -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**
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
@ -99,7 +101,7 @@ class Dropbox
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* force the update to reset
|
* force the update to reset
|
||||||
**/
|
* */
|
||||||
public $forceReset = false;
|
public $forceReset = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +110,7 @@ class Dropbox
|
|||||||
public function __construct(JModelLegacy $model, $buildType)
|
public function __construct(JModelLegacy $model, $buildType)
|
||||||
{
|
{
|
||||||
// set the url at this point for now
|
// 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
|
// set the local model
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
// set the build type
|
// set the build type
|
||||||
@ -185,7 +187,7 @@ class Dropbox
|
|||||||
if (2 == $this->dropboxOption)
|
if (2 == $this->dropboxOption)
|
||||||
{
|
{
|
||||||
// simply set the path
|
// simply set the path
|
||||||
$this->targetPath = '/'.trim(strtolower($this->dropboxTarget), '/');
|
$this->targetPath = '/' . trim(strtolower($this->dropboxTarget), '/');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -223,11 +225,10 @@ 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" .
|
||||||
"Authorization: Bearer ".$this->oauthToken,
|
"Authorization: Bearer " . $this->oauthToken,
|
||||||
'method' => "POST"
|
'method' => "POST"
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -239,28 +240,30 @@ class Dropbox
|
|||||||
$options['http']['content'] = $this->query;
|
$options['http']['content'] = $this->query;
|
||||||
|
|
||||||
$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()
|
||||||
{
|
{
|
||||||
$headers = array('Authorization: Bearer '. $this->oauthToken,
|
$headers = array('Authorization: Bearer ' . $this->oauthToken,
|
||||||
'Content-Type: application/json'
|
'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);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
// check if query is set
|
// check if query is set
|
||||||
@ -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);
|
||||||
@ -318,15 +327,15 @@ class Dropbox
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->error_summary[] = $this->type.'_error';
|
$this->error_summary[] = $this->type . '_error';
|
||||||
break;
|
break;
|
||||||
case "create_shared_link":
|
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
|
// we stored the link
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$this->error_summary[] = $this->type.'_error';
|
$this->error_summary[] = $this->type . '_error';
|
||||||
break;
|
break;
|
||||||
case "get_shared_link_metadata":
|
case "get_shared_link_metadata":
|
||||||
if (isset($data->path_lower))
|
if (isset($data->path_lower))
|
||||||
@ -334,14 +343,14 @@ class Dropbox
|
|||||||
$this->targetPath = $data->path_lower;
|
$this->targetPath = $data->path_lower;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$this->error_summary[] = $this->type.'_error';
|
$this->error_summary[] = $this->type . '_error';
|
||||||
break;
|
break;
|
||||||
case "revoke":
|
case "revoke":
|
||||||
if (is_null($data))
|
if (is_null($data))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$this->error_summary[] = $this->type.'_error';
|
$this->error_summary[] = $this->type . '_error';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->forceReset = true;
|
$this->forceReset = true;
|
||||||
@ -386,7 +395,7 @@ class Dropbox
|
|||||||
{
|
{
|
||||||
foreach ($this->addTypes as $add)
|
foreach ($this->addTypes as $add)
|
||||||
{
|
{
|
||||||
if (strpos($item->name,$add) !== false)
|
if (strpos($item->name, $add) !== false)
|
||||||
{
|
{
|
||||||
$addLink = true;
|
$addLink = true;
|
||||||
}
|
}
|
||||||
@ -417,7 +426,7 @@ class Dropbox
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$path = 'VDM_pLeK_h0uEr'.$path;
|
$path = 'VDM_pLeK_h0uEr' . $path;
|
||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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))
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user