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:
@ -12,21 +12,29 @@
|
||||
// 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\Component\Helper as JCBHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper;
|
||||
use VDM\Joomla\Utilities\FormHelper as JCBFormHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
/**
|
||||
* Powers List Model
|
||||
*/
|
||||
class ComponentbuilderModelPowers 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 ComponentbuilderModelPowers extends ListModel
|
||||
'onchange' => 'this.form.submit();',
|
||||
);
|
||||
$options = array(
|
||||
'' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_NAMESPACE_FOUND') . ' -'
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_NAMESPACE_FOUND') . ' -'
|
||||
);
|
||||
// check if we have namespace (and limit to an extension if it is set)
|
||||
if (($namespaces = JCBFilterHelper::namespaces()) !== null)
|
||||
{
|
||||
$options = array(
|
||||
'' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_A_NAMESPACE') . ' -'
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_A_NAMESPACE') . ' -'
|
||||
);
|
||||
// make sure we do not lose the key values in normal merge
|
||||
$options = $options + $namespaces;
|
||||
@ -101,7 +109,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
'onchange' => 'this.form.submit();',
|
||||
);
|
||||
$options = array(
|
||||
'' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_PATHS_FOUND') . ' -'
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_PATHS_FOUND') . ' -'
|
||||
);
|
||||
|
||||
// add the paths found in global settings
|
||||
@ -110,7 +118,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
$core = $params->get('super_powers_core', 'joomla/super-powers');
|
||||
|
||||
$options = array(
|
||||
'' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_APPROVED_PATH') . ' -',
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_APPROVED_PATH') . ' -',
|
||||
$core => $core
|
||||
);
|
||||
|
||||
@ -165,7 +173,7 @@ class ComponentbuilderModelPowers 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'))
|
||||
@ -236,7 +244,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
@ -251,12 +259,12 @@ class ComponentbuilderModelPowers 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)
|
||||
{
|
||||
@ -279,7 +287,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
}
|
||||
|
||||
// set selection value to a translatable value
|
||||
if (ComponentbuilderHelper::checkArray($items))
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
@ -290,7 +298,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
@ -298,7 +306,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
/**
|
||||
* Method to convert selection values to translatable string.
|
||||
*
|
||||
* @return translatable string
|
||||
* @return string The translatable string.
|
||||
*/
|
||||
public function selectionTranslation($value,$name)
|
||||
{
|
||||
@ -313,7 +321,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
'trait' => 'COM_COMPONENTBUILDER_POWER_TRAIT'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
if (isset($typeArray[$value]) && ComponentbuilderHelper::checkString($typeArray[$value]))
|
||||
if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value]))
|
||||
{
|
||||
return $typeArray[$value];
|
||||
}
|
||||
@ -326,25 +334,25 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
1 => 'COM_COMPONENTBUILDER_POWER_APPROVED'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
if (isset($approvedArray[$value]) && ComponentbuilderHelper::checkString($approvedArray[$value]))
|
||||
if (isset($approvedArray[$value]) && StringHelper::check($approvedArray[$value]))
|
||||
{
|
||||
return $approvedArray[$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
|
||||
@ -411,7 +419,7 @@ class ComponentbuilderModelPowers 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);
|
||||
@ -452,11 +460,11 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
$query->where('a.type = ' . (int) $_type);
|
||||
}
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkString($_type))
|
||||
elseif (StringHelper::check($_type))
|
||||
{
|
||||
$query->where('a.type = ' . $db->quote($db->escape($_type)));
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkArray($_type))
|
||||
elseif (UtilitiesArrayHelper::check($_type))
|
||||
{
|
||||
// Secure the array for the query
|
||||
$_type = array_map( function ($val) use(&$db) {
|
||||
@ -471,7 +479,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
return (int) $val;
|
||||
}
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkString($val))
|
||||
elseif (StringHelper::check($val))
|
||||
{
|
||||
return $db->quote($db->escape($val));
|
||||
}
|
||||
@ -492,22 +500,24 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
$query->where('a.approved = ' . (int) $_approved);
|
||||
}
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkString($_approved))
|
||||
elseif (StringHelper::check($_approved))
|
||||
{
|
||||
$query->where('a.approved = ' . $db->quote($db->escape($_approved)));
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
@ -522,13 +532,13 @@ class ComponentbuilderModelPowers 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;
|
||||
}
|
||||
@ -537,13 +547,13 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
$id .= ':' . $this->getState('filter.modified_by');
|
||||
// Check if the value is an array
|
||||
$_type = $this->getState('filter.type');
|
||||
if (ComponentbuilderHelper::checkArray($_type))
|
||||
if (UtilitiesArrayHelper::check($_type))
|
||||
{
|
||||
$id .= ':' . implode(':', $_type);
|
||||
}
|
||||
// Check if this is only an number or string
|
||||
elseif (is_numeric($_type)
|
||||
|| ComponentbuilderHelper::checkString($_type))
|
||||
|| StringHelper::check($_type))
|
||||
{
|
||||
$id .= ':' . $_type;
|
||||
}
|
||||
@ -558,19 +568,18 @@ class ComponentbuilderModelPowers 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('*');
|
||||
@ -582,7 +591,7 @@ class ComponentbuilderModelPowers 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);
|
||||
|
||||
@ -603,7 +612,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$db->execute();
|
||||
return $db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user