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,14 +12,22 @@
// 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\Filter\InputFilter;
use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\UCM\UCMType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Helper\TagsHelper;
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
@ -130,16 +138,16 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
* @return Table A database object
*
* @since 1.6
*/
public function getTable($type = 'custom_admin_view', $prefix = 'ComponentbuilderTable', $config = array())
public function getTable($type = 'custom_admin_view', $prefix = 'ComponentbuilderTable', $config = [])
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
return Table::getInstance($type, $prefix, $config);
}
@ -175,13 +183,12 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
ComponentbuilderHelper::set($this->vastDevMod, 'custom_admin_view__'.$id);
ComponentbuilderHelper::set('custom_admin_view__'.$id, $this->vastDevMod);
// set a return value if found
$jinput = JFactory::getApplication()->input;
$jinput = Factory::getApplication()->input;
$return = $jinput->get('return', null, 'base64');
ComponentbuilderHelper::set($this->vastDevMod . '__return', $return);
// set a GUID value if found
if (isset($item) && ObjectHelper::check($item) && isset($item->guid)
&& method_exists('ComponentbuilderHelper', 'validGUID')
&& ComponentbuilderHelper::validGUID($item->guid))
&& GuidHelper::valid($item->guid))
{
ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid);
}
@ -190,7 +197,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
return $this->vastDevMod;
}
/**
* Method to get a single record.
*
@ -345,13 +352,12 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
ComponentbuilderHelper::set($this->vastDevMod, 'custom_admin_view__'.$id);
ComponentbuilderHelper::set('custom_admin_view__'.$id, $this->vastDevMod);
// set a return value if found
$jinput = JFactory::getApplication()->input;
$jinput = Factory::getApplication()->input;
$return = $jinput->get('return', null, 'base64');
ComponentbuilderHelper::set($this->vastDevMod . '__return', $return);
// set a GUID value if found
if (isset($item) && ObjectHelper::check($item) && isset($item->guid)
&& method_exists('ComponentbuilderHelper', 'validGUID')
&& ComponentbuilderHelper::validGUID($item->guid))
&& GuidHelper::valid($item->guid))
{
ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid);
}
@ -371,7 +377,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
}
$item->custom_button = $bucket;
// update the fields
$objectUpdate = new stdClass();
$objectUpdate = new \stdClass();
$objectUpdate->id = (int) $item->id;
$objectUpdate->custom_button = json_encode($bucket);
// be sure to update the table if we found repeatable fields that are still not converted
@ -393,7 +399,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform'))
public function getForm($data = [], $loadData = true, $options = array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
@ -420,7 +426,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
return false;
}
$jinput = JFactory::getApplication()->input;
$jinput = Factory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we need to check for that first.
if ($jinput->get('a_id'))
@ -433,7 +439,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
$id = $jinput->get('id', 0, 'INT');
}
$user = JFactory::getUser();
$user = Factory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
@ -490,7 +496,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
}
// update all editors to use this components global editor
$global_editor = JComponentHelper::getParams('com_componentbuilder')->get('editor', 'none');
$global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none');
// now get all the editor fields
$editors = $form->getXml()->xpath("//field[@type='editor']");
// check if we found any
@ -518,13 +524,13 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
/**
* Method to get the script that have to be included on the form
*
* @return string script files
* @return string script files
*/
public function getScript()
{
return 'media/com_componentbuilder/js/custom_admin_view.js';
}
/**
* Method to test whether a record can be deleted.
*
@ -543,7 +549,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
return;
}
$user = JFactory::getUser();
$user = Factory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('core.delete', 'com_componentbuilder.custom_admin_view.' . (int) $record->id);
}
@ -561,8 +567,8 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
$recordId = (!empty($record->id)) ? $record->id : 0;
$user = Factory::getUser();
$recordId = $record->id ?? 0;
if ($recordId)
{
@ -576,28 +582,28 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// In the absence of better information, revert to the component permissions.
return parent::canEditState($record);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = array(), $key = 'id')
protected function allowEdit($data = [], $key = 'id')
{
// Check specific edit permission then general edit permission.
$user = JFactory::getUser();
$user = Factory::getUser();
return $user->authorise('core.edit', 'com_componentbuilder.custom_admin_view.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_componentbuilder');
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
* @param Table $table A Table object.
*
* @return void
*
@ -605,19 +611,19 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
$date = Factory::getDate();
$user = Factory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
@ -629,7 +635,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__componentbuilder_custom_admin_view'));
@ -644,7 +650,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
@ -659,10 +665,10 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
*
* @since 1.6
*/
protected function loadFormData()
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_componentbuilder.edit.custom_admin_view.data', array());
$data = Factory::getApplication()->getUserState('com_componentbuilder.edit.custom_admin_view.data', []);
if (empty($data))
{
@ -685,7 +691,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
{
return array('guid');
}
/**
* Method to delete one or more records.
*
@ -701,7 +707,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
{
return false;
}
return true;
}
@ -721,10 +727,10 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
{
return false;
}
return true;
}
}
/**
* Method to perform batch operations on an item or a set of items.
*
@ -750,30 +756,30 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
$this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = ComponentbuilderHelper::getActions('custom_admin_view');
$this->batchSet = true;
$this->user = Factory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new UCMType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = ComponentbuilderHelper::getActions('custom_admin_view');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
$this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new JUcmType;
$type = new UCMType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
@ -810,8 +816,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
$this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
@ -837,7 +842,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->user = Factory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = ComponentbuilderHelper::getActions('custom_admin_view');
@ -863,7 +868,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
$values['published'] = 0;
}
$newIds = array();
$newIds = [];
// Parent exists so let's proceed
while (!empty($pks))
{
@ -876,7 +881,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
if (!$this->user->authorise('core.edit', $contexts[$pk]))
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
$this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
@ -892,19 +897,19 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
$this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Only for strings
if (ComponentbuilderHelper::checkString($this->table->name) && !is_numeric($this->table->name))
if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name))
{
$this->table->name = $this->generateUnique('name',$this->table->name);
}
// insert all set values
if (ComponentbuilderHelper::checkArray($values))
if (UtilitiesArrayHelper::check($values))
{
foreach ($values as $key => $value)
{
@ -916,7 +921,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
}
// update all unique fields
if (ComponentbuilderHelper::checkArray($uniqueFields))
if (UtilitiesArrayHelper::check($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
@ -980,7 +985,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->user = Factory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = ComponentbuilderHelper::getActions('custom_admin_view');
@ -988,7 +993,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
if (!$this->canDo->get('core.edit') && !$this->canDo->get('custom_admin_view.batch'))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
@ -1005,7 +1010,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
{
if (!$this->user->authorise('core.edit', $contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
@ -1021,13 +1026,13 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
$this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// insert all set values.
if (ComponentbuilderHelper::checkArray($values))
if (UtilitiesArrayHelper::check($values))
{
foreach ($values as $key => $value)
{
@ -1071,7 +1076,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
return true;
}
/**
* Method to save the form data.
*
@ -1083,15 +1088,15 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
$input = Factory::getApplication()->input;
$filter = InputFilter::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) && isset($data['metadata']['author']))
{
$data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
$metadata = new JRegistry;
$metadata = new Registry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
@ -1141,7 +1146,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// Set the custom_get items to data.
if (isset($data['custom_get']) && is_array($data['custom_get']))
{
$custom_get = new JRegistry;
$custom_get = new Registry;
$custom_get->loadArray($data['custom_get']);
$data['custom_get'] = (string) $custom_get;
}
@ -1154,7 +1159,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// Set the libraries items to data.
if (isset($data['libraries']) && is_array($data['libraries']))
{
$libraries = new JRegistry;
$libraries = new Registry;
$libraries->loadArray($data['libraries']);
$data['libraries'] = (string) $libraries;
}
@ -1167,7 +1172,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// Set the ajax_input items to data.
if (isset($data['ajax_input']) && is_array($data['ajax_input']))
{
$ajax_input = new JRegistry;
$ajax_input = new Registry;
$ajax_input->loadArray($data['ajax_input']);
$data['ajax_input'] = (string) $ajax_input;
}
@ -1180,7 +1185,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// Set the custom_button items to data.
if (isset($data['custom_button']) && is_array($data['custom_button']))
{
$custom_button = new JRegistry;
$custom_button = new Registry;
$custom_button->loadArray($data['custom_button']);
$data['custom_button'] = (string) $custom_button;
}
@ -1261,11 +1266,11 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
{
$data['php_model'] = base64_encode($data['php_model']);
}
// Set the Params Items to data
if (isset($data['params']) && is_array($data['params']))
{
$params = new JRegistry;
$params = new Registry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
@ -1275,7 +1280,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (ComponentbuilderHelper::checkArray($uniqueFields))
if (UtilitiesArrayHelper::check($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
@ -1283,14 +1288,14 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
@ -1303,7 +1308,6 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
@ -1329,7 +1333,7 @@ class ComponentbuilderModelCustom_admin_view extends AdminModel
// Alter the title
$table = $this->getTable();
while ($table->load(array('title' => $title)))
while ($table->load(['title' => $title]))
{
$title = StringHelper::increment($title);
}