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,20 +12,27 @@
|
||||
// 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\ArrayHelper as UtilitiesArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
|
||||
/**
|
||||
* Joomla_plugins List Model
|
||||
*/
|
||||
class ComponentbuilderModelJoomla_plugins 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',
|
||||
@ -85,7 +92,7 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
if (($plugin_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate_plugins', $url)) !== false)
|
||||
{
|
||||
// get the app object
|
||||
$app = JFactory::getApplication();
|
||||
$app = Factory::getApplication();
|
||||
// set the table names
|
||||
$tables = array();
|
||||
$tables['e'] = 'class_extends';
|
||||
@ -105,7 +112,7 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
{
|
||||
// extract the boilerplate class extends and check if already set
|
||||
if (($classExtends = ComponentbuilderHelper::extractBoilerplateClassExtends($fooClass, 'plugins')) !== false &&
|
||||
($classExtendsID = ComponentbuilderHelper::getVar('class_extends', $classExtends, 'name', 'id')) === false)
|
||||
($classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id')) === false)
|
||||
{
|
||||
// load the extends class name
|
||||
$class = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $classExtends);
|
||||
@ -118,17 +125,17 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
// store the class
|
||||
$this->storePluginBoilerplate($tables['e'], $models['e'], $class, $app);
|
||||
// work around
|
||||
$classExtendsID = ComponentbuilderHelper::getVar('class_extends', $classExtends, 'name', 'id');
|
||||
$classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id');
|
||||
}
|
||||
// set plugin group if not already set
|
||||
if (($pluginGroupID = ComponentbuilderHelper::getVar('joomla_plugin_group', $tree->path, 'name', 'id')) === false)
|
||||
if (($pluginGroupID = GetHelper::var('joomla_plugin_group', $tree->path, 'name', 'id')) === false)
|
||||
{
|
||||
// load the plugin group name
|
||||
$pluginGroup = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $tree->path, 'class_extends' => $classExtendsID);
|
||||
// store the group
|
||||
$this->storePluginBoilerplate($tables['g'], $models['g'], $pluginGroup, $app);
|
||||
// work around
|
||||
$pluginGroupID = ComponentbuilderHelper::getVar('joomla_plugin_group', $tree->path, 'name', 'id');
|
||||
$pluginGroupID = GetHelper::var('joomla_plugin_group', $tree->path, 'name', 'id');
|
||||
}
|
||||
// extract the boilerplate class property and methods
|
||||
if (($classProperiesMethods = ComponentbuilderHelper::extractBoilerplateClassPropertiesMethods($fooClass, $classExtends, 'plugins', $pluginGroupID)) !== false)
|
||||
@ -205,7 +212,7 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
// Attempt to save the data.
|
||||
if (!$method->save($validData))
|
||||
{
|
||||
$app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BOILERPLATE_PLUGIN_S_DATA_COULD_NOT_BE_SAVED', $table), 'error');
|
||||
$app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BOILERPLATE_PLUGIN_S_DATA_COULD_NOT_BE_SAVED', $table), 'error');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -225,7 +232,7 @@ class ComponentbuilderModelJoomla_plugins 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'))
|
||||
@ -282,7 +289,7 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
@ -297,12 +304,12 @@ class ComponentbuilderModelJoomla_plugins 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)
|
||||
{
|
||||
@ -316,22 +323,22 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -368,7 +375,7 @@ class ComponentbuilderModelJoomla_plugins 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);
|
||||
@ -409,7 +416,7 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
$query->where('a.class_extends = ' . (int) $_class_extends);
|
||||
}
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkString($_class_extends))
|
||||
elseif (StringHelper::check($_class_extends))
|
||||
{
|
||||
$query->where('a.class_extends = ' . $db->quote($db->escape($_class_extends)));
|
||||
}
|
||||
@ -426,22 +433,24 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
$query->where('a.joomla_plugin_group = ' . (int) $_joomla_plugin_group);
|
||||
}
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkString($_joomla_plugin_group))
|
||||
elseif (StringHelper::check($_joomla_plugin_group))
|
||||
{
|
||||
$query->where('a.joomla_plugin_group = ' . $db->quote($db->escape($_joomla_plugin_group)));
|
||||
}
|
||||
|
||||
// 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.
|
||||
*
|
||||
@ -456,13 +465,13 @@ class ComponentbuilderModelJoomla_plugins 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;
|
||||
}
|
||||
@ -479,19 +488,18 @@ class ComponentbuilderModelJoomla_plugins 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('*');
|
||||
@ -503,7 +511,7 @@ class ComponentbuilderModelJoomla_plugins 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);
|
||||
|
||||
@ -524,7 +532,7 @@ class ComponentbuilderModelJoomla_plugins extends ListModel
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$db->execute();
|
||||
return $db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user