forked from opencast-ilias/OpenCast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
2,647 additions
and
246 deletions.
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
classes/Conf/PublicationUsage/class.xoctPublicationGroupFormGUI.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
114
classes/Conf/PublicationUsage/class.xoctPublicationGroupTableGUI.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.