mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 22:34:50 +03:00
минимально запускающаяся версия компонента
This commit is contained in:
parent
e08f89aaef
commit
f4dc0127a9
13
com_oauthserver/administrator/access.xml
Normal file
13
com_oauthserver/administrator/access.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<access component="com_oauthserver">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC"/>
|
||||
<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC"/>
|
||||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC"/>
|
||||
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC"/>
|
||||
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC"/>
|
||||
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC"/>
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC"/>
|
||||
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC"/>
|
||||
</section>
|
||||
</access>
|
25
com_oauthserver/administrator/config.xml
Normal file
25
com_oauthserver/administrator/config.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0"?>
|
||||
<config addfieldprefix="Joomla\Component\RadicalMart\Administrator\Field">
|
||||
<fieldset name="general" label="COM_RADICALMART_GENERAL">
|
||||
<fieldset name="general_root" label="COM_RADICALMART_GENERAL">
|
||||
<field name="legacy_mode" type="radio"
|
||||
label="COM_RADICALMART_PARAMS_LEGACY_MODE"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="1">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<fieldset name="permissions"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
description="JCONFIG_PERMISSIONS_DESC">
|
||||
<field name="rules" type="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
class="inputbox"
|
||||
validate="rules"
|
||||
filter="rules"
|
||||
component="com_oauthserver"
|
||||
section="component"/>
|
||||
</fieldset>
|
||||
</config>
|
23
com_oauthserver/administrator/forms/client.xml
Normal file
23
com_oauthserver/administrator/forms/client.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<config>
|
||||
<inlinehelp button="show"/>
|
||||
</config>
|
||||
<fieldset name="global">
|
||||
<field name="client_name" type="text"
|
||||
label="COM_OAUTHSERVER_CLIENT_FORM_CLIENT_NAME_LABEL"
|
||||
description="COM_OAUTHSERVER_CLIENT_FORM_CLIENT_NAME_DESCRIPTION"
|
||||
required="1"
|
||||
/>
|
||||
<field name="client_token"
|
||||
type="text"
|
||||
readonly="1"
|
||||
label="COM_OAUTHSERVER_CLIENT_FORM_CLIENT_TOKEN_LABEL"
|
||||
description="COM_OAUTHSERVER_CLIENT_FORM_CLIENT_TOKEN_DESCRIPTION"/>
|
||||
<field name="client_id"
|
||||
type="text"
|
||||
readonly="1"
|
||||
label="COM_OAUTHSERVER_CLIENT_FORM_CLIENT_ID_LABEL"
|
||||
description="COM_OAUTHSERVER_CLIENT_FORM_CLIENT_ID_DESCRIPTION"/>
|
||||
</fieldset>
|
||||
</form>
|
22
com_oauthserver/administrator/forms/filter_clients.xml
Normal file
22
com_oauthserver/administrator/forms/filter_clients.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="filter">
|
||||
<field name="search" type="text"
|
||||
label="JSEARCH_FILTER"
|
||||
hint="JSEARCH_FILTER"/>
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field name="fullordering" type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
onchange="Joomla.submitFilter(this.form);"
|
||||
default="client.id DESC">
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="client.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="client.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
<field name="limit" type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
onchange="Joomla.submitFilter(this.form);"
|
||||
default="25"/>
|
||||
</fields>
|
||||
</form>
|
0
com_oauthserver/administrator/forms/index.html
Normal file
0
com_oauthserver/administrator/forms/index.html
Normal file
@ -1,13 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Joomla\CMS\Component\Router\RouterFactoryInterface;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
||||
use Joomla\CMS\Extension\ComponentInterface;
|
||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
|
||||
use Joomla\CMS\HTML\Registry;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Webmasterskaya\Component\OauthServer\Administrator\Extension\Component;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
return new class implements ServiceProviderInterface {
|
||||
|
||||
public function register(\Joomla\DI\Container $container)
|
||||
public function register(Container $container): void
|
||||
{
|
||||
// TODO: Implement register() method.
|
||||
$container->registerServiceProvider(new MVCFactory('\\Webmasterskaya\\Component\\OauthServer'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Webmasterskaya\\Component\\OauthServer'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\Webmasterskaya\\Component\\OauthServer'));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$component = new Component($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setRegistry($container->get(Registry::class));
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
12
com_oauthserver/administrator/sql/install.mysql.utf8.sql
Normal file
12
com_oauthserver/administrator/sql/install.mysql.utf8.sql
Normal file
@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS `#__webmasterskaya_oauthserver_clients`
|
||||
(
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`client_name` varchar(150) NOT NULL,
|
||||
`client_token` varchar(255) NOT NULL,
|
||||
`client_id` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `client_token` (`client_token`),
|
||||
UNIQUE KEY `client_id` (`client_id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
DEFAULT COLLATE = utf8mb4_unicode_ci;
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
|
||||
class ClientController extends FormController
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $text_prefix = 'COM_OAUTHSERVER_CLIENT';
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The default view.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $default_view = 'clients';
|
||||
}
|
10
com_oauthserver/administrator/src/Dispatcher/Dispatcher.php
Normal file
10
com_oauthserver/administrator/src/Dispatcher/Dispatcher.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Dispatcher;
|
||||
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcher;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
class Dispatcher extends ComponentDispatcher
|
||||
{
|
||||
}
|
40
com_oauthserver/administrator/src/Model/ClientModel.php
Normal file
40
com_oauthserver/administrator/src/Model/ClientModel.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
|
||||
class ClientModel extends AdminModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $context = 'com_oauthserver.client';
|
||||
|
||||
/**
|
||||
* Client item.
|
||||
*
|
||||
* @var array|null
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?array $_item = null;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param bool $loadData
|
||||
* @return \Joomla\CMS\Form\Form|bool
|
||||
* @throws \Exception
|
||||
* @since version
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true): Form|bool
|
||||
{
|
||||
return $this->loadForm('com_oauthserver.client', 'client',
|
||||
['control' => 'jform', 'load_data' => $loadData]);
|
||||
}
|
||||
}
|
116
com_oauthserver/administrator/src/Model/ClientsModel.php
Normal file
116
com_oauthserver/administrator/src/Model/ClientsModel.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
class ClientsModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $context = 'com_oauthserver.clients';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null)
|
||||
{
|
||||
// Add the ordering filtering fields whitelist
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'client.id'
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config, $factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null): void
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Adjust the context to support modal layouts.
|
||||
if ($layout = $app->input->get('layout')) {
|
||||
$this->context .= '.' . $layout;
|
||||
}
|
||||
|
||||
// List state information
|
||||
$ordering = empty($ordering) ? 'client.id' : $ordering;
|
||||
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function getStoreId($id = ''): string
|
||||
{
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a DatabaseQuery object for retrieving the data set from a database.
|
||||
*
|
||||
* @return \Joomla\Database\QueryInterface A QueryInterface object to retrieve the data set.
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function getListQuery(): \Joomla\Database\QueryInterface
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select(['client.id', 'client.client_name', 'client.client_token', 'client.client_id',])
|
||||
->from($db->qn('#__webmasterskaya_oauthserver_clients', 'client'));
|
||||
|
||||
// Filter by search state
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search)) {
|
||||
$query->where('client.name LIKE :search')
|
||||
->bind(':search', $search, ParameterType::STRING);
|
||||
}
|
||||
|
||||
// Add the list ordering clause
|
||||
$ordering = $this->state->get('list.ordering', 'client.id');
|
||||
$direction = $this->state->get('list.direction', 'desc');
|
||||
$query->order($db->escape($ordering) . ' ' . $db->escape($direction));
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
21
com_oauthserver/administrator/src/Table/ClientTable.php
Normal file
21
com_oauthserver/administrator/src/Table/ClientTable.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
class ClientTable extends Table
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
parent::__construct('#__webmasterskaya_oauthserver_clients', 'id', $db);
|
||||
}
|
||||
}
|
131
com_oauthserver/administrator/src/View/Client/HtmlView.php
Normal file
131
com_oauthserver/administrator/src/View/Client/HtmlView.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\View\Client;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
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;
|
||||
|
||||
class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
||||
{
|
||||
/**
|
||||
* Model state variables.
|
||||
*
|
||||
* @var \Joomla\CMS\Object\CMSObject
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected CMSObject $state;
|
||||
|
||||
/**
|
||||
* Form object.
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected Form $form;
|
||||
|
||||
/**
|
||||
* The active item.
|
||||
*
|
||||
* @var object
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected object $item;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse.
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
|
||||
// Check for errors
|
||||
if (count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode('\n', $errors), 500);
|
||||
}
|
||||
|
||||
// Hard set layout
|
||||
$this->setLayout('edit');
|
||||
|
||||
// Add title and toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add title and toolbar.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
// Hide main menu
|
||||
Factory::getApplication()->input->set('hidemainmenu', true);
|
||||
|
||||
$canDo = ContentHelper::getActions('com_oauthserver', 'client');
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$toolbar = Toolbar::getInstance('toolbar');
|
||||
|
||||
// Set page title
|
||||
$isNew = ($this->item->id == 0);
|
||||
$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)) {
|
||||
$toolbar->apply('client.apply');
|
||||
|
||||
$dropdown = $toolbar->dropdownButton('save-group');
|
||||
$dropdown->configure(
|
||||
function (Toolbar $actions) use ($user) {
|
||||
$actions->save('client.save');
|
||||
$actions->save2new('client.save2new');
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$itemEditable = $canDo->get('core.edit');
|
||||
if ($itemEditable) {
|
||||
$toolbar->apply('client.apply');
|
||||
}
|
||||
|
||||
$dropdown = $toolbar->dropdownButton('save-group');
|
||||
$dropdown->configure(
|
||||
function (Toolbar $childBar) use ($itemEditable, $canDo) {
|
||||
if ($itemEditable) {
|
||||
$childBar->save('client.save');
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save2new('client.save2new');
|
||||
}
|
||||
$childBar
|
||||
->standardButton('save-reset', 'COM_OAUTHSERVER_CLIENT_SAVE_AND_RESET')
|
||||
->task('client.save2reset')
|
||||
->formValidation(true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar->cancel('client.cancel');
|
||||
|
||||
ToolbarHelper::inlinehelp();
|
||||
}
|
||||
}
|
142
com_oauthserver/administrator/src/View/Clients/HtmlView.php
Normal file
142
com_oauthserver/administrator/src/View/Clients/HtmlView.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Pagination\Pagination;
|
||||
use Joomla\CMS\Toolbar\ToolbarFactoryInterface;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
||||
{
|
||||
/**
|
||||
* Model state variables.
|
||||
*
|
||||
* @var \Joomla\CMS\Object\CMSObject
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected CMSObject $state;
|
||||
|
||||
/**
|
||||
* An array of items.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $items;
|
||||
|
||||
/**
|
||||
* Pagination object.
|
||||
*
|
||||
* @var \Joomla\CMS\Pagination\Pagination
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected Pagination $pagination;
|
||||
|
||||
/**
|
||||
* Form object for search filters.
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Form $filterForm;
|
||||
|
||||
|
||||
/**
|
||||
* The active search filters.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public array $activeFilters;
|
||||
|
||||
/**
|
||||
* Is this view an Empty State.
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private bool $isEmptyState = false;
|
||||
|
||||
/**
|
||||
* Display the view.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse.
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
// Set empty state
|
||||
if (empty($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
|
||||
$this->setLayout('emptystate');
|
||||
}
|
||||
|
||||
// Check for errors
|
||||
if (count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode('\n', $errors), 500);
|
||||
}
|
||||
|
||||
if ($this->getLayout() !== 'modal') {
|
||||
// Add title and toolbar
|
||||
$this->addToolbar();
|
||||
}
|
||||
|
||||
// Set status field value
|
||||
$this->filterForm->setValue('status', null, $this->state->get('filter.status'));
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add title and toolbar.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
$canDo = ContentHelper::getActions('com_oauthserver', 'clients');
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$toolbar = Factory::getContainer()->get(ToolbarFactoryInterface::class)->createToolbar('toolbar');
|
||||
|
||||
// Set page title
|
||||
ToolbarHelper::title(Text::_('COM_OAUTHSERVER') . ': ' . Text::_('COM_OAUTHSERVER_CLIENTS'));
|
||||
|
||||
// Add create button
|
||||
if ($canDo->get('core.create')
|
||||
|| \count($user->getAuthorisedCategories('com_oauthserver', 'core.create')) > 0) {
|
||||
$toolbar->addNew('client.add');
|
||||
}
|
||||
|
||||
// Add actions dropdown
|
||||
if (!$this->isEmptyState) {
|
||||
// TODO: Что мы тут в дропдаун пихаем?
|
||||
}
|
||||
|
||||
// Add preferences button
|
||||
if ($user->authorise('core.admin', 'com_oauthserver')
|
||||
|| $user->authorise('core.options', 'com_oauthserver')) {
|
||||
$toolbar->preferences('com_oauthserver');
|
||||
}
|
||||
}
|
||||
}
|
49
com_oauthserver/administrator/tmpl/client/edit.php
Normal file
49
com_oauthserver/administrator/tmpl/client/edit.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var \Webmasterskaya\Component\OauthServer\Administrator\View\Client\HtmlView $this
|
||||
*/
|
||||
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate');
|
||||
|
||||
?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_oauthserver&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="client-form" aria-label="<?php echo Text::_('COM_OAUTHSERVER_CLIENT_FORM_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>" class="form-validate">
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>
|
||||
|
||||
<div class="main-card">
|
||||
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', Text::_('COM_BANNERS_BANNER_DETAILS')); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<fieldset id="fieldset-publishingdata" class="options-form">
|
||||
<legend><?php echo Text::_('COM_OAUTHSERVER_CLIENT'); ?></legend>
|
||||
<div>
|
||||
<?php echo $this->form->renderFieldset('global');?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
|
2
com_oauthserver/administrator/tmpl/clients/default.php
Normal file
2
com_oauthserver/administrator/tmpl/clients/default.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
|
27
com_oauthserver/administrator/tmpl/clients/emptystate.php
Normal file
27
com_oauthserver/administrator/tmpl/clients/emptystate.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @var \Webmasterskaya\Component\OauthServer\Administrator\View\Clients\HtmlView $this
|
||||
*/
|
||||
|
||||
$displayData = [
|
||||
'textPrefix' => 'COM_OAUTHSERVER_ORDERS',
|
||||
'icon' => 'icon-copy',
|
||||
];
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ($user->authorise('core.create', 'com_oauthserver')
|
||||
|| count($user->getAuthorisedCategories('com_oauthserver', 'core.create')) > 0
|
||||
|| $user->authorise('product.create', 'com_oauthserver')
|
||||
|| count($user->getAuthorisedCategories('com_oauthserver', 'client.create')) > 0
|
||||
) {
|
||||
$displayData['createURL'] = 'index.php?option=com_oauthserver&task=client.add';
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
67
com_oauthserver/oauthserver.xml
Normal file
67
com_oauthserver/oauthserver.xml
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>COM_OAUTHSERVER</name>
|
||||
<description>COM_OAUTHSERVER_DESCRIPTION</description>
|
||||
<author>Artem Vasilev</author>
|
||||
<authorEmail>kern.usr@gmial.com</authorEmail>
|
||||
<authorUrl>https://webmasterskaya.xyz</authorUrl>
|
||||
<creationDate>March 2024</creationDate>
|
||||
<copyright>Copyright (C) 2024 Webmasterskaya. All rights reserved.</copyright>
|
||||
<license>MIT; see LICENSE.txt</license>
|
||||
<version>RELEASE_VERSION</version>
|
||||
<namespace path="src">Webmasterskaya\Component\OauthServer</namespace>
|
||||
<install>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<uninstall>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<update>
|
||||
<schemas>
|
||||
<schemapath type="mysql">sql/updates/mysql</schemapath>
|
||||
</schemas>
|
||||
</update>
|
||||
<files folder="site">
|
||||
<folder>forms</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.ini</language>
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.sys.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.sys.ini</language>
|
||||
</languages>
|
||||
<administration>
|
||||
<menu>COM_OAUTHSERVER</menu>
|
||||
<submenu>
|
||||
<menu
|
||||
link="option=com_oauthserver"
|
||||
view="clients"
|
||||
img="class:clients"
|
||||
alt="Oauth Server/Clients"
|
||||
>
|
||||
com_oauthserver_clients
|
||||
</menu>
|
||||
</submenu>
|
||||
<files folder="administrator">
|
||||
<folder>forms</folder>
|
||||
<folder>services</folder>
|
||||
<folder>sql</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.ini</language>
|
||||
<language tag="en-GB">language/en-GB/en-GB.com_oauthserver.sys.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.ini</language>
|
||||
<language tag="ru-RU">language/ru-RU/ru-RU.com_oauthserver.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
0
com_oauthserver/site/forms/index.html
Normal file
0
com_oauthserver/site/forms/index.html
Normal file
0
com_oauthserver/site/src/index.html
Normal file
0
com_oauthserver/site/src/index.html
Normal file
0
com_oauthserver/site/tmpl/index.html
Normal file
0
com_oauthserver/site/tmpl/index.html
Normal file
Loading…
Reference in New Issue
Block a user