Changed JArrayHelper to use ArrayHelper and added the use namespace to the files needed. Changed JString to use StringHelper and added the use namespace to the files needed. Fixed the spelling mistake of uniqe. Made changes to compiler to accomidate the new pro member feature that added viewsDefaultOrdering options. Fixed the moving of custom fields found in subforms of a plugin or module. Improved the sorting options to correctly map for custom fields and the category field.

This commit is contained in:
2020-05-22 01:38:20 +02:00
parent f314464575
commit 2564b75e5d
236 changed files with 2041 additions and 1594 deletions

View File

@ -13,6 +13,8 @@
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Componentbuilder Component_mysql_tweaks Model
@ -423,7 +425,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
*
* @since 3.0
*/
protected function getUniqeFields()
protected function getUniqueFields()
{
return false;
}
@ -482,7 +484,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
{
// Sanitize ids.
$pks = array_unique($pks);
JArrayHelper::toInteger($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
@ -523,7 +525,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
if (!empty($commands['move_copy']))
{
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
$cmd = ArrayHelper::getValue($commands, 'move_copy', 'c');
if ($cmd == 'c')
{
@ -590,8 +592,8 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
return false;
}
// get list of uniqe fields
$uniqeFields = $this->getUniqeFields();
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
@ -642,7 +644,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
// Only for strings
if (ComponentbuilderHelper::checkString($this->table->joomla_component) && !is_numeric($this->table->joomla_component))
{
$this->table->joomla_component = $this->generateUniqe('joomla_component',$this->table->joomla_component);
$this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component);
}
// insert all set values
@ -657,12 +659,12 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
}
}
// update all uniqe fields
if (ComponentbuilderHelper::checkArray($uniqeFields))
// update all unique fields
if (ComponentbuilderHelper::checkArray($uniqueFields))
{
foreach ($uniqeFields as $uniqeField)
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqeField = $this->generateUniqe($uniqeField,$this->table->$uniqeField);
$this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
@ -859,16 +861,16 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
$data['params'] = (string) $params;
}
// Alter the uniqe field for save as copy
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other uniqe fields
$uniqeFields = $this->getUniqeFields();
if (ComponentbuilderHelper::checkArray($uniqeFields))
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (ComponentbuilderHelper::checkArray($uniqueFields))
{
foreach ($uniqeFields as $uniqeField)
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqeField] = $this->generateUniqe($uniqeField,$data[$uniqeField]);
$data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
@ -881,7 +883,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
}
/**
* Method to generate a uniqe value.
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
@ -890,15 +892,15 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
*
* @since 3.0
*/
protected function generateUniqe($field,$value)
protected function generateUnique($field,$value)
{
// set field value uniqe
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = JString::increment($value);
$value = StringHelper::increment($value);
}
return $value;
@ -920,7 +922,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
while ($table->load(array('title' => $title)))
{
$title = JString::increment($title);
$title = StringHelper::increment($title);
}
return $title;