_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 <?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; 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\MVC\View\GenericDataException;
use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarFactoryInterface;
use Joomla\CMS\Toolbar\ToolbarHelper; use Joomla\CMS\Toolbar\ToolbarHelper;
\defined('_JEXEC') or die;
class HtmlView extends \Joomla\CMS\MVC\View\HtmlView 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'); $this->item = $this->get('Item');
// Check for errors // Check for errors
if (count($errors = $this->get('Errors'))) { if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode('\n', $errors), 500); 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'); $title = ($isNew) ? Text::_('COM_OAUTHSERVER_CLIENT_ADD') : Text::_('COM_OAUTHSERVER_CLIENT_EDIT');
ToolbarHelper::title(Text::_('COM_OAUTHSERVER') . ': ' . $title, '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'); $toolbar->apply('client.apply');
$dropdown = $toolbar->dropdownButton('save-group'); $dropdown = $toolbar->dropdownButton('save-group');
@ -101,18 +111,23 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
$actions->save2new('client.save2new'); $actions->save2new('client.save2new');
} }
); );
} else { }
else
{
$itemEditable = $canDo->get('core.edit'); $itemEditable = $canDo->get('core.edit');
if ($itemEditable) { if ($itemEditable)
{
$toolbar->apply('client.apply'); $toolbar->apply('client.apply');
} }
$dropdown = $toolbar->dropdownButton('save-group'); $dropdown = $toolbar->dropdownButton('save-group');
$dropdown->configure( $dropdown->configure(
function (Toolbar $childBar) use ($itemEditable, $canDo) { function (Toolbar $childBar) use ($itemEditable, $canDo) {
if ($itemEditable) { if ($itemEditable)
{
$childBar->save('client.save'); $childBar->save('client.save');
if ($canDo->get('core.create')) { if ($canDo->get('core.create'))
{
$childBar->save2new('client.save2new'); $childBar->save2new('client.save2new');
} }
$childBar $childBar

View File

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