diff --git a/components/ILIAS/DataCollection/classes/CreateView/class.ilDclCreateViewTableGUI.php b/components/ILIAS/DataCollection/classes/CreateView/class.ilDclCreateViewTableGUI.php index 7a63e633811f..301d4b2952a8 100755 --- a/components/ILIAS/DataCollection/classes/CreateView/class.ilDclCreateViewTableGUI.php +++ b/components/ILIAS/DataCollection/classes/CreateView/class.ilDclCreateViewTableGUI.php @@ -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'); diff --git a/components/ILIAS/DataCollection/classes/EditView/class.ilDclEditViewTableGUI.php b/components/ILIAS/DataCollection/classes/EditView/class.ilDclEditViewTableGUI.php index 23adab3ec163..11e72f729833 100755 --- a/components/ILIAS/DataCollection/classes/EditView/class.ilDclEditViewTableGUI.php +++ b/components/ILIAS/DataCollection/classes/EditView/class.ilDclEditViewTableGUI.php @@ -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'); diff --git a/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldListTableGUI.php b/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldListTableGUI.php index c214d8bd2948..a4e85531fb5c 100755 --- a/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldListTableGUI.php +++ b/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldListTableGUI.php @@ -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'); diff --git a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewEditFieldsTableGUI.php b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewEditFieldsTableGUI.php index 14eeff9c3da1..e65dc609eabe 100755 --- a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewEditFieldsTableGUI.php +++ b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewEditFieldsTableGUI.php @@ -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'); diff --git a/components/ILIAS/Exercise/Submission/class.ilExerciseSubmissionTableGUI.php b/components/ILIAS/Exercise/Submission/class.ilExerciseSubmissionTableGUI.php index 2257fa0a43e4..df54803041e7 100755 --- a/components/ILIAS/Exercise/Submission/class.ilExerciseSubmissionTableGUI.php +++ b/components/ILIAS/Exercise/Submission/class.ilExerciseSubmissionTableGUI.php @@ -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"); diff --git a/components/ILIAS/Scorm2004/classes/class.ilSCORM2004TrackingItemsTableGUI.php b/components/ILIAS/Scorm2004/classes/class.ilSCORM2004TrackingItemsTableGUI.php index c93c13a5db45..ccda2747b9c4 100755 --- a/components/ILIAS/Scorm2004/classes/class.ilSCORM2004TrackingItemsTableGUI.php +++ b/components/ILIAS/Scorm2004/classes/class.ilSCORM2004TrackingItemsTableGUI.php @@ -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(); diff --git a/components/ILIAS/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php b/components/ILIAS/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php index 4ce14380a98c..df12b90ca187 100755 --- a/components/ILIAS/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php +++ b/components/ILIAS/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php @@ -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(); diff --git a/components/ILIAS/Table/Table.php b/components/ILIAS/Table/Table.php index 8e5717dffbb6..d1cdec551f3e 100644 --- a/components/ILIAS/Table/Table.php +++ b/components/ILIAS/Table/Table.php @@ -20,6 +20,8 @@ namespace ILIAS; +use ILIAS\components\Table\Setup\LegacyTableSetupAgent; + class Table implements Component\Component { public function init( @@ -34,5 +36,7 @@ public function init( ): void { $contribute[Component\Resource\PublicAsset::class] = fn() => new Component\Resource\ComponentJS($this, "ServiceTable.js"); + + $contribute[\ILIAS\Setup\Agent::class] = static fn() => new LegacyTableSetupAgent(); } } diff --git a/components/ILIAS/Table/classes/class.TableGUIRequest.php b/components/ILIAS/Table/classes/class.TableGUIRequest.php index 087178a2749c..1e788b0302e9 100755 --- a/components/ILIAS/Table/classes/class.TableGUIRequest.php +++ b/components/ILIAS/Table/classes/class.TableGUIRequest.php @@ -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"); @@ -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"); diff --git a/components/ILIAS/Table/classes/class.ilTable2GUI.php b/components/ILIAS/Table/classes/class.ilTable2GUI.php index 7ea891adb91d..e5f977ca56ff 100755 --- a/components/ILIAS/Table/classes/class.ilTable2GUI.php +++ b/components/ILIAS/Table/classes/class.ilTable2GUI.php @@ -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 = ""; @@ -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; @@ -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(); @@ -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 @@ -1698,10 +1688,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 @@ -1723,10 +1709,6 @@ public function resetFilter(): void $item->clearFromSession(); } } - - // #13209 - $this->requested_tmpl_create = ""; - $this->requested_tmpl_delete = ""; } /** @@ -1830,97 +1812,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"); @@ -2499,90 +2390,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()) { diff --git a/components/ILIAS/Table/classes/class.ilTableTemplatesStorage.php b/components/ILIAS/Table/classes/class.ilTableTemplatesStorage.php deleted file mode 100755 index 95b07e7b5364..000000000000 --- a/components/ILIAS/Table/classes/class.ilTableTemplatesStorage.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * @deprecated 10 - * - */ -class ilTableTemplatesStorage -{ - protected ilDBInterface $db; - - public function __construct() - { - global $DIC; - $this->db = $DIC->database(); - } - - /** - * Store table template - */ - public function store( - string $a_context, - int $a_user_id, - string $a_name, - array $a_state - ): void { - $ilDB = $this->db; - - if ($a_context == "" || $a_name == "") { - return; - } - - $ilDB->replace( - "table_templates", - array( - "name" => array("text", $a_name), - "user_id" => array("integer", $a_user_id), - "context" => array("text", $a_context)), - array( - "value" => array("text", serialize($a_state)) - ) - ); - } - - /** - * Get table template - */ - public function load( - string $a_context, - int $a_user_id, - string $a_name - ): ?array { - $ilDB = $this->db; - - if ($a_context == "" || $a_name == "") { - return null; - } - - $set = $ilDB->query( - "SELECT value FROM table_templates " . - " WHERE name = " . $ilDB->quote($a_name, "text") . - " AND user_id = " . $ilDB->quote($a_user_id, "integer") . - " AND context = " . $ilDB->quote($a_context, "text") - ); - $rec = $ilDB->fetchAssoc($set); - return unserialize((string) $rec["value"]); - } - - /** - * Delete table template - */ - public function delete( - string $a_context, - int $a_user_id, - string $a_name - ): void { - $ilDB = $this->db; - - if ($a_context == "" || $a_name == "") { - return; - } - - $ilDB->query( - "DELETE FROM table_templates " . - " WHERE name = " . $ilDB->quote($a_name, "text") . - " AND user_id = " . $ilDB->quote($a_user_id, "integer") . - " AND context = " . $ilDB->quote($a_context, "text") - ); - } - - /** - * List templates - */ - public function getNames( - string $a_context, - int $a_user_id - ): array { - $ilDB = $this->db; - - if ($a_context == "") { - return []; - } - - $set = $ilDB->query( - "SELECT name FROM table_templates " . - " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") . - " AND context = " . $ilDB->quote($a_context, "text") . - " ORDER BY name" - ); - $result = array(); - while ($rec = $ilDB->fetchAssoc($set)) { - $result[] = $rec["name"]; - } - return $result; - } -} diff --git a/components/ILIAS/Table/src/Setup/LegacyTableSetupAgent.php b/components/ILIAS/Table/src/Setup/LegacyTableSetupAgent.php new file mode 100644 index 000000000000..9342f24ca12d --- /dev/null +++ b/components/ILIAS/Table/src/Setup/LegacyTableSetupAgent.php @@ -0,0 +1,73 @@ +db = $db; + } + + public function step_1(): void + { + if ($this->db->tableExists('table_templates')) { + $this->db->dropTable('table_templates'); + } + } +} diff --git a/components/ILIAS/Table/templates/default/tpl.table2.html b/components/ILIAS/Table/templates/default/tpl.table2.html index 40146f02a093..e2395695e370 100755 --- a/components/ILIAS/Table/templates/default/tpl.table2.html +++ b/components/ILIAS/Table/templates/default/tpl.table2.html @@ -70,28 +70,7 @@
- {COLUMN_SELECTOR} {ROW_SELECTOR} {TEMPLATE_SELECTOR} {EXPORT_SELECTOR} - - -