ILIAS  release_8 Revision v8.24
ILIAS\Style\Content\CharacteristicDBRepo Class Reference
+ Collaboration diagram for ILIAS\Style\Content\CharacteristicDBRepo:

Public Member Functions

 __construct (ilDBInterface $db, InternalDataService $factory)
 
 addCharacteristic (int $style_id, string $type, string $char, bool $hidden=false, int $order_nr=0, bool $outdated=false)
 
 exists (int $style_id, string $type, string $char)
 
 getByKey (int $style_id, string $type, string $characteristic)
 
 getByType (int $style_id, string $type)
 
 getByTypes (int $style_id, array $types, bool $include_hidden=true, bool $include_outdated=true)
 
 getBySuperType (int $style_id, string $super_type)
 Get characteristics by supertype. More...
 
 saveTitles (int $style_id, string $type, string $characteristic, array $titles)
 Save titles for characteristic. More...
 
 addTitle (int $style_id, string $type, string $characteristic, string $lang, string $title)
 
 cloneAllFromStyle (int $from_style_id, int $to_style_id)
 
 saveHidden (int $style_id, string $type, string $characteristic, bool $hide)
 Save characteristic hidden status. More...
 
 saveOutdated (int $style_id, string $type, string $characteristic, bool $outdated)
 Save characteristic outdated status. More...
 
 isOutdated (int $style_id, string $type, string $characteristic)
 
 saveOrderNr (int $style_id, string $type, string $characteristic, int $order_nr)
 
 deleteCharacteristic (int $style_id, string $type, string $tag, string $class)
 
 replaceParameter (int $style_id, string $a_tag, string $a_class, string $a_par, string $a_val, string $a_type, int $a_mq_id=0, bool $a_custom=false)
 
 deleteParameter (int $style_id, string $tag, string $class, string $par, string $type, int $mq_id=0, bool $custom=false)
 
 updateColorName (int $style_id, string $old_name, string $new_name)
 

Protected Attributes

ilDBInterface $db
 
InternalDataService $factory
 

Detailed Description

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

Definition at line 29 of file class.CharacteristicDBRepo.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\Content\CharacteristicDBRepo::__construct ( ilDBInterface  $db,
InternalDataService  $factory 
)

Member Function Documentation

◆ addCharacteristic()

ILIAS\Style\Content\CharacteristicDBRepo::addCharacteristic ( int  $style_id,
string  $type,
string  $char,
bool  $hidden = false,
int  $order_nr = 0,
bool  $outdated = false 
)

Definition at line 42 of file class.CharacteristicDBRepo.php.

49 : void {
50 $db = $this->db;
51
52 $db->insert("style_char", [
53 "style_id" => ["integer", $style_id],
54 "type" => ["text", $type],
55 "characteristic" => ["text", $char],
56 "hide" => ["integer", $hidden],
57 "order_nr" => ["integer", $order_nr],
58 "outdated" => ["integer", $outdated]
59 ]);
60 }
insert(string $table_name, array $values)
$type

◆ addTitle()

ILIAS\Style\Content\CharacteristicDBRepo::addTitle ( int  $style_id,
string  $type,
string  $characteristic,
string  $lang,
string  $title 
)

Definition at line 220 of file class.CharacteristicDBRepo.php.

226 : void {
227 $db = $this->db;
228
229 $db->insert("style_char_title", [
230 "style_id" => ["integer", $style_id],
231 "type" => ["text", $type],
232 "characteristic" => ["text", $characteristic],
233 "lang" => ["text", $lang],
234 "title" => ["text", $title]
235 ]);
236 }
$lang
Definition: xapiexit.php:26

◆ cloneAllFromStyle()

ILIAS\Style\Content\CharacteristicDBRepo::cloneAllFromStyle ( int  $from_style_id,
int  $to_style_id 
)

Definition at line 239 of file class.CharacteristicDBRepo.php.

242 : void {
243 $set = $this->db->queryF("SELECT * FROM style_char " .
244 " WHERE style_id = %s ",
245 ["integer"],
246 [$from_style_id]
247 );
248 while ($rec = $this->db->fetchAssoc($set)) {
249 $this->db->insert("style_char", [
250 "style_id" => ["integer", $to_style_id],
251 "type" => ["text", $rec["type"]],
252 "characteristic" => ["text", $rec["characteristic"]],
253 "hide" => ["integer", (int) ($rec["hide"] ?? 0)],
254 "outdated" => ["integer", (int) ($rec["outdated"] ?? 0)],
255 "order_nr" => ["integer", (int) ($rec["order_nr"] ?? 0)]
256 ]);
257 }
258 $set = $this->db->queryF("SELECT * FROM style_char_title " .
259 " WHERE style_id = %s ",
260 ["integer"],
261 [$from_style_id]
262 );
263 while ($rec = $this->db->fetchAssoc($set)) {
264 $this->db->insert("style_char_title", [
265 "style_id" => ["integer", $to_style_id],
266 "type" => ["text", $rec["type"]],
267 "characteristic" => ["text", $rec["characteristic"]],
268 "lang" => ["text", $rec["lang"]],
269 "title" => ["text", $rec["title"]]
270 ]);
271 }
272 }

