ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilContentStyleSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected ilDBInterface $db;
28 public array $styles = array();
29
30 public function __construct()
31 {
32 global $DIC;
33
34 $this->db = $DIC->database();
35 $this->read();
36 }
37
41 public function addStyle(int $a_style_id): void
42 {
43 $this->styles[$a_style_id] =
44 array("id" => $a_style_id,
45 "title" => ilObject::_lookupTitle($a_style_id));
46 }
47
51 public function removeStyle(int $a_id): void
52 {
53 unset($this->styles[$a_id]);
54 }
55
56 public function update(): bool
57 {
59
60 // save styles of style folder
61 // note: there are no different style folders in ILIAS, only the one in the settings
62 $q = "DELETE FROM style_folder_styles";
63 $ilDB->manipulate($q);
64 foreach ($this->styles as $style) {
65 $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES" .
66 "(" . $ilDB->quote(0, "integer") . ", " .
67 $ilDB->quote((int) $style["id"], "integer") . ")";
68 $ilDB->manipulate($q);
69 }
70
71 return true;
72 }
73
74 public function read(): void
75 {
77
78 // get styles of style folder
79 $q = "SELECT * FROM style_folder_styles JOIN style_data ON (style_id = style_data.id)";
80
81 $style_set = $ilDB->query($q);
82 $this->styles = array();
83 while ($style_rec = $ilDB->fetchAssoc($style_set)) {
84 $this->styles[$style_rec["style_id"]] =
85 array("id" => $style_rec["style_id"],
86 "title" => ilObject::_lookupTitle((int) $style_rec["style_id"]),
87 "category" => $style_rec["category"]);
88 }
89
90 $this->styles =
91 ilArrayUtil::sortArray($this->styles, "title", "asc", false, true);
92 }
93
94 public function getStyles(): array
95 {
96 return $this->styles;
97 }
98}
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
removeStyle(int $a_id)
remove Style from style list
addStyle(int $a_style_id)
Add style to style folder.
static _lookupTitle(int $obj_id)
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23