mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-24 02:44:51 +03:00
_JEXEC & copyright
This commit is contained in:
parent
ce0b9a6bc9
commit
e406da6ad7
@ -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
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -44,7 +52,7 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|||||||
/**
|
/**
|
||||||
* Execute and display a template script.
|
* Execute and display a template script.
|
||||||
*
|
*
|
||||||
* @param string $tpl The name of the template file to parse.
|
* @param string $tpl The name of the template file to parse.
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*
|
*
|
||||||
@ -53,11 +61,12 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|||||||
public function display($tpl = null): void
|
public function display($tpl = null): void
|
||||||
{
|
{
|
||||||
$this->state = $this->get('State');
|
$this->state = $this->get('State');
|
||||||
$this->form = $this->get('Form');
|
$this->form = $this->get('Form');
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +92,7 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|||||||
|
|
||||||
$canDo = ContentHelper::getActions('com_oauthserver', 'client');
|
$canDo = ContentHelper::getActions('com_oauthserver', 'client');
|
||||||
|
|
||||||
$user = $this->getCurrentUser();
|
$user = $this->getCurrentUser();
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
$toolbar = Toolbar::getInstance('toolbar');
|
||||||
|
|
||||||
// Set page title
|
// Set page title
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -73,7 +80,7 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|||||||
/**
|
/**
|
||||||
* Display the view.
|
* Display the view.
|
||||||
*
|
*
|
||||||
* @param string $tpl The name of the template file to parse.
|
* @param string $tpl The name of the template file to parse.
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*
|
*
|
||||||
@ -81,23 +88,26 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|||||||
*/
|
*/
|
||||||
public function display($tpl = null): void
|
public function display($tpl = null): void
|
||||||
{
|
{
|
||||||
$this->state = $this->get('State');
|
$this->state = $this->get('State');
|
||||||
$this->items = $this->get('Items');
|
$this->items = $this->get('Items');
|
||||||
$this->pagination = $this->get('Pagination');
|
$this->pagination = $this->get('Pagination');
|
||||||
$this->filterForm = $this->get('FilterForm');
|
$this->filterForm = $this->get('FilterForm');
|
||||||
$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();
|
||||||
}
|
}
|
||||||
@ -117,7 +127,7 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|||||||
{
|
{
|
||||||
$canDo = ContentHelper::getActions('com_oauthserver', 'clients');
|
$canDo = ContentHelper::getActions('com_oauthserver', 'clients');
|
||||||
|
|
||||||
$user = $this->getCurrentUser();
|
$user = $this->getCurrentUser();
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
$toolbar = Toolbar::getInstance('toolbar');
|
||||||
|
|
||||||
// Set page title
|
// Set page title
|
||||||
@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user