◆ deleteCharacteristic()

ILIAS\Style\Content\CharacteristicDBRepo::deleteCharacteristic ( int  $style_id,
string  $type,
string  $tag,
string  $class 
)

Definition at line 361 of file class.CharacteristicDBRepo.php.

366 : void {
367 $db = $this->db;
368
369 // delete characteristic record
371 "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
372 array("integer", "text", "text"),
373 array($style_id, $type, $class)
374 );
375
376 // delete parameter records
378 "DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
379 array("integer", "text", "text", "text"),
380 array($style_id, $tag, $type, $class)
381 );
382 }
manipulateF(string $query, array $types, array $values)

◆ deleteParameter()

ILIAS\Style\Content\CharacteristicDBRepo::deleteParameter ( int  $style_id,
string  $tag,
string  $class,
string  $par,
string  $type,
int  $mq_id = 0,
bool  $custom = false 
)

Definition at line 440 of file class.CharacteristicDBRepo.php.

448 : void {
449 $db = $this->db;
450
451 $q = "DELETE FROM style_parameter WHERE " .
452 " style_id = " . $db->quote($style_id, "integer") . " AND " .
453 " tag = " . $db->quote($tag, "text") . " AND " .
454 " class = " . $db->quote($class, "text") . " AND " .
455 " mq_id = " . $db->quote($mq_id, "integer") . " AND " .
456 " custom = " . $db->quote($custom, "integer") . " AND " .
457 " " . $db->equals("type", $type, "text", true) . " AND " .
458 " parameter = " . $db->quote($par, "text");
459
460 $db->manipulate($q);
461 }
equals(string $columns, $value, string $type, bool $emptyOrNull=false)
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.

◆ exists()

ILIAS\Style\Content\CharacteristicDBRepo::exists ( int  $style_id,
string  $type,
string  $char 
)

Definition at line 62 of file class.CharacteristicDBRepo.php.

