Release of v5.1.1-beta1

Add JCB new package engine.
This commit is contained in:
2025-06-18 19:49:35 +00:00
parent 3b502eb09b
commit 70718936b4
464 changed files with 34151 additions and 13973 deletions

View File

@ -45,7 +45,6 @@ use VDM\Joomla\Componentbuilder\Fieldtype\Factory as FieldtypeFactory;
use VDM\Joomla\Componentbuilder\JoomlaPower\Factory as JoomlaPowerFactory;
use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory;
use VDM\Joomla\Componentbuilder\Snippet\Factory as SnippetFactory;
use VDM\Joomla\Interfaces\Remote\GetInterface;
use Joomla\CMS\Form\FormHelper as FormFormHelper;
// No direct access to this file
@ -4286,7 +4285,7 @@ class AjaxModel extends ListModel
* @param array $libraries The original list of library GUIDs.
*
* @return array|false Sanitized and validated list of libraries, or false.
* @since 5.2.1
* @since 5.1.1
*/
protected function expandAndValidateLibraries(array $libraries)
{
@ -4315,7 +4314,7 @@ class AjaxModel extends ListModel
}
elseif (is_numeric($bundled))
{
$expanded[$bundled] = bundled;
$expanded[$bundled] = $bundled;
}
}
else
@ -4405,7 +4404,7 @@ class AjaxModel extends ListModel
* @param mixed $key The value used to identify the snippet.
*
* @return string|false 'guid', 'id', or false if invalid.
* @since 5.2.1
* @since 5.1.1
*/
protected function resolveSnippetKeyField($key)
{
@ -5277,7 +5276,7 @@ class AjaxModel extends ListModel
*
* @return string|null
*
* @since 5.2.1
* @since 5.1.1
*/
protected function getTargetAreaPower($power): ?string
{
@ -5291,7 +5290,7 @@ class AjaxModel extends ListModel
* @param string $area The target area
*
* @return array
* @since 5.2.1
* @since 5.1.1
*/
public function getRepoIndex(string $repo, string $area): array
{
@ -5318,8 +5317,17 @@ class AjaxModel extends ListModel
return ['success' => false, 'message' => $e->getMessage()];
}
if ($result !== null)
if (!empty($result))
{
foreach($result as &$values)
{
// ensure we don't leak the repo token
if (isset($values->token))
{
$values->token = '***redacted***';
}
}
return ['success' => true, 'index' => $result];
}
@ -5334,7 +5342,7 @@ class AjaxModel extends ListModel
* @param array $selected The selected powers
*
* @return array
* @since 5.2.1
* @since 5.1.1
*/
public function initSelectedPowers(string $repo, string $area, array $selected): array
{
@ -5370,12 +5378,72 @@ class AjaxModel extends ListModel
return ['success' => false, 'message' => Text::_('COM_COMPONENTBUILDER_THE_REPO_INDEX_FAILED_TO_LOAD_PLEASE_TRY_AGAIN')];
}
/**
* Method to initialize the selected packages
*
* @param string $repo The repo to list index
* @param string $area The target area
* @param array $selected The selected powers
*
* @return array
* @since 5.1.1
*/
public function initSelectedPackages(string $repo, string $area, array $selected): array
{
if (!GuidHelper::valid($repo))
{
return ['success' => false, 'message' => Text::_('COM_COMPONENTBUILDER_INVALID_REPO_SELECTED')];
}
if (($Power = $this->getTargetAreaPower($area)) === null)
{
return ['success' => false, 'message' => Text::_('COM_COMPONENTBUILDER_INVALID_AREA_SELECTED')];
}
$result = [];
try
{
$class = $this->getPowerClass($Power, "Package.Builder.Get");
$entity = $this->getPowerClass($Power, "{$area}.Remote.Get");
if (!empty($selected) && $class !== null && $entity !== null)
{
$table = $entity->getTable();
$repo_path = $entity->path($repo);
$result = $class->init($table, $selected, $repo_path);
}
}
catch (\Exception $e)
{
return ['success' => false, 'message' => $e->getMessage()];
}
if ($this->hasIntResults($result))
{
return ['success' => true, 'result_log' => $result];
}
return ['success' => false, 'message' => Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_FAILED_PLEASE_TRY_AGAIN')];
}
/**
* Check if at least one key in the array has a non-empty value.
*
* @param array $data The result array (with 'local', 'not_found', 'added' keys)
*
* @return bool True if some values are non-empty; false if all are empty.
* @since 5.1.1
*/
protected static function hasIntResults(array $data): bool
{
return (bool) array_filter($data);
}
/**
* The powers that we can initialize
*
* @var array
* @since 5.2.1
* @since 5.1.1
*/
protected array $powers = [
'AdminView' => 'PackageFactory',
@ -5388,12 +5456,16 @@ class AjaxModel extends ListModel
'Joomla.Power' => 'JoomlaPowerFactory',
'Layout' => 'PackageFactory',
'Library' => 'PackageFactory',
'Module' => 'PackageFactory',
'JoomlaModule' => 'PackageFactory',
'JoomlaPlugin' => 'PackageFactory',
'Power' => 'PowerFactory',
'Plugin' => 'PackageFactory',
'SiteView' => 'PackageFactory',
'Snippet' => 'SnippetFactory',
'Template' => 'PackageFactory'
'Template' => 'PackageFactory',
'ClassExtends' => 'PackageFactory',
'ClassProperty' => 'PackageFactory',
'ClassMethod' => 'PackageFactory',
'Placeholder' => 'PackageFactory'
];
/**
@ -5402,10 +5474,10 @@ class AjaxModel extends ListModel
* @param string $factoryName The factory name
* @param string $getClass The remote power class name
*
* @return GetInterface|null
* @since 5.2.1
* @return mixed
* @since 5.1.1
*/
protected function getPowerClass(string $factoryName, string $getClass): ?GetInterface
protected function getPowerClass(string $factoryName, string $getClass)
{
return match ($factoryName) {
'PowerFactory' => PowerFactory::_($getClass),

View File

@ -596,42 +596,6 @@ class Class_methodModel extends AdminModel
return $data;
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 12.2
*/
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);
// now change the required field attributes value
foreach ($requiredFields as $requiredField)
{
// make sure there is a string value
if (UtilitiesStringHelper::check($requiredField))
{
// change to false
$form->setFieldAttribute($requiredField, 'required', 'false');
// also clear the data set
unset($data[$requiredField]);
}
}
}
return parent::validate($form, $data, $group);
}
/**
* Method to get the unique fields of this table.
*

View File

@ -283,10 +283,6 @@ class Class_propertiesModel extends ListModel
// From the componentbuilder_item table
$query->from($db->quoteName('#__componentbuilder_class_property', 'a'));
// From the componentbuilder_joomla_plugin_group table.
$query->select($db->quoteName(['g.name','g.id'],['joomla_plugin_group_name','joomla_plugin_group_id']));
$query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'g') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('g.guid') . ')');
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))

View File

@ -587,42 +587,6 @@ class Class_propertyModel extends AdminModel
return $data;
}
/**
* Method to validate the form data.
*
* @param JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return mixed Array of filtered data if valid, false otherwise.
*
* @see JFormRule
* @see JFilterInput
* @since 12.2
*/
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);
// now change the required field attributes value
foreach ($requiredFields as $requiredField)
{
// make sure there is a string value
if (UtilitiesStringHelper::check($requiredField))
{
// change to false
$form->setFieldAttribute($requiredField, 'required', 'false');
// also clear the data set
unset($data[$requiredField]);
}
}
}
return parent::validate($form, $data, $group);
}
/**
* Method to get the unique fields of this table.
*

View File

@ -25,7 +25,7 @@ use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
use VDM\Joomla\Componentbuilder\Compiler\Helper\Compiler;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\File;
use Joomla\CMS\Installer\InstallerHelper;
use Joomla\CMS\Installer\Installer;

View File

@ -133,6 +133,9 @@ class ComponentbuilderModel extends ListModel
'custom_code.access' => 'custom_code.access',
'custom_codes.submenu' => 'custom_code.submenu',
'custom_codes.dashboard_list' => 'custom_code.dashboard_list',
'class_extends.create' => 'class_extends.create',
'class_extendings.access' => 'class_extends.access',
'class_extends.access' => 'class_extends.access',
'class_property.create' => 'class_property.create',
'class_properties.access' => 'class_property.access',
'class_property.access' => 'class_property.access',
@ -254,9 +257,6 @@ class ComponentbuilderModel extends ListModel
'library_files_folders_urls.create' => 'library_files_folders_urls.create',
'libraries_files_folders_urls.access' => 'library_files_folders_urls.access',
'library_files_folders_urls.access' => 'library_files_folders_urls.access',
'class_extends.create' => 'class_extends.create',
'class_extendings.access' => 'class_extends.access',
'class_extends.access' => 'class_extends.access',
'joomla_module_updates.create' => 'joomla_module_updates.create',
'joomla_modules_updates.access' => 'joomla_module_updates.access',
'joomla_module_updates.access' => 'joomla_module_updates.access',

View File

@ -88,12 +88,12 @@ class Custom_admin_viewsModel extends ListModel
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'g.name','main_get',
'a.add_php_ajax','add_php_ajax',
'a.add_custom_button','add_custom_button',
'a.system_name','system_name',
'a.name','name',
'a.description','description'
'a.description','description',
'g.name','main_get'
);
}
@ -193,13 +193,6 @@ class Custom_admin_viewsModel extends ListModel
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$main_get = $this->getUserStateFromRequest($this->context . '.filter.main_get', 'filter_main_get');
if ($formSubmited)
{
$main_get = $app->input->post->get('main_get');
$this->setState('filter.main_get', $main_get);
}
$add_php_ajax = $this->getUserStateFromRequest($this->context . '.filter.add_php_ajax', 'filter_add_php_ajax');
if ($formSubmited)
{
@ -235,6 +228,13 @@ class Custom_admin_viewsModel extends ListModel
$this->setState('filter.description', $description);
}
$main_get = $this->getUserStateFromRequest($this->context . '.filter.main_get', 'filter_main_get');
if ($formSubmited)
{
$main_get = $app->input->post->get('main_get');
$this->setState('filter.main_get', $main_get);
}
// List state information.
parent::populateState($ordering, $direction);
}
@ -414,46 +414,6 @@ class Custom_admin_viewsModel extends ListModel
}
}
// Filter by Main_get.
$_main_get = $this->getState('filter.main_get');
if (is_numeric($_main_get))
{
if (is_float($_main_get))
{
$query->where('a.main_get = ' . (float) $_main_get);
}
else
{
$query->where('a.main_get = ' . (int) $_main_get);
}
}
elseif (StringHelper::check($_main_get))
{
$query->where('a.main_get = ' . $db->quote($db->escape($_main_get)));
}
elseif (UtilitiesArrayHelper::check($_main_get))
{
// Secure the array for the query
$_main_get = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (StringHelper::check($val))
{
return $db->quote($db->escape($val));
}
}, $_main_get);
// Filter by the Main_get Array.
$query->where('a.main_get IN (' . implode(',', $_main_get) . ')');
}
// Filter by Add_php_ajax.
$_add_php_ajax = $this->getState('filter.add_php_ajax');
if (is_numeric($_add_php_ajax))
@ -529,23 +489,12 @@ class Custom_admin_viewsModel extends ListModel
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
// Check if the value is an array
$_main_get = $this->getState('filter.main_get');
if (UtilitiesArrayHelper::check($_main_get))
{
$id .= ':' . implode(':', $_main_get);
}
// Check if this is only an number or string
elseif (is_numeric($_main_get)
|| StringHelper::check($_main_get))
{
$id .= ':' . $_main_get;
}
$id .= ':' . $this->getState('filter.add_php_ajax');
$id .= ':' . $this->getState('filter.add_custom_button');
$id .= ':' . $this->getState('filter.system_name');
$id .= ':' . $this->getState('filter.name');
$id .= ':' . $this->getState('filter.description');
$id .= ':' . $this->getState('filter.main_get');
return parent::getStoreId($id);
}

View File

@ -23,6 +23,7 @@ use Joomla\Utilities\ArrayHelper;
use Joomla\Input\Input;
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
use Joomla\CMS\Helper\TagsHelper;
use VDM\Joomla\Utilities\FormHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
@ -97,6 +98,44 @@ class Dynamic_getsModel extends ListModel
$this->app ??= Factory::getApplication();
}
/**
* Get the filter form - Override the parent method
*
* @param array $data data
* @param boolean $loadData load current data
*
* @return Form|null The Form object or false on error
*
* @since JCB 2.12.5
*/
public function getFilterForm($data = array(), $loadData = true)
{
// load form from the parent class
$form = parent::getFilterForm($data, $loadData);
// Create the "getgroup" filter
$attributes = [
'name' => 'getgroup',
'type' => 'list',
'onchange' => 'this.form.submit();',
];
$options = [
'' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_GET_GROUP') . ' -',
'main' => Text::_('COM_COMPONENTBUILDER_MAIN_GET'),
'custom' => Text::_('COM_COMPONENTBUILDER_CUSTOM_GET')
];
$form->setField(FormHelper::xml($attributes, $options),'filter');
$form->setValue(
'getgroup',
'filter',
$this->state->get("filter.getgroup")
);
array_push($this->filter_fields, 'getgroup');
return $form;
}
/**
* Method to auto-populate the model state.
*
@ -280,6 +319,22 @@ class Dynamic_getsModel extends ListModel
// From the componentbuilder_item table
$query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a'));
// Filtering "getgroup"
$filter_getgroup = $this->state->get("filter.getgroup");
if (!empty($filter_getgroup))
{
if ($filter_getgroup === 'main')
{
// the main gets
$query->where($db->quoteName('a.gettype') . ' IN (1,2)');
}
elseif ($filter_getgroup === 'custom')
{
// the custom gets
$query->where($db->quoteName('a.gettype') . ' IN (3,4)');
}
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
@ -362,6 +417,29 @@ class Dynamic_getsModel extends ListModel
{
$query->where('a.gettype = ' . $db->quote($db->escape($_gettype)));
}
elseif (UtilitiesArrayHelper::check($_gettype))
{
// Secure the array for the query
$_gettype = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (StringHelper::check($val))
{
return $db->quote($db->escape($val));
}
}, $_gettype);
// Filter by the Gettype Array.
$query->where('a.gettype IN (' . implode(',', $_gettype) . ')');
}
// Add the list ordering clause.
$orderCol = $this->getState('list.ordering', 'a.id');
@ -404,7 +482,18 @@ class Dynamic_getsModel extends ListModel
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.main_source');
$id .= ':' . $this->getState('filter.gettype');
// Check if the value is an array
$_gettype = $this->getState('filter.gettype');
if (UtilitiesArrayHelper::check($_gettype))
{
$id .= ':' . implode(':', $_gettype);
}
// Check if this is only an number or string
elseif (is_numeric($_gettype)
|| StringHelper::check($_gettype))
{
$id .= ':' . $_gettype;
}
$id .= ':' . $this->getState('filter.name');
return parent::getStoreId($id);

View File

@ -33,6 +33,7 @@ use VDM\Joomla\Utilities\SessionHelper;
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Componentbuilder\Utilities\FilterHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
@ -298,7 +299,7 @@ class FieldtypeModel extends AdminModel
*
* @return mixed An array of data items on success, false on failure.
*/
public function getVxlfields()
public function getVxifields()
{
// Get the user object.
$user = Factory::getApplication()->getIdentity();
@ -322,7 +323,7 @@ class FieldtypeModel extends AdminModel
{
// column name, and id
$type_extension = explode('__', $filter_extension);
if (($guids = JCBFilterHelper::linked((string) $type_extension[1], (string) $type_extension[0])) !== null)
if (($guids = FilterHelper::linked((string) $type_extension[1], (string) $type_extension[0])) !== null)
{
$field_guids = $guids;
}
@ -338,7 +339,7 @@ class FieldtypeModel extends AdminModel
$filter_admin_view = $this->state->get("filter.admin_view");
if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view))
{
if (($guids = JCBFilterHelper::linked((string) $filter_admin_view, 'admin_view')) !== null)
if (($guids = FilterHelper::linked((string) $filter_admin_view, 'admin_view')) !== null)
{
// view will return less fields, so we ignore the component
$field_guids = $guids;
@ -436,13 +437,13 @@ class FieldtypeModel extends AdminModel
foreach ($items as $nr => &$item)
{
// convert datatype
$item->datatype = $this->selectionTranslationVxlfields($item->datatype, 'datatype');
$item->datatype = $this->selectionTranslationVxifields($item->datatype, 'datatype');
// convert indexes
$item->indexes = $this->selectionTranslationVxlfields($item->indexes, 'indexes');
$item->indexes = $this->selectionTranslationVxifields($item->indexes, 'indexes');
// convert null_switch
$item->null_switch = $this->selectionTranslationVxlfields($item->null_switch, 'null_switch');
$item->null_switch = $this->selectionTranslationVxifields($item->null_switch, 'null_switch');
// convert store
$item->store = $this->selectionTranslationVxlfields($item->store, 'store');
$item->store = $this->selectionTranslationVxifields($item->store, 'store');
}
}
@ -456,7 +457,7 @@ class FieldtypeModel extends AdminModel
*
* @return string The translatable string.
*/
public function selectionTranslationVxlfields($value,$name)
public function selectionTranslationVxifields($value,$name)
{
// Array of datatype language strings
if ($name === 'datatype')

View File

@ -14,7 +14,7 @@ use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\Filesystem\Path;
use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\Installer\InstallerHelper;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
@ -25,7 +25,6 @@ use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use Joomla\CMS\Filesystem\Folder as FilesystemFolder;
// No direct access to this file
\defined('_JEXEC') or die;
@ -940,7 +939,7 @@ class Import_joomla_componentsimportModel extends BaseDatabaseModel
if (is_dir($customDir))
{
// great we have some custom stuff lets move it
if (!FilesystemFolder::copy($customDir, $customPath,'',true))
if (!Folder::copy($customDir, $customPath,'',true))
{
$this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_BCUSTOM_FILESB_NOT_MOVED_TO_CORRECT_LOCATION'), 'error');
$success = false;
@ -956,7 +955,7 @@ class Import_joomla_componentsimportModel extends BaseDatabaseModel
if (is_dir($imageDir))
{
// great we have some images lets move them
if (!FilesystemFolder::copy($imageDir, $imagesPath,'',true))
if (!Folder::copy($imageDir, $imagesPath,'',true))
{
$this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_BIMAGESB_NOT_MOVED_TO_CORRECT_LOCATION'), 'error');
$success = false;
@ -972,7 +971,7 @@ class Import_joomla_componentsimportModel extends BaseDatabaseModel
if (is_dir($dynamicDir))
{
// get a list of folders
$folders = FilesystemFolder::folders($dynamicDir);
$folders = Folder::folders($dynamicDir);
// check if we have files
if(UtilitiesArrayHelper::check($folders))
{
@ -980,7 +979,7 @@ class Import_joomla_componentsimportModel extends BaseDatabaseModel
{
$destination = $this->setDynamicPath($folder);
$fullPath = str_replace('//', '/', $dynamicDir . '/' . $folder);
if (!is_dir($fullPath) || !FilesystemFolder::copy($fullPath, $destination,'',true))
if (!is_dir($fullPath) || !Folder::copy($fullPath, $destination,'',true))
{
$this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FOLDER_BSB_WAS_NOT_MOVED_TO_BSB', $folder, $destination), 'error');
$success = false;
@ -993,7 +992,7 @@ class Import_joomla_componentsimportModel extends BaseDatabaseModel
}
}
// get a list of files
$files = FilesystemFolder::files($dynamicDir);
$files = Folder::files($dynamicDir);
// check if we have files
if(UtilitiesArrayHelper::check($files))
{
@ -1056,7 +1055,7 @@ class Import_joomla_componentsimportModel extends BaseDatabaseModel
// we are changing the working directory to the tmp path (important)
chdir($tmpPath);
// get a list of files in the current directory tree (all)
$files = FilesystemFolder::files('.', '.', true, true);
$files = Folder::files('.', '.', true, true);
// read in the file content
foreach ($files as $file)
{

View File

@ -14,7 +14,7 @@ use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\Filesystem\Path;
use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\Installer\InstallerHelper;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;

View File

@ -30,7 +30,6 @@ use VDM\Joomla\Componentbuilder\Fieldtype\Factory as FieldtypeFactory;
use VDM\Joomla\Componentbuilder\JoomlaPower\Factory as JoomlaPowerFactory;
use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory;
use VDM\Joomla\Componentbuilder\Snippet\Factory as SnippetFactory;
use VDM\Joomla\Interfaces\Remote\GetInterface;
// No direct access to this file
\defined('_JEXEC') or die;
@ -320,7 +319,7 @@ class Initialization_selectionModel extends ItemModel
*
* @return array|null
*
* @since 5.2.1
* @since 5.1.1
*/
protected function getTargetAreaPower(): ?array
{
@ -333,7 +332,7 @@ class Initialization_selectionModel extends ItemModel
*
* @return array|null
* @throws \Exception
* @since 5.2.1
* @since 5.1.1
*/
protected function getPaths(): ?array
{
@ -368,7 +367,7 @@ class Initialization_selectionModel extends ItemModel
* The powers that we can initialize
*
* @var array
* @since 5.2.1
* @since 5.1.1
*/
protected array $powers = [
'AdminView' => 'PackageFactory',
@ -381,12 +380,16 @@ class Initialization_selectionModel extends ItemModel
'Joomla.Power' => 'JoomlaPowerFactory',
'Layout' => 'PackageFactory',
'Library' => 'PackageFactory',
'Module' => 'PackageFactory',
'JoomlaModule' => 'PackageFactory',
'JoomlaPlugin' => 'PackageFactory',
'Power' => 'PowerFactory',
'Plugin' => 'PackageFactory',
'SiteView' => 'PackageFactory',
'Snippet' => 'SnippetFactory',
'Template' => 'PackageFactory'
'Template' => 'PackageFactory',
'ClassExtends' => 'PackageFactory',
'ClassProperty' => 'PackageFactory',
'ClassMethod' => 'PackageFactory',
'Placeholder' => 'PackageFactory'
];
/**
@ -395,10 +398,10 @@ class Initialization_selectionModel extends ItemModel
* @param string $factoryName The factory name
* @param string $getClass The remote power class name
*
* @return GetInterface|null
* @since 5.2.1
* @return mixed
* @since 5.1.1
*/
protected function getPowerClass(string $factoryName, string $getClass): ?GetInterface
protected function getPowerClass(string $factoryName, string $getClass)
{
return match ($factoryName) {
'PowerFactory' => PowerFactory::_($getClass),

View File

@ -93,6 +93,37 @@ class Joomla_componentModel extends AdminModel
'not_required'
)
),
'libs_helpers' => array(
'fullwidth' => array(
'creatuserhelper',
'adduikit',
'addfootable',
'add_email_helper',
'add_php_helper_both',
'php_helper_both',
'add_php_helper_admin',
'php_helper_admin',
'add_admin_event',
'php_admin_event',
'add_php_helper_site',
'php_helper_site',
'add_site_event',
'php_site_event',
'add_javascript',
'javascript',
'add_css_admin',
'css_admin',
'add_css_site',
'css_site'
)
),
'dynamic_build' => array(
'fullwidth' => array(
'note_buildcomp_dynamic_mysql',
'buildcomp',
'buildcompsql'
)
),
'dynamic_integration' => array(
'left' => array(
'add_update_server',
@ -122,13 +153,13 @@ class Joomla_componentModel extends AdminModel
'crowdin_account_api_key'
)
),
'mysql' => array(
'fullwidth' => array(
'add_sql',
'sql',
'add_sql_uninstall',
'sql_uninstall',
'assets_table_fix'
'readme' => array(
'left' => array(
'addreadme',
'readme'
),
'right' => array(
'note_readme'
)
),
'dash_install' => array(
@ -155,44 +186,13 @@ class Joomla_componentModel extends AdminModel
'php_method_install'
)
),
'libs_helpers' => array(
'mysql' => array(
'fullwidth' => array(
'creatuserhelper',
'adduikit',
'addfootable',
'add_email_helper',
'add_php_helper_both',
'php_helper_both',
'add_php_helper_admin',
'php_helper_admin',
'add_admin_event',
'php_admin_event',
'add_php_helper_site',
'php_helper_site',
'add_site_event',
'php_site_event',
'add_javascript',
'javascript',
'add_css_admin',
'css_admin',
'add_css_site',
'css_site'
)
),
'readme' => array(
'left' => array(
'addreadme',
'readme'
),
'right' => array(
'note_readme'
)
),
'dynamic_build' => array(
'fullwidth' => array(
'note_buildcomp_dynamic_mysql',
'buildcomp',
'buildcompsql'
'add_sql',
'sql',
'add_sql_uninstall',
'sql_uninstall',
'assets_table_fix'
)
),
'settings' => array(
@ -216,14 +216,9 @@ class Joomla_componentModel extends AdminModel
'spacer_hr_6',
'to_ignore_note',
'toignore',
'spacer_hr_7',
'jcb_export_package_note',
'export_key',
'joomla_source_link',
'export_buy_link'
'spacer_hr_7'
),
'fullwidth' => array(
'spacer_hr_8',
'note_on_contributors',
'addcontributors',
'emptycontributors',
@ -388,16 +383,10 @@ class Joomla_componentModel extends AdminModel
$item->metadata = $registry->toArray();
}
if (!empty($item->sql_uninstall))
if (!empty($item->javascript))
{
// base64 Decode sql_uninstall.
$item->sql_uninstall = base64_decode($item->sql_uninstall);
}
if (!empty($item->php_postflight_update))
{
// base64 Decode php_postflight_update.
$item->php_postflight_update = base64_decode($item->php_postflight_update);
// base64 Decode javascript.
$item->javascript = base64_decode($item->javascript);
}
if (!empty($item->css_site))
@ -412,22 +401,16 @@ class Joomla_componentModel extends AdminModel
$item->php_helper_site = base64_decode($item->php_helper_site);
}
if (!empty($item->javascript))
if (!empty($item->php_preflight_update))
{
// base64 Decode javascript.
$item->javascript = base64_decode($item->javascript);
// base64 Decode php_preflight_update.
$item->php_preflight_update = base64_decode($item->php_preflight_update);
}
if (!empty($item->php_method_install))
if (!empty($item->sql_uninstall))
{
// base64 Decode php_method_install.
$item->php_method_install = base64_decode($item->php_method_install);
}
if (!empty($item->php_admin_event))
{
// base64 Decode php_admin_event.
$item->php_admin_event = base64_decode($item->php_admin_event);
// base64 Decode sql_uninstall.
$item->sql_uninstall = base64_decode($item->sql_uninstall);
}
if (!empty($item->php_site_event))
@ -442,10 +425,10 @@ class Joomla_componentModel extends AdminModel
$item->css_admin = base64_decode($item->css_admin);
}
if (!empty($item->php_preflight_update))
if (!empty($item->php_postflight_update))
{
// base64 Decode php_preflight_update.
$item->php_preflight_update = base64_decode($item->php_preflight_update);
// base64 Decode php_postflight_update.
$item->php_postflight_update = base64_decode($item->php_postflight_update);
}
if (!empty($item->php_preflight_install))
@ -454,6 +437,12 @@ class Joomla_componentModel extends AdminModel
$item->php_preflight_install = base64_decode($item->php_preflight_install);
}
if (!empty($item->php_method_install))
{
// base64 Decode php_method_install.
$item->php_method_install = base64_decode($item->php_method_install);
}
if (!empty($item->php_postflight_install))
{
// base64 Decode php_postflight_install.
@ -496,6 +485,12 @@ class Joomla_componentModel extends AdminModel
$item->php_helper_admin = base64_decode($item->php_helper_admin);
}
if (!empty($item->php_admin_event))
{
// base64 Decode php_admin_event.
$item->php_admin_event = base64_decode($item->php_admin_event);
}
// Get the basic encryption.
$basickey = ComponentbuilderHelper::getCryptKey('basic');
// Get the encryption object.
@ -507,12 +502,6 @@ class Joomla_componentModel extends AdminModel
$item->crowdin_username = rtrim($basic->decryptString($item->crowdin_username), "\0");
}
if (!empty($item->export_key) && $basickey && !is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true)))
{
// basic decrypt data export_key.
$item->export_key = rtrim($basic->decryptString($item->export_key), "\0");
}
if (!empty($item->crowdin_project_api_key) && $basickey && !is_numeric($item->crowdin_project_api_key) && $item->crowdin_project_api_key === base64_encode(base64_decode($item->crowdin_project_api_key, true)))
{
// basic decrypt data crowdin_project_api_key.
@ -1507,16 +1496,10 @@ class Joomla_componentModel extends AdminModel
$data['addcontributors'] = '';
}
// Set the sql_uninstall string to base64 string.
if (isset($data['sql_uninstall']))
// Set the javascript string to base64 string.
if (isset($data['javascript']))
{
$data['sql_uninstall'] = base64_encode($data['sql_uninstall']);
}
// Set the php_postflight_update string to base64 string.
if (isset($data['php_postflight_update']))
{
$data['php_postflight_update'] = base64_encode($data['php_postflight_update']);
$data['javascript'] = base64_encode($data['javascript']);
}
// Set the css_site string to base64 string.
@ -1531,22 +1514,16 @@ class Joomla_componentModel extends AdminModel
$data['php_helper_site'] = base64_encode($data['php_helper_site']);
}
// Set the javascript string to base64 string.
if (isset($data['javascript']))
// Set the php_preflight_update string to base64 string.
if (isset($data['php_preflight_update']))
{
$data['javascript'] = base64_encode($data['javascript']);
$data['php_preflight_update'] = base64_encode($data['php_preflight_update']);
}
// Set the php_method_install string to base64 string.
if (isset($data['php_method_install']))
// Set the sql_uninstall string to base64 string.
if (isset($data['sql_uninstall']))
{
$data['php_method_install'] = base64_encode($data['php_method_install']);
}
// Set the php_admin_event string to base64 string.
if (isset($data['php_admin_event']))
{
$data['php_admin_event'] = base64_encode($data['php_admin_event']);
$data['sql_uninstall'] = base64_encode($data['sql_uninstall']);
}
// Set the php_site_event string to base64 string.
@ -1561,10 +1538,10 @@ class Joomla_componentModel extends AdminModel
$data['css_admin'] = base64_encode($data['css_admin']);
}
// Set the php_preflight_update string to base64 string.
if (isset($data['php_preflight_update']))
// Set the php_postflight_update string to base64 string.
if (isset($data['php_postflight_update']))
{
$data['php_preflight_update'] = base64_encode($data['php_preflight_update']);
$data['php_postflight_update'] = base64_encode($data['php_postflight_update']);
}
// Set the php_preflight_install string to base64 string.
@ -1573,6 +1550,12 @@ class Joomla_componentModel extends AdminModel
$data['php_preflight_install'] = base64_encode($data['php_preflight_install']);
}
// Set the php_method_install string to base64 string.
if (isset($data['php_method_install']))
{
$data['php_method_install'] = base64_encode($data['php_method_install']);
}
// Set the php_postflight_install string to base64 string.
if (isset($data['php_postflight_install']))
{
@ -1615,6 +1598,12 @@ class Joomla_componentModel extends AdminModel
$data['php_helper_admin'] = base64_encode($data['php_helper_admin']);
}
// Set the php_admin_event string to base64 string.
if (isset($data['php_admin_event']))
{
$data['php_admin_event'] = base64_encode($data['php_admin_event']);
}
// Get the basic encryption key.
$basickey = ComponentbuilderHelper::getCryptKey('basic');
// Get the encryption object
@ -1626,12 +1615,6 @@ class Joomla_componentModel extends AdminModel
$data['crowdin_username'] = $basic->encryptString($data['crowdin_username']);
}
// Encrypt data export_key.
if (isset($data['export_key']) && $basickey)
{
$data['export_key'] = $basic->encryptString($data['export_key']);
}
// Encrypt data crowdin_project_api_key.
if (isset($data['crowdin_project_api_key']) && $basickey)
{

View File

@ -484,28 +484,26 @@ class Joomla_componentsModel extends ListModel
continue;
}
// decode sql_uninstall
$item->sql_uninstall = base64_decode($item->sql_uninstall);
// decode php_postflight_update
$item->php_postflight_update = base64_decode($item->php_postflight_update);
// decode javascript
$item->javascript = base64_decode($item->javascript);
// decode css_site
$item->css_site = base64_decode($item->css_site);
// decode php_helper_site
$item->php_helper_site = base64_decode($item->php_helper_site);
// decode javascript
$item->javascript = base64_decode($item->javascript);
// decode php_method_install
$item->php_method_install = base64_decode($item->php_method_install);
// decode php_admin_event
$item->php_admin_event = base64_decode($item->php_admin_event);
// decode php_preflight_update
$item->php_preflight_update = base64_decode($item->php_preflight_update);
// decode sql_uninstall
$item->sql_uninstall = base64_decode($item->sql_uninstall);
// decode php_site_event
$item->php_site_event = base64_decode($item->php_site_event);
// decode css_admin
$item->css_admin = base64_decode($item->css_admin);
// decode php_preflight_update
$item->php_preflight_update = base64_decode($item->php_preflight_update);
// decode php_postflight_update
$item->php_postflight_update = base64_decode($item->php_postflight_update);
// decode php_preflight_install
$item->php_preflight_install = base64_decode($item->php_preflight_install);
// decode php_method_install
$item->php_method_install = base64_decode($item->php_method_install);
// decode php_postflight_install
$item->php_postflight_install = base64_decode($item->php_postflight_install);
// decode php_method_uninstall
@ -519,27 +517,24 @@ class Joomla_componentsModel extends ListModel
}
// decode buildcompsql
$item->buildcompsql = base64_decode($item->buildcompsql);
if ($basickey && !is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true)))
{
// decrypt export_key
$item->export_key = $basic->decryptString($item->export_key);
}
// decode readme
$item->readme = base64_decode($item->readme);
// decode php_helper_both
$item->php_helper_both = base64_decode($item->php_helper_both);
if ($basickey && !is_numeric($item->crowdin_project_api_key) && $item->crowdin_project_api_key === base64_encode(base64_decode($item->crowdin_project_api_key, true)))
{
// decrypt crowdin_project_api_key
$item->crowdin_project_api_key = $basic->decryptString($item->crowdin_project_api_key);
}
// decode php_helper_both
$item->php_helper_both = base64_decode($item->php_helper_both);
// decode php_helper_admin
$item->php_helper_admin = base64_decode($item->php_helper_admin);
if ($basickey && !is_numeric($item->crowdin_account_api_key) && $item->crowdin_account_api_key === base64_encode(base64_decode($item->crowdin_account_api_key, true)))
{
// decrypt crowdin_account_api_key
$item->crowdin_account_api_key = $basic->decryptString($item->crowdin_account_api_key);
}
// decode php_helper_admin
$item->php_helper_admin = base64_decode($item->php_helper_admin);
// decode php_admin_event
$item->php_admin_event = base64_decode($item->php_admin_event);
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);

