Skip to content

Commit

Permalink
Table/Overlays/Templates: Remove legacy overlays (and with this: tabl…
Browse files Browse the repository at this point in the history
…e templates)
  • Loading branch information
mjansenDatabay committed Nov 12, 2024
1 parent 0ed5794 commit 1074a21
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 608 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function __construct(ilDclCreateViewDefinitionGUI $a_parent_obj)
$this->setTopCommands(true);
$this->setEnableHeader(true);
$this->setShowRowsSelector(false);
$this->setShowTemplates(false);
$this->setEnableHeader(true);
$this->setEnableTitle(true);
$this->setDefaultOrderDirection('asc');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function __construct(ilDclEditViewDefinitionGUI $a_parent_obj)
$this->setTopCommands(true);
$this->setEnableHeader(true);
$this->setShowRowsSelector(false);
$this->setShowTemplates(false);
$this->setEnableHeader(true);
$this->setEnableTitle(true);
$this->setDefaultOrderDirection('asc');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function __construct(ilDclFieldListGUI $a_parent_obj, string $a_parent_cm
$this->setTopCommands(true);
$this->setEnableHeader(true);
$this->setShowRowsSelector(false);
$this->setShowTemplates(false);
$this->setEnableHeader(true);
$this->setEnableTitle(true);
$this->setDefaultOrderDirection('asc');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function __construct(ilDclTableViewEditGUI $a_parent_obj)
$this->setTopCommands(true);
$this->setEnableHeader(true);
$this->setShowRowsSelector(false);
$this->setShowTemplates(false);
$this->setEnableHeader(true);
$this->setEnableTitle(true);
$this->setDefaultOrderDirection('asc');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public function __construct(

parent::__construct($a_parent_obj, $a_parent_cmd);

$this->setShowTemplates(true);

$this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
$this->setRowTemplate("tpl.exc_members_row.html", "components/ILIAS/Exercise");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function __construct(int $a_obj_id, ?object $a_parent_obj, string $a_pare
// $this->setDefaultOrderField("cp_node_id, user_id");
$this->setDefaultOrderField("");
$this->setDefaultOrderDirection("asc");
$this->setShowTemplates(true);

$this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
// $this->initFilter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function __construct(int $a_obj_id, ?object $a_parent_obj, string $a_pare
// $this->setDefaultOrderField("cp_node_id, user_id");
$this->setDefaultOrderField("");
$this->setDefaultOrderDirection("asc");
$this->setShowTemplates(true);

$this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
// $this->initFilter();
Expand Down
15 changes: 0 additions & 15 deletions components/ILIAS/Table/classes/class.TableGUIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public function getExportMode(string $prefix): int
return $this->int($prefix . "_xpt");
}

public function getTemplate(string $prefix): string
{
return $this->str($prefix . "_tpl");
}

public function getRows(string $prefix): ?int
{
$rows = $this->str($prefix . "_trows");
Expand Down Expand Up @@ -94,16 +89,6 @@ public function getFSF(string $id): bool
return (bool) $this->int("tblfsf" . $id);
}

public function getTemplCreate(): string
{
return $this->str("tbltplcrt");
}

public function getTemplDelete(): string
{
return $this->str("tbltpldel");
}

public function getTableId(): string
{
return $this->str("table_id");
Expand Down
193 changes: 0 additions & 193 deletions components/ILIAS/Table/classes/class.ilTable2GUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class ilTable2GUI extends ilTableGUI
public const EXPORT_CSV = 2;
public const ACTION_ALL_LIMIT = 1000;
private \ILIAS\DI\UIServices $ui;
protected string $requested_tmpl_delete;
protected string $requested_tmpl_create;
protected string $requested_nav_par2 = "";
protected string $requested_nav_par = "";
protected string $requested_nav_par1 = "";
Expand Down Expand Up @@ -66,7 +64,6 @@ class ilTable2GUI extends ilTableGUI
protected bool $top_commands = true;
protected array $selectable_columns = array();
protected array $selected_column = array();
protected bool $show_templates = false;
protected bool $show_rows_selector = true; // JF, 2014-10-27
protected bool $rows_selector_off = false;

Expand Down Expand Up @@ -164,11 +161,6 @@ public function __construct(
// activate export mode
if (isset($this->table_request)) {
$this->export_mode = $this->table_request->getExportMode($this->prefix);

// template handling
if ($this->table_request->getTemplate($this->prefix) != "") {
$this->restoreTemplate($this->table_request->getTemplate($this->prefix));
}
}

$this->determineLimit();
Expand All @@ -190,8 +182,6 @@ protected function getRequestedValues(): void
$this->requested_nav_par = $this->table_request->getNavPar($this->getNavParameter());
$this->requested_nav_par1 = $this->table_request->getNavPar($this->getNavParameter(), 1);
$this->requested_nav_par2 = $this->table_request->getNavPar($this->getNavParameter(), 2);
$this->requested_tmpl_create = $this->table_request->getTemplCreate();
$this->requested_tmpl_delete = $this->table_request->getTemplDelete();
}

public function setOpenFormTag(bool $a_val): void
Expand Down Expand Up @@ -1709,10 +1699,6 @@ public function writeFilterToSession(): void
if ($advmd_record_gui) {
$advmd_record_gui->importFilter();
}

// #13209
$this->requested_tmpl_create = "";
$this->requested_tmpl_delete = "";
}

public function resetFilter(): void
Expand All @@ -1734,10 +1720,6 @@ public function resetFilter(): void
$item->clearFromSession();
}
}