66 : bool {
67 $db = $this->db;
68
69 $set = $db->queryF(
70 "SELECT * FROM style_char " .
71 " WHERE style_id = %s AND type = %s AND characteristic = %s",
72 ["integer", "text", "text"],
73 [$style_id, $type, $char]
74 );
75 if ($db->fetchAssoc($set)) {
76 return true;
77 }
78 return false;
79 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

◆ getByKey()

ILIAS\Style\Content\CharacteristicDBRepo::getByKey ( int  $style_id,
string  $type,
string  $characteristic 
)

Definition at line 81 of file class.CharacteristicDBRepo.php.

85 : ?Characteristic {
86 $db = $this->db;
87
88 $set = $db->queryF(
89 "SELECT * FROM style_char " .
90 " WHERE style_id = %s AND type = %s AND characteristic = %s ",
91 ["integer", "text", "text"],
92 [$style_id, $type, $characteristic]
93 );
94 if ($rec = $db->fetchAssoc($set)) {
95 $set2 = $db->queryF(
96 "SELECT * FROM style_char_title " .
97 " WHERE style_id = %s AND type = %s AND characteristic = %s ",
98 ["integer", "text", "text"],
99 [$style_id, $type, $characteristic]
100 );
101 $titles = [];
102 while ($rec2 = $db->fetchAssoc($set2)) {
103 $titles[$rec2["lang"]] = $rec2["title"];
104 }
105 return $this->factory->characteristic(
106 $type,
107 $characteristic,
108 (bool) $rec["hide"],
109 $titles,
110 $style_id,
111 (int) $rec["order_nr"],
112 (bool) $rec["outdated"]
113 );
114 }
115 return null;
116 }

References $type, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

+ Here is the call graph for this function:

◆ getBySuperType()

ILIAS\Style\Content\CharacteristicDBRepo::getBySuperType ( int  $style_id,
string  $super_type 
)

Get characteristics by supertype.

Returns
Characteristic[]

Definition at line 177 of file class.CharacteristicDBRepo.php.

180 : array {
182 $types = $stypes[$super_type];
183
184 return $this->getByTypes(
185 $style_id,
186 $types
187 );
188 }
getByTypes(int $style_id, array $types, bool $include_hidden=true, bool $include_outdated=true)

◆ getByType()

ILIAS\Style\Content\CharacteristicDBRepo::getByType ( int  $style_id,
string  $type 
)

Definition at line 118 of file class.CharacteristicDBRepo.php.

121 : array {
122 return $this->getByTypes(
123 $style_id,
124 [$type]
125 );
126 }

◆ getByTypes()

ILIAS\Style\Content\CharacteristicDBRepo::getByTypes ( int  $style_id,
array  $types,
bool  $include_hidden = true,
bool  $include_outdated = true 
)

Definition at line 128 of file class.CharacteristicDBRepo.php.

133 : array {
134 $db = $this->db;
135
136 $set = $db->queryF(
137 "SELECT * FROM style_char " .
138 " WHERE style_id = %s AND " . $db->in("type", $types, false, "text") .
139 " ORDER BY order_nr, type, characteristic",
140 ["integer"],
141 [$style_id]
142 );
143 $chars = [];
144 while ($rec = $db->fetchAssoc($set)) {
145 if (($rec["hide"] && !$include_hidden) ||
146 ($rec["outdated"] && !$include_outdated)) {
147 continue;
148 }
149
150 $set2 = $db->queryF(
151 "SELECT * FROM style_char_title " .
152 " WHERE style_id = %s AND type = %s AND characteristic = %s ",
153 ["integer", "text", "text"],
154 [$style_id, $rec["type"], $rec["characteristic"]]
155 );
156 $titles = [];
157 while ($rec2 = $db->fetchAssoc($set2)) {
158 $titles[$rec2["lang"]] = $rec2["title"];
159 }
160 $chars[] = $this->factory->characteristic(
161 $rec["type"],
162 $rec["characteristic"],
163 (bool) $rec["hide"],
164 $titles,
165 $style_id,
166 (int) $rec["order_nr"],
167 (bool) $rec["outdated"]
168 );
169 }
170 return $chars;
171 }
in(string $field, array $values, bool $negate=false, string $type="")

References ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

+ Here is the call graph for this function:

◆ isOutdated()

ILIAS\Style\Content\CharacteristicDBRepo::isOutdated ( int  $style_id,
string  $type,
string  $characteristic 
)

Definition at line 322 of file class.CharacteristicDBRepo.php.

326 : bool {
327 $db = $this->db;
328
329 $set = $db->queryF("SELECT outdated FROM style_char " .
330 " WHERE style_id = %s AND type = %s AND characteristic = %s",
331 ["integer", "text", "text"],
332 [$style_id, $type, $characteristic]
333 );
334 if ($rec = $db->fetchAssoc($set)) {
335 return (bool) $rec["outdated"];
336 }
337 return false;
338 }

◆ replaceParameter()

ILIAS\Style\Content\CharacteristicDBRepo::replaceParameter ( int  $style_id,
string  $a_tag,
string  $a_class,
string  $a_par,
string  $a_val,
string  $a_type,
int  $a_mq_id = 0,
bool  $a_custom = false 
)

Definition at line 388 of file class.CharacteristicDBRepo.php.

397 : void {
398 $db = $this->db;
399
400 $set = $db->queryF(
401 "SELECT * FROM style_parameter " .
402 " WHERE style_id = %s AND tag = %s AND class = %s AND mq_id = %s " .
403 " AND custom = %s AND type = %s AND parameter = %s ",
404 ["integer", "text", "text", "integer", "integer", "text", "text"],
405 [$style_id, $a_tag, $a_class, $a_mq_id, $a_custom, $a_type, $a_par]
406 );
407
408 if ($set->fetchRow()) {
409 $db->update(
410 "style_parameter",
411 [
412 "value" => ["text", $a_val]
413 ],
414 [ // where
415 "style_id" => ["integer", $style_id],
416 "tag" => ["text", $a_tag],
417 "class" => ["text", $a_class],
418 "mq_id" => ["integer", $a_mq_id],
419 "custom" => ["integer", $a_custom],
420 "type" => ["text", $a_type],
421 "parameter" => ["text", $a_par]
422 ]
423 );
424 } else {
425 $id = $db->nextId("style_parameter");
426 $db->insert("style_parameter", [
427 "id" => ["integer", $id],
428 "value" => ["text", $a_val],
429 "style_id" => ["integer", $style_id],
430 "tag" => ["text", $a_tag],
431 "class" => ["text", $a_class],
432 "type" => ["text", $a_type],
433 "parameter" => ["text", $a_par],
434 "mq_id" => ["integer", $a_mq_id],
435 "custom" => ["integer", $a_custom]
436 ]);
437 }
438 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
nextId(string $table_name)

References ilDBInterface\update().

+ Here is the call graph for this function:

◆ saveHidden()

ILIAS\Style\Content\CharacteristicDBRepo::saveHidden ( int  $style_id,
string  $type,
string  $characteristic,
bool  $hide 
)

Save characteristic hidden status.

Definition at line 277 of file class.CharacteristicDBRepo.php.

282 : void {
283 $db = $this->db;
284
285 $db->update(
286 "style_char",
287 [
288 "hide" => ["integer", $hide]
289 ],
290 [ // where
291 "style_id" => ["integer", $style_id],
292 "type" => ["text", $type],
293 "characteristic" => ["text", $characteristic]
294 ]
295 );
296 }

◆ saveOrderNr()

ILIAS\Style\Content\CharacteristicDBRepo::saveOrderNr ( int  $style_id,
string  $type,
string  $characteristic,
int  $order_nr 
)

Definition at line 340 of file class.CharacteristicDBRepo.php.

345 : void {
346 $db = $this->db;
347
348 $db->update(
349 "style_char",
350 [
351 "order_nr" => ["integer", $order_nr]
352 ],
353 [ // where
354 "style_id" => ["integer", $style_id],
355 "type" => ["text", $type],
356 "characteristic" => ["text", $characteristic]
357 ]
358 );
359 }

◆ saveOutdated()

ILIAS\Style\Content\CharacteristicDBRepo::saveOutdated ( int  $style_id,
string  $type,
string  $characteristic,
bool  $outdated 
)

Save characteristic outdated status.

Definition at line 301 of file class.CharacteristicDBRepo.php.

306 : void {
307 $db = $this->db;
308
309 $db->update(
310 "style_char",
311 [
312 "outdated" => ["integer", $outdated]
313 ],
314 [ // where
315 "style_id" => ["integer", $style_id],
316 "type" => ["text", $type],
317 "characteristic" => ["text", $characteristic]
318 ]
319 );
320 }

◆ saveTitles()

ILIAS\Style\Content\CharacteristicDBRepo::saveTitles ( int  $style_id,
string  $type,
string  $characteristic,
array  $titles 
)

Save titles for characteristic.

Definition at line 194 of file class.CharacteristicDBRepo.php.

199 : void {
200 $db = $this->db;
201
203 "DELETE FROM style_char_title " .
204 " WHERE style_id = %s AND type = %s AND characteristic = %s ",
205 ["integer", "text", "text"],
206 [$style_id, $type, $characteristic]
207 );
208
209 foreach ($titles as $l => $title) {
210 $this->addTitle(
211 $style_id,
212 $type,
213 $characteristic,
214 $l,
215 $title
216 );
217 }
218 }
addTitle(int $style_id, string $type, string $characteristic, string $lang, string $title)

References $type.

◆ updateColorName()

ILIAS\Style\Content\CharacteristicDBRepo::updateColorName ( int  $style_id,
string  $old_name,
string  $new_name 
)

Definition at line 463 of file class.CharacteristicDBRepo.php.

467 : void {
468 if ($old_name == $new_name) {
469 return;
470 }
471
472 $db = $this->db;
473
474 $color_attributes = [
475 "background-color",
476 "color",
477 "border-color",
478 "border-top-color",
479 "border-bottom-color",
480 "border-left-color",
481 "border-right-color",
482 ];
483
484 $set = $db->queryF(
485 "SELECT * FROM style_parameter " .
486 " WHERE style_id = %s AND " . $db->in("parameter", $color_attributes, false, "text"),
487 ["integer"],
488 [$style_id]
489 );
490 while ($rec = $db->fetchAssoc($set)) {
491 if ($rec["value"] == "!" . $old_name ||
492 is_int(strpos($rec["value"], "!" . $old_name . "("))) {
493 // parameter is based on color -> rename it
494 $this->replaceParameter(
495 $style_id,
496 $rec["tag"],
497 $rec["class"],
498 $rec["parameter"],
499 str_replace($old_name, $new_name, $rec["value"]),
500 $rec["type"],
501 $rec["mq_id"],
502 $rec["custom"]
503 );
504 }
505 }
506 }
replaceParameter(int $style_id, string $a_tag, string $a_class, string $a_par, string $a_val, string $a_type, int $a_mq_id=0, bool $a_custom=false)

Field Documentation

◆ $db

ilDBInterface ILIAS\Style\Content\CharacteristicDBRepo::$db
protected

◆ $factory

InternalDataService ILIAS\Style\Content\CharacteristicDBRepo::$factory
protected

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