ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\COPage\Page\PageDBRepository Class Reference
+ Collaboration diagram for ILIAS\COPage\Page\PageDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db)
 
 lookupParentId (int $page_id, string $parent_type)
 
 writeParentId (string $parent_type, int $page_id, int $parent_id)
 
 writeActive (int $page_id, string $parent_type, bool $active)
 
 getActivationDataByParentId (int $parent_id)
 
 getActivationData (int $page_id, string $parent_type, string $lang)
 
 lookupContainsDeactivatedElements (int $page_id, string $parent_type, string $lang)
 
 getParentObjectContributorData (string $parent_type, int $parent_id, string $lang)
 
 getPageContributorData (string $parent_type, int $page_id, string $lang)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.PageDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\Page\PageDBRepository::__construct ( \ilDBInterface  $db)

Definition at line 30 of file class.PageDBRepository.php.

31 {
32 $this->db = $db;
33 }

References ILIAS\COPage\Page\PageDBRepository\$db.

Member Function Documentation

◆ getActivationData()

ILIAS\COPage\Page\PageDBRepository::getActivationData ( int  $page_id,
string  $parent_type,
string  $lang 
)

Definition at line 84 of file class.PageDBRepository.php.

84 : ?array
85 {
86 $set = $this->db->queryF(
87 "SELECT active, activation_start, activation_end, show_activation_info " .
88 "FROM page_object WHERE page_id = %s AND parent_type = %s AND lang = %s",
89 ["integer", "text", "text"],
90 [$page_id, $parent_type, $lang]
91 );
92 $record = $this->db->fetchAssoc($set);
93 return $record ?: null;
94 }

◆ getActivationDataByParentId()

ILIAS\COPage\Page\PageDBRepository::getActivationDataByParentId ( int  $parent_id)
Returns
list<array<string, mixed>>

Definition at line 69 of file class.PageDBRepository.php.

69 : array
70 {
71 $set = $this->db->queryF(
72 "SELECT page_id, parent_type, lang, active, activation_start, activation_end, show_activation_info " .
73 "FROM page_object WHERE parent_id = %s",
74 ["integer"],
75 [$parent_id]
76 );
77 $records = [];
78 while ($record = $this->db->fetchAssoc($set)) {
79 $records[] = $record;
80 }
81 return $records;
82 }

◆ getPageContributorData()

ILIAS\COPage\Page\PageDBRepository::getPageContributorData ( string  $parent_type,
int  $page_id,
string  $lang 
)
Returns
array{pages: list<array<string, mixed>>, history: list<array<string, mixed>>}

Definition at line 157 of file class.PageDBRepository.php.

161 : array {
162 $and_lang = $lang !== "" ? " AND lang = %s" : "";
163 $types = ["integer", "text", "integer"];
164 $values = [$page_id, $parent_type, 0];
165 if ($lang !== "") {
166 $types[] = "text";
167 $values[] = $lang;
168 }
169
170 $pages = [];
171 $set = $this->db->queryF(
172 "SELECT last_change_user, lang FROM page_object " .
173 " WHERE page_id = %s AND parent_type = %s " .
174 " AND last_change_user != %s" . $and_lang,
175 $types,
176 $values
177 );
178 while ($page = $this->db->fetchAssoc($set)) {
179 $pages[] = $page;
180 }
181
182 $history = [];
183 $set = $this->db->queryF(
184 "SELECT count(*) as cnt, lang, page_id, user_id FROM page_history " .
185 " WHERE page_id = %s AND parent_type = %s AND user_id != %s " . $and_lang .
186 " GROUP BY user_id, page_id, lang ",
187 $types,
188 $values
189 );
190 while ($page = $this->db->fetchAssoc($set)) {
191 $history[] = $page;
192 }
193
194 return ["pages" => $pages, "history" => $history];
195 }

◆ getParentObjectContributorData()

