_JEXEC & copyright

This commit is contained in:
Artem Vasilev 2024-03-09 18:57:42 +03:00
parent ce0b9a6bc9
commit e406da6ad7
2 changed files with 55 additions and 27 deletions

View File

@ -1,4 +1,11 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_oauthserver
*
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
* @license MIT; see LICENSE.txt
**/
namespace Webmasterskaya\Component\OauthServer\Administrator\View\Client;
@ -9,9 +16,10 @@ use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarFactoryInterface;
use Joomla\CMS\Toolbar\ToolbarHelper;
\defined('_JEXEC') or die;
class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
{
/**
@ -57,7 +65,8 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
$this->item = $this->get('Item');
// Check for errors
if (count($errors = $this->get('Errors'))) {
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode('\n', $errors), 500);
}
@ -91,7 +100,8 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
$title = ($isNew) ? Text::_('COM_OAUTHSERVER_CLIENT_ADD') : Text::_('COM_OAUTHSERVER_CLIENT_EDIT');
ToolbarHelper::title(Text::_('COM_OAUTHSERVER') . ': ' . $title, 'edit');
if ($isNew && (count($user->getAuthorisedCategories('com_oauthserver', 'core.create')) > 0)) {
if ($isNew && (count($user->getAuthorisedCategories('com_oauthserver', 'core.create')) > 0))
{
$toolbar->apply('client.apply');
$dropdown = $toolbar->dropdownButton('save-group');
@ -101,18 +111,23 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
$actions->save2new('client.save2new');
}
);
} else {
}
else
{
$itemEditable = $canDo->get('core.edit');
if ($itemEditable) {
if ($itemEditable)
{
$toolbar->apply('client.apply');
}
$dropdown = $toolbar->dropdownButton('save-group');
$dropdown->configure(
function (Toolbar $childBar) use ($itemEditable, $canDo) {
if ($itemEditable) {
if ($itemEditable)
{
$childBar->save('client.save');
if ($canDo->get('core.create')) {
if ($canDo->get('core.create'))
{
$childBar->save2new('client.save2new');
}
$childBar

View File

@ -1,8 +1,14 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_oauthserver
*
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
* @license MIT; see LICENSE.txt
**/
namespace Webmasterskaya\Component\OauthServer\Administrator\View\Clients;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
@ -10,9 +16,10 @@ use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarFactoryInterface;
use Joomla\CMS\Toolbar\ToolbarHelper;
\defined('_JEXEC') or die;
class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
{
/**
@ -88,16 +95,19 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
$this->activeFilters = $this->get('ActiveFilters');
// Set empty state
if (empty($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
if (empty($this->items) && $this->isEmptyState = $this->get('IsEmptyState'))
{
$this->setLayout('emptystate');
}
// Check for errors
if (count($errors = $this->get('Errors'))) {
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode('\n', $errors), 500);
}
if ($this->getLayout() !== 'modal') {
if ($this->getLayout() !== 'modal')
{
// Add title and toolbar
$this->addToolbar();
}
@ -125,11 +135,13 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
// Add create button
if ($canDo->get('core.create')
|| \count($user->getAuthorisedCategories('com_oauthserver', 'core.create')) > 0) {
|| \count($user->getAuthorisedCategories('com_oauthserver', 'core.create')) > 0)
{
$toolbar->addNew('client.add');
}
if ($canDo->get('core.delete')) {
if ($canDo->get('core.delete'))
{
$toolbar->delete('clients.delete')
->text('JTOOLBAR_DELETE')
->message('JGLOBAL_CONFIRM_DELETE')
@ -138,7 +150,8 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
// Add preferences button
if ($user->authorise('core.admin', 'com_oauthserver')
|| $user->authorise('core.options', 'com_oauthserver')) {
|| $user->authorise('core.options', 'com_oauthserver'))
{
$toolbar->preferences('com_oauthserver');
}
}