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,10 +12,21 @@
|
||||
// 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\ArrayHelper as UtilitiesArrayHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
|
||||
/**
|
||||
* Componentbuilder Component_mysql_tweaks Admin Model
|
||||
@ -65,18 +76,18 @@ class ComponentbuilderModelComponent_mysql_tweaks 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 = 'component_mysql_tweaks', $prefix = 'ComponentbuilderTable', $config = array())
|
||||
public function getTable($type = 'component_mysql_tweaks', $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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to get a single record.
|
||||
*
|
||||
@ -115,7 +126,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
}
|
||||
|
||||
// update the fields
|
||||
$objectUpdate = new stdClass();
|
||||
$objectUpdate = new \stdClass();
|
||||
$objectUpdate->id = (int) $item->id;
|
||||
// repeatable values to check
|
||||
$arrayChecker = array(
|
||||
@ -160,7 +171,7 @@ class ComponentbuilderModelComponent_mysql_tweaks 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;
|
||||
@ -187,7 +198,7 @@ class ComponentbuilderModelComponent_mysql_tweaks 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'))
|
||||
@ -200,7 +211,7 @@ class ComponentbuilderModelComponent_mysql_tweaks 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.
|
||||
@ -263,13 +274,13 @@ class ComponentbuilderModelComponent_mysql_tweaks 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/component_mysql_tweaks.js';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
@ -288,7 +299,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
return;
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
$user = Factory::getUser();
|
||||
// The record has been set. Check the record permissions.
|
||||
return $user->authorise('component_mysql_tweaks.delete', 'com_componentbuilder.component_mysql_tweaks.' . (int) $record->id);
|
||||
}
|
||||
@ -306,8 +317,8 @@ class ComponentbuilderModelComponent_mysql_tweaks 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)
|
||||
{
|
||||
@ -321,28 +332,28 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
// In the absence of better information, revert to the component permissions.
|
||||
return $user->authorise('component_mysql_tweaks.edit.state', 'com_componentbuilder');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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('component_mysql_tweaks.edit', 'com_componentbuilder.component_mysql_tweaks.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_mysql_tweaks.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
|
||||
*
|
||||
@ -350,19 +361,19 @@ class ComponentbuilderModelComponent_mysql_tweaks 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();
|
||||
@ -374,7 +385,7 @@ class ComponentbuilderModelComponent_mysql_tweaks 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_component_mysql_tweaks'));
|
||||
@ -389,7 +400,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->id;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($table->id))
|
||||
{
|
||||
// Increment the items version number.
|
||||
@ -404,10 +415,10 @@ class ComponentbuilderModelComponent_mysql_tweaks 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.component_mysql_tweaks.data', array());
|
||||
$data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_mysql_tweaks.data', []);
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
@ -430,7 +441,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to delete one or more records.
|
||||
*
|
||||
@ -446,7 +457,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -466,10 +477,10 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to perform batch operations on an item or a set of items.
|
||||
*
|
||||
@ -495,30 +506,30 @@ class ComponentbuilderModelComponent_mysql_tweaks 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('component_mysql_tweaks');
|
||||
$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('component_mysql_tweaks');
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -555,8 +566,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
|
||||
if (!$done)
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||
|
||||
$this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -582,7 +592,7 @@ class ComponentbuilderModelComponent_mysql_tweaks 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('component_mysql_tweaks');
|
||||
@ -608,7 +618,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
$values['published'] = 0;
|
||||
}
|
||||
|
||||
$newIds = array();
|
||||
$newIds = [];
|
||||
// Parent exists so let's proceed
|
||||
while (!empty($pks))
|
||||
{
|
||||
@ -621,7 +631,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
if (!$this->user->authorise('component_mysql_tweaks.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;
|
||||
}
|
||||
|
||||
@ -637,19 +647,19 @@ class ComponentbuilderModelComponent_mysql_tweaks 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->joomla_component) && !is_numeric($this->table->joomla_component))
|
||||
if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component))
|
||||
{
|
||||
$this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component);
|
||||
}
|
||||
|
||||
// insert all set values
|
||||
if (ComponentbuilderHelper::checkArray($values))
|
||||
if (UtilitiesArrayHelper::check($values))
|
||||
{
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
@ -661,7 +671,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
}
|
||||
|
||||
// update all unique fields
|
||||
if (ComponentbuilderHelper::checkArray($uniqueFields))
|
||||
if (UtilitiesArrayHelper::check($uniqueFields))
|
||||
{
|
||||
foreach ($uniqueFields as $uniqueField)
|
||||
{
|
||||
@ -725,7 +735,7 @@ class ComponentbuilderModelComponent_mysql_tweaks 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('component_mysql_tweaks');
|
||||
@ -733,7 +743,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
|
||||
if (!$this->canDo->get('component_mysql_tweaks.edit') && !$this->canDo->get('component_mysql_tweaks.batch'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -750,7 +760,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
{
|
||||
if (!$this->user->authorise('component_mysql_tweaks.edit', $contexts[$pk]))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -766,13 +776,13 @@ class ComponentbuilderModelComponent_mysql_tweaks 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)
|
||||
{
|
||||
@ -816,7 +826,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
@ -828,15 +838,15 @@ class ComponentbuilderModelComponent_mysql_tweaks 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;
|
||||
}
|
||||
@ -846,14 +856,14 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
if (isset($data['clone_me']) && $data['clone_me'] > 0)
|
||||
{
|
||||
// get sql_tweak data from clone_me (component_mysql_tweaks)
|
||||
$data['sql_tweak'] = ComponentbuilderHelper::getVar('component_mysql_tweaks', $data['clone_me'], 'joomla_component', 'sql_tweak');
|
||||
$data['sql_tweak'] = GetHelper::var('component_mysql_tweaks', $data['clone_me'], 'joomla_component', 'sql_tweak');
|
||||
}
|
||||
|
||||
|
||||
// Set the sql_tweak items to data.
|
||||
if (isset($data['sql_tweak']) && is_array($data['sql_tweak']))
|
||||
{
|
||||
$sql_tweak = new JRegistry;
|
||||
$sql_tweak = new Registry;
|
||||
$sql_tweak->loadArray($data['sql_tweak']);
|
||||
$data['sql_tweak'] = (string) $sql_tweak;
|
||||
}
|
||||
@ -862,11 +872,11 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
// Set the empty sql_tweak to data
|
||||
$data['sql_tweak'] = '';
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -876,7 +886,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
{
|
||||
// Automatic handling of other unique fields
|
||||
$uniqueFields = $this->getUniqueFields();
|
||||
if (ComponentbuilderHelper::checkArray($uniqueFields))
|
||||
if (UtilitiesArrayHelper::check($uniqueFields))
|
||||
{
|
||||
foreach ($uniqueFields as $uniqueField)
|
||||
{
|
||||
@ -884,14 +894,14 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parent::save($data))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to generate a unique value.
|
||||
*
|
||||
@ -904,7 +914,6 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
*/
|
||||
protected function generateUnique($field,$value)
|
||||
{
|
||||
|
||||
// set field value unique
|
||||
$table = $this->getTable();
|
||||
|
||||
@ -930,7 +939,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends AdminModel
|
||||
// Alter the title
|
||||
$table = $this->getTable();
|
||||
|
||||
while ($table->load(array('title' => $title)))
|
||||
while ($table->load(['title' => $title]))
|
||||
{
|
||||
$title = StringHelper::increment($title);
|
||||
}
|
||||
|
Reference in New Issue
Block a user