ILIAS\COPage\Page\PageDBRepository::getParentObjectContributorData ( string  $parent_type,
int  $parent_id,
string  $lang 
)
Returns
array{pages: list<array<string, mixed>>, history: list<array<string, mixed>>}

Definition at line 114 of file class.PageDBRepository.php.

118 : array {
119 $and_lang = $lang !== "" ? " AND lang = %s" : "";
120 $types = ["integer", "text", "integer"];
121 $values = [$parent_id, $parent_type, 0];
122 if ($lang !== "") {
123 $types[] = "text";
124 $values[] = $lang;
125 }
126
127 $pages = [];
128 $set = $this->db->queryF(
129 "SELECT last_change_user, lang, page_id FROM page_object " .
130 " WHERE parent_id = %s AND parent_type = %s " .
131 " AND last_change_user != %s" . $and_lang,
132 $types,
133 $values
134 );
135 while ($page = $this->db->fetchAssoc($set)) {
136 $pages[] = $page;
137 }
138
139 $history = [];
140 $set = $this->db->queryF(
141 "SELECT count(*) as cnt, lang, page_id, user_id FROM page_history " .
142 " WHERE parent_id = %s AND parent_type = %s AND user_id != %s " . $and_lang .
143 " GROUP BY page_id, user_id, lang ",
144 $types,
145 $values
146 );
147 while ($page = $this->db->fetchAssoc($set)) {
148 $history[] = $page;
149 }
150
151 return ["pages" => $pages, "history" => $history];
152 }

◆ lookupContainsDeactivatedElements()

ILIAS\COPage\Page\PageDBRepository::lookupContainsDeactivatedElements ( int  $page_id,
string  $parent_type,
string  $lang 
)

Definition at line 96 of file class.PageDBRepository.php.

100 : bool {
101 $set = $this->db->queryF(
102 "SELECT page_id FROM page_object " .
103 "WHERE page_id = %s AND parent_type = %s AND lang = %s " .
104 "AND inactive_elements = %s",
105 ["integer", "text", "text", "integer"],
106 [$page_id, $parent_type, $lang, 1]
107 );
108 return (bool) $this->db->fetchAssoc($set);
109 }

◆ lookupParentId()

ILIAS\COPage\Page\PageDBRepository::lookupParentId ( int  $page_id,
string  $parent_type 
)

Definition at line 35 of file class.PageDBRepository.php.

35 : int
36 {
37 $set = $this->db->queryF(
38 "SELECT parent_id FROM page_object WHERE page_id = %s AND parent_type = %s",
39 ["integer", "text"],
40 [$page_id, $parent_type]
41 );
42 $record = $this->db->fetchAssoc($set);
43 return (int) ($record["parent_id"] ?? 0);
44 }

◆ writeActive()

ILIAS\COPage\Page\PageDBRepository::writeActive ( int  $page_id,
string  $parent_type,
bool  $active 
)

Definition at line 55 of file class.PageDBRepository.php.

55 : void
56 {
57 $this->db->manipulateF(
58 "UPDATE page_object SET active = %s, activation_start = %s, " .
59 " activation_end = %s WHERE page_id = %s" .
60 " AND parent_type = %s AND lang = %s",
61 ["int", "timestamp", "timestamp", "integer", "text", "text"],
62 [(int) $active, null, null, $page_id, $parent_type, "-"]
63 );
64 }

◆ writeParentId()

ILIAS\COPage\Page\PageDBRepository::writeParentId ( string  $parent_type,
int  $page_id,
int  $parent_id 
)

Definition at line 46 of file class.PageDBRepository.php.

46 : void
47 {
48 $this->db->manipulateF(
49 "UPDATE page_object SET parent_id = %s WHERE page_id = %s AND parent_type = %s",
50 ["integer", "integer", "text"],
51 [$parent_id, $page_id, $parent_type]
52 );
53 }

Field Documentation

◆ $db

ilDBInterface ILIAS\COPage\Page\PageDBRepository::$db
protected

The documentation for this class was generated from the following file: