Files
Component-Builder/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_MODEL.php
Robot 8549348a61 Release of v4.1.0
Add [AllowDynamicProperties] in the base view class for J5. Move the _prepareDocument  above the display call in the base view class. Remove all backward compatibility issues, so JCB will not need the [Backward Compatibility] plugin to run. Added new import powers for custom import of spreadsheets. Move the setDocument and _prepareDocument above the display in the site view and custom admin view. Update the trashhelper layout to work in Joomla 5. Add AllowDynamicProperties (Joomla 4+5) to view class to allow Custom Dynamic Get methods to work without issues. Fix Save failed issue in dynamicGet. #1148. Move all [TEXT, EDITOR, TEXTAREA] fields from [NOT NULL] to [NULL]. Add the DateHelper class and improve the date methods. Add simple SessionHelper class. Add first classes for the new import engine. Improve the [VDM Registry] to be Joomla Registry Compatible. Move all registries to the [VDM Registry] class. Fix Checked Out to be null and not 0. (#1194). Fix created_by, modified_by, checked_out fields in the compiler of the SQL. (#1194). Update all core date fields in table class. (#1188). Update created_by, modified_by, checked_out fields in table class. Implementation of the decentralized Super-Power CORE repository network. (#1190). Fix the noticeboard to display Llewellyn's Joomla Social feed. Started compiling JCB4 on Joomla 5 with PHP 8.2. Add init_defaults option for dynamic form selection setup (to int new items with default values dynamically). Update all JCB 4 tables to utf8mb4_unicode_ci collation if misaligned. Move all internal ID linking to GUID inside of JCB 4. Updated the admin-tab-fields in add-fields view. #1205. Remove Custom Import Tab from admin view. Improved the customcode and placeholder search features.
2025-02-14 23:01:37 +02:00

224 lines
5.3 KiB
PHP

<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this JCB template file (EVER)
defined('_JCB_TEMPLATE') or die;
?>
###BOM###
namespace ###NAMESPACEPREFIX###\Component\###ComponentNamespace###\Administrator\Model;
###CUSTOM_ADMIN_VIEWS_MODEL_HEADER###
// No direct access to this file
\defined('_JEXEC') or die;
/**
* ###Component### List Model for ###SViews###
*
* @since 1.6
*/
class ###SViews###Model extends ListModel
{
/**
* Represents the current user object.
*
* @var User The user object representing the current user.
* @since 3.2.0
*/
protected User $user;
/**
* The unique identifier of the current user.
*
* @var int|null The ID of the current user.
* @since 3.2.0
*/
protected ?int $userId;
/**
* Flag indicating whether the current user is a guest.
*
* @var int 1 if the user is a guest, 0 otherwise.
* @since 3.2.0
*/
protected int $guest;
/**
* An array of groups that the current user belongs to.
*
* @var array|null An array of user group IDs.
* @since 3.2.0
*/
protected ?array $groups;
/**
* An array of view access levels for the current user.
*
* @var array|null An array of access level IDs.
* @since 3.2.0
*/
protected ?array $levels;
/**
* The application object.
*
* @var CMSApplicationInterface The application instance.
* @since 3.2.0
*/
protected CMSApplicationInterface $app;
/**
* The input object, providing access to the request data.
*
* @var Input The input object.
* @since 3.2.0
*/
protected Input $input;
/**
* The styles array.
*
* @var array
* @since 4.3
*/
protected array $styles = [
'administrator/components/com_###component###/assets/css/admin.css',
'administrator/components/com_###component###/assets/css/###sviews###.css'
];
/**
* The scripts array.
*
* @var array
* @since 4.3
*/
protected array $scripts = [
'administrator/components/com_###component###/assets/js/admin.js'
];
/**
* A custom property for UI Kit components.
*
* @var mixed Property for storing UI Kit component-related data or objects.
* @since 3.2.0
*/
protected $uikitComp = [];
/**
* Constructor
*
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
* @param ?MVCFactoryInterface $factory The factory.
*
* @since 1.6
* @throws \Exception
*/
public function __construct($config = [], MVCFactoryInterface $factory = null)
{
parent::__construct($config, $factory);
$this->app ??= Factory::getApplication();
$this->input ??= $this->app->getInput();
// Set the current user for authorisation checks (for those calling this model directly)
$this->user ??= $this->getCurrentUser();
$this->userId = $this->user->get('id');
$this->guest = $this->user->get('guest');
$this->groups = $this->user->get('groups');
$this->authorisedGroups = $this->user->getAuthorisedGroups();
$this->levels = $this->user->getAuthorisedViewLevels();
// will be removed
$this->initSet = true;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @since 1.6
*/
protected function getListQuery()
{###CUSTOM_ADMIN_GET_LIST_QUERY###
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
* @since 1.6
*/
public function getItems()
{
$user = $this->user;
// check if this user has permission to access items
if (!$user->authorise('###sviews###.access', 'com_###component###'))
{
$this->app->enqueueMessage(Text::_('Not authorised!'), 'error');
// redirect away if not a correct to default view
$this->app->redirect('index.php?option=com_###component###');
return false;
}###LICENSE_LOCKED_CHECK######CUSTOM_ADMIN_BEFORE_GET_ITEMS###
// load parent items
$items = parent::getItems();
// Get the global params
$globalParams = ComponentHelper::getParams('com_###component###', true);###CUSTOM_ADMIN_GET_ITEMS######CUSTOM_ADMIN_AFTER_GET_ITEMS###
// return items
return $items;
}
/**
* Method to get the styles that have to be included on the view
*
* @return array styles files
* @since 4.3
*/
public function getStyles(): array
{
return $this->styles;
}
/**
* Method to set the styles that have to be included on the view
*
* @return void
* @since 4.3
*/
public function setStyles(string $path): void
{
$this->styles[] = $path;
}
/**
* Method to get the script that have to be included on the view
*
* @return array script files
* @since 4.3
*/
public function getScripts(): array
{
return $this->scripts;
}
/**
* Method to set the script that have to be included on the view
*
* @return void
* @since 4.3
*/
public function setScript(string $path): void
{
$this->scripts[] = $path;
}###CUSTOM_ADMIN_CUSTOM_METHODS######LICENSE_LOCKED_SET_BOOL######CUSTOM_ADMIN_CUSTOM_BUTTONS_METHOD###
}