Resolves gh-59 the repeatable field id problem. Also improved the export and import to insure snippets and linked admin views are re-mapped on import of the component. Also fixed the target and match field conditions in admin views to re-map the ids correctly.
This commit is contained in:
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 108 of this MVC
|
||||
@build 24th March, 2017
|
||||
@version @update number 109 of this MVC
|
||||
@build 31st March, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage admin_view.php
|
||||
@ -245,18 +245,18 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin
|
||||
$item->php_controller = base64_decode($item->php_controller);
|
||||
}
|
||||
|
||||
if (!empty($item->php_controller_list))
|
||||
{
|
||||
// base64 Decode php_controller_list.
|
||||
$item->php_controller_list = base64_decode($item->php_controller_list);
|
||||
}
|
||||
|
||||
if (!empty($item->php_model))
|
||||
{
|
||||
// base64 Decode php_model.
|
||||
$item->php_model = base64_decode($item->php_model);
|
||||
}
|
||||
|
||||
if (!empty($item->php_controller_list))
|
||||
{
|
||||
// base64 Decode php_controller_list.
|
||||
$item->php_controller_list = base64_decode($item->php_controller_list);
|
||||
}
|
||||
|
||||
if (!empty($item->php_model_list))
|
||||
{
|
||||
// base64 Decode php_model_list.
|
||||
@ -1428,18 +1428,18 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin
|
||||
$data['php_controller'] = base64_encode($data['php_controller']);
|
||||
}
|
||||
|
||||
// Set the php_controller_list string to base64 string.
|
||||
if (isset($data['php_controller_list']))
|
||||
{
|
||||
$data['php_controller_list'] = base64_encode($data['php_controller_list']);
|
||||
}
|
||||
|
||||
// Set the php_model string to base64 string.
|
||||
if (isset($data['php_model']))
|
||||
{
|
||||
$data['php_model'] = base64_encode($data['php_model']);
|
||||
}
|
||||
|
||||
// Set the php_controller_list string to base64 string.
|
||||
if (isset($data['php_controller_list']))
|
||||
{
|
||||
$data['php_controller_list'] = base64_encode($data['php_controller_list']);
|
||||
}
|
||||
|
||||
// Set the php_model_list string to base64 string.
|
||||
if (isset($data['php_model_list']))
|
||||
{
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 108 of this MVC
|
||||
@build 24th March, 2017
|
||||
@version @update number 109 of this MVC
|
||||
@build 31st March, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage admin_views.php
|
||||
@ -312,10 +312,10 @@ class ComponentbuilderModelAdmin_views extends JModelList
|
||||
$item->javascript_views_footer = base64_decode($item->javascript_views_footer);
|
||||
// decode php_controller
|
||||
$item->php_controller = base64_decode($item->php_controller);
|
||||
// decode php_controller_list
|
||||
$item->php_controller_list = base64_decode($item->php_controller_list);
|
||||
// decode php_model
|
||||
$item->php_model = base64_decode($item->php_model);
|
||||
// decode php_controller_list
|
||||
$item->php_controller_list = base64_decode($item->php_controller_list);
|
||||
// decode php_model_list
|
||||
$item->php_model_list = base64_decode($item->php_model_list);
|
||||
// decode html_import_view
|
||||
|
@ -9,8 +9,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 108 of this MVC
|
||||
@build 24th March, 2017
|
||||
@version @update number 109 of this MVC
|
||||
@build 31st March, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage admin_view.js
|
||||
|
@ -1917,17 +1917,17 @@
|
||||
<option value="0">
|
||||
COM_COMPONENTBUILDER_ADMIN_VIEW_NO</option>
|
||||
</field>
|
||||
<!-- Php_controller_list Field. Type: Textarea. (joomla) -->
|
||||
<!-- Php_model Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="php_controller_list"
|
||||
label="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_LABEL"
|
||||
name="php_model"
|
||||
label="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_LABEL"
|
||||
rows="30"
|
||||
cols="15"
|
||||
description="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_DESCRIPTION"
|
||||
description="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_HINT"
|
||||
hint="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_HINT"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Addtables Field. Type: Repeatable. (joomla) -->
|
||||
@ -1969,17 +1969,17 @@
|
||||
</fieldset>
|
||||
</fields>
|
||||
</field>
|
||||
<!-- Php_model Field. Type: Textarea. (joomla) -->
|
||||
<!-- Php_controller_list Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="php_model"
|
||||
label="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_LABEL"
|
||||
name="php_controller_list"
|
||||
label="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_LABEL"
|
||||
rows="30"
|
||||
cols="15"
|
||||
description="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_DESCRIPTION"
|
||||
description="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_MODEL_HINT"
|
||||
hint="COM_COMPONENTBUILDER_ADMIN_VIEW_PHP_CONTROLLER_LIST_HINT"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Note_beginner_import Field. Type: Note. A None Database Field. (joomla) -->
|
||||
|
@ -9,8 +9,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 266 of this MVC
|
||||
@build 30th March, 2017
|
||||
@version @update number 297 of this MVC
|
||||
@build 31st March, 2017
|
||||
@created 6th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage joomla_component.js
|
||||
|
@ -81,11 +81,14 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
}
|
||||
|
||||
protected $app;
|
||||
protected $target = false;
|
||||
protected $newID = array();
|
||||
protected $forceUpdate = 0;
|
||||
protected $hasKey = 0;
|
||||
protected $sleutle = null;
|
||||
protected $target = false;
|
||||
protected $newID = array();
|
||||
protected $forceUpdate = 0;
|
||||
protected $hasKey = 0;
|
||||
protected $sleutle = null;
|
||||
protected $updateAfter = array('field' => array(), 'adminview' => array());
|
||||
protected $fieldTypes = array();
|
||||
protected $isRepeatable = array();
|
||||
|
||||
/**
|
||||
* Import an spreadsheet from either folder, url or upload.
|
||||
@ -652,6 +655,11 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// we then store the snippet
|
||||
if (!$this->saveSmartItems($data, 'snippet', $db, $user, $today))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// we then store the dynamic_get
|
||||
if (!$this->saveSmartItems($data, 'dynamic_get', $db, $user, $today))
|
||||
{
|
||||
@ -687,6 +695,8 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// do a after all run on all items that need it
|
||||
$this->updateAfter($db);
|
||||
// lets move all the files to its correct location
|
||||
if (!$this->moveSmartStuff($dir))
|
||||
{
|
||||
@ -756,6 +766,11 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
$canEdit = $canDo->get('core.edit');
|
||||
$canState = $canDo->get('core.edit.state');
|
||||
$canCreate = $canDo->get('core.create');
|
||||
// set id keeper
|
||||
if (!isset($this->newID[$type]))
|
||||
{
|
||||
$this->newID[$type] = array();
|
||||
}
|
||||
foreach ($items[$type] as $item)
|
||||
{
|
||||
$oldID = $item->id;
|
||||
@ -769,7 +784,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
// make sure we have the correct ID set
|
||||
$item->id = $local->id;
|
||||
// yes it is newer, lets update
|
||||
// yes it is newer, lets update (or is being forced)
|
||||
if ($canEdit && $id = $this->updateLocalItem($item, $type, $db, $user, $today, $canState))
|
||||
{
|
||||
$this->newID[$type][$oldID] = $id;
|
||||
@ -808,6 +823,120 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update some items after all
|
||||
*
|
||||
* @param object $db The database object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
protected function updateAfter($db)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->updateAfter['field']))
|
||||
{
|
||||
// update repeatable
|
||||
foreach ($this->updateAfter['field'] as $field)
|
||||
{
|
||||
if (isset($this->newID['field'][$field]))
|
||||
{
|
||||
$field = $this->newID['field'][$field];
|
||||
}
|
||||
// get the field from db
|
||||
if ($xml = ComponentbuilderHelper::getVar('field', $field, 'id', 'xml'))
|
||||
{
|
||||
if (ComponentbuilderHelper::checkJson($xml))
|
||||
{
|
||||
$xml = json_decode($xml);
|
||||
$fields = ComponentbuilderHelper::getBetween($xml, 'fields="', '"');
|
||||
$fieldsSets = array();
|
||||
if (strpos($fields, ',') !== false)
|
||||
{
|
||||
// multiple fields
|
||||
$fieldsSets = array_map('trim', (array) explode(',', $fields));
|
||||
}
|
||||
elseif (is_numeric($fields))
|
||||
{
|
||||
// single field
|
||||
$fieldsSets[] = (int) $fields;
|
||||
}
|
||||
// update the fields
|
||||
if (ComponentbuilderHelper::checkArray($fieldsSets))
|
||||
{
|
||||
$bucket = array();
|
||||
foreach ($fieldsSets as $id)
|
||||
{
|
||||
if (isset($this->newID['field'][$id]))
|
||||
{
|
||||
$bucket[] = $this->newID['field'][$id];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BREPEATABLEB_IDS_MISMATCH_IN_BFIELDSB_AND_WAS_EMREMOVEDEM_FROM_THE_FIELD', $id, $field), 'warning');
|
||||
}
|
||||
}
|
||||
if (ComponentbuilderHelper::checkArray($bucket))
|
||||
{
|
||||
$string = implode(',', $bucket);
|
||||
$xml = json_encode(str_replace('fields="' . $fields . '"', 'fields="' . $string . '"', $xml));
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml = '';
|
||||
}
|
||||
$object = new stdClass;
|
||||
$object->id = $field;
|
||||
$object->xml = $xml;
|
||||
// update the field
|
||||
$db->updateObject('#__componentbuilder_field', $object, 'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// do a after all run on admin views that need it
|
||||
if (ComponentbuilderHelper::checkArray($this->updateAfter['adminview']))
|
||||
{
|
||||
// update the addlinked_views
|
||||
foreach ($this->updateAfter['adminview'] as $adminview)
|
||||
{
|
||||
if (isset($this->newID['admin_view'][$adminview]))
|
||||
{
|
||||
$adminview = $this->newID['admin_view'][$adminview];
|
||||
}
|
||||
// get the field from db
|
||||
if ($addlinked_views = ComponentbuilderHelper::getVar('admin_view', $adminview, 'id', 'addlinked_views'))
|
||||
{
|
||||
if (ComponentbuilderHelper::checkJson($addlinked_views))
|
||||
{
|
||||
$addlinked_views = json_decode($addlinked_views, true);
|
||||
if (ComponentbuilderHelper::checkArray($addlinked_views['adminview']))
|
||||
{
|
||||
foreach ($addlinked_views['adminview'] as $nr => $admin)
|
||||
{
|
||||
if (isset($this->newID['admin_view'][$admin]))
|
||||
{
|
||||
$addlinked_views['adminview'][$nr] = $this->newID['admin_view'][$admin];
|
||||
}
|
||||
else
|
||||
{
|
||||
$addlinked_views['adminview'][$nr] = '';
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BLINKED_VIEWB_IDS_MISMATCH_IN_BADMIN_VIEWSB_AND_WAS_EMREMOVEDEM_FROM_THE_LINKED_VIEWS', $admin, $adminview), 'warning');
|
||||
}
|
||||
}
|
||||
// update the fields
|
||||
$object = new stdClass;
|
||||
$object->id = $adminview;
|
||||
$object->addlinked_views = json_encode($addlinked_views);
|
||||
// update the admin view
|
||||
$db->updateObject('#__componentbuilder_admin_view', $object, 'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prep the item
|
||||
*
|
||||
@ -822,7 +951,6 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
**/
|
||||
protected function prepItem($item, &$type, $action, &$user, &$today)
|
||||
{
|
||||
$this->updateAfter = false;
|
||||
// actions to effect both
|
||||
if (isset($item->asset_id))
|
||||
{
|
||||
@ -841,9 +969,19 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
case 'field':
|
||||
// update the fieldtype
|
||||
if (isset($item->fieldtype) && isset($this->newID['fieldtype'][$item->fieldtype]))
|
||||
if (isset($item->fieldtype) && is_numeric($item->fieldtype) && $item->fieldtype > 0 && isset($this->newID['fieldtype'][$item->fieldtype]))
|
||||
{
|
||||
$item->fieldtype = $this->newID['fieldtype'][$item->fieldtype];
|
||||
// update repeatable field values
|
||||
if ($this->checkRepeatable($item->fieldtype))
|
||||
{
|
||||
$this->updateAfter['field'][$item->id] = $item->id; // repeatable
|
||||
}
|
||||
}
|
||||
elseif (!is_numeric($item->fieldtype) || $item->fieldtype == 0)
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BFIELD_TYPEB_NOT_SET_FOR_BSB', ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
|
||||
unset($item->fieldtype);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -853,7 +991,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
break;
|
||||
case 'dynamic_get':
|
||||
// update the view_table_main ID
|
||||
if (isset($item->main_source) && $item->main_source == 1 && isset($item->view_table_main) && is_numeric($item->view_table_main))
|
||||
if (isset($item->main_source) && $item->main_source == 1 && isset($item->view_table_main) && is_numeric($item->view_table_main) && $item->view_table_main > 0)
|
||||
{
|
||||
if (isset($this->newID['admin_view'][$item->view_table_main]))
|
||||
{
|
||||
@ -897,33 +1035,60 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
case 'layout':
|
||||
case 'template':
|
||||
// update the dynamic_get
|
||||
if (isset($item->dynamic_get) && isset($this->newID['dynamic_get'][$item->dynamic_get]))
|
||||
if (isset($item->dynamic_get) && is_numeric($item->dynamic_get) && $item->dynamic_get > 0 && isset($this->newID['dynamic_get'][$item->dynamic_get]))
|
||||
{
|
||||
$item->dynamic_get = $this->newID['dynamic_get'][$item->dynamic_get];
|
||||
}
|
||||
elseif (!is_numeric($item->dynamic_get) || $item->dynamic_get == 0)
|
||||
{
|
||||
unset($item->dynamic_get);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BDYNAMIC_GETB_IDS_MISMATCH_IN_BSB', $item->dynamic_get, ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
|
||||
unset($item->dynamic_get);
|
||||
}
|
||||
// update the snippet
|
||||
if (isset($item->snippet) && is_numeric($item->snippet) && $item->snippet > 0 && isset($this->newID['snippet'][$item->snippet]))
|
||||
{
|
||||
$item->snippet = $this->newID['snippet'][$item->snippet];
|
||||
}
|
||||
elseif (!is_numeric($item->snippet) || $item->snippet == 0)
|
||||
{
|
||||
unset($item->snippet);
|
||||
}
|
||||
else
|
||||
{
|
||||
// $this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSNIPPETB_IDS_MISMATCH_IN_BSB', $item->snippet, ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
|
||||
// unset($item->snippet);
|
||||
}
|
||||
break;
|
||||
case 'custom_admin_view':
|
||||
case 'site_view':
|
||||
// update the main_get
|
||||
if (isset($item->main_get) && isset($this->newID['dynamic_get'][$item->main_get]))
|
||||
if (isset($item->main_get) && is_numeric($item->main_get) && $item->main_get > 0 && isset($this->newID['dynamic_get'][$item->main_get]))
|
||||
{
|
||||
$item->main_get = $this->newID['dynamic_get'][$item->main_get];
|
||||
}
|
||||
elseif (!is_numeric($item->main_get) || $item->main_get == 0)
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BMAIN_GETB_NOT_SET_FOR_BSB', ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
|
||||
unset($item->main_get);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BMAIN_GETB_IDS_MISMATCH_IN_BSB', $item->main_get, ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'error');
|
||||
return false;
|
||||
}
|
||||
// update the dynamic_get
|
||||
if (isset($item->dynamic_get) && isset($this->newID['dynamic_get'][$item->dynamic_get]))
|
||||
if (isset($item->dynamic_get) && is_numeric($item->dynamic_get) && $item->dynamic_get > 0 && isset($this->newID['dynamic_get'][$item->dynamic_get]))
|
||||
{
|
||||
$item->dynamic_get = $this->newID['dynamic_get'][$item->dynamic_get];
|
||||
}
|
||||
elseif (!is_numeric($item->dynamic_get) || $item->dynamic_get == 0)
|
||||
{
|
||||
unset($item->dynamic_get);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BDYNAMIC_GETB_IDS_MISMATCH_IN_BSB', $item->dynamic_get, ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
|
||||
@ -946,14 +1111,14 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BCUSTOM_GET_IN_SB_HAS_ID_MISMATCH_OF_SELECTED_BDYNAMIC_GETB_SO_THE_IDS_WAS_REMOVED', '('.ComponentbuilderHelper::safeString($type, 'w').':'.$item->id.')', $id), 'warning');
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BCUSTOM_GET_IN_SB_HAS_ID_MISMATCH_OF_SELECTED_BDYNAMIC_GETB_SO_THE_IDS_WAS_REMOVED', '('.ComponentbuilderHelper::safeString($type, 'w').':'.$item->id.')', $get), 'warning');
|
||||
unset($custom_get[$nr]);
|
||||
}
|
||||
}
|
||||
// load it back if there is any remaining
|
||||
if (ComponentbuilderHelper::checkArray($custom_get))
|
||||
{
|
||||
$item->custom_get = json_encode($custom_get);
|
||||
$item->custom_get = json_encode( (object) $custom_get);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -964,6 +1129,20 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
unset($item->custom_get);
|
||||
}
|
||||
// update the snippet
|
||||
if (isset($item->snippet) && is_numeric($item->snippet) && $item->snippet > 0 && isset($this->newID['snippet'][$item->snippet]))
|
||||
{
|
||||
$item->snippet = $this->newID['snippet'][$item->snippet];
|
||||
}
|
||||
elseif (!is_numeric($item->snippet) || $item->snippet == 0)
|
||||
{
|
||||
unset($item->snippet);
|
||||
}
|
||||
else
|
||||
{
|
||||
// $this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSNIPPETB_IDS_MISMATCH_IN_BSB', $item->snippet, ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
|
||||
// unset($item->snippet);
|
||||
}
|
||||
break;
|
||||
case 'admin_view':
|
||||
// we must clear the demo content (since it was not moved as far as we know) TODO
|
||||
@ -1001,23 +1180,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
// update the addlinked_views
|
||||
if (isset($item->addlinked_views) && ComponentbuilderHelper::checkJson($item->addlinked_views))
|
||||
{
|
||||
$addlinked_views = json_decode($item->addlinked_views, true);
|
||||
foreach ($addlinked_views['adminview'] as $nr => $id)
|
||||
{
|
||||
// update the addlinked_views
|
||||
if (isset($this->newID['admin_view'][$id]))
|
||||
{
|
||||
$addlinked_views['adminview'][$nr] = $this->newID['admin_view'][$id];
|
||||
}
|
||||
else
|
||||
{
|
||||
// this is painful but true...
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BLINKED_ADMIN_VIEW_IN_SB_HAS_ID_MISMATCH_OF_SELECTED_BADMIN_VIEWB_SO_THE_IDS_WAS_NOT_UPDATED', '('.ComponentbuilderHelper::safeString($type, 'w').':'.$item->id.')', $id), 'warning');
|
||||
$this->updateAfter = true;
|
||||
}
|
||||
}
|
||||
// load it back
|
||||
$item->addlinked_views = json_encode($addlinked_views);
|
||||
$this->updateAfter['adminview'][$item->id] = $item->id; // addlinked_views
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1037,6 +1200,8 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
$ids = array((int) $ids);
|
||||
}
|
||||
// the bucket to load the items back
|
||||
$bucket = array();
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
if (!is_numeric($id))
|
||||
@ -1045,14 +1210,22 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
}
|
||||
if (isset($this->newID['field'][$id]))
|
||||
{
|
||||
$addconditions[$target][$nr] = $this->newID['field'][$id];
|
||||
$bucket[] = $this->newID['field'][$id];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSB_HAS_ID_MISMATCH_OF_SELECTED_BFIELDB_SO_THE_IDS_WAS_REMOVED', ComponentbuilderHelper::safeString($target, 'Ww') . ' in ('.ComponentbuilderHelper::safeString($type, 'w').':'.$item->id.')', $id), 'warning');
|
||||
$addconditions[$target][$nr] = '';
|
||||
$bucket[] = '';
|
||||
}
|
||||
}
|
||||
if (count($bucket) == 1)
|
||||
{
|
||||
$addconditions[$target][$nr] = $bucket[0];
|
||||
}
|
||||
elseif (count($bucket) > 1)
|
||||
{
|
||||
$addconditions[$target][$nr] = $bucket;
|
||||
}
|
||||
}
|
||||
}
|
||||
// load it back
|
||||
@ -1209,6 +1382,80 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a field is a repeatable field
|
||||
*
|
||||
* @param string $typeID The type ID
|
||||
*
|
||||
* @return bool true on success
|
||||
*
|
||||
*/
|
||||
protected function checkRepeatable($typeID)
|
||||
{
|
||||
if(isset($this->isRepeatable[$typeID]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkArray($this->isRepeatable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif ($type = $this->getFieldType($typeID))
|
||||
{
|
||||
if ('repeatable' === $type)
|
||||
{
|
||||
$this->isRepeatable[$typeID] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field type
|
||||
*
|
||||
* @param string $id The field type id
|
||||
*
|
||||
* @return string field type
|
||||
*
|
||||
*/
|
||||
protected function getFieldType($id)
|
||||
{
|
||||
if (!isset($this->fieldTypes[$id]))
|
||||
{
|
||||
$properties = ComponentbuilderHelper::getVar('fieldtype', $id, 'id', 'properties');
|
||||
if (ComponentbuilderHelper::checkJson($properties))
|
||||
{
|
||||
$properties = json_decode($properties, true);
|
||||
if (isset($properties['name']) && ComponentbuilderHelper::checkArray($properties['name']))
|
||||
{
|
||||
foreach ($properties['name'] as $key => $value)
|
||||
{
|
||||
if ('type' === $value)
|
||||
{
|
||||
if (isset($properties['example'][$key]) && ComponentbuilderHelper::checkString($properties['example'][$key]))
|
||||
{
|
||||
$this->fieldTypes[$id] = $properties['example'][$key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if not found
|
||||
if (!isset($this->fieldTypes[$id]) && $name = ComponentbuilderHelper::getVar('fieldtype', $id, 'id', 'name'))
|
||||
{
|
||||
$this->fieldTypes[$id] = ComponentbuilderHelper::safeString($name);
|
||||
}
|
||||
}
|
||||
// return the type
|
||||
if (isset($this->fieldTypes[$id]))
|
||||
{
|
||||
return $this->fieldTypes[$id];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the local item
|
||||
*
|
||||
@ -1380,6 +1627,19 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
// get by code name (since there should only be one)
|
||||
$getter = 'alias';
|
||||
break;
|
||||
case 'snippet':
|
||||
// get by snippet (since there should only be one snippet like that)
|
||||
if ($retry == 2)
|
||||
{
|
||||
$getter = array('name', 'snippet', 'url', 'type', 'heading');
|
||||
}
|
||||
else
|
||||
{
|
||||
// get by id name..
|
||||
$getter = array('id', 'name', 'snippet', 'url', 'type', 'heading');
|
||||
$retryAgain = 2;
|
||||
}
|
||||
break;
|
||||
case 'custom_code':
|
||||
// get by code to insure its correctly matched
|
||||
$getter = array('code', 'comment_type', 'target');
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 266 of this MVC
|
||||
@build 30th March, 2017
|
||||
@version @update number 297 of this MVC
|
||||
@build 31st March, 2017
|
||||
@created 6th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage joomla_component.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 266 of this MVC
|
||||
@build 30th March, 2017
|
||||
@version @update number 297 of this MVC
|
||||
@build 31st March, 2017
|
||||
@created 6th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage joomla_components.php
|
||||
@ -81,6 +81,8 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
protected $layoutIds = array();
|
||||
protected $customCodeIds = array();
|
||||
protected $customCodeM = array();
|
||||
protected $fieldTypes = array();
|
||||
protected $isRepeatable = array();
|
||||
|
||||
/**
|
||||
* Method to build the export package
|
||||
@ -390,7 +392,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
$values = json_decode($values, true);
|
||||
}
|
||||
// make sure we have an array
|
||||
if (('custom_code' !== $table && 'component' !== $key) && (!ComponentbuilderHelper::checkArray($values) || !isset($values[$key]) || !ComponentbuilderHelper::checkArray($values[$key])))
|
||||
if (('custom_code' !== $table && 'component' !== $key && 'custom_get' !== $key) && (!ComponentbuilderHelper::checkArray($values) || !isset($values[$key]) || !ComponentbuilderHelper::checkArray($values[$key])))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -409,6 +411,10 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
{
|
||||
$query->where('a.component IN (' . implode(',',$values) . ')');
|
||||
}
|
||||
elseif ('custom_get' === $key)
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$values) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$values[$key]) . ')');
|
||||
@ -438,6 +444,15 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
{
|
||||
$searchArray = array('php_view','php_jview','php_jview_display','php_document','js_document','css_document','css');
|
||||
}
|
||||
// reset the global array
|
||||
if ('template' === $table)
|
||||
{
|
||||
$this->templateIds = array();
|
||||
}
|
||||
elseif ('layout' === $table)
|
||||
{
|
||||
$this->layoutIds = array();
|
||||
}
|
||||
// start loading the data
|
||||
if (!isset($this->smartExport[$table]))
|
||||
{
|
||||
@ -445,20 +460,20 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
}
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// set the data per id only once
|
||||
if (isset($this->smartExport[$table][$item->id]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// load to global object
|
||||
$this->smartExport[$table][$item->id] = $item;
|
||||
// set the custom code ID's
|
||||
$this->setCustomCodeIds($item, $table);
|
||||
// actions to take if table is admin_view
|
||||
if ('admin_view' === $table)
|
||||
{
|
||||
// add fields
|
||||
$this->setData($user, $db, 'field', $item->addfields, 'field');
|
||||
// add admin views
|
||||
if (isset($item->addlinked_views))
|
||||
{
|
||||
// $this->setData($user, $db, 'admin_view', $item->addlinked_views, 'adminview'); TODO infinite loop error
|
||||
}
|
||||
// admin icon
|
||||
$this->moveIt(array('image' => array($item->icon)), 'image');
|
||||
// admin icon_add
|
||||
@ -471,6 +486,27 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
{
|
||||
// add field types
|
||||
$this->setData($user, $db, 'fieldtype', array('fieldtype' => array($item->fieldtype)), 'fieldtype');
|
||||
// we must add a repeatable field subfields
|
||||
if ($this->checkRepeatable($item->fieldtype))
|
||||
{
|
||||
$fields = ComponentbuilderHelper::getBetween(json_decode($item->xml), 'fields="', '"');
|
||||
$fieldsSets = array();
|
||||
if (strpos($fields, ',') !== false)
|
||||
{
|
||||
// multiple fields
|
||||
$fieldsSets = (array) explode(',', $fields);
|
||||
}
|
||||
elseif (is_numeric($fields))
|
||||
{
|
||||
// single field
|
||||
$fieldsSets[] = (int) $fields;
|
||||
}
|
||||
// get fields
|
||||
if (ComponentbuilderHelper::checkArray($fieldsSets))
|
||||
{
|
||||
$this->setData($user, $db, 'field', array('field' => $fieldsSets), 'field');
|
||||
}
|
||||
}
|
||||
}
|
||||
// actions to take if table is site_view and custom_admin_view
|
||||
if ('site_view' === $table || 'custom_admin_view' === $table)
|
||||
@ -480,29 +516,116 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
// add search array templates and layouts
|
||||
foreach ($searchArray as $scripter)
|
||||
{
|
||||
if (isset($view->{'add_'.$scripter}) && $view->{'add_'.$scripter} == 1)
|
||||
if (isset($item->{'add_'.$scripter}) && $item->{'add_'.$scripter} == 1)
|
||||
{
|
||||
$this->getTemplateLayout($view->$scripter, $db);
|
||||
$this->getTemplateLayout($item->$scripter, $db);
|
||||
}
|
||||
}
|
||||
// add dynamic gets
|
||||
$this->setData($user, $db, 'dynamic_get', array('dynamic_get' => array($item->main_get)), 'dynamic_get');
|
||||
$this->setData($user, $db, 'dynamic_get', array('dynamic_get' => $item->custom_get), 'dynamic_get');
|
||||
$this->setData($user, $db, 'dynamic_get', $item->custom_get, 'custom_get');
|
||||
if ('custom_admin_view' === $table && isset($item->icon))
|
||||
{
|
||||
// view icon
|
||||
$this->moveIt(array('image' => array($item->icon)), 'image');
|
||||
}
|
||||
// add snippets
|
||||
$this->setData($user, $db, 'snippet', array('snippet' => array($item->snippet)), 'snippet');
|
||||
}
|
||||
// actions to take if table is template and layout
|
||||
if ('layout' === $table || 'template' === $table)
|
||||
{
|
||||
// search for templates & layouts
|
||||
$this->getTemplateLayout(base64_decode($item->$table), $db, $user);
|
||||
// add search array templates and layouts
|
||||
if (isset($item->add_php_view) && $item->add_php_view == 1)
|
||||
{
|
||||
$this->getTemplateLayout($item->php_view, $db, $user);
|
||||
}
|
||||
// add dynamic gets
|
||||
$this->setData($user, $db, 'dynamic_get', array('dynamic_get' => $item->dynamic_get), 'dynamic_get');
|
||||
// add snippets
|
||||
$this->setData($user, $db, 'snippet', array('snippet' => array($item->snippet)), 'snippet');
|
||||
}
|
||||
// set the custom code ID's
|
||||
$this->setCustomCodeIds($item, $table);
|
||||
// load to global object
|
||||
$this->smartExport[$table][$item->id] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a field is a repeatable field
|
||||
*
|
||||
* @param string $typeID The type ID
|
||||
*
|
||||
* @return bool true on success
|
||||
*
|
||||
*/
|
||||
protected function checkRepeatable($typeID)
|
||||
{
|
||||
if(isset($this->isRepeatable[$typeID]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkArray($this->isRepeatable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif ($type = $this->getFieldType($typeID))
|
||||
{
|
||||
if ('repeatable' === $type)
|
||||
{
|
||||
$this->isRepeatable[$typeID] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field type
|
||||
*
|
||||
* @param string $id The field type id
|
||||
*
|
||||
* @return string field type
|
||||
*
|
||||
*/
|
||||
protected function getFieldType($id)
|
||||
{
|
||||
if (!isset($this->fieldTypes[$id]))
|
||||
{
|
||||
$properties = ComponentbuilderHelper::getVar('fieldtype', $id, 'id', 'properties');
|
||||
if (ComponentbuilderHelper::checkJson($properties))
|
||||
{
|
||||
$properties = json_decode($properties, true);
|
||||
if (isset($properties['name']) && ComponentbuilderHelper::checkArray($properties['name']))
|
||||
{
|
||||
foreach ($properties['name'] as $key => $value)
|
||||
{
|
||||
if ('type' === $value)
|
||||
{
|
||||
if (isset($properties['example'][$key]) && ComponentbuilderHelper::checkString($properties['example'][$key]))
|
||||
{
|
||||
$this->fieldTypes[$id] = $properties['example'][$key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if not found
|
||||
if (!isset($this->fieldTypes[$id]) && $name = ComponentbuilderHelper::getVar('fieldtype', $id, 'id', 'name'))
|
||||
{
|
||||
$this->fieldTypes[$id] = ComponentbuilderHelper::safeString($name);
|
||||
}
|
||||
}
|
||||
// return the type
|
||||
if (isset($this->fieldTypes[$id]))
|
||||
{
|
||||
return $this->fieldTypes[$id];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Template and Layout Data
|
||||
*
|
||||
@ -511,7 +634,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
protected function getTemplateLayout($default, &$db)
|
||||
protected function getTemplateLayout($default, &$db, $user = false)
|
||||
{
|
||||
// set the Template data
|
||||
$temp1 = ComponentbuilderHelper::getAllBetween($default, "\$this->loadTemplate('","')");
|
||||
@ -592,6 +715,20 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
$this->getTemplateLayout($get, $db);
|
||||
}
|
||||
}
|
||||
// Set the Data
|
||||
if ($user)
|
||||
{
|
||||
// add templates
|
||||
if (ComponentbuilderHelper::checkArray($this->templateIds))
|
||||
{
|
||||
$this->setData($user, $db, 'template', array('template' => $this->templateIds), 'template');
|
||||
}
|
||||
// add layouts
|
||||
if (ComponentbuilderHelper::checkArray($this->layoutIds))
|
||||
{
|
||||
$this->setData($user, $db, 'layout', array('layout' => $this->layoutIds), 'layout');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user