Release of v4.0.0-rc1
Improved the Schema Table update engine (more). Fix autoloader timing, and loading. Implement the Joomla Powers in JCB code, to move away from JClasses.
This commit is contained in:
@ -598,223 +598,6 @@ class Admin_viewsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_admin_view table
|
||||
$query->from($db->quoteName('#__componentbuilder_admin_view', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
|
||||
// do not use these filters in the export method
|
||||
if (!isset($_export) || !$_export)
|
||||
{
|
||||
// Filtering "joomla components"
|
||||
$filter_joomla_component = $this->state->get("filter.joomla_component");
|
||||
if ($filter_joomla_component !== null && !empty($filter_joomla_component))
|
||||
{
|
||||
if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_admin_views')) !== null)
|
||||
{
|
||||
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && $user->authorise('admin_view.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode php_allowedit
|
||||
$item->php_allowedit = base64_decode($item->php_allowedit);
|
||||
// decode php_postsavehook
|
||||
$item->php_postsavehook = base64_decode($item->php_postsavehook);
|
||||
// decode php_before_save
|
||||
$item->php_before_save = base64_decode($item->php_before_save);
|
||||
// decode php_getlistquery
|
||||
$item->php_getlistquery = base64_decode($item->php_getlistquery);
|
||||
// decode php_import_ext
|
||||
$item->php_import_ext = base64_decode($item->php_import_ext);
|
||||
// decode php_after_publish
|
||||
$item->php_after_publish = base64_decode($item->php_after_publish);
|
||||
// decode php_after_cancel
|
||||
$item->php_after_cancel = base64_decode($item->php_after_cancel);
|
||||
// decode php_batchmove
|
||||
$item->php_batchmove = base64_decode($item->php_batchmove);
|
||||
// decode php_after_delete
|
||||
$item->php_after_delete = base64_decode($item->php_after_delete);
|
||||
// decode php_import
|
||||
$item->php_import = base64_decode($item->php_import);
|
||||
// decode php_getitems_after_all
|
||||
$item->php_getitems_after_all = base64_decode($item->php_getitems_after_all);
|
||||
// decode php_getform
|
||||
$item->php_getform = base64_decode($item->php_getform);
|
||||
// decode php_save
|
||||
$item->php_save = base64_decode($item->php_save);
|
||||
// decode php_allowadd
|
||||
$item->php_allowadd = base64_decode($item->php_allowadd);
|
||||
// decode php_before_cancel
|
||||
$item->php_before_cancel = base64_decode($item->php_before_cancel);
|
||||
// decode php_batchcopy
|
||||
$item->php_batchcopy = base64_decode($item->php_batchcopy);
|
||||
// decode php_before_publish
|
||||
$item->php_before_publish = base64_decode($item->php_before_publish);
|
||||
// decode php_before_delete
|
||||
$item->php_before_delete = base64_decode($item->php_before_delete);
|
||||
// decode php_document
|
||||
$item->php_document = base64_decode($item->php_document);
|
||||
// decode sql
|
||||
$item->sql = base64_decode($item->sql);
|
||||
// decode php_import_display
|
||||
$item->php_import_display = base64_decode($item->php_import_display);
|
||||
// decode php_import_setdata
|
||||
$item->php_import_setdata = base64_decode($item->php_import_setdata);
|
||||
// decode css_view
|
||||
$item->css_view = base64_decode($item->css_view);
|
||||
// decode css_views
|
||||
$item->css_views = base64_decode($item->css_views);
|
||||
// decode javascript_view_file
|
||||
$item->javascript_view_file = base64_decode($item->javascript_view_file);
|
||||
// decode javascript_view_footer
|
||||
$item->javascript_view_footer = base64_decode($item->javascript_view_footer);
|
||||
// decode javascript_views_file
|
||||
$item->javascript_views_file = base64_decode($item->javascript_views_file);
|
||||
// decode javascript_views_footer
|
||||
$item->javascript_views_footer = base64_decode($item->javascript_views_footer);
|
||||
// decode php_controller
|
||||
$item->php_controller = base64_decode($item->php_controller);
|
||||
// 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 php_ajaxmethod
|
||||
$item->php_ajaxmethod = base64_decode($item->php_ajaxmethod);
|
||||
// decode html_import_view
|
||||
$item->html_import_view = base64_decode($item->html_import_view);
|
||||
// decode php_getitem
|
||||
$item->php_getitem = base64_decode($item->php_getitem);
|
||||
// decode php_import_headers
|
||||
$item->php_import_headers = base64_decode($item->php_import_headers);
|
||||
// decode php_import_save
|
||||
$item->php_import_save = base64_decode($item->php_import_save);
|
||||
// decode php_getitems
|
||||
$item->php_getitems = base64_decode($item->php_getitems);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_admin_view");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -205,7 +205,7 @@ class AjaxModel extends ListModel
|
||||
protected function componentDetailsDisplay($object)
|
||||
{
|
||||
// set some vars
|
||||
$image = (StringHelper::check($object->image)) ? '<img alt="Joomla Component Image" src="'. \JUri::root() . $object->image . '" style="float: right;">': '';
|
||||
$image = (StringHelper::check($object->image)) ? '<img alt="Joomla Component Image" src="'. Uri::root() . $object->image . '" style="float: right;">': '';
|
||||
$desc = (StringHelper::check($object->description)) ? $object->description : $object->short_description;
|
||||
$placeholder = ($object->add_placeholders == 1) ? '<span class="btn btn-small btn-success"> ' . Text::_('COM_COMPONENTBUILDER_YES') . ' </span>' : '<span class="btn btn-small btn-danger"> ' .Text::_('COM_COMPONENTBUILDER_NO') . ' </span>' ;
|
||||
$debug = ($object->debug_linenr == 1) ? '<span class="btn btn-small btn-success"> ' .Text::_('COM_COMPONENTBUILDER_YES') . '</span>' : ' <span class="btn btn-small btn-danger"> ' .Text::_('COM_COMPONENTBUILDER_NO') . ' </span>' ;
|
||||
@ -243,11 +243,11 @@ class AjaxModel extends ListModel
|
||||
$result['error'] = '<span style="color: red;">' . Text::sprintf('COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_FOR_S', $type) . '</span>';
|
||||
if ($this->hasCurl())
|
||||
{
|
||||
$path = '*/5 * * * * curl -s "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.backup" >/dev/null 2>&1';
|
||||
$path = '*/5 * * * * curl -s "' .Uri::root() . 'index.php?option=com_componentbuilder&task=api.backup" >/dev/null 2>&1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = '*/5 * * * * wget "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.backup" >/dev/null 2>&1';
|
||||
$path = '*/5 * * * * wget "' .Uri::root() . 'index.php?option=com_componentbuilder&task=api.backup" >/dev/null 2>&1';
|
||||
}
|
||||
$result['path'] = '<code>' . $path . '</code>';
|
||||
}
|
||||
@ -256,11 +256,11 @@ class AjaxModel extends ListModel
|
||||
$result['error'] = '<span style="color: red;">' . Text::sprintf('COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_FOR_S', $type) . '</span>';
|
||||
if ($this->hasCurl())
|
||||
{
|
||||
$path = '* * * * * curl -s "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand" >/dev/null 2>&1';
|
||||
$path = '* * * * * curl -s "' .Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand" >/dev/null 2>&1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = '* * * * * wget "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand" >/dev/null 2>&1';
|
||||
$path = '* * * * * wget "' .Uri::root() . 'index.php?option=com_componentbuilder&task=api.expand" >/dev/null 2>&1';
|
||||
}
|
||||
$result['path'] = '<code>' . $path . '</code>';
|
||||
}
|
||||
|
@ -385,134 +385,6 @@ class Class_methodsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_class_method table
|
||||
$query->from($db->quoteName('#__componentbuilder_class_method', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && $user->authorise('class_method.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode code
|
||||
$item->code = base64_decode($item->code);
|
||||
// decode comment
|
||||
$item->comment = base64_decode($item->comment);
|
||||
// decode arguments
|
||||
$item->arguments = base64_decode($item->arguments);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_class_method");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -383,132 +383,6 @@ class Class_propertiesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_class_property table
|
||||
$query->from($db->quoteName('#__componentbuilder_class_property', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && $user->authorise('class_property.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode comment
|
||||
$item->comment = base64_decode($item->comment);
|
||||
// decode default
|
||||
$item->default = base64_decode($item->default);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_class_property");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -46,7 +46,7 @@ class ComponentbuilderModel extends ListModel
|
||||
$icons = [];
|
||||
// view groups array
|
||||
$viewGroups = array(
|
||||
'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png.powers', 'png.search', 'png||importjcbpackages||index.php?option=com_componentbuilder&view=joomla_components&task=joomla_components.smartImport', 'png.admin_views', 'png.custom_admin_views', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.get_snippets', 'png.validation_rules', 'png.field.add', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.servers', 'png.help_documents')
|
||||
'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png.powers', 'png.search', 'png.admin_views', 'png.custom_admin_views', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.validation_rules', 'png.field.add', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.languages', 'png.servers', 'png.help_documents')
|
||||
);
|
||||
// view access array
|
||||
$viewAccess = [
|
||||
@ -55,8 +55,6 @@ class ComponentbuilderModel extends ListModel
|
||||
'search.access' => 'search.access',
|
||||
'search.submenu' => 'search.submenu',
|
||||
'search.dashboard_list' => 'search.dashboard_list',
|
||||
'get_snippets.submenu' => 'get_snippets.submenu',
|
||||
'get_snippets.dashboard_list' => 'get_snippets.dashboard_list',
|
||||
'joomla_component.create' => 'joomla_component.create',
|
||||
'joomla_components.access' => 'joomla_component.access',
|
||||
'joomla_component.access' => 'joomla_component.access',
|
||||
@ -159,6 +157,7 @@ class ComponentbuilderModel extends ListModel
|
||||
'languages.access' => 'language.access',
|
||||
'language.access' => 'language.access',
|
||||
'languages.submenu' => 'language.submenu',
|
||||
'languages.dashboard_list' => 'language.dashboard_list',
|
||||
'server.create' => 'server.create',
|
||||
'servers.access' => 'server.access',
|
||||
'server.access' => 'server.access',
|
||||
|
@ -506,171 +506,6 @@ class Custom_admin_viewsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_custom_admin_view table
|
||||
$query->from($db->quoteName('#__componentbuilder_custom_admin_view', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
|
||||
// do not use these filters in the export method
|
||||
if (!isset($_export) || !$_export)
|
||||
{
|
||||
// Filtering "joomla components"
|
||||
$filter_joomla_component = $this->state->get("filter.joomla_component");
|
||||
if ($filter_joomla_component !== null && !empty($filter_joomla_component))
|
||||
{
|
||||
if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_custom_admin_views')) !== null)
|
||||
{
|
||||
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && $user->authorise('custom_admin_view.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode css_document
|
||||
$item->css_document = base64_decode($item->css_document);
|
||||
// decode css
|
||||
$item->css = base64_decode($item->css);
|
||||
// decode js_document
|
||||
$item->js_document = base64_decode($item->js_document);
|
||||
// decode javascript_file
|
||||
$item->javascript_file = base64_decode($item->javascript_file);
|
||||
// decode default
|
||||
$item->default = base64_decode($item->default);
|
||||
// decode php_ajaxmethod
|
||||
$item->php_ajaxmethod = base64_decode($item->php_ajaxmethod);
|
||||
// decode php_document
|
||||
$item->php_document = base64_decode($item->php_document);
|
||||
// decode php_view
|
||||
$item->php_view = base64_decode($item->php_view);
|
||||
// decode php_jview_display
|
||||
$item->php_jview_display = base64_decode($item->php_jview_display);
|
||||
// decode php_jview
|
||||
$item->php_jview = base64_decode($item->php_jview);
|
||||
// decode php_controller
|
||||
$item->php_controller = base64_decode($item->php_controller);
|
||||
// decode php_model
|
||||
$item->php_model = base64_decode($item->php_model);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_custom_admin_view");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -468,149 +468,6 @@ class Custom_codesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_custom_code table
|
||||
$query->from($db->quoteName('#__componentbuilder_custom_code', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && $user->authorise('custom_code.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// [1641]=> Target (code action)
|
||||
$item->target_code = $item->target;
|
||||
// decode code
|
||||
$item->code = base64_decode($item->code);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
|
||||
if (UtilitiesArrayHelper::check($items) && !isset($_export))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
if ($item->target == 2)
|
||||
{
|
||||
$item->component_system_name = $item->system_name;
|
||||
$item->path = '[CUSTO'.'MCODE='.$item->id.']'; // so it is not detected
|
||||
if (StringHelper::check($item->function_name))
|
||||
{
|
||||
$item->path = '[CUSTO'.'MCODE='.$item->function_name.']'; // so it is not detected
|
||||
}
|
||||
$item->type = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_custom_code");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -376,144 +376,6 @@ class Dynamic_getsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_dynamic_get table
|
||||
$query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && $user->authorise('dynamic_get.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode php_calculation
|
||||
$item->php_calculation = base64_decode($item->php_calculation);
|
||||
// decode php_router_parse
|
||||
$item->php_router_parse = base64_decode($item->php_router_parse);
|
||||
// decode php_custom_get
|
||||
$item->php_custom_get = base64_decode($item->php_custom_get);
|
||||
// decode php_before_getitem
|
||||
$item->php_before_getitem = base64_decode($item->php_before_getitem);
|
||||
// decode php_after_getitem
|
||||
$item->php_after_getitem = base64_decode($item->php_after_getitem);
|
||||
// decode php_getlistquery
|
||||
$item->php_getlistquery = base64_decode($item->php_getlistquery);
|
||||
// decode php_before_getitems
|
||||
$item->php_before_getitems = base64_decode($item->php_before_getitems);
|
||||
// decode php_after_getitems
|
||||
$item->php_after_getitems = base64_decode($item->php_after_getitems);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_dynamic_get");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -649,190 +649,6 @@ class FieldsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_field table
|
||||
$query->from($db->quoteName('#__componentbuilder_field', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
|
||||
// do not use these filters in the export method
|
||||
if (!isset($_export) || !$_export)
|
||||
{
|
||||
// Filtering "extension"
|
||||
$filter_extension = $this->state->get("filter.extension");
|
||||
$field_ids = array();
|
||||
$get_ids = true;
|
||||
if ($get_ids && $filter_extension !== null && !empty($filter_extension))
|
||||
{
|
||||
// column name, and id
|
||||
$type_extension = explode('__', $filter_extension);
|
||||
if (($ids = JCBFilterHelper::linked((int) $type_extension[1], (string) $type_extension[0])) !== null)
|
||||
{
|
||||
$field_ids = $ids;
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
$get_ids = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filtering "admin_view"
|
||||
$filter_admin_view = $this->state->get("filter.admin_view");
|
||||
if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view))
|
||||
{
|
||||
if (($ids = JCBFilterHelper::linked((int) $filter_admin_view, 'admin_view')) !== null)
|
||||
{
|
||||
// view will return less fields, so we ignore the component
|
||||
$field_ids = $ids;
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
$get_ids = false;
|
||||
}
|
||||
}
|
||||
// now check if we have IDs
|
||||
if ($get_ids && UtilitiesArrayHelper::check($field_ids))
|
||||
{
|
||||
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $field_ids) . ')');
|
||||
}
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode on_save_model_field
|
||||
$item->on_save_model_field = base64_decode($item->on_save_model_field);
|
||||
// decode initiator_on_get_model
|
||||
$item->initiator_on_get_model = base64_decode($item->initiator_on_get_model);
|
||||
// decode initiator_on_save_model
|
||||
$item->initiator_on_save_model = base64_decode($item->initiator_on_save_model);
|
||||
// decode css_views
|
||||
$item->css_views = base64_decode($item->css_views);
|
||||
// decode css_view
|
||||
$item->css_view = base64_decode($item->css_view);
|
||||
// decode on_get_model_field
|
||||
$item->on_get_model_field = base64_decode($item->on_get_model_field);
|
||||
// decode javascript_view_footer
|
||||
$item->javascript_view_footer = base64_decode($item->javascript_view_footer);
|
||||
// decode javascript_views_footer
|
||||
$item->javascript_views_footer = base64_decode($item->javascript_views_footer);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_field");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -289,7 +289,7 @@ class FieldtypeModel extends AdminModel
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getVxtfields()
|
||||
public function getVxsfields()
|
||||
{
|
||||
// Get the user object.
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
@ -431,13 +431,13 @@ class FieldtypeModel extends AdminModel
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// convert datatype
|
||||
$item->datatype = $this->selectionTranslationVxtfields($item->datatype, 'datatype');
|
||||
$item->datatype = $this->selectionTranslationVxsfields($item->datatype, 'datatype');
|
||||
// convert indexes
|
||||
$item->indexes = $this->selectionTranslationVxtfields($item->indexes, 'indexes');
|
||||
$item->indexes = $this->selectionTranslationVxsfields($item->indexes, 'indexes');
|
||||
// convert null_switch
|
||||
$item->null_switch = $this->selectionTranslationVxtfields($item->null_switch, 'null_switch');
|
||||
$item->null_switch = $this->selectionTranslationVxsfields($item->null_switch, 'null_switch');
|
||||
// convert store
|
||||
$item->store = $this->selectionTranslationVxtfields($item->store, 'store');
|
||||
$item->store = $this->selectionTranslationVxsfields($item->store, 'store');
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ class FieldtypeModel extends AdminModel
|
||||
*
|
||||
* @return string The translatable string.
|
||||
*/
|
||||
public function selectionTranslationVxtfields($value,$name)
|
||||
public function selectionTranslationVxsfields($value,$name)
|
||||
{
|
||||
// Array of datatype language strings
|
||||
if ($name === 'datatype')
|
||||
|
@ -321,128 +321,6 @@ class FieldtypesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_fieldtype table
|
||||
$query->from($db->quoteName('#__componentbuilder_fieldtype', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.ordering ASC');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && $user->authorise('fieldtype.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_fieldtype");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -403,122 +403,6 @@ class Help_documentsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_help_document table
|
||||
$query->from($db->quoteName('#__componentbuilder_help_document', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.ordering ASC');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && $user->authorise('help_document.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_help_document");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -1,752 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
namespace VDM\Component\Componentbuilder\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\Filesystem\Path;
|
||||
use Joomla\CMS\Filter\OutputFilter;
|
||||
use Joomla\CMS\Installer\InstallerHelper;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
use Joomla\String\StringHelper;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/***
|
||||
* Componentbuilder Import Base Database Model
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ImportModel extends BaseDatabaseModel
|
||||
{
|
||||
// set uploading values
|
||||
protected $use_streams = false;
|
||||
protected $allow_unsafe = false;
|
||||
protected $safeFileOptions = [];
|
||||
|
||||
/**
|
||||
* @var object JTable object
|
||||
*/
|
||||
protected $_table = null;
|
||||
|
||||
/**
|
||||
* @var object JTable object
|
||||
*/
|
||||
protected $_url = null;
|
||||
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_componentbuilder.import';
|
||||
|
||||
/**
|
||||
* Import Settings
|
||||
*/
|
||||
protected $getType = NULL;
|
||||
protected $dataType = NULL;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = Factory::getApplication('administrator');
|
||||
|
||||
$this->setState('message', $app->getUserState('com_componentbuilder.message'));
|
||||
$app->setUserState('com_componentbuilder.message', '');
|
||||
|
||||
// Recall the 'Import from Directory' path.
|
||||
$path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path'));
|
||||
$this->setState('import.directory', $path);
|
||||
parent::populateState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Import an spreadsheet from either folder, url or upload.
|
||||
*
|
||||
* @return boolean result of import
|
||||
*
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$this->setState('action', 'import');
|
||||
$app = Factory::getApplication();
|
||||
$session = Factory::getSession();
|
||||
$package = null;
|
||||
$continue = false;
|
||||
// get import type
|
||||
$this->getType = $app->input->getString('gettype', NULL);
|
||||
// get import type
|
||||
$this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL);
|
||||
|
||||
if ($package === null)
|
||||
{
|
||||
switch ($this->getType)
|
||||
{
|
||||
case 'folder':
|
||||
// Remember the 'Import from Directory' path.
|
||||
$app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory');
|
||||
$package = $this->_getPackageFromFolder();
|
||||
break;
|
||||
|
||||
case 'upload':
|
||||
$package = $this->_getPackageFromUpload();
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
$package = $this->_getPackageFromUrl();
|
||||
break;
|
||||
|
||||
case 'continue':
|
||||
$continue = true;
|
||||
$package = $session->get('package', null);
|
||||
$package = json_decode($package, true);
|
||||
// clear session
|
||||
$session->clear('package');
|
||||
$session->clear('dataType');
|
||||
$session->clear('hasPackage');
|
||||
break;
|
||||
|
||||
default:
|
||||
$app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_NO_IMPORT_TYPE_FOUND'));
|
||||
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Was the package valid?
|
||||
if (!$package || !$package['type'])
|
||||
{
|
||||
if (in_array($this->getType, array('upload', 'url')))
|
||||
{
|
||||
$this->remove($package['packagename']);
|
||||
}
|
||||
|
||||
$app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// first link data to table headers
|
||||
if(!$continue){
|
||||
$package = json_encode($package);
|
||||
$session->set('package', $package);
|
||||
$session->set('dataType', $this->dataType);
|
||||
$session->set('hasPackage', true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// set the data
|
||||
$headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true);
|
||||
if (!$this->setData($package,$this->dataType,$headerList))
|
||||
{
|
||||
// There was an error importing the package
|
||||
$msg = Text::_('COM_COMPONENTBUILDER_IMPORT_ERROR');
|
||||
$back = $session->get('backto_VDM_IMPORT', NULL);
|
||||
if ($back)
|
||||
{
|
||||
$app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back);
|
||||
$session->clear('backto_VDM_IMPORT');
|
||||
}
|
||||
$result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Package imported sucessfully
|
||||
$msg = Text::sprintf('COM_COMPONENTBUILDER_IMPORT_SUCCESS', $package['packagename']);
|
||||
$back = $session->get('backto_VDM_IMPORT', NULL);
|
||||
if ($back)
|
||||
{
|
||||
$app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back);
|
||||
$session->clear('backto_VDM_IMPORT');
|
||||
}
|
||||
$result = true;
|
||||
}
|
||||
|
||||
// Set some model state values
|
||||
$app->enqueueMessage($msg);
|
||||
|
||||
// remove file after import
|
||||
$this->remove($package['packagename']);
|
||||
$session->clear($this->getType.'_VDM_IMPORTHEADERS');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Works out an importation spreadsheet from a HTTP upload
|
||||
*
|
||||
* @return spreadsheet definition or false on failure
|
||||
*/
|
||||
protected function _getPackageFromUpload()
|
||||
{
|
||||
// Get the uploaded file information
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->input;
|
||||
|
||||
// Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get.
|
||||
$userfile = $input->files->get('import_package', null, 'raw');
|
||||
|
||||
// Make sure that file uploads are enabled in php
|
||||
if (!(bool) ini_get('file_uploads'))
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTFILE'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is no uploaded file, we have a problem...
|
||||
if (!is_array($userfile))
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_NO_FILE_SELECTED'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if there was a problem uploading the file.
|
||||
if ($userfile['error'] || $userfile['size'] < 1)
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build the appropriate paths
|
||||
$config = Factory::getConfig();
|
||||
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
|
||||
$tmp_src = $userfile['tmp_name'];
|
||||
|
||||
// Move uploaded file
|
||||
$p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions);
|
||||
|
||||
// Was the package downloaded?
|
||||
if (!$p_file)
|
||||
{
|
||||
$session = Factory::getSession();
|
||||
$session->clear('package');
|
||||
$session->clear('dataType');
|
||||
$session->clear('hasPackage');
|
||||
// was not uploaded
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that this is a valid spreadsheet
|
||||
$package = $this->check($userfile['name']);
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import an spreadsheet from a directory
|
||||
*
|
||||
* @return array Spreadsheet details or false on failure
|
||||
*
|
||||
*/
|
||||
protected function _getPackageFromFolder()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->input;
|
||||
|
||||
// Get the path to the package to import
|
||||
$p_dir = $input->getString('import_directory');
|
||||
$p_dir = Path::clean($p_dir);
|
||||
// Did you give us a valid path?
|
||||
if (!file_exists($p_dir))
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Detect the package type
|
||||
$type = $this->getType;
|
||||
|
||||
// Did you give us a valid package?
|
||||
if (!$type)
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning');
|
||||
}
|
||||
|
||||
// check the extention
|
||||
if(!$this->checkExtension($p_dir))
|
||||
{
|
||||
// set error message
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$package['packagename'] = null;
|
||||
$package['dir'] = $p_dir;
|
||||
$package['type'] = $type;
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import an spreadsheet from a URL
|
||||
*
|
||||
* @return Package details or false on failure
|
||||
*
|
||||
*/
|
||||
protected function _getPackageFromUrl()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->input;
|
||||
|
||||
// Get the URL of the package to import
|
||||
$url = $input->getString('import_url');
|
||||
|
||||
// Did you give us a URL?
|
||||
if (!$url)
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_ENTER_A_URL'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Download the package at the URL given
|
||||
$p_file = InstallerHelper::downloadPackage($url);
|
||||
|
||||
// Was the package downloaded?
|
||||
if (!$p_file)
|
||||
{
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_INVALID_URL'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that this is a valid spreadsheet
|
||||
$package = $this->check($p_file);
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a file and verifies it as a spreadsheet file
|
||||
* Supports .csv .xlsx .xls and .ods
|
||||
*
|
||||
* @param string $p_filename The uploaded package filename or import directory
|
||||
*
|
||||
* @return array of elements
|
||||
*
|
||||
*/
|
||||
protected function check($archivename)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
// Clean the name
|
||||
$archivename = Path::clean($archivename);
|
||||
|
||||
// check the extention
|
||||
if(!$this->checkExtension($archivename))
|
||||
{
|
||||
// Cleanup the import files
|
||||
$this->remove($archivename);
|
||||
$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning');
|
||||
return false;
|
||||
}
|
||||
|
||||
$config = Factory::getConfig();
|
||||
// set Package Name
|
||||
$check['packagename'] = $archivename;
|
||||
|
||||
// set directory
|
||||
$check['dir'] = $config->get('tmp_path'). '/' .$archivename;
|
||||
|
||||
// set type
|
||||
$check['type'] = $this->getType;
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the extension
|
||||
*
|
||||
* @param string $file Name of the uploaded file
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
*/
|
||||
protected function checkExtension($file)
|
||||
{
|
||||
// check the extention
|
||||
switch(strtolower(pathinfo($file, PATHINFO_EXTENSION)))
|
||||
{
|
||||
case 'xls':
|
||||
case 'ods':
|
||||
case 'csv':
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up temporary uploaded spreadsheet
|
||||
*
|
||||
* @param string $package Name of the uploaded spreadsheet file
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
*/
|
||||
protected function remove($package)
|
||||
{
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
$config = Factory::getConfig();
|
||||
$package = $config->get('tmp_path'). '/' .$package;
|
||||
|
||||
// Is the package file a valid file?
|
||||
if (is_file($package))
|
||||
{
|
||||
File::delete($package);
|
||||
}
|
||||
elseif (is_file(Path::clean($package)))
|
||||
{
|
||||
// It might also be just a base filename
|
||||
File::delete(Path::clean($package));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data from the spreadsheet to the database
|
||||
*
|
||||
* @param string $package Paths to the uploaded package file
|
||||
*
|
||||
* @return boolean false on failure
|
||||
*
|
||||
**/
|
||||
protected function setData($package,$table,$target_headers)
|
||||
{
|
||||
if (UtilitiesArrayHelper::check($target_headers))
|
||||
{
|
||||
// make sure the file is loaded
|
||||
ComponentbuilderHelper::composerAutoload('phpspreadsheet');
|
||||
$jinput = Factory::getApplication()->input;
|
||||
foreach($target_headers as $header)
|
||||
{
|
||||
if (($column = $jinput->getString($header, false)) !== false ||
|
||||
($column = $jinput->getString(strtolower($header), false)) !== false)
|
||||
{
|
||||
$data['target_headers'][$header] = $column;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['target_headers'][$header] = null;
|
||||
}
|
||||
}
|
||||
// set the data
|
||||
if(isset($package['dir']))
|
||||
{
|
||||
$inputFileType = IOFactory::identify($package['dir']);
|
||||
$excelReader = IOFactory::createReader($inputFileType);
|
||||
$excelReader->setReadDataOnly(true);
|
||||
$excelObj = $excelReader->load($package['dir']);
|
||||
$data['array'] = $excelObj->getActiveSheet()->toArray(null, true,true,true);
|
||||
$excelObj->disconnectWorksheets();
|
||||
unset($excelObj);
|
||||
return $this->save($data, $table);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the data from the file to the database
|
||||
*
|
||||
* @param string $package Paths to the uploaded package file
|
||||
*
|
||||
* @return boolean false on failure
|
||||
*
|
||||
**/
|
||||
protected function save($data,$table)
|
||||
{
|
||||
// import the data if there is any
|
||||
if(UtilitiesArrayHelper::check($data['array']))
|
||||
{
|
||||
// get user object
|
||||
$user = Factory::getUser();
|
||||
// remove header if it has headers
|
||||
$id_key = $data['target_headers']['id'];
|
||||
$published_key = $data['target_headers']['published'];
|
||||
$ordering_key = $data['target_headers']['ordering'];
|
||||
// get the first array set
|
||||
$firstSet = reset($data['array']);
|
||||
|
||||
// check if first array is a header array and remove if true
|
||||
if($firstSet[$id_key] == 'id' || $firstSet[$published_key] == 'published' || $firstSet[$ordering_key] == 'ordering')
|
||||
{
|
||||
array_shift($data['array']);
|
||||
}
|
||||
|
||||
// make sure there is still values in array and that it was not only headers
|
||||
if(UtilitiesArrayHelper::check($data['array']) && $user->authorise($table.'.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder'))
|
||||
{
|
||||
// set target.
|
||||
$target = array_flip($data['target_headers']);
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// set some defaults
|
||||
$todayDate = Factory::getDate()->toSql();
|
||||
// get global action permissions
|
||||
$canDo = ComponentbuilderHelper::getActions($table);
|
||||
$canEdit = $canDo->get('core.edit');
|
||||
$canState = $canDo->get('core.edit.state');
|
||||
$canCreate = $canDo->get('core.create');
|
||||
$hasAlias = $this->getAliasesUsed($table);
|
||||
// prosses the data
|
||||
foreach($data['array'] as $row)
|
||||
{
|
||||
$found = false;
|
||||
if (isset($row[$id_key]) && is_numeric($row[$id_key]) && $row[$id_key] > 0)
|
||||
{
|
||||
// raw items import & update!
|
||||
$query = $db->getQuery(true);
|
||||
$query
|
||||
->select('version')
|
||||
->from($db->quoteName('#__componentbuilder_'.$table))
|
||||
->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key]));
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
$found = $db->getNumRows();
|
||||
}
|
||||
|
||||
if($found && $canEdit)
|
||||
{
|
||||
// update item
|
||||
$id = $row[$id_key];
|
||||
$version = $db->loadResult();
|
||||
// reset all buckets
|
||||
$query = $db->getQuery(true);
|
||||
$fields = array();
|
||||
// Fields to update.
|
||||
foreach($row as $key => $cell)
|
||||
{
|
||||
// ignore column
|
||||
if ('IGNORE' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// update modified
|
||||
if ('modified_by' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// update modified
|
||||
if ('modified' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// update version
|
||||
if ('version' == $target[$key])
|
||||
{
|
||||
$cell = (int) $version + 1;
|
||||
}
|
||||
// verify publish authority
|
||||
if ('published' == $target[$key] && !$canState)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// set to update array
|
||||
if(in_array($key, $data['target_headers']) && is_numeric($cell))
|
||||
{
|
||||
$fields[] = $db->quoteName($target[$key]) . ' = ' . $cell;
|
||||
}
|
||||
elseif(in_array($key, $data['target_headers']) && is_string($cell))
|
||||
{
|
||||
$fields[] = $db->quoteName($target[$key]) . ' = ' . $db->quote($cell);
|
||||
}
|
||||
elseif(in_array($key, $data['target_headers']) && is_null($cell))
|
||||
{
|
||||
// if import data is null then set empty
|
||||
$fields[] = $db->quoteName($target[$key]) . " = ''";
|
||||
}
|
||||
}
|
||||
// load the defaults
|
||||
$fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
|
||||
$fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
|
||||
// Conditions for which records should be updated.
|
||||
$conditions = array(
|
||||
$db->quoteName('id') . ' = ' . $id
|
||||
);
|
||||
|
||||
$query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
elseif ($canCreate)
|
||||
{
|
||||
// insert item
|
||||
$query = $db->getQuery(true);
|
||||
// reset all buckets
|
||||
$columns = array();
|
||||
$values = array();
|
||||
$version = false;
|
||||
// Insert columns. Insert values.
|
||||
foreach($row as $key => $cell)
|
||||
{
|
||||
// ignore column
|
||||
if ('IGNORE' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// remove id
|
||||
if ('id' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// update created
|
||||
if ('created_by' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// update created
|
||||
if ('created' == $target[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Make sure the alias is incremented
|
||||
if ('alias' == $target[$key])
|
||||
{
|
||||
$cell = $this->getAlias($cell,$table);
|
||||
}
|
||||
// update version
|
||||
if ('version' == $target[$key])
|
||||
{
|
||||
$cell = 1;
|
||||
$version = true;
|
||||
}
|
||||
// set to insert array
|
||||
if(in_array($key, $data['target_headers']) && is_numeric($cell))
|
||||
{
|
||||
$columns[] = $target[$key];
|
||||
$values[] = $cell;
|
||||
}
|
||||
elseif(in_array($key, $data['target_headers']) && is_string($cell))
|
||||
{
|
||||
$columns[] = $target[$key];
|
||||
$values[] = $db->quote($cell);
|
||||
}
|
||||
elseif(in_array($key, $data['target_headers']) && is_null($cell))
|
||||
{
|
||||
// if import data is null then set empty
|
||||
$columns[] = $target[$key];
|
||||
$values[] = "''";
|
||||
}
|
||||
}
|
||||
// load the defaults
|
||||
$columns[] = 'created_by';
|
||||
$values[] = $db->quote($user->id);
|
||||
$columns[] = 'created';
|
||||
$values[] = $db->quote($todayDate);
|
||||
if (!$version)
|
||||
{
|
||||
$columns[] = 'version';
|
||||
$values[] = 1;
|
||||
}
|
||||
// Prepare the insert query.
|
||||
$query
|
||||
->insert($db->quoteName('#__componentbuilder_'.$table))
|
||||
->columns($db->quoteName($columns))
|
||||
->values(implode(',', $values));
|
||||
// Set the query using our newly populated query object and execute it.
|
||||
$db->setQuery($query);
|
||||
$done = $db->execute();
|
||||
if ($done)
|
||||
{
|
||||
$aId = $db->insertid();
|
||||
// make sure the access of asset is set
|
||||
ComponentbuilderHelper::setAsset($aId,$table);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getAlias($name,$type = false)
|
||||
{
|
||||
// sanitize the name to an alias
|
||||
if (Factory::getConfig()->get('unicodeslugs') == 1)
|
||||
{
|
||||
$alias = OutputFilter::stringURLUnicodeSlug($name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$alias = OutputFilter::stringURLSafe($name);
|
||||
}
|
||||
// must be a uniqe alias
|
||||
if ($type)
|
||||
{
|
||||
return $this->getUniqe($alias,'alias',$type);
|
||||
}
|
||||
return $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a uniqe value.
|
||||
*
|
||||
* @param string $field name.
|
||||
* @param string $value data.
|
||||
* @param string $type table.
|
||||
*
|
||||
* @return string New value.
|
||||
*/
|
||||
protected function getUniqe($value,$field,$type)
|
||||
{
|
||||
// insure the filed is always uniqe
|
||||
while (isset($this->uniqeValueArray[$type][$field][$value]))
|
||||
{
|
||||
$value = StringHelper::increment($value, 'dash');
|
||||
}
|
||||
$this->uniqeValueArray[$type][$field][$value] = $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function getAliasesUsed($table)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = $this->getDatabase();
|
||||
// first we check if there is a alias column
|
||||
$columns = $db->getTableColumns('#__componentbuilder_'.$table);
|
||||
if(isset($columns['alias'])){
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('alias')));
|
||||
$query->from($db->quoteName('#__componentbuilder_'.$table));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$aliases = $db->loadColumn();
|
||||
foreach($aliases as $alias)
|
||||
{
|
||||
$this->uniqeValueArray[$table]['alias'][$alias] = $alias;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1469,11 +1469,9 @@ class Joomla_componentModel extends AdminModel
|
||||
{
|
||||
$data['system_name'] = $data['name'];
|
||||
}
|
||||
|
||||
// make sure that the component code name is safe.
|
||||
if (isset($data['name_code']) && is_string($data['name_code']))
|
||||
{
|
||||
$data['name_code'] = ComponentCodeNameHelper::safe($data['name_code']);
|
||||
}
|
||||
$data['name_code'] = ComponentCodeNameHelper::safe($data['name_code']);
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (empty($data['guid']) && $data['id'] > 0)
|
||||
|
@ -340,156 +340,6 @@ class Joomla_modulesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_joomla_module table
|
||||
$query->from($db->quoteName('#__componentbuilder_joomla_module', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('joomla_module.access', 'com_componentbuilder.joomla_module.' . (int) $item->id) && $user->authorise('joomla_module.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode default
|
||||
$item->default = base64_decode($item->default);
|
||||
// decode php_preflight_update
|
||||
$item->php_preflight_update = base64_decode($item->php_preflight_update);
|
||||
// decode php_preflight_uninstall
|
||||
$item->php_preflight_uninstall = base64_decode($item->php_preflight_uninstall);
|
||||
// decode mod_code
|
||||
$item->mod_code = base64_decode($item->mod_code);
|
||||
// decode php_postflight_install
|
||||
$item->php_postflight_install = base64_decode($item->php_postflight_install);
|
||||
// decode php_postflight_update
|
||||
$item->php_postflight_update = base64_decode($item->php_postflight_update);
|
||||
// decode php_method_uninstall
|
||||
$item->php_method_uninstall = base64_decode($item->php_method_uninstall);
|
||||
// decode class_helper_header
|
||||
$item->class_helper_header = base64_decode($item->class_helper_header);
|
||||
// decode sql
|
||||
$item->sql = base64_decode($item->sql);
|
||||
// decode class_helper_code
|
||||
$item->class_helper_code = base64_decode($item->class_helper_code);
|
||||
// decode sql_uninstall
|
||||
$item->sql_uninstall = base64_decode($item->sql_uninstall);
|
||||
// decode readme
|
||||
$item->readme = base64_decode($item->readme);
|
||||
// decode php_script_construct
|
||||
$item->php_script_construct = base64_decode($item->php_script_construct);
|
||||
// decode php_preflight_install
|
||||
$item->php_preflight_install = base64_decode($item->php_preflight_install);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_joomla_module");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -27,6 +27,7 @@ use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use Joomla\CMS\Http\Http;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
@ -150,7 +151,7 @@ class LanguagesModel extends ListModel
|
||||
{
|
||||
$updateSite = $this->getUpdateSite();
|
||||
|
||||
$http = new JHttp;
|
||||
$http = new Http;
|
||||
|
||||
try
|
||||
{
|
||||
@ -405,128 +406,6 @@ class LanguagesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_language table
|
||||
$query->from($db->quoteName('#__componentbuilder_language', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.ordering ASC');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && $user->authorise('language.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_language");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -369,132 +369,6 @@ class LayoutsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_layout table
|
||||
$query->from($db->quoteName('#__componentbuilder_layout', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && $user->authorise('layout.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode php_view
|
||||
$item->php_view = base64_decode($item->php_view);
|
||||
// decode layout
|
||||
$item->layout = base64_decode($item->layout);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_layout");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -283,130 +283,6 @@ class PlaceholdersModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_placeholder table
|
||||
$query->from($db->quoteName('#__componentbuilder_placeholder', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && $user->authorise('placeholder.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode value
|
||||
$item->value = base64_decode($item->value);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_placeholder");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -30,9 +30,8 @@ use Joomla\Input\Input;
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use VDM\Joomla\FOF\Encrypt\AES;
|
||||
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
@ -220,104 +219,10 @@ class ServerModel extends AdminModel
|
||||
$item->username = rtrim($basic->decryptString($item->username), "\0");
|
||||
}
|
||||
}
|
||||
$this->sales_serverupdate_servervvvw = $item->id;
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list data.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getVydlinked_components()
|
||||
{
|
||||
// Get the user object.
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_joomla_component table
|
||||
$query->from($db->quoteName('#__componentbuilder_joomla_component', 'a'));
|
||||
|
||||
// Filter by sales_serverupdate_servervvvw global.
|
||||
$sales_serverupdate_servervvvw = $this->sales_serverupdate_servervvvw;
|
||||
if (is_numeric($sales_serverupdate_servervvvw ))
|
||||
{
|
||||
$query->where('a.sales_server = ' . (int) $sales_serverupdate_servervvvw . ' OR a.update_server = ' . (int) $sales_serverupdate_servervvvw, ' OR');
|
||||
}
|
||||
elseif (is_string($sales_serverupdate_servervvvw))
|
||||
{
|
||||
$query->where('a.sales_server = ' . $db->quote($sales_serverupdate_servervvvw) . ' OR a.update_server = ' . $db->quote($sales_serverupdate_servervvvw), ' OR');
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.update_server = -5');
|
||||
}
|
||||
|
||||
// Join over the asset groups.
|
||||
$query->select('ag.title AS access_level');
|
||||
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
|
||||
// Filter by access level.
|
||||
$_access = $this->getState('filter.access');
|
||||
if ($_access && is_numeric($_access))
|
||||
{
|
||||
$query->where('a.access = ' . (int) $_access);
|
||||
}
|
||||
elseif (UtilitiesArrayHelper::check($_access))
|
||||
{
|
||||
// Secure the array for the query
|
||||
$_access = ArrayHelper::toInteger($_access);
|
||||
// Filter by the Access Array.
|
||||
$query->where('a.access IN (' . implode(',', $_access) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.published ASC');
|
||||
$query->order('a.ordering ASC');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $user->authorise('joomla_component.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
|
@ -26,7 +26,6 @@ use Joomla\CMS\Helper\TagsHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
@ -351,178 +350,6 @@ class ServersModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_server table
|
||||
$query->from($db->quoteName('#__componentbuilder_server', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.ordering ASC');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Get the basic encryption key.
|
||||
$basickey = ComponentbuilderHelper::getCryptKey('basic');
|
||||
// Get the encryption object.
|
||||
$basic = new AES($basickey);
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && $user->authorise('server.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($basickey && !is_numeric($item->signature) && $item->signature === base64_encode(base64_decode($item->signature, true)))
|
||||
{
|
||||
// decrypt signature
|
||||
$item->signature = $basic->decryptString($item->signature);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->private_key) && $item->private_key === base64_encode(base64_decode($item->private_key, true)))
|
||||
{
|
||||
// decrypt private_key
|
||||
$item->private_key = $basic->decryptString($item->private_key);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->secret) && $item->secret === base64_encode(base64_decode($item->secret, true)))
|
||||
{
|
||||
// decrypt secret
|
||||
$item->secret = $basic->decryptString($item->secret);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->password) && $item->password === base64_encode(base64_decode($item->password, true)))
|
||||
{
|
||||
// decrypt password
|
||||
$item->password = $basic->decryptString($item->password);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->private) && $item->private === base64_encode(base64_decode($item->private, true)))
|
||||
{
|
||||
// decrypt private
|
||||
$item->private = $basic->decryptString($item->private);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->path) && $item->path === base64_encode(base64_decode($item->path, true)))
|
||||
{
|
||||
// decrypt path
|
||||
$item->path = $basic->decryptString($item->path);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->port) && $item->port === base64_encode(base64_decode($item->port, true)))
|
||||
{
|
||||
// decrypt port
|
||||
$item->port = $basic->decryptString($item->port);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->host) && $item->host === base64_encode(base64_decode($item->host, true)))
|
||||
{
|
||||
// decrypt host
|
||||
$item->host = $basic->decryptString($item->host);
|
||||
}
|
||||
if ($basickey && !is_numeric($item->username) && $item->username === base64_encode(base64_decode($item->username, true)))
|
||||
{
|
||||
// decrypt username
|
||||
$item->username = $basic->decryptString($item->username);
|
||||
}
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_server");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -514,171 +514,6 @@ class Site_viewsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_site_view table
|
||||
$query->from($db->quoteName('#__componentbuilder_site_view', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
|
||||
// do not use these filters in the export method
|
||||
if (!isset($_export) || !$_export)
|
||||
{
|
||||
// Filtering "joomla components"
|
||||
$filter_joomla_component = $this->state->get("filter.joomla_component");
|
||||
if ($filter_joomla_component !== null && !empty($filter_joomla_component))
|
||||
{
|
||||
if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_site_views')) !== null)
|
||||
{
|
||||
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && $user->authorise('site_view.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode js_document
|
||||
$item->js_document = base64_decode($item->js_document);
|
||||
// decode javascript_file
|
||||
$item->javascript_file = base64_decode($item->javascript_file);
|
||||
// decode default
|
||||
$item->default = base64_decode($item->default);
|
||||
// decode css_document
|
||||
$item->css_document = base64_decode($item->css_document);
|
||||
// decode css
|
||||
$item->css = base64_decode($item->css);
|
||||
// decode php_ajaxmethod
|
||||
$item->php_ajaxmethod = base64_decode($item->php_ajaxmethod);
|
||||
// decode php_document
|
||||
$item->php_document = base64_decode($item->php_document);
|
||||
// decode php_view
|
||||
$item->php_view = base64_decode($item->php_view);
|
||||
// decode php_jview_display
|
||||
$item->php_jview_display = base64_decode($item->php_jview_display);
|
||||
// decode php_jview
|
||||
$item->php_jview = base64_decode($item->php_jview);
|
||||
// decode php_controller
|
||||
$item->php_controller = base64_decode($item->php_controller);
|
||||
// decode php_model
|
||||
$item->php_model = base64_decode($item->php_model);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_site_view");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -461,130 +461,6 @@ class SnippetsModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_snippet table
|
||||
$query->from($db->quoteName('#__componentbuilder_snippet', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && $user->authorise('snippet.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode snippet
|
||||
$item->snippet = base64_decode($item->snippet);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_snippet");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -369,132 +369,6 @@ class TemplatesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_template table
|
||||
$query->from($db->quoteName('#__componentbuilder_template', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && $user->authorise('template.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode php_view
|
||||
$item->php_view = base64_decode($item->php_view);
|
||||
// decode template
|
||||
$item->template = base64_decode($item->template);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_template");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
@ -281,130 +281,6 @@ class Validation_rulesModel extends ListModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get list export data.
|
||||
*
|
||||
* @param array $pks The ids of the items to get
|
||||
* @param JUser $user The user making the request
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExportData($pks, $user = null)
|
||||
{
|
||||
// setup the query
|
||||
if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks)
|
||||
{
|
||||
// Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
|
||||
$_export = true;
|
||||
// Get the user object if not set.
|
||||
if (!isset($user) || !ObjectHelper::check($user))
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
}
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select some fields
|
||||
$query->select('a.*');
|
||||
|
||||
// From the componentbuilder_validation_rule table
|
||||
$query->from($db->quoteName('#__componentbuilder_validation_rule', 'a'));
|
||||
// The bulk export path
|
||||
if ('bulk' === $pks)
|
||||
{
|
||||
$query->where('a.id > 0');
|
||||
}
|
||||
// A large array of ID's will not work out well
|
||||
elseif ($pks_size > 500)
|
||||
{
|
||||
// Use lowest ID
|
||||
$query->where('a.id >= ' . (int) min($pks));
|
||||
// Use highest ID
|
||||
$query->where('a.id <= ' . (int) max($pks));
|
||||
}
|
||||
// The normal default path
|
||||
else
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Order the results by ordering
|
||||
$query->order('a.id desc');
|
||||
|
||||
// Load the items
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Set values to display correctly.
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Remove items the user can't access.
|
||||
$access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && $user->authorise('validation_rule.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode php
|
||||
$item->php = base64_decode($item->php);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
unset($item->checked_out_time);
|
||||
}
|
||||
}
|
||||
// Add headers to items array.
|
||||
$headers = $this->getExImPortHeaders();
|
||||
if (ObjectHelper::check($headers))
|
||||
{
|
||||
array_unshift($items,$headers);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get header.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getExImPortHeaders()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
// get the columns
|
||||
$columns = $db->getTableColumns("#__componentbuilder_validation_rule");
|
||||
if (UtilitiesArrayHelper::check($columns))
|
||||
{
|
||||
// remove the headers you don't import/export.
|
||||
unset($columns['asset_id']);
|
||||
unset($columns['checked_out']);
|
||||
unset($columns['checked_out_time']);
|
||||
$headers = new \stdClass();
|
||||
foreach ($columns as $column => $type)
|
||||
{
|
||||
$headers->{$column} = $column;
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
|
Reference in New Issue
Block a user