Skip to content

Commit

Permalink
first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Aug 14, 2023
1 parent 2fc7742 commit 922c921
Show file tree
Hide file tree
Showing 36 changed files with 2,647 additions and 246 deletions.
158 changes: 158 additions & 0 deletions classes/Conf/PublicationUsage/class.xoctPublicationGroupFormGUI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

use srag\DIC\OpenCast\DICTrait;
use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsageGroup;

/**
* Class xoctPublicationGroupFormGUI
*
* @author Farbod Zamani Boroujeni <zamani@elan-ev.de>
*/
class xoctPublicationGroupFormGUI extends ilPropertyFormGUI
{
use DICTrait;
public const PLUGIN_CLASS_NAME = ilOpenCastPlugin::class;

public const F_NAME = 'name';
public const F_DISPLAY_NAME = 'display_name';
public const F_DESCRIPTION = 'description';
public const F_DISPLAY_NAME_MAX_LENGTH = 10;

/**
* @var PublicationUsageGroup
*/
protected $object;
/**
* @var xoctPublicationUsageGUI
*/
protected $parent_gui;
/**
* @var bool $is_new
*/
protected $is_new = true;



/**
* @param xoctPublicationUsageGUI $parent_gui
* @param PublicationUsageGroup $xoctPublicationUsageGroup
* @param bool $is_new
*/
public function __construct($parent_gui, $xoctPublicationUsageGroup, $is_new = true)
{
parent::__construct();
$this->object = $xoctPublicationUsageGroup;
$this->parent_gui = $parent_gui;
$this->parent_gui->setTab();
self::dic()->ctrl()->saveParameter($parent_gui, 'id');
$this->is_new = $is_new;
$this->initForm();
}


/**
*
*/
protected function initForm()
{
$this->setTarget('_top');
$this->setFormAction(self::dic()->ctrl()->getFormAction($this->parent_gui));
$this->initButtons();

$te = new ilTextInputGUI($this->txt(self::F_NAME), self::F_NAME);
$te->setRequired(true);
$this->addItem($te);

$max_lenght = self::F_DISPLAY_NAME_MAX_LENGTH;
$display_name = (!empty($this->object->getDisplayName()) ? $this->object->getDisplayName() : '{added display name}');
$info = sprintf($this->txt(self::F_DISPLAY_NAME . '_info'), $max_lenght, strtolower($display_name));
$te = new ilTextInputGUI($this->txt(self::F_DISPLAY_NAME), self::F_DISPLAY_NAME);
$te->setInfo($info);
$te->setMaxLength($max_lenght);
$te->setRequired(true);
$this->addItem($te);

$te = new ilTextAreaInputGUI($this->txt(self::F_DESCRIPTION), self::F_DESCRIPTION);
$this->addItem($te);
}


/**
* @param $lang_var
*
* @return string
*/
protected function txt($lang_var): string
{
return $this->parent_gui->txt("group_{$lang_var}");
}


/**
*
*/
public function fillForm()
{
$array = [
self::F_NAME => $this->object->getName(),
self::F_DISPLAY_NAME => $this->object->getDisplayName(),
self::F_DESCRIPTION => $this->object->getDescription(),
];

$this->setValuesByArray($array);
}


/**
* returns whether checkinput was successful or not.
*
* @return bool
*/
public function fillObject(): bool
{
if (!$this->checkInput()) {
return false;
}

$this->object->setName($this->getInput(self::F_NAME));
$this->object->setDisplayName($this->getInput(self::F_DISPLAY_NAME));
$this->object->setDescription($this->getInput(self::F_DESCRIPTION));

return true;
}


/**
* @return bool
*/
public function saveObject(): bool
{
if (!$this->fillObject()) {
return false;
}
if ($this->is_new) {
$this->object->create();
} else {
$this->object->update();
}

return true;
}


/**
*
*/
protected function initButtons()
{
if ($this->is_new) {
$this->setTitle($this->parent_gui->txt('create_group'));
$this->addCommandButton(xoctPublicationUsageGUI::CMD_CREATE_NEW_GROUP, $this->parent_gui->txt(xoctPublicationUsageGUI::CMD_CREATE));
} else {
$this->setTitle($this->parent_gui->txt('edit_group'));
$this->addCommandButton(xoctPublicationUsageGUI::CMD_UPDATE_GROUP, $this->parent_gui->txt(xoctPublicationUsageGUI::CMD_UPDATE));
}

$this->addCommandButton(xoctPublicationUsageGUI::CMD_CANCEL, $this->parent_gui->txt(xoctPublicationUsageGUI::CMD_CANCEL));
}
}
114 changes: 114 additions & 0 deletions classes/Conf/PublicationUsage/class.xoctPublicationGroupTableGUI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