// #13209
$this->requested_tmpl_create = "";
$this->requested_tmpl_delete = "";
}

/**
Expand Down Expand Up @@ -1841,97 +1823,6 @@ public function fillFooter(): void
$column_selector = $cb_over->getHTML();
$footer = true;
}
if ($this->getShowTemplates() && is_object($ilUser)) {
// template handling
if ($this->requested_tmpl_create != "") {
if ($this->saveTemplate($this->requested_tmpl_create)) {
$this->main_tpl->setOnScreenMessage('success', $lng->txt("tbl_template_created"));
}
} elseif ($this->requested_tmpl_delete != "") {
if ($this->deleteTemplate($this->requested_tmpl_delete)) {
$this->main_tpl->setOnScreenMessage('success', $lng->txt("tbl_template_deleted"));
}
}

$create_id = "template_create_overlay_" . $this->getId();
$delete_id = "template_delete_overlay_" . $this->getId();
$list_id = "template_stg_" . $this->getId();

$storage = new ilTableTemplatesStorage();
$templates = $storage->getNames($this->getContext(), $ilUser->getId());

// form to delete template
if (count($templates) > 0) {
$lng->loadLanguageModule("form");
$this->tpl->setCurrentBlock("template_editor_delete_item");
$this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
$this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
$this->tpl->parseCurrentBlock();
foreach ($templates as $name) {
$this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
$this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
$this->tpl->parseCurrentBlock();
}

$this->tpl->setCurrentBlock("template_editor_delete");
$this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
$this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
$this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
$this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
$this->tpl->parseCurrentBlock();
}

$this->tpl->setCurrentBlock("template_editor");
$this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
$this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
$this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
$this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
$this->tpl->parseCurrentBlock();

// load saved template
$actions = [];
$actions[] = $ui_factory->button()->shy(
$lng->txt("tbl_template_create"),
""
)->withOnLoadCode(static function ($id) use ($list_id) {
return "document.getElementById('$id').id = '" . $list_id . "_create';";
});
if (count($templates) > 0) {
$actions[] = $ui_factory->button()->shy(
$lng->txt("tbl_template_delete"),
""
)->withOnLoadCode(static function ($id) use ($list_id) {
return "document.getElementById('$id').id = '" . $list_id . "_delete';";
});
foreach ($templates as $name) {
$ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
$actions[] = $ui_factory->link()->standard(
$name,
$ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd)
);
$ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
}
}
$dd = $ui_factory->dropdown()->standard(
$actions
)->withLabel($lng->txt("tbl_templates"));
$this->tpl->setVariable("TEMPLATE_SELECTOR", " " . $ui_renderer->render($dd));

// form to save new template
$overlay = new ilOverlayGUI($create_id);
$overlay->setTrigger($list_id . "_create");
$overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
$overlay->setAutoHide(false);
$overlay->add();

if (count($templates) > 0) {
$overlay = new ilOverlayGUI($delete_id);
$overlay->setTrigger($list_id . "_delete");
$overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
$overlay->setAutoHide(false);
$overlay->add();
}
}

if ($footer) {
$this->tpl->setCurrentBlock("tbl_footer");
Expand Down Expand Up @@ -2510,90 +2401,6 @@ public function getShowRowsSelector(): bool
return $this->show_rows_selector;
}

public function setShowTemplates(bool $a_value): void
{
$this->show_templates = $a_value;
}

public function getShowTemplates(): bool
{
return $this->show_templates;
}

/**
* Restore state from template
*/
public function restoreTemplate(string $a_name): bool
{
global $DIC;

$ilUser = $DIC->user();

$a_name = ilUtil::stripSlashes($a_name);

if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
$storage = new ilTableTemplatesStorage();

$data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
if (is_array($data)) {
foreach ($data as $property => $value) {
$this->storeProperty($property, $value);
}
}

$data["filter_values"] = unserialize((string) $data["filter_values"]);
if ($data["filter_values"]) {
$this->restore_filter_values = $data["filter_values"];
}

$this->restore_filter = true;

return true;
}
return false;
}

/**
* Save current state as template
*/
public function saveTemplate(string $a_name): bool
{
global $DIC;

$ilUser = $DIC->user();

$a_name = ilLegacyFormElementsUtil::prepareFormOutput($a_name, true);

if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
$storage = new ilTableTemplatesStorage();

$state = $this->getCurrentState();
$state["filter_values"] = serialize($state["filter_values"] ?? null);
$state["selfields"] = serialize($state["selfields"] ?? null);
$state["selfilters"] = serialize($state["selfilters"] ?? null);

$storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
return true;
}
return false;
}

public function deleteTemplate(string $a_name): bool
{
global $DIC;

$ilUser = $DIC->user();

$a_name = ilLegacyFormElementsUtil::prepareFormOutput($a_name, true);

if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
$storage = new ilTableTemplatesStorage();
$storage->delete($this->getContext(), $ilUser->getId(), $a_name);
return true;
}
return false;
}

public function getLimit(): int
{
if ($this->getExportMode() || $this->getPrintMode()) {
Expand Down
Loading

0 comments on commit 1074a21

Please sign in to comment.