Component-Builder/admin/compiler/joomla_4/ADMIN_VIEWS_MODEL.php
Robot c8540f2efc
Update on v4.0.0-alpha1 (beta for next version)
Here's an update on the current version, which includes changes towards the next release still in beta.
2024-03-11 16:14:23 +02:00

190 lines
4.2 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;
###ADMIN_VIEWS_MODEL_HEADER###
// No direct access to this file
\defined('_JEXEC') or die;
/**
* ###Views### List Model
*
* @since 1.6
*/
class ###Views###Model extends ListModel
{
/**
* The application object.
*
* @var CMSApplicationInterface The application instance.
* @since 3.2.0
*/
protected CMSApplicationInterface $app;
/**
* 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/###views###.css'
];
/**
* The scripts array.
*
* @var array
* @since 4.3
*/
protected array $scripts = [
'administrator/components/com_###component###/assets/js/admin.js'
];
/**
* 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)
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
###FILTER_FIELDS###
);
}
parent::__construct($config, $factory);
$this->app ??= Factory::getApplication();
}###ADMIN_CUSTOM_BUTTONS_METHOD_LIST###
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
* @since 1.7.0
*/
protected function populateState($ordering = null, $direction = null)
{
$app = $this->app;
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}###POPULATESTATE###
// List state information.
parent::populateState($ordering, $direction);
}
/**
* 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()
{###LICENSE_LOCKED_CHECK######CHECKINCALL###
// load parent items
$items = parent::getItems();###GET_ITEMS_METHOD_STRING_FIX######SELECTIONTRANSLATIONFIX######GET_ITEMS_METHOD_AFTER_ALL###
// return items
return $items;
}###SELECTIONTRANSLATIONFIXFUNC###
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @since 1.6
*/
protected function getListQuery()
{###LICENSE_LOCKED_CHECK###
###LISTQUERY###
}###MODELEXPORTMETHOD######LICENSE_LOCKED_SET_BOOL###
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
* @since 1.6
*/
protected function getStoreId($id = '')
{
###STOREDID###
return parent::getStoreId($id);
}
/**
* 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;
}###AUTOCHECKIN###
}