View File

@ -24,9 +24,8 @@ use Joomla\Input\Input;
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
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;
use VDM\Joomla\Utilities\StringHelper;
// No direct access to this file
\defined('_JEXEC') or die;
@ -98,175 +97,6 @@ class Joomla_pluginsModel extends ListModel
$this->app ??= Factory::getApplication();
}
/**
* get Boilerplate
*
* @return boolean
*/
public function getBoilerplate()
{
// get boilerplate repo root details
if (($repo_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate', ComponentbuilderHelper::$bolerplateAPI)) !== false)
{
$found = array_values(array_filter(
$repo_tree,
function($tree) {
if (isset($tree->path) && $tree->path === 'plugins')
{
return true;
}
return false;
}
));
// make sure we have the correct boilerplate
if (UtilitiesArrayHelper::check($found) && count($found) == 1 && method_exists(__CLASS__, 'getPluginsBoilerplate'))
{
// get the plugins boilerplate
return $this->getPluginsBoilerplate($found[0]->url);
}
}
return false;
}
/**
* get Plugin Boilerplate
*
* @return boolean true on success
*
*/
protected function getPluginsBoilerplate($url)
{
// get boilerplate root for plugins
if (($plugin_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate_plugins', $url)) !== false)
{
// get the app object
$app = Factory::getApplication();
// set the table names
$tables = array();
$tables['e'] = 'class_extends';
$tables['g'] = 'joomla_plugin_group';
$tables['m'] = 'class_method';
$tables['p'] = 'class_property';
// load the needed models
$models = array();
$models['e'] = ComponentbuilderHelper::getModel($tables['e']);
$models['g'] = ComponentbuilderHelper::getModel($tables['g']);
$models['p'] = ComponentbuilderHelper::getModel($tables['p']);
$models['m'] = ComponentbuilderHelper::getModel($tables['m']);
// get the needed data of each plugin group
$groups = array_map(
function($tree) use(&$app, &$models, &$tables){
if (($fooClass = ComponentbuilderHelper::getFileContents(ComponentbuilderHelper::$bolerplatePath . '/plugins/' . $tree->path . '/foo.php')) !== false && StringHelper::check($fooClass))
{
// extract the boilerplate class extends and check if already set
if (($classExtends = ComponentbuilderHelper::extractBoilerplateClassExtends($fooClass, 'plugins')) !== 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);
// extract the boilerplate class header
$class['head'] = ComponentbuilderHelper::extractBoilerplateClassHeader($fooClass, $classExtends, 'plugins');
// extract the boilerplate class comment
$class['comment'] = ComponentbuilderHelper::extractBoilerplateClassComment($fooClass, $classExtends, 'plugins');
// set the extension type
$class['extension_type'] = 'plugins';
// store the class
$this->storePluginBoilerplate($tables['e'], $models['e'], $class, $app);
// work around
$classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id');
}
// set plugin group if not already set
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 = 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)
{
// create the properties found
if (isset($classProperiesMethods['property']) && UtilitiesArrayHelper::check($classProperiesMethods['property']))
{
foreach ($classProperiesMethods['property'] as $_property)
{
// force update by default
$this->storePluginBoilerplate($tables['p'], $models['p'], $_property, $app);
}
}
// create the method found (TODO just create for now but we could later add a force update)
if (isset($classProperiesMethods['method']) && UtilitiesArrayHelper::check($classProperiesMethods['method']))
{
foreach ($classProperiesMethods['method'] as $_method)
{
// force update by default
$this->storePluginBoilerplate($tables['m'], $models['m'], $_method, $app);
}
}
}
}
},
$plugin_tree
);
}
}
/**
* store Plugin Boilerplate
*
* @return boolean true on success
*
*/
protected function storePluginBoilerplate(&$table, &$method, &$boilerplate, &$app)
{
// Sometimes the form needs some posted data, such as for plugins and modules.
$form = $method->getForm($boilerplate, false);
if (!$form)
{
$app->enqueueMessage($method->getError(), 'error');
return false;
}
// Send an object which can be modified through the plugin event
$objData = (object) $boilerplate;
$app->triggerEvent(
'onContentNormaliseRequestData',
array('com_componentbuilder.' . $table, $objData, $form)
);
$boilerplate = (array) $objData;
// Test whether the data is valid.
$validData = $method->validate($form, $boilerplate);
// Check for validation errors.
if ($validData === false)
{
// Get the validation messages.
$errors = $method->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof \Exception)
{
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
}
else
{
$app->enqueueMessage($errors[$i], 'warning');
}
}
return false;
}
// Attempt to save the data.
if (!$method->save($validData))
{
$app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BOILERPLATE_PLUGIN_S_DATA_COULD_NOT_BE_SAVED', $table), 'error');
return false;
}
return true;
}
/**
* Method to auto-populate the model state.
*

View File

@ -265,7 +265,8 @@ class RepositoriesModel extends ListModel
{
$typeArray = array(
0 => 'COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION',
1 => 'COM_COMPONENTBUILDER_REPOSITORY_GITEA'
1 => 'COM_COMPONENTBUILDER_REPOSITORY_GITEA',
2 => 'COM_COMPONENTBUILDER_REPOSITORY_GITHUB'
);
// Now check if value is found in this array
if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value]))
@ -340,7 +341,7 @@ class RepositoriesModel extends ListModel
else
{
$search = $db->quote('%' . $db->escape($search) . '%');
$query->where('(a.organisation LIKE '.$search.' OR a.repository LIKE '.$search.' OR a.target LIKE '.$search.' OR a.type LIKE '.$search.' OR a.base LIKE '.$search.' OR a.guid LIKE '.$search.' OR a.username LIKE '.$search.')');
$query->where('(a.organisation LIKE '.$search.' OR a.repository LIKE '.$search.' OR a.target LIKE '.$search.' OR a.type LIKE '.$search.' OR a.base LIKE '.$search.' OR a.guid LIKE '.$search.' OR a.author_email LIKE '.$search.' OR a.author_name LIKE '.$search.' OR a.username LIKE '.$search.')');
}
}

View File

@ -58,7 +58,9 @@ class RepositoryModel extends AdminModel
'type',
'base',
'username',
'token'
'token',
'author_name',
'author_email'
),
'right' => array(
'organisation',

View File

@ -88,12 +88,12 @@ class Site_viewsModel extends ListModel
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'g.name','main_get',
'a.add_php_ajax','add_php_ajax',
'a.add_custom_button','add_custom_button',
'a.system_name','system_name',
'a.name','name',
'a.description','description',
'g.name','main_get',
'a.context','context'
);
}
@ -194,13 +194,6 @@ class Site_viewsModel extends ListModel
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$main_get = $this->getUserStateFromRequest($this->context . '.filter.main_get', 'filter_main_get');
if ($formSubmited)
{
$main_get = $app->input->post->get('main_get');
$this->setState('filter.main_get', $main_get);
}
$add_php_ajax = $this->getUserStateFromRequest($this->context . '.filter.add_php_ajax', 'filter_add_php_ajax');
if ($formSubmited)
{
@ -236,6 +229,13 @@ class Site_viewsModel extends ListModel
$this->setState('filter.description', $description);
}
$main_get = $this->getUserStateFromRequest($this->context . '.filter.main_get', 'filter_main_get');
if ($formSubmited)
{
$main_get = $app->input->post->get('main_get');
$this->setState('filter.main_get', $main_get);
}
$context = $this->getUserStateFromRequest($this->context . '.filter.context', 'filter_context');
if ($formSubmited)
{
@ -422,46 +422,6 @@ class Site_viewsModel extends ListModel
}
}
// Filter by Main_get.
$_main_get = $this->getState('filter.main_get');
if (is_numeric($_main_get))
{
if (is_float($_main_get))
{
$query->where('a.main_get = ' . (float) $_main_get);
}
else
{
$query->where('a.main_get = ' . (int) $_main_get);
}
}
elseif (StringHelper::check($_main_get))
{
$query->where('a.main_get = ' . $db->quote($db->escape($_main_get)));
}
elseif (UtilitiesArrayHelper::check($_main_get))
{
// Secure the array for the query
$_main_get = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (StringHelper::check($val))
{
return $db->quote($db->escape($val));
}
}, $_main_get);
// Filter by the Main_get Array.
$query->where('a.main_get IN (' . implode(',', $_main_get) . ')');
}
// Filter by Add_php_ajax.
$_add_php_ajax = $this->getState('filter.add_php_ajax');
if (is_numeric($_add_php_ajax))
@ -537,23 +497,12 @@ class Site_viewsModel extends ListModel
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
// Check if the value is an array
$_main_get = $this->getState('filter.main_get');
if (UtilitiesArrayHelper::check($_main_get))
{
$id .= ':' . implode(':', $_main_get);
}
// Check if this is only an number or string
elseif (is_numeric($_main_get)
|| StringHelper::check($_main_get))
{
$id .= ':' . $_main_get;
}
$id .= ':' . $this->getState('filter.add_php_ajax');
$id .= ':' . $this->getState('filter.add_custom_button');
$id .= ':' . $this->getState('filter.system_name');
$id .= ':' . $this->getState('filter.name');
$id .= ':' . $this->getState('filter.description');
$id .= ':' . $this->getState('filter.main_get');
$id .= ':' . $this->getState('filter.context');
return parent::getStoreId($id);