ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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)
 
 getAllParametersOfCharacteristic (int $style_id, string $type, string $characteristic)
 
 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 
)

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, ILIAS\Style\Content\CharacteristicDBRepo\$factory, and factory().

37  {
38  $this->db = $db;
39  $this->factory = $factory;
40  }
factory()
+ Here is the call graph for this function:

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.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, and ilDBInterface\insert().

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)
+ Here is the call graph for this function:

◆ 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.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, and ilDBInterface\insert().

Referenced by ILIAS\Style\Content\CharacteristicDBRepo\saveTitles().

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  }
insert(string $table_name, array $values)
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

◆ deleteCharacteristic()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, and ilDBInterface\manipulateF().

369  : void {
370  $db = $this->db;
371 
372  // delete characteristic record
373  $db->manipulateF(
374  "DELETE FROM style_char WHERE style_id = %s AND type = %s AND characteristic = %s",
375  array("integer", "text", "text"),
376  array($style_id, $type, $class)
377  );
378 
379  // delete parameter records
380  $db->manipulateF(
381  "DELETE FROM style_parameter WHERE style_id = %s AND tag = %s AND type = %s AND class = %s",
382  array("integer", "text", "text", "text"),
383  array($style_id, $tag, $type, $class)
384  );
385  }
manipulateF(string $query, array $types, array $values)
+ Here is the call graph for this function:

◆ 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 461 of file class.CharacteristicDBRepo.php.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, $q, ilDBInterface\equals(), ilDBInterface\manipulate(), and ilDBInterface\quote().

469  : void {
470  $db = $this->db;
471 
472  $q = "DELETE FROM style_parameter WHERE " .
473  " style_id = " . $db->quote($style_id, "integer") . " AND " .
474  " tag = " . $db->quote($tag, "text") . " AND " .
475  " class = " . $db->quote($class, "text") . " AND " .
476  " mq_id = " . $db->quote($mq_id, "integer") . " AND " .
477  " custom = " . $db->quote($custom, "integer") . " AND " .
478  " " . $db->equals("type", $type, "text", true) . " AND " .
479  " parameter = " . $db->quote($par, "text");
480 
481  $db->manipulate($q);
482  }
equals(string $columns, $value, string $type, bool $emptyOrNull=false)
quote($value, string $type)
$q
Definition: shib_logout.php:23
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ exists()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

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)
+ Here is the call graph for this function:

◆ getAllParametersOfCharacteristic()

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

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

References $data.

447  : array {
448  $set = $this->db->queryF(
449  "SELECT * FROM style_parameter " .
450  " WHERE style_id = %s AND class = %s AND type = %s",
451  ["integer", "string", "string"],
452  [$style_id, $characteristic, $type]
453  );
454  $data = [];
455  while ($rec = $this->db->fetchAssoc($set)) {
456  $data[] = $rec;
457  }
458  return $data;
459  }

◆ getByKey()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, factory(), ilDBInterface\fetchAssoc(), null, and ilDBInterface\queryF().

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  }
fetchAssoc(ilDBStatement $statement)
factory()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
queryF(string $query, array $types, array $values)
+ 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.

References ilObjStyleSheet\_getStyleSuperTypes(), and ILIAS\Style\Content\CharacteristicDBRepo\getByTypes().

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)
+ Here is the call graph for this function:

◆ getByType()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\getByTypes().

121  : array {
122  return $this->getByTypes(
123  $style_id,
124  [$type]
125  );
126  }
getByTypes(int $style_id, array $types, bool $include_hidden=true, bool $include_outdated=true)
+ Here is the call graph for this function:

◆ 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.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, factory(), ilDBInterface\fetchAssoc(), ilDBInterface\in(), and ilDBInterface\queryF().

Referenced by ILIAS\Style\Content\CharacteristicDBRepo\getBySuperType(), and ILIAS\Style\Content\CharacteristicDBRepo\getByType().

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  }
fetchAssoc(ilDBStatement $statement)
factory()
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isOutdated()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

328  : bool {
329  $db = $this->db;
330 
331  $set = $db->queryF(
332  "SELECT outdated FROM style_char " .
333  " WHERE style_id = %s AND type = %s AND characteristic = %s",
334  ["integer", "text", "text"],
335  [$style_id, $type, $characteristic]
336  );
337  if ($rec = $db->fetchAssoc($set)) {
338  return (bool) $rec["outdated"];
339  }
340  return false;
341  }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:

◆ 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 391 of file class.CharacteristicDBRepo.php.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, $id, ilDBInterface\insert(), ilDBInterface\nextId(), ilDBInterface\queryF(), and ilDBInterface\update().

Referenced by ILIAS\Style\Content\CharacteristicDBRepo\updateColorName().

