ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.HistoryTableBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\COPage\History;
22
28
30{
31 protected \ILIAS\UI\Factory $ui_factory;
32 protected int $page_id;
33 protected string $parent_type;
34 protected string $lang;
35 protected bool $rselect = false;
36 protected bool $lselect = false;
37
38 public function __construct(
39 protected InternalDomainService $domain,
40 protected InternalGUIService $gui,
41 object $parent_gui,
42 string $parent_cmd,
43 int $page_id,
44 string $parent_type,
45 string $lang
46 ) {
47 $this->page_id = $page_id;
48 $this->parent_type = $parent_type;
49 $this->lang = $lang;
50 $this->ui_factory = $this->gui->ui()->factory();
51 parent::__construct($parent_gui, $parent_cmd);
52 }
53
54 protected function getId(): string
55 {
56 return "ilCOPgHistoryTable";
57 }
58
59 protected function getTitle(): string
60 {
61 return $this->domain->lng()->txt("content_page_history");
62 }
63
64 protected function getRetrieval(): RetrievalInterface
65 {
66 return $this->domain->historyRetrieval(
67 $this->page_id,
68 $this->parent_type,
69 $this->lang
70 );
71 }
72
73 protected function transformRow(array $data_row): array
74 {
75 $ctrl = $this->gui->ctrl();
76
77 $nr = (int) $data_row["nr"];
78
79 $ctrl->setParameter($this->parent_gui, "old_nr", $nr);
80 $ctrl->setParameter($this->parent_gui, "history_mode", "1");
81 $date_link = $this->ui_factory->link()->standard(
83 $ctrl->getLinkTarget($this->parent_gui, "preview")
84 );
85 $ctrl->setParameter($this->parent_gui, "history_mode", "");
86 $ctrl->setParameter($this->parent_gui, "old_nr", "");
87
88 $user = "";
89 if (\ilObject::_exists((int) $data_row["user"])) {
91 (int) $data_row["user"],
92 true,
93 true,
94 $ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
95 );
96 }
97
98 return [
99 "id" => (string) $nr,
100 "date" => $date_link,
101 "user" => $user
102 ];
103 }
104
105 protected function activeAction(string $action, array $data_row): bool
106 {
107 if ($action === "rollbackConfirmation" && $data_row["nr"] > 0) {
108 return true;
109 }
110 return false;
111 }
112
114 {
115 $lng = $this->domain->lng();
116
117 $table = $table
118 ->linkColumn("date", $lng->txt("date"))
119 ->textColumn("user", $lng->txt("user"))
120 ->multiAction("compareVersion", $lng->txt("cont_page_compare"))
121 ->singleAction("rollbackConfirmation", $lng->txt("cont_rollback"));
122
123 return $table;
124 }
125}
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, object $parent_gui, string $parent_cmd, int $page_id, string $parent_type, string $lang)
transformRow(array $data_row)
transform raw data array to table row data array
linkColumn(string $key, string $title, bool $sortable=false)
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:26