Migrates view HTML classes to use getModel() directly instead of the deprecated magic get() calls to model methods. Refactores event handling (contentPrepare, titlePrepare, contentBeforeDisplay, contentAfterDisplay) to use Joomla 5’s native event dispatcher via the model’s new getDispatcher() method. Updates table classes to properly support NULL values, both in the store() method and in table variable definitions. #1245. Extractes the setAutoCheckIn() and setCheckInCall() logic into a dedicated CheckInNow class for cleaner design. Replace all direct $app->input property calls with the recommended $app->getInput() method across the entire codebase.
130 lines
3.2 KiB
PHP
130 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* @package Joomla.Component.Builder
|
|
*
|
|
* @created 30th April, 2015
|
|
* @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 file
|
|
defined('_JEXEC') or die('Restricted access');
|
|
?>
|
|
###BOM###
|
|
|
|
// No direct access to this file
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
###CUSTOM_ADMIN_VIEW_MODEL_HEADER###
|
|
|
|
/**
|
|
* ###Component### ###SView### Item Model
|
|
*/
|
|
class ###Component###Model###SView### extends ItemModel
|
|
{
|
|
/**
|
|
* Model context string.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $_context = 'com_###component###.###sview###';
|
|
|
|
/**
|
|
* Model user data.
|
|
*
|
|
* @var strings
|
|
*/
|
|
protected $user;
|
|
protected $userId;
|
|
protected $guest;
|
|
protected $groups;
|
|
protected $levels;
|
|
protected $app;
|
|
protected $input;
|
|
protected $uikitComp;
|
|
|
|
/**
|
|
* @var object item
|
|
*/
|
|
protected $item;
|
|
|
|
/**
|
|
* Method to auto-populate the model state.
|
|
*
|
|
* Note. Calling getState in this method will result in recursion.
|
|
*
|
|
* @since 1.6
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function populateState()
|
|
{
|
|
$this->app = Factory::getApplication();
|
|
$this->input = method_exists($this->app, 'getInput') ? $this->app->getInput() : $this->app->input;
|
|
// Get the item main id
|
|
$id = $this->input->getInt('id', null);
|
|
$this->setState('###sview###.id', $id);
|
|
|
|
// Load the parameters.
|
|
parent::populateState();
|
|
}
|
|
|
|
/**
|
|
* Method to get article data.
|
|
*
|
|
* @param integer $pk The id of the article.
|
|
*
|
|
* @return mixed Menu item data object on success, false on failure.
|
|
*/
|
|
public function getItem($pk = null)
|
|
{
|
|
$this->user = Factory::getUser();
|
|
// check if this user has permission to access item
|
|
if (!$this->user->authorise('###sview###.access', 'com_###component###'))
|
|
{
|
|
$app = Factory::getApplication();
|
|
$app->enqueueMessage(Text::_('Not authorised!'), 'error');
|
|
// redirect away if not a correct to cPanel/default view
|
|
$app->redirect('index.php?option=com_###component###');
|
|
return false;
|
|
}
|
|
$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();
|
|
$this->initSet = true;
|
|
|
|
$pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###CUSTOM_ADMIN_BEFORE_GET_ITEM###
|
|
|
|
if ($this->_item === null)
|
|
{
|
|
$this->_item = [];
|
|
}###LICENSE_LOCKED_CHECK###
|
|
|
|
if (!isset($this->_item[$pk]))
|
|
{
|
|
try
|
|
{###CUSTOM_ADMIN_GET_ITEM###
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
if ($e->getCode() == 404)
|
|
{
|
|
// Need to go thru the error handler to allow Redirect to work.
|
|
JError::raiseError(404, $e->getMessage());
|
|
}
|
|
else
|
|
{
|
|
$this->setError($e);
|
|
$this->_item[$pk] = false;
|
|
}
|
|
}
|
|
}###CUSTOM_ADMIN_AFTER_GET_ITEM###
|
|
|
|
return $this->_item[$pk];
|
|
}###CUSTOM_ADMIN_CUSTOM_METHODS######LICENSE_LOCKED_SET_BOOL######CUSTOM_ADMIN_CUSTOM_BUTTONS_METHOD###
|
|
}
|