use srag\DIC\OpenCast\DICTrait;
use srag\DIC\OpenCast\Exception\DICException;
use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsageGroup;
use srag\Plugins\Opencast\Model\Publication\Config\PublicationUsageGroupRepository;

/**
* Class xoctPublicationGroupTableGUI
*
* @author Farbod Zamani Boroujeni <zamani@elan-ev.de>
*/
class xoctPublicationGroupTableGUI extends ilTable2GUI
{
use DICTrait;
public const PLUGIN_CLASS_NAME = ilOpenCastPlugin::class;

public const TBL_ID = 'tbl_xoct_pub_g';
/**
* @var array
*/
protected $filter = [];


/**
* @param xoctPublicationUsageGUI $a_parent_obj
* @param string $a_parent_cmd
*/
public function __construct(xoctPublicationUsageGUI $a_parent_obj, $a_parent_cmd)
{
$this->setId(self::TBL_ID);
$this->setPrefix(self::TBL_ID);
$this->setFormName(self::TBL_ID);
self::dic()->ctrl()->saveParameter($a_parent_obj, $this->getNavParameter());
parent::__construct($a_parent_obj, $a_parent_cmd);
$this->parent_obj = $a_parent_obj;
$this->setTitle($this->parent_obj->txt('table_title_usage_group'));
$this->setRowTemplate('tpl.publication_group.html', 'Customizing/global/plugins/Services/Repository/RepositoryObject/OpenCast');
$this->setFormAction(self::dic()->ctrl()->getFormAction($a_parent_obj));
$this->initColumns();
$this->parseData();
}


/**
* @param array $a_set
*
* @throws DICException
*/
public function fillRow($a_set)
{
/**
* @var $PublicationUsageGroup PublicationUsageGroup
*/
$xoctPublicationUsageGroup = PublicationUsageGroup::find($a_set['id']);
$this->tpl->setVariable('NAME', $xoctPublicationUsageGroup->getName());
$this->tpl->setVariable('DISPLAY_NAME', $xoctPublicationUsageGroup->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $xoctPublicationUsageGroup->getDescription());

$this->addActionMenu($xoctPublicationUsageGroup);
}


protected function initColumns()
{
$this->addColumn($this->parent_obj->txt('group_name'));
$this->addColumn($this->parent_obj->txt('group_display_name'));
$this->addColumn($this->parent_obj->txt('group_description'));

$this->addColumn(self::plugin()->getPluginObject()->txt('common_actions'), '', '150px');
}


/**
* @param PublicationUsageGroup $xoctPublicationUsageGroup
*
* @throws DICException
*/
protected function addActionMenu(PublicationUsageGroup $xoctPublicationUsageGroup)
{
$current_selection_list = new ilAdvancedSelectionListGUI();
$current_selection_list->setListTitle(self::plugin()->getPluginObject()->txt('common_actions'));
$current_selection_list->setId(self::TBL_ID . '_actions_' . $xoctPublicationUsageGroup->getId());
$current_selection_list->setUseImages(false);

self::dic()->ctrl()->setParameter($this->parent_obj, 'id', $xoctPublicationUsageGroup->getId());
$current_selection_list->addItem($this->parent_obj->txt(xoctPublicationUsageGUI::CMD_EDIT), xoctPublicationUsageGUI::CMD_EDIT_GROUP, self::dic()->ctrl()->getLinkTarget($this->parent_obj, xoctPublicationUsageGUI::CMD_EDIT_GROUP));
$current_selection_list->addItem($this->parent_obj->txt(xoctPublicationUsageGUI::CMD_DELETE), xoctPublicationUsageGUI::CMD_DELETE_GROUP, self::dic()->ctrl()->getLinkTarget($this->parent_obj, xoctPublicationUsageGUI::CMD_CONFIRM_DELETE_GROUP));

$this->tpl->setVariable('ACTIONS', $current_selection_list->getHTML());
}


protected function parseData()
{
$groups = PublicationUsageGroupRepository::getSortedArrayList();
$this->setData($groups);
}


/**
* @param $item
*/
protected function addAndReadFilterItem(ilFormPropertyGUI $item)
{
$this->addFilterItem($item);
$item->readFromSession();
if ($item instanceof ilCheckboxInputGUI) {
$this->filter[$item->getPostVar()] = $item->getChecked();
} else {
$this->filter[$item->getPostVar()] = $item->getValue();
}
}
}
Loading

0 comments on commit 922c921

Please sign in to comment.