Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/7/remove dictrait & Opencast PHP Library integration #186

Merged
merged 36 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bdf6e61
oc-php-lib installation
ferishili Jul 21, 2023
b176462
oc-php-lib integration
ferishili Jul 21, 2023
ad8c256
bugfix
ferishili Jul 25, 2023
8d55b7b
bugfix: no effective use of new classnames --all
ferishili Jul 31, 2023
957baa4
bugfix: no effective uses --remaining
ferishili Jul 31, 2023
d6335f2
more accurate sign player links for mp4s
ferishili Aug 7, 2023
2f63948
Removed DICTrait from classes/*
chfsx Aug 10, 2023
7cc688d
[FIX] removed DICTrait from src/*
chfsx Aug 10, 2023
b1742d3
Removed most of ERRORS in inspection profile
chfsx Jun 23, 2023
55e0eb2
Several Code Improvements
chfsx Aug 10, 2023
f97f19f
Another Bunch of code improvements
chfsx Aug 10, 2023
f11f87f
[FIX] missing static plugin() call replacement
chfsx Aug 17, 2023
8f9aa9d
oc-php-lib installation
ferishili Jul 21, 2023
e54339e
oc-php-lib integration
ferishili Jul 21, 2023
3c257c6
bugfix: no effective use of new classnames --all
ferishili Jul 31, 2023
7d6d41b
[FIX] updated classmap
chfsx Aug 17, 2023
4995493
Moved API to PSR-4 namespace
chfsx Aug 17, 2023
62c0397
Introduce new container for opencast
chfsx Aug 17, 2023
bc6a258
Make API usage non static
chfsx Aug 17, 2023
7931c55
renamed method to routes()
chfsx Aug 17, 2023
28c1be4
renamed method to rest()
chfsx Aug 17, 2023
c511bfb
Finalized non static usage of API
chfsx Aug 17, 2023
4322d33
Merge branch 'oc-php-lib' of https://github.com/srsolutionsag/OpenCas…
ferishili Aug 18, 2023
ae283ca
after resolving conflicts fixes
ferishili Aug 18, 2023
9db1158
upgrading elan-ev/OpencastApi lib to 1.4
ferishili Aug 18, 2023
d6727fe
providing default api creds, if not exists
ferishili Aug 21, 2023
f47f480
[FIX] removed JSON_THROW_ON_ERROR
chfsx Aug 21, 2023
0b85663
bugfix: secure link with new OpencastAPI
ferishili Aug 21, 2023
e22a254
removing old xoctOpencastApi & co.
ferishili Aug 21, 2023
592b6ca
[FIX] remove static self::plugin() calls
chfsx Aug 21, 2023
d0ed663
Merge pull request #2 from srsolutionsag/elan/oc-php-lib_2
ferishili Aug 21, 2023
9689283
follow-up fixes for DICTrait refactorings
ferishili Aug 22, 2023
397aa54
Merge branch 'version_check_fix' into oc-php-lib
ferishili Aug 23, 2023
614ba21
Merge branch 'issue-183' into oc-php-lib
ferishili Aug 23, 2023
63f88f9
fix: config misplaced ui
ferishili Aug 23, 2023
0cf065f
fix: removing "more_entropy" flag from uniqids
ferishili Aug 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 21 additions & 14 deletions classes/Conf/Export/class.xoctConfExportGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,32 @@
*/
class xoctConfExportGUI extends xoctGUI
{
/**
* @var \ilToolbarGUI
*/
protected $toolbar;

public function __construct()
{
global $DIC;
parent::__construct();
$this->toolbar = $DIC->toolbar();
}

protected function index()
{
$b = ilLinkButton::getInstance();
$b->setCaption('rep_robj_xoct_admin_export');
$b->setUrl(self::dic()->ctrl()->getLinkTarget($this, 'export'));
self::dic()->toolbar()->addButtonInstance($b);
self::dic()->toolbar()->addSpacer();
self::dic()->toolbar()->addSeparator();
self::dic()->toolbar()->addSpacer();
$b->setUrl($this->ctrl->getLinkTarget($this, 'export'));
$this->toolbar->addButtonInstance($b);
$this->toolbar->addSpacer();
$this->toolbar->addSeparator();
$this->toolbar->addSpacer();

self::dic()->toolbar()->setFormAction(self::dic()->ctrl()->getLinkTarget($this, 'import'), true);
$this->toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'import'), true);
$import = new ilFileInputGUI('xoct_import', 'xoct_import');
self::dic()->toolbar()->addInputItem($import);
self::dic()->toolbar()->addFormButton(self::plugin()->translate('admin_import'), 'import');
$this->toolbar->addInputItem($import);
$this->toolbar->addFormButton($this->plugin->txt('admin_import'), 'import');
}

/**
Expand All @@ -39,6 +51,7 @@ protected function import()

/**
*
* @return never
*/
protected function export()
{
Expand All @@ -48,32 +61,26 @@ protected function export()
exit;
}


protected function add()
{
}


protected function create()
{
}


protected function edit()
{
}


protected function update()
{
}


protected function confirmDelete()
{
}


protected function delete()
{
}
Expand Down
124 changes: 75 additions & 49 deletions classes/Conf/Metadata/class.xoctMetadataConfigGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use ILIAS\UI\Component\Input\Container\Form\Standard;
use ILIAS\UI\Factory as UIFactory;
use ILIAS\UI\Renderer;
use srag\DIC\OpenCast\Exception\DICException;
use srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR;
use srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigRepository;
use srag\Plugins\Opencast\Model\Metadata\Config\MDPrefillOption;
Expand All @@ -13,9 +12,12 @@
use srag\Plugins\Opencast\Model\Metadata\Definition\MDFieldDefinition;
use srag\Plugins\Opencast\UI\Metadata\Config\MDConfigTable;
use srag\Plugins\Opencast\Model\Metadata\Definition\MDDataType;
use srag\Plugins\Opencast\LegacyHelpers\OutputTrait;

abstract class xoctMetadataConfigGUI extends xoctGUI
{
use OutputTrait;

public const CMD_STORE = 'store';
public const CMD_REORDER = 'reorder';

Expand Down Expand Up @@ -53,28 +55,42 @@ abstract class xoctMetadataConfigGUI extends xoctGUI
* @var ilPlugin
*/
protected $plugin;
/**
* @var \ilToolbarGUI
*/
private $toolbar;
/**
* @var \ILIAS\DI\UIServices
*/
private $ui;
/**
* @var \ILIAS\HTTP\Services
*/
private $http;

public function __construct(
MDFieldConfigRepository $repository,
MDCatalogueFactory $md_catalogue_factory,
Container $dic,
ilPlugin $plugin
Container $dic
) {
parent::__construct();
$this->dic = $dic;
$ui = $this->dic->ui();
$this->toolbar = $this->dic->toolbar();
$this->ui = $this->dic->ui();
$this->http = $this->dic->http();
$this->repository = $repository;
$this->ui_factory = self::dic()->ui()->factory();
$this->renderer = self::dic()->ui()->renderer();
$this->ui_factory = $ui->factory();
$this->renderer = $ui->renderer();
$this->md_catalogue_factory = $md_catalogue_factory;
$this->dic = $dic;
$this->plugin = $plugin;
}


/**
* @throws xoctException
*/
public function executeCommand()
public function executeCommand(): void
{
$cmd = self::dic()->ctrl()->getCmd(self::CMD_STANDARD);
$cmd = $this->ctrl->getCmd(self::CMD_STANDARD);
if (!in_array($cmd, self::$available_commands)) {
throw new xoctException(xoctException::INTERNAL_ERROR, "invalid command: $cmd");
}
Expand All @@ -89,30 +105,35 @@ protected function index()
{
$items = [];
foreach ($this->getAvailableMetadataFields() as $field_id) {
self::dic()->ctrl()->setParameter($this, 'field_id', $field_id);
$this->ctrl->setParameter($this, 'field_id', $field_id);
$items[] = $this->ui_factory->link()->standard(
$field_id,
self::dic()->ctrl()->getLinkTarget($this, self::CMD_ADD)
$this->ctrl->getLinkTarget($this, self::CMD_ADD)
);
}
self::dic()->ctrl()->clearParameters($this);
if (count($items)) {
self::dic()->toolbar()->addComponent(
self::dic()->ui()->factory()->dropdown()->standard(
$this->ctrl->clearParameters($this);
if ($items !== []) {
$this->toolbar->addComponent(
$this->ui->factory()->dropdown()->standard(
$items
)->withLabel(self::plugin()->translate('btn_add_new_metadata_field'))
)->withLabel($this->plugin->txt('btn_add_new_metadata_field'))
);
}

self::output()->output($this->buildTable());
$this->ui->mainTemplate()->setContent($this->buildTable()->getHTML());
}

protected function buildTable(): MDConfigTable
{
return new MDConfigTable($this, $this->getTableTitle(), $this->dic, $this->plugin, $this->repository->getArray());
return new MDConfigTable(
$this,
$this->getTableTitle(),
$this->dic,
$this->plugin,
$this->repository->getArray()
);
}


/**
* @throws ilTemplateException
* @throws xoctException
Expand All @@ -122,7 +143,7 @@ protected function add()
{
$field_id = filter_input(INPUT_GET, 'field_id', FILTER_SANITIZE_STRING);
$form = $this->buildForm($field_id);
self::output()->output($this->renderer->render($form));
$this->output($this->renderer->render($form));
}

/**
Expand All @@ -134,7 +155,7 @@ protected function edit()
{
$field_id = filter_input(INPUT_GET, 'field_id', FILTER_SANITIZE_STRING);
$form = $this->buildForm($field_id);
self::output()->output($this->renderer->render($form));
$this->output($this->renderer->render($form));
}

/**
Expand All @@ -145,15 +166,15 @@ protected function edit()
protected function store()
{
$field_id = filter_input(INPUT_GET, 'field_id', FILTER_SANITIZE_STRING);
$form = $this->buildForm($field_id)->withRequest(self::dic()->http()->request());
$form = $this->buildForm($field_id)->withRequest($this->http->request());
$data = $form->getData();
if (is_null($data)) {
$this->dic->ui()->mainTemplate()->setContent($this->renderer->render($form));
return;
}
$this->repository->storeFromArray($data['fields']);
ilUtil::sendSuccess(self::plugin()->translate('msg_success'), true);
self::dic()->ctrl()->redirect($this, self::CMD_STANDARD);
ilUtil::sendSuccess($this->plugin->txt('msg_success'), true);
$this->ctrl->redirect($this, self::CMD_STANDARD);
}

protected function confirmDelete()
Expand All @@ -170,10 +191,10 @@ protected function delete()

protected function getAvailableMetadataFields(): array
{
$already_configured = array_map(function (MDFieldConfigAR $md_config) {
$already_configured = array_map(function (MDFieldConfigAR $md_config): string {
return $md_config->getFieldId();
}, $this->repository->getAll(false));
$available_total = array_map(function (MDFieldDefinition $md_field_def) {
$available_total = array_map(function (MDFieldDefinition $md_field_def): string {
return $md_field_def->getId();
}, $this->getMetadataCatalogue()->getFieldDefinitions());
return array_diff($available_total, $already_configured);
Expand All @@ -182,51 +203,53 @@ protected function getAvailableMetadataFields(): array
abstract protected function getMetadataCatalogue(): MDCatalogue;

/**
* @param string $field_id
* @param string $cmd
* @return Standard
* @throws DICException
* @throws xoctException
*/
protected function buildForm(string $field_id): Standard
{
self::dic()->ctrl()->setParameter($this, 'field_id', $field_id);
$this->ctrl->setParameter($this, 'field_id', $field_id);
$md_field_def = $this->getMetadataCatalogue()->getFieldById($field_id);
$md_field_config = $this->repository->findByFieldId($field_id);
$fields = [
'field_id' => $this->ui_factory->input()->field()->text(
self::plugin()->translate('md_field_id')
$this->plugin->txt('md_field_id')
)
->withDisabled(true)
->withValue($field_id)
->withRequired(true),
'title_de' => $this->ui_factory->input()->field()->text(
self::plugin()->translate('md_title_de')
$this->plugin->txt('md_title_de')
)
->withRequired(true)
->withValue(
$md_field_config ? $md_field_config->getTitle('de') : ''
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getTitle(
'de'
) : ''
),
'title_en' => $this->ui_factory->input()->field()->text(
self::plugin()->translate('md_title_en')
$this->plugin->txt('md_title_en')
)
->withRequired(true)
->withValue(
$md_field_config ? $md_field_config->getTitle('en') : ''
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getTitle(
'en'
) : ''
),
'visible_for_permissions' => $this->ui_factory->input()->field()->select(
self::plugin()->translate('md_visible_for_permissions'),
$this->plugin->txt('md_visible_for_permissions'),
[
MDFieldConfigAR::VISIBLE_ALL => $this->plugin->txt('md_visible_all'),
MDFieldConfigAR::VISIBLE_ADMIN => $this->plugin->txt('md_visible_admin')
]
)->withRequired(true)
->withValue(
$md_field_config ? $md_field_config->getVisibleForPermissions(
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getVisibleForPermissions(
) : null
),
'required' => $this->ui_factory->input()->field()->checkbox(
self::plugin()->translate('md_required')
$this->plugin->txt('md_required')
)
->withDisabled(
$md_field_def->isRequired() || $md_field_def->isReadOnly()
Expand All @@ -236,41 +259,44 @@ protected function buildForm(string $field_id): Standard
) || ($md_field_config && $md_field_config->isRequired())
),
'read_only' => $this->ui_factory->input()->field()->checkbox(
self::plugin()->translate('md_read_only')
$this->plugin->txt('md_read_only')
)
->withDisabled($md_field_def->isReadOnly())
->withValue(
$md_field_def->isReadOnly(
) || ($md_field_config && $md_field_config->isReadOnly())
),
'prefill' => $this->ui_factory->input()->field()->select(
self::plugin()->translate('md_prefill'),
$this->plugin->txt('md_prefill'),
$this->getPrefillOptions()
)
->withRequired(true)
->withDisabled($md_field_def->isReadOnly())
->withValue(
$md_field_config ? $md_field_config->getPrefill()->getValue(
) : MDPrefillOption::T_NONE
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getPrefill(
)->getValue() : MDPrefillOption::T_NONE
)
];

if ($md_field_def->getType()->getTitle() === MDDataType::TYPE_TEXT_SELECTION) {
$fields['values'] = $this->ui_factory->input()->field()->textarea(
self::plugin()->translate('md_values'),
self::plugin()->translate('md_values_info', '', [MDFieldConfigAR::VALUE_SEPERATOR])
$this->plugin->txt('md_values'),
$this->plugin->txt('md_values_info')
)->withValue(
$md_field_config ? $md_field_config->getValuesAsEditableString() : ''
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getValuesAsEditableString(
) : ''
)->withRequired(true)
->withDisabled($md_field_def->isReadOnly());
->withDisabled($md_field_def->isReadOnly());
}

return $this->ui_factory->input()->container()->form()->standard(
self::dic()->ctrl()->getFormAction($this, self::CMD_STORE),
$this->ctrl->getFormAction($this, self::CMD_STORE),
[
'fields' => $this->ui_factory->input()->field()->section(
$fields,
$this->plugin->txt('md_conf_form_' . ($md_field_config ? 'edit' : 'create'))
$this->plugin->txt(
'md_conf_form_' . ($md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? 'edit' : 'create')
)
)
]
);
Expand All @@ -280,7 +306,7 @@ protected function getPrefillOptions(): array
{
$options = [];
foreach (MDPrefillOption::$allowed_values as $allowed_value) {
$options[$allowed_value] = self::plugin()->translate('md_prefill_' . $allowed_value);
$options[$allowed_value] = $this->plugin->txt('md_prefill_' . $allowed_value);
}
return $options;
}
Expand Down
Loading