400  : void {
401  $db = $this->db;
402 
403  $set = $db->queryF(
404  "SELECT * FROM style_parameter " .
405  " WHERE style_id = %s AND tag = %s AND class = %s AND mq_id = %s " .
406  " AND custom = %s AND type = %s AND parameter = %s ",
407  ["integer", "text", "text", "integer", "integer", "text", "text"],
408  [$style_id, $a_tag, $a_class, $a_mq_id, $a_custom, $a_type, $a_par]
409  );
410 
411  if ($set->fetchRow()) {
412  $db->update(
413  "style_parameter",
414  [
415  "value" => ["text", $a_val]
416  ],
417  [ // where
418  "style_id" => ["integer", $style_id],
419  "tag" => ["text", $a_tag],
420  "class" => ["text", $a_class],
421  "mq_id" => ["integer", $a_mq_id],
422  "custom" => ["integer", $a_custom],
423  "type" => ["text", $a_type],
424  "parameter" => ["text", $a_par]
425  ]
426  );
427  } else {
428  $id = $db->nextId("style_parameter");
429  $db->insert("style_parameter", [
430  "id" => ["integer", $id],
431  "value" => ["text", $a_val],
432  "style_id" => ["integer", $style_id],
433  "tag" => ["text", $a_tag],
434  "class" => ["text", $a_class],
435  "type" => ["text", $a_type],
436  "parameter" => ["text", $a_par],
437  "mq_id" => ["integer", $a_mq_id],
438  "custom" => ["integer", $a_custom]
439  ]);
440  }
441  }
insert(string $table_name, array $values)
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
nextId(string $table_name)
queryF(string $query, array $types, array $values)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller 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 279 of file class.CharacteristicDBRepo.php.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, and ilDBInterface\update().

284  : void {
285  $db = $this->db;
286 
287  $db->update(
288  "style_char",
289  [
290  "hide" => ["integer", $hide]
291  ],
292  [ // where
293  "style_id" => ["integer", $style_id],
294  "type" => ["text", $type],
295  "characteristic" => ["text", $characteristic]
296  ]
297  );
298  }
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
+ Here is the call graph for this function:

◆ saveOrderNr()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, and ilDBInterface\update().

348  : void {
349  $db = $this->db;
350 
351  $db->update(
352  "style_char",
353  [
354  "order_nr" => ["integer", $order_nr]
355  ],
356  [ // where
357  "style_id" => ["integer", $style_id],
358  "type" => ["text", $type],
359  "characteristic" => ["text", $characteristic]
360  ]
361  );
362  }
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
+ Here is the call graph for this function:

◆ saveOutdated()

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

Save characteristic outdated status.

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, and ilDBInterface\update().

308  : void {
309  $db = $this->db;
310 
311  $db->update(
312  "style_char",
313  [
314  "outdated" => ["integer", $outdated]
315  ],
316  [ // where
317  "style_id" => ["integer", $style_id],
318  "type" => ["text", $type],
319  "characteristic" => ["text", $characteristic]
320  ]
321  );
322  }
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
+ Here is the call graph for this function:

◆ 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.

References ILIAS\Style\Content\CharacteristicDBRepo\$db, ILIAS\Style\Content\CharacteristicDBRepo\addTitle(), and ilDBInterface\manipulateF().

199  : void {
200  $db = $this->db;
201 
202  $db->manipulateF(
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  }
manipulateF(string $query, array $types, array $values)
addTitle(int $style_id, string $type, string $characteristic, string $lang, string $title)
+ Here is the call graph for this function:

◆ updateColorName()

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

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

References ILIAS\Style\Content\CharacteristicDBRepo\$db, ilDBInterface\fetchAssoc(), ilDBInterface\in(), ilDBInterface\queryF(), and ILIAS\Style\Content\CharacteristicDBRepo\replaceParameter().

488  : void {
489  if ($old_name == $new_name) {
490  return;
491  }
492 
493  $db = $this->db;
494 
495  $color_attributes = [
496  "background-color",
497  "color",
498  "border-color",
499  "border-top-color",
500  "border-bottom-color",
501  "border-left-color",
502  "border-right-color",
503  ];
504 
505  $set = $db->queryF(
506  "SELECT * FROM style_parameter " .
507  " WHERE style_id = %s AND " . $db->in("parameter", $color_attributes, false, "text"),
508  ["integer"],
509  [$style_id]
510  );
511  while ($rec = $db->fetchAssoc($set)) {
512  if ($rec["value"] == "!" . $old_name ||
513  is_int(strpos($rec["value"], "!" . $old_name . "("))) {
514  // parameter is based on color -> rename it
515  $this->replaceParameter(
516  $style_id,
517  $rec["tag"],
518  $rec["class"],
519  $rec["parameter"],
520  str_replace($old_name, $new_name, $rec["value"]),
521  $rec["type"],
522  $rec["mq_id"],
523  $rec["custom"]
524  );
525  }
526  }
527  }
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)
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:

Field Documentation

◆ $db

◆ $factory

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

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