Stable release of v3.2.0-beta1

Move beta to main repo. Fix #1053 so that the right and left tabs display correctly in Joomla 4&5.
This commit is contained in:
2024-03-02 22:10:30 +02:00
parent 3c91a5cdbb
commit d1e1a56671
1786 changed files with 73608 additions and 37437 deletions

View File

@ -12,20 +12,28 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Helper\TagsHelper;
use VDM\Joomla\Utilities\FormHelper as JCBFormHelper;
use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Custom_admin_views List Model
*/
class ComponentbuilderModelCustom_admin_views extends ListModel
{
public function __construct($config = array())
public function __construct($config = [])
{
if (empty($config['filter_fields']))
{
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
@ -67,13 +75,13 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
'onchange' => 'this.form.submit();',
);
$options = array(
'' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -'
'' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -'
);
// check if we have joomla components
if (($joomla_components = JCBFilterHelper::names('joomla_component')) !== null)
{
$options = array(
'' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -'
'' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -'
);
// make sure we do not lose the key values in normal merge
$options = $options + $joomla_components;
@ -103,7 +111,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$app = Factory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
@ -181,7 +189,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
@ -196,12 +204,12 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$items = parent::getItems();
// Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items))
if (UtilitiesArrayHelper::check($items))
{
// Get the user object if not set.
if (!isset($user) || !ComponentbuilderHelper::checkObject($user))
if (!isset($user) || !ObjectHelper::check($user))
{
$user = JFactory::getUser();
$user = Factory::getUser();
}
foreach ($items as $nr => &$item)
{
@ -217,7 +225,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
}
// set selection value to a translatable value
if (ComponentbuilderHelper::checkArray($items))
if (UtilitiesArrayHelper::check($items))
{
foreach ($items as $nr => &$item)
{
@ -228,7 +236,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
}
}
// return items
return $items;
}
@ -236,7 +244,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
/**
* Method to convert selection values to translatable string.
*
* @return translatable string
* @return string The translatable string.
*/
public function selectionTranslation($value,$name)
{
@ -248,7 +256,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
0 => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO'
);
// Now check if value is found in this array
if (isset($add_php_ajaxArray[$value]) && ComponentbuilderHelper::checkString($add_php_ajaxArray[$value]))
if (isset($add_php_ajaxArray[$value]) && StringHelper::check($add_php_ajaxArray[$value]))
{
return $add_php_ajaxArray[$value];
}
@ -261,25 +269,25 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
0 => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO'
);
// Now check if value is found in this array
if (isset($add_custom_buttonArray[$value]) && ComponentbuilderHelper::checkString($add_custom_buttonArray[$value]))
if (isset($add_custom_buttonArray[$value]) && StringHelper::check($add_custom_buttonArray[$value]))
{
return $add_custom_buttonArray[$value];
}
}
return $value;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = JFactory::getUser();
$user = Factory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$db = Factory::getDBO();
$query = $db->getQuery(true);
// Select some fields
@ -331,7 +339,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
{
$query->where('a.access = ' . (int) $_access);
}
elseif (ComponentbuilderHelper::checkArray($_access))
elseif (UtilitiesArrayHelper::check($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
@ -372,11 +380,11 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$query->where('a.main_get = ' . (int) $_main_get);
}
}
elseif (ComponentbuilderHelper::checkString($_main_get))
elseif (StringHelper::check($_main_get))
{
$query->where('a.main_get = ' . $db->quote($db->escape($_main_get)));
}
elseif (ComponentbuilderHelper::checkArray($_main_get))
elseif (UtilitiesArrayHelper::check($_main_get))
{
// Secure the array for the query
$_main_get = array_map( function ($val) use(&$db) {
@ -391,7 +399,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
return (int) $val;
}
}
elseif (ComponentbuilderHelper::checkString($val))
elseif (StringHelper::check($val))
{
return $db->quote($db->escape($val));
}
@ -412,7 +420,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$query->where('a.add_php_ajax = ' . (int) $_add_php_ajax);
}
}
elseif (ComponentbuilderHelper::checkString($_add_php_ajax))
elseif (StringHelper::check($_add_php_ajax))
{
$query->where('a.add_php_ajax = ' . $db->quote($db->escape($_add_php_ajax)));
}
@ -429,16 +437,18 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$query->where('a.add_custom_button = ' . (int) $_add_custom_button);
}
}
elseif (ComponentbuilderHelper::checkString($_add_custom_button))
elseif (StringHelper::check($_add_custom_button))
{
$query->where('a.add_custom_button = ' . $db->quote($db->escape($_add_custom_button)));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.id');
$orderDirn = $this->state->get('list.direction', 'desc');
$orderCol = $this->getState('list.ordering', 'a.id');
$orderDirn = $this->getState('list.direction', 'desc');
if ($orderCol != '')
{
// Check that the order direction is valid encase we have a field called direction as part of filers.
$orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc';
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
@ -456,17 +466,17 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
public function getExportData($pks, $user = null)
{
// setup the query
if (($pks_size = ComponentbuilderHelper::checkArray($pks)) !== false || 'bulk' === $pks)
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) || !ComponentbuilderHelper::checkObject($user))
if (!isset($user) || !ObjectHelper::check($user))
{
$user = JFactory::getUser();
$user = Factory::getUser();
}
// Create a new query object.
$db = JFactory::getDBO();
$db = Factory::getDBO();
$query = $db->getQuery(true);
// Select some fields
@ -529,7 +539,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$items = $db->loadObjectList();
// Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items))
if (UtilitiesArrayHelper::check($items))
{
foreach ($items as $nr => &$item)
{
@ -573,7 +583,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (ComponentbuilderHelper::checkObject($headers))
if (ObjectHelper::check($headers))
{
array_unshift($items,$headers);
}
@ -591,16 +601,16 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
public function getExImPortHeaders()
{
// Get a db connection.
$db = JFactory::getDbo();
$db = Factory::getDbo();
// get the columns
$columns = $db->getTableColumns("#__componentbuilder_custom_admin_view");
if (ComponentbuilderHelper::checkArray($columns))
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();
$headers = new \stdClass();
foreach ($columns as $column => $type)
{
$headers->{$column} = $column;
@ -609,7 +619,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
}
return false;
}
/**
* Method to get a store id based on model configuration state.
*
@ -624,13 +634,13 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (ComponentbuilderHelper::checkArray($_access))
if (UtilitiesArrayHelper::check($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| ComponentbuilderHelper::checkString($_access))
|| StringHelper::check($_access))
{
$id .= ':' . $_access;
}
@ -639,13 +649,13 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$id .= ':' . $this->getState('filter.modified_by');
// Check if the value is an array
$_main_get = $this->getState('filter.main_get');
if (ComponentbuilderHelper::checkArray($_main_get))
if (UtilitiesArrayHelper::check($_main_get))
{
$id .= ':' . implode(':', $_main_get);
}
// Check if this is only an number or string
elseif (is_numeric($_main_get)
|| ComponentbuilderHelper::checkString($_main_get))
|| StringHelper::check($_main_get))
{
$id .= ':' . $_main_get;
}
@ -661,19 +671,18 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
/**
* Build an SQL query to checkin all items left checked out longer then a set time.
*
* @return a bool
*
* @return bool
* @since 3.2.0
*/
protected function checkInNow()
protected function checkInNow(): bool
{
// Get set check in time
$time = JComponentHelper::getParams('com_componentbuilder')->get('check_in');
$time = ComponentHelper::getParams('com_componentbuilder')->get('check_in');
if ($time)
{
// Get a db connection.
$db = JFactory::getDbo();
$db = Factory::getDbo();
// Reset query.
$query = $db->getQuery(true);
$query->select('*');
@ -685,7 +694,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
if ($db->getNumRows())
{
// Get Yesterdays date.
$date = JFactory::getDate()->modify($time)->toSql();
$date = Factory::getDate()->modify($time)->toSql();
// Reset query.
$query = $db->getQuery(true);
@ -706,7 +715,7 @@ class ComponentbuilderModelCustom_admin_views extends ListModel
$db->setQuery($query);
$db->execute();
return $db->execute();
}
}