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:
@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user