Skip to content

Commit

Permalink
[FEATURE] ILIAS 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
chfsx committed Aug 26, 2024
1 parent df11ddb commit c4e2db3
Show file tree
Hide file tree
Showing 268 changed files with 3,603 additions and 3,561 deletions.
3 changes: 3 additions & 0 deletions classes/Conf/Export/class.xoctConfExportGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
class xoctConfExportGUI extends xoctGUI
{
private const EXPORT_FILE_NAME = 'opencastexport.xml';
/**
* @readonly
*/
private FileUpload $upload;
/**
* @var \ilToolbarGUI
Expand Down
41 changes: 14 additions & 27 deletions classes/Conf/Metadata/class.xoctMetadataConfigGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ abstract class xoctMetadataConfigGUI extends xoctGUI
public const CMD_LOAD_LIST = 'loadList';
public const CMD_CONFIRM_LOAD_LIST = 'confirmLoadList';

protected MDFieldConfigRepository $repository;

protected static $available_commands = [
self::CMD_STANDARD,
self::CMD_EDIT,
Expand All @@ -51,27 +49,22 @@ abstract class xoctMetadataConfigGUI extends xoctGUI

protected UIFactory $ui_factory;
protected Renderer $renderer;
protected MDCatalogueFactory $md_catalogue_factory;
protected Container $dic;
private ilToolbarGUI $toolbar;
private UIServices $ui;
private ListProvider $listprovider;
private array $post_ids = [];

public function __construct(
MDFieldConfigRepository $repository,
MDCatalogueFactory $md_catalogue_factory,
Container $dic
protected MDFieldConfigRepository $repository,
protected MDCatalogueFactory $md_catalogue_factory,
protected Container $dic
) {
parent::__construct();
$this->dic = $dic;
$ui = $this->dic->ui();
$this->toolbar = $this->dic->toolbar();
$this->ui = $this->dic->ui();
$this->repository = $repository;
$this->ui_factory = $ui->factory();
$this->renderer = $ui->renderer();
$this->md_catalogue_factory = $md_catalogue_factory;
$this->listprovider = new ListProvider();
$this->post_ids = $this->http->request()->getParsedBody()['ids'] ?? [];
}
Expand Down Expand Up @@ -194,9 +187,7 @@ protected function loadList(): void
$digested_list = $this->digestList($this->listprovider->getList($source), $field_id);
if (!empty($digested_list)) {
$separator = MDFieldConfigAR::VALUE_SEPERATOR;
$converted_list = array_map(function ($key, $value) use ($separator) {
return "$key$separator$value";
}, array_keys($digested_list), array_values($digested_list));
$converted_list = array_map(fn($key, $value): string => "$key$separator$value", array_keys($digested_list), array_values($digested_list));
if (!empty($converted_list)) {
$encoded_list = base64_encode(json_encode($converted_list));
$this->ctrl->setParameter($this, 'possible_values_list', $encoded_list);
Expand Down Expand Up @@ -231,8 +222,8 @@ protected function digestList(array $raw_list, string $field_id): array
{
$digested = [];
foreach ($raw_list as $key => $value) {
if ($field_id == 'language') {
$split = explode('.', $value);
if ($field_id === 'language') {
$split = explode('.', (string) $value);
$default_text = ucfirst(strtolower($split[count($split) - 1]));
$translated = $this->getLocaleString(
'md_lang_list_' . $key,
Expand All @@ -242,8 +233,8 @@ protected function digestList(array $raw_list, string $field_id): array
$digested[$key] = $translated;
continue;
}
if ($field_id == 'license') {
$value = json_decode($value);
if ($field_id === 'license') {
$value = json_decode((string) $value);
if (!$value) {
continue;
}
Expand Down Expand Up @@ -293,12 +284,8 @@ protected function delete(): void

protected function getAvailableMetadataFields(): array
{
$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): string {
return $md_field_def->getId();
}, $this->getMetadataCatalogue()->getFieldDefinitions());
$already_configured = array_map(fn(MDFieldConfigAR $md_config): string => $md_config->getFieldId(), $this->repository->getAll(false));
$available_total = array_map(fn(MDFieldDefinition $md_field_def): string => $md_field_def->getId(), $this->getMetadataCatalogue()->getFieldDefinitions());
return array_diff($available_total, $already_configured);
}

Expand All @@ -322,7 +309,7 @@ protected function buildForm(string $field_id): Standard
)
->withRequired(true)
->withValue(
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getTitle(
$md_field_config instanceof MDFieldConfigAR ? $md_field_config->getTitle(
'de'
) : ''
),
Expand All @@ -331,7 +318,7 @@ protected function buildForm(string $field_id): Standard
)
->withRequired(true)
->withValue(
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getTitle(
$md_field_config instanceof MDFieldConfigAR ? $md_field_config->getTitle(
'en'
) : ''
),
Expand All @@ -343,7 +330,7 @@ protected function buildForm(string $field_id): Standard
]
)->withRequired(true)
->withValue(
$md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? $md_field_config->getVisibleForPermissions(
$md_field_config instanceof MDFieldConfigAR ? $md_field_config->getVisibleForPermissions(
) : null
),
'required' => $this->ui_factory->input()->field()->checkbox(
Expand Down Expand Up @@ -450,7 +437,7 @@ protected function buildForm(string $field_id): Standard
'fields' => $this->ui_factory->input()->field()->section(
$fields,
$this->plugin->txt(
'md_conf_form_' . ($md_field_config instanceof \srag\Plugins\Opencast\Model\Metadata\Config\MDFieldConfigAR ? 'edit' : 'create')
'md_conf_form_' . ($md_field_config instanceof MDFieldConfigAR ? 'edit' : 'create')
)
)
]
Expand Down
15 changes: 15 additions & 0 deletions classes/Conf/Metadata/class.xoctMetadataConfigRouterGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,25 @@ class xoctMetadataConfigRouterGUI
{
public const SUBTAB_EVENTS = 'events';
public const SUBTAB_SERIES = 'series';
/**
* @readonly
*/
private ilCtrlInterface $ctrl;
/**
* @readonly
*/
private ilTabsGUI $tabs;
/**
* @readonly
*/
private OpencastDIC $legacy_container;
/**
* @readonly
*/
private ilOpenCastPlugin $plugin;
/**
* @readonly
*/
private Container $container;

public function __construct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,17 @@ public function getLocaleString(string $string, ?string $module = '', ?string $f
public const F_ADDED_ROLE_ACTIONS_DOWNLOAD = 'added_role_actions_download';
public const F_ADDED_ROLE_ACTIONS_ANNOTATE = 'added_role_actions_annotate';
private ilOpenCastPlugin $plugin;
protected PermissionTemplate $object;
protected xoctPermissionTemplateGUI $parent_gui;
protected bool $is_new;

/**
* @param xoctPermissionTemplateGUI $parent_gui
*/
public function __construct($parent_gui, PermissionTemplate $xoctPermissionTemplate)
public function __construct(protected xoctPermissionTemplateGUI $parent_gui, protected PermissionTemplate $object)
{
$opencastContainer = Init::init();
$this->plugin = $opencastContainer[ilOpenCastPlugin::class];
parent::__construct();
$this->object = $xoctPermissionTemplate;
$this->parent_gui = $parent_gui;
$opencastContainer->ilias()->ctrl()->saveParameter($parent_gui, xoctPermissionTemplateGUI::IDENTIFIER);
$opencastContainer->ilias()->ctrl()->saveParameter($this->parent_gui, xoctPermissionTemplateGUI::IDENTIFIER);
$this->is_new = ($this->object->getId() == 0);
$this->initForm();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function delete(): void
$tpl_id = (int) ($this->http->request()->getQueryParams()['tpl_id'] ?? 0);
$template = PermissionTemplate::find($tpl_id);
$ilConfirmationGUI = new ilConfirmationGUI();
$ilConfirmationGUI->setHeaderText($this->plugin->txt('msg_confirm_delete_perm_template', 'common'));
$ilConfirmationGUI->setHeaderText($this->plugin->txt('msg_confirm_delete_perm_template'));
$ilConfirmationGUI->setFormAction($this->ctrl->getFormAction($this));
$ilConfirmationGUI->addItem('tpl_id', (string) $tpl_id, $template->getTitle());
$ilConfirmationGUI->setConfirm($this->getLocaleString('delete', 'common'), self::CMD_CONFIRM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ protected function initColumns()
}

#[ReturnTypeWillChange]
protected function fillRow(/*array*/ $a_set): void
protected function fillRow(/*array*/ array $a_set): void
{
$a_set['title'] = $this->user->getLanguage() == 'de' ? $a_set['title_de'] : $a_set['title_en'];
$a_set['info'] = $this->user->getLanguage() == 'de' ? $a_set['info_de'] : $a_set['info_en'];
$a_set['title'] = $this->user->getLanguage() === 'de' ? $a_set['title_de'] : $a_set['title_en'];
$a_set['info'] = $this->user->getLanguage() === 'de' ? $a_set['info_de'] : $a_set['info_en'];
$a_set['actions'] = $this->buildActions($a_set);
$a_set['default'] = $a_set['is_default'] ? 'ok' : 'not_ok';
$a_set['read'] = $a_set['read_access'] ? 'ok' : 'not_ok';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public function getLocaleString(string $string, ?string $module = '', ?string $f
* @var PluginConfig
*/
protected $object;
/**
* @var xoctConfGUI
*/
protected \xoctPermissionTemplateGUI $parent_gui;
/**
* @var string
*/
Expand All @@ -37,10 +33,9 @@ public function getLocaleString(string $string, ?string $module = '', ?string $f
/**
* @param $parent_gui
*/
public function __construct(xoctPermissionTemplateGUI $parent_gui)
public function __construct(protected \xoctPermissionTemplateGUI $parent_gui)
{
parent::__construct();
$this->parent_gui = $parent_gui;
$this->initForm();
}

Expand Down Expand Up @@ -97,7 +92,7 @@ public function fillForm(): void
*
* @internal param $key
*/
private function getValuesForItem($item, &$array): void
private function getValuesForItem($item, array &$array): void
{
if (self::checkItem($item)) {
$key = $item->getPostVar();
Expand Down Expand Up @@ -152,7 +147,7 @@ public static function checkForSubItem($item): bool
*
* @return bool
*/
public static function checkItem($item)
public static function checkItem($item): bool
{
return !$item instanceof ilFormSectionHeaderGUI;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,14 @@ public function getLocaleString(string $string, ?string $module = '', ?string $f
public const F_DESCRIPTION = 'description';
public const F_DISPLAY_NAME_MAX_LENGTH = 10;

protected PublicationUsageGroup $object;
protected \xoctPublicationUsageGUI $parent_gui;
protected bool $is_new;

public function __construct(
xoctPublicationUsageGUI $parent_gui,
PublicationUsageGroup $publication_usage_group,
bool $is_new = true
protected \xoctPublicationUsageGUI $parent_gui,
protected PublicationUsageGroup $object,
protected bool $is_new = true
) {
parent::__construct();
$this->object = $publication_usage_group;
$this->parent_gui = $parent_gui;
$this->parent_gui->setTab();
$this->ctrl->saveParameter($parent_gui, 'id');
$this->is_new = $is_new;
$this->ctrl->saveParameter($this->parent_gui, 'id');
$this->initForm();
}

Expand All @@ -55,8 +48,8 @@ protected function initForm(): void
$this->addItem($te);

$max_length = self::F_DISPLAY_NAME_MAX_LENGTH;
$display_name = (!empty($this->object->getDisplayName()) ? $this->object->getDisplayName(
) : '{added display name}');
$display_name = (empty($this->object->getDisplayName()) ? '{added display name}' : $this->object->getDisplayName(
));
$info = sprintf($this->getLocaleString(self::F_DISPLAY_NAME . '_info'), $max_length, strtolower($display_name));
$te = new ilTextInputGUI($this->getLocaleString(self::F_DISPLAY_NAME), self::F_DISPLAY_NAME);
$te->setInfo($info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public function getLocaleString(string $string, ?string $module = '', ?string $f
public const F_MEDIATYPE = 'mediatype';
public const F_OVERWRITE_DOWNLOAD_PERM = 'overwrite_download_perm';
public const F_EXT_DL_SOURCE = 'ext_dl_source';

protected PublicationSubUsage $object;
protected \xoctPublicationUsageGUI $parent_gui;
protected bool $is_new;
/**
* @var ilOpenCastPlugin
*/
Expand All @@ -55,9 +51,9 @@ public function getLocaleString(string $string, ?string $module = '', ?string $f
protected $legacy_container;

public function __construct(
xoctPublicationUsageGUI $parent_gui,
PublicationSubUsage $publication_sub_usage,
bool $is_new = true
protected \xoctPublicationUsageGUI $parent_gui,
protected PublicationSubUsage $object,
protected bool $is_new = true
) {
global $DIC;
$this->container = Init::init();
Expand All @@ -68,11 +64,8 @@ public function __construct(
);
$DIC->ui()->mainTemplate()->addOnLoadCode('il.Opencast.Form.publicationUsage.init()');
parent::__construct();
$this->object = $publication_sub_usage;
$this->parent_gui = $parent_gui;
$this->parent_gui->setTab();
$this->ctrl->saveParameter($parent_gui, 'id');
$this->is_new = $is_new;
$this->ctrl->saveParameter($this->parent_gui, 'id');
$this->initForm();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,13 @@ protected function fillRow(/*array*/ $a_set): void
$group_name = '';
if (!is_null($publication_sub_usage->getGroupId())) {
$publication_usage_group = PublicationUsageGroup::find($publication_sub_usage->getGroupId());
$group_name = $publication_usage_group ? $publication_usage_group->getName() : $group_name;
$group_name = $publication_usage_group !== null ? $publication_usage_group->getName() : $group_name;
}
$this->tpl->setVariable('GROUP_NAME', $group_name);

$extras = [];
if ($publication_sub_usage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD ||
$publication_sub_usage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
if ($publication_sub_usage->isExternalDownloadSource()) {
$extras[] = $this->getLocaleString('ext_dl_source');
}
if (($publication_sub_usage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD || $publication_sub_usage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD_FALLBACK) && $publication_sub_usage->isExternalDownloadSource()) {
$extras[] = $this->getLocaleString('ext_dl_source');
}
$this->tpl->setVariable('EXTRA_CONFIG', implode('<br>', $extras));

Expand Down Expand Up @@ -149,13 +146,9 @@ protected function parseData(): void
{
$subs = PublicationSubUsage::getArray();
// Sorting by parent usage id.
usort($subs, function ($sub1, $sub2) {
return strcmp($sub1['parent_usage_id'], $sub2['parent_usage_id']);
});
usort($subs, fn(array $sub1, array $sub2): int => strcmp((string) $sub1['parent_usage_id'], (string) $sub2['parent_usage_id']));
// Sorting by title.
usort($subs, function ($sub1, $sub2) {
return strcmp($sub1['title'], $sub2['title']);
});
usort($subs, fn(array $sub1, array $sub2): int => strcmp((string) $sub1['title'], (string) $sub2['title']));
$this->setData($subs);
}

Expand All @@ -166,10 +159,6 @@ protected function addAndReadFilterItem(ilFormPropertyGUI $item): void
{
$this->addFilterItem($item);
$item->readFromSession();
if ($item instanceof ilCheckboxInputGUI) {
$this->filter[$item->getPostVar()] = $item->getChecked();
} else {
$this->filter[$item->getPostVar()] = $item->getValue();
}
$this->filter[$item->getPostVar()] = $item instanceof ilCheckboxInputGUI ? $item->getChecked() : $item->getValue();
}
}
Loading

0 comments on commit c4e2db3

Please sign